OSDN Git Service

dcee30fec7269a32ef5bd8af7ce66b1b028271dd
[android-x86/external-swiftshader.git] / src / GLES2 / libGLESv2 / Device.hpp
1 // SwiftShader Software Renderer\r
2 //\r
3 // Copyright(c) 2005-2012 TransGaming Inc.\r
4 //\r
5 // All rights reserved. No part of this software may be copied, distributed, transmitted,\r
6 // transcribed, stored in a retrieval system, translated into any human or computer\r
7 // language by any means, or disclosed to third parties without the explicit written\r
8 // agreement of TransGaming Inc. Without such an agreement, no rights or licenses, express\r
9 // or implied, including but not limited to any patent rights, are granted to you.\r
10 //\r
11 \r
12 #ifndef gl_Device_hpp\r
13 #define gl_Device_hpp\r
14 \r
15 #include "Renderer/Renderer.hpp"\r
16 \r
17 namespace gl\r
18 {\r
19         class Texture;\r
20 }\r
21 \r
22 namespace gl\r
23 {\r
24         class Image;\r
25 \r
26         enum PrimitiveType\r
27         {\r
28                 DRAW_POINTLIST,\r
29                 DRAW_LINELIST,\r
30                 DRAW_LINESTRIP,\r
31                 DRAW_LINELOOP,\r
32                 DRAW_TRIANGLELIST,\r
33                 DRAW_TRIANGLESTRIP,\r
34                 DRAW_TRIANGLEFAN\r
35         };\r
36 \r
37         struct Viewport\r
38         {\r
39                 int x0;\r
40                 int y0;\r
41                 unsigned int width;\r
42                 unsigned int height;\r
43                 float minZ;\r
44                 float maxZ;\r
45         };\r
46 \r
47         class Device : public sw::Renderer\r
48         {\r
49         public:\r
50                 explicit Device(sw::Context *context);\r
51 \r
52                 virtual ~Device();\r
53 \r
54                 virtual void clearColor(unsigned int color, unsigned int rgbaMask);\r
55                 virtual void clearDepth(float z);\r
56                 virtual void clearStencil(unsigned int stencil, unsigned int mask);\r
57                 virtual Image *createDepthStencilSurface(unsigned int width, unsigned int height, sw::Format format, int multiSampleDepth, bool discard);\r
58                 virtual Image *createRenderTarget(unsigned int width, unsigned int height, sw::Format format, int multiSampleDepth, bool lockable);\r
59                 virtual void drawIndexedPrimitive(PrimitiveType type, unsigned int indexOffset, unsigned int primitiveCount, int indexSize);\r
60                 virtual void drawPrimitive(PrimitiveType primitiveType, unsigned int primiveCount);\r
61                 virtual void setDepthStencilSurface(Image *newDepthStencil);\r
62                 virtual void setPixelShader(sw::PixelShader *shader);\r
63                 virtual void setPixelShaderConstantF(unsigned int startRegister, const float *constantData, unsigned int count);\r
64                 virtual void setScissorEnable(bool enable);\r
65                 virtual void setRenderTarget(Image *renderTarget);\r
66                 virtual void setScissorRect(const sw::Rect &rect);\r
67                 virtual void setVertexShader(sw::VertexShader *shader);\r
68                 virtual void setVertexShaderConstantF(unsigned int startRegister, const float *constantData, unsigned int count);\r
69                 virtual void setViewport(const Viewport &viewport);\r
70 \r
71                 virtual bool stretchRect(Image *sourceSurface, const sw::Rect *sourceRect, Image *destSurface, const sw::Rect *destRect, bool filter);\r
72                 virtual void finish();\r
73 \r
74         private:\r
75                 sw::Context *const context;\r
76 \r
77                 bool bindResources();\r
78                 void bindShaderConstants();\r
79                 bool bindViewport();   // Also adjusts for scissoring\r
80 \r
81                 bool validRectangle(const sw::Rect *rect, Image *surface);\r
82 \r
83                 Viewport viewport;\r
84                 sw::Rect scissorRect;\r
85                 bool scissorEnable;\r
86 \r
87                 sw::PixelShader *pixelShader;\r
88                 sw::VertexShader *vertexShader;\r
89 \r
90                 bool pixelShaderDirty;\r
91                 int pixelShaderConstantsFDirty;\r
92                 bool vertexShaderDirty;\r
93                 int vertexShaderConstantsFDirty;\r
94 \r
95                 float pixelShaderConstantF[224][4];\r
96                 float vertexShaderConstantF[256][4];\r
97 \r
98                 Image *renderTarget;\r
99                 Image *depthStencil;\r
100         };\r
101 }\r
102 \r
103 #endif   // gl_Device_hpp\r