OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef GrGLGpu_DEFINED | 8 #ifndef GrGLGpu_DEFINED |
9 #define GrGLGpu_DEFINED | 9 #define GrGLGpu_DEFINED |
10 | 10 |
11 #include "GrGLContext.h" | 11 #include "GrGLContext.h" |
12 #include "GrGLIRect.h" | 12 #include "GrGLIRect.h" |
13 #include "GrGLIndexBuffer.h" | 13 #include "GrGLIndexBuffer.h" |
14 #include "GrGLPathRendering.h" | 14 #include "GrGLPathRendering.h" |
15 #include "GrGLProgram.h" | 15 #include "GrGLProgram.h" |
16 #include "GrGLRenderTarget.h" | 16 #include "GrGLRenderTarget.h" |
17 #include "GrGLStencilAttachment.h" | 17 #include "GrGLStencilAttachment.h" |
18 #include "GrGLTexture.h" | 18 #include "GrGLTexture.h" |
19 #include "GrGLVertexArray.h" | 19 #include "GrGLVertexArray.h" |
20 #include "GrGLVertexBuffer.h" | 20 #include "GrGLVertexBuffer.h" |
21 #include "GrGpu.h" | 21 #include "GrGpu.h" |
| 22 #include "SkMipMapLevel.h" |
22 #include "GrPipelineBuilder.h" | 23 #include "GrPipelineBuilder.h" |
| 24 #include "SkTArray.h" |
23 #include "GrXferProcessor.h" | 25 #include "GrXferProcessor.h" |
24 #include "SkTypes.h" | 26 #include "SkTypes.h" |
25 | 27 |
26 class GrPipeline; | 28 class GrPipeline; |
27 class GrNonInstancedVertices; | 29 class GrNonInstancedVertices; |
28 | 30 |
29 #ifdef SK_DEVELOPER | 31 #ifdef SK_DEVELOPER |
30 #define PROGRAM_CACHE_STATS | 32 #define PROGRAM_CACHE_STATS |
31 #endif | 33 #endif |
32 | 34 |
(...skipping 22 matching lines...) Expand all Loading... |
55 void discard(GrRenderTarget*) override; | 57 void discard(GrRenderTarget*) override; |
56 | 58 |
57 // Used by GrGLProgram to configure OpenGL state. | 59 // Used by GrGLProgram to configure OpenGL state. |
58 void bindTexture(int unitIdx, const GrTextureParams& params, GrGLTexture* te
xture); | 60 void bindTexture(int unitIdx, const GrTextureParams& params, GrGLTexture* te
xture); |
59 | 61 |
60 bool onGetReadPixelsInfo(GrSurface* srcSurface, int readWidth, int readHeigh
t, size_t rowBytes, | 62 bool onGetReadPixelsInfo(GrSurface* srcSurface, int readWidth, int readHeigh
t, size_t rowBytes, |
61 GrPixelConfig readConfig, DrawPreference*, | 63 GrPixelConfig readConfig, DrawPreference*, |
62 ReadPixelTempDrawInfo*) override; | 64 ReadPixelTempDrawInfo*) override; |
63 | 65 |
64 bool onGetWritePixelsInfo(GrSurface* dstSurface, int width, int height, | 66 bool onGetWritePixelsInfo(GrSurface* dstSurface, int width, int height, |
65 size_t rowBytes, GrPixelConfig srcConfig, DrawPref
erence*, | 67 GrPixelConfig srcConfig, DrawPreference*, |
66 WritePixelTempDrawInfo*) override; | 68 WritePixelTempDrawInfo*) override; |
67 | 69 |
68 bool initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* desc) const
override; | 70 bool initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* desc) const
override; |
69 | 71 |
70 // These functions should be used to bind GL objects. They track the GL stat
e and skip redundant | 72 // These functions should be used to bind GL objects. They track the GL stat
e and skip redundant |
71 // bindings. Making the equivalent glBind calls directly will confuse the st
ate tracking. | 73 // bindings. Making the equivalent glBind calls directly will confuse the st
ate tracking. |
72 void bindVertexArray(GrGLuint id) { | 74 void bindVertexArray(GrGLuint id) { |
73 fHWGeometryState.setVertexArrayID(this, id); | 75 fHWGeometryState.setVertexArrayID(this, id); |
74 } | 76 } |
75 void bindIndexBufferAndDefaultVertexArray(GrGLuint id) { | 77 void bindIndexBufferAndDefaultVertexArray(GrGLuint id) { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 | 118 |
117 private: | 119 private: |
118 GrGLGpu(GrGLContext* ctx, GrContext* context); | 120 GrGLGpu(GrGLContext* ctx, GrContext* context); |
119 | 121 |
120 // GrGpu overrides | 122 // GrGpu overrides |
121 void onResetContext(uint32_t resetBits) override; | 123 void onResetContext(uint32_t resetBits) override; |
122 | 124 |
123 void xferBarrier(GrRenderTarget*, GrXferBarrierType) override; | 125 void xferBarrier(GrRenderTarget*, GrXferBarrierType) override; |
124 | 126 |
125 GrTexture* onCreateTexture(const GrSurfaceDesc& desc, GrGpuResource::LifeCyc
le lifeCycle, | 127 GrTexture* onCreateTexture(const GrSurfaceDesc& desc, GrGpuResource::LifeCyc
le lifeCycle, |
126 const void* srcData, size_t rowBytes) override; | 128 const SkTArray<SkMipMapLevel>& texels) override; |
127 GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc, | 129 GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc, |
128 GrGpuResource::LifeCycle lifeCycle, | 130 GrGpuResource::LifeCycle lifeCycle, |
129 const void* srcData) override; | 131 const SkTArray<SkMipMapLevel>& texels)
override; |
| 132 |
130 GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) override; | 133 GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) override; |
131 GrIndexBuffer* onCreateIndexBuffer(size_t size, bool dynamic) override; | 134 GrIndexBuffer* onCreateIndexBuffer(size_t size, bool dynamic) override; |
132 GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&, GrWrapOwnership
) override; | 135 GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&, GrWrapOwnership
) override; |
133 GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&, | 136 GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&, |
134 GrWrapOwnership) override; | 137 GrWrapOwnership) override; |
135 // Given a GrPixelConfig return the index into the stencil format array on G
rGLCaps to a | 138 // Given a GrPixelConfig return the index into the stencil format array on G
rGLCaps to a |
136 // compatible stencil format. | 139 // compatible stencil format. |
137 int getCompatibleStencilIndex(GrPixelConfig config); | 140 int getCompatibleStencilIndex(GrPixelConfig config); |
138 | 141 |
139 void onClear(GrRenderTarget*, const SkIRect& rect, GrColor color) override; | 142 void onClear(GrRenderTarget*, const SkIRect& rect, GrColor color) override; |
140 | 143 |
141 void onClearStencilClip(GrRenderTarget*, const SkIRect& rect, bool insideCli
p) override; | 144 void onClearStencilClip(GrRenderTarget*, const SkIRect& rect, bool insideCli
p) override; |
142 | 145 |
143 bool onReadPixels(GrSurface*, | 146 bool onReadPixels(GrSurface*, |
144 int left, int top, | 147 int left, int top, |
145 int width, int height, | 148 int width, int height, |
146 GrPixelConfig, | 149 GrPixelConfig, |
147 void* buffer, | 150 void* buffer, |
148 size_t rowBytes) override; | 151 size_t rowBytes) override; |
149 | 152 |
150 bool onWritePixels(GrSurface*, | 153 bool onWritePixels(GrSurface*, |
151 int left, int top, int width, int height, | 154 int left, int top, int width, int height, |
152 GrPixelConfig config, const void* buffer, | 155 GrPixelConfig config, |
153 size_t rowBytes) override; | 156 const SkTArray<SkMipMapLevel>& texels) override; |
154 | 157 |
155 void onResolveRenderTarget(GrRenderTarget* target) override; | 158 void onResolveRenderTarget(GrRenderTarget* target) override; |
156 | 159 |
157 void onDraw(const DrawArgs&, const GrNonInstancedVertices&) override; | 160 void onDraw(const DrawArgs&, const GrNonInstancedVertices&) override; |
158 | 161 |
159 bool onCopySurface(GrSurface* dst, | 162 bool onCopySurface(GrSurface* dst, |
160 GrSurface* src, | 163 GrSurface* src, |
161 const SkIRect& srcRect, | 164 const SkIRect& srcRect, |
162 const SkIPoint& dstPoint) override; | 165 const SkIPoint& dstPoint) override; |
163 | 166 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 bool configToGLFormats(GrPixelConfig config, | 268 bool configToGLFormats(GrPixelConfig config, |
266 bool getSizedInternal, | 269 bool getSizedInternal, |
267 GrGLenum* internalFormat, | 270 GrGLenum* internalFormat, |
268 GrGLenum* externalFormat, | 271 GrGLenum* externalFormat, |
269 GrGLenum* externalType) const; | 272 GrGLenum* externalType) const; |
270 // helper for onCreateTexture and writeTexturePixels | 273 // helper for onCreateTexture and writeTexturePixels |
271 bool uploadTexData(const GrSurfaceDesc& desc, | 274 bool uploadTexData(const GrSurfaceDesc& desc, |
272 bool isNewTexture, | 275 bool isNewTexture, |
273 int left, int top, int width, int height, | 276 int left, int top, int width, int height, |
274 GrPixelConfig dataConfig, | 277 GrPixelConfig dataConfig, |
275 const void* data, | 278 const SkTArray<SkMipMapLevel>& texels); |
276 size_t rowBytes); | |
277 | 279 |
278 // helper for onCreateCompressedTexture. If width and height are | 280 // helper for onCreateCompressedTexture. If width and height are |
279 // set to -1, then this function will use desc.fWidth and desc.fHeight | 281 // set to -1, then this function will use desc.fWidth and desc.fHeight |
280 // for the size of the data. The isNewTexture flag should be set to true | 282 // for the size of the data. The isNewTexture flag should be set to true |
281 // whenever a new texture needs to be created. Otherwise, we assume that | 283 // whenever a new texture needs to be created. Otherwise, we assume that |
282 // the texture is already in GPU memory and that it's going to be updated | 284 // the texture is already in GPU memory and that it's going to be updated |
283 // with new data. | 285 // with new data. |
284 bool uploadCompressedTexData(const GrSurfaceDesc& desc, | 286 bool uploadCompressedTexData(const GrSurfaceDesc& desc, |
285 const void* data, | 287 const SkTArray<SkMipMapLevel>& texels, |
286 bool isNewTexture = true, | 288 bool isNewTexture = true, |
287 int left = 0, int top = 0, | 289 int left = 0, int top = 0, |
288 int width = -1, int height = -1); | 290 int width = -1, int height = -1); |
289 | 291 |
290 bool createRenderTargetObjects(const GrSurfaceDesc&, GrGpuResource::LifeCycl
e lifeCycle, | 292 bool createRenderTargetObjects(const GrSurfaceDesc&, GrGpuResource::LifeCycl
e lifeCycle, |
291 GrGLuint texID, GrGLRenderTarget::IDDesc*); | 293 GrGLuint texID, GrGLRenderTarget::IDDesc*); |
292 | 294 |
293 enum TempFBOTarget { | 295 enum TempFBOTarget { |
294 kSrc_TempFBOTarget, | 296 kSrc_TempFBOTarget, |
295 kDst_TempFBOTarget | 297 kDst_TempFBOTarget |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 | 498 |
497 // Mapping of pixel configs to known supported stencil formats to be used | 499 // Mapping of pixel configs to known supported stencil formats to be used |
498 // when adding a stencil buffer to a framebuffer. | 500 // when adding a stencil buffer to a framebuffer. |
499 int fPixelConfigToStencilIndex[kGrPixelConfigCnt]; | 501 int fPixelConfigToStencilIndex[kGrPixelConfigCnt]; |
500 | 502 |
501 typedef GrGpu INHERITED; | 503 typedef GrGpu INHERITED; |
502 friend class GrGLPathRendering; // For accessing setTextureUnit. | 504 friend class GrGLPathRendering; // For accessing setTextureUnit. |
503 }; | 505 }; |
504 | 506 |
505 #endif | 507 #endif |
OLD | NEW |