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 GrGpu_DEFINED | 8 #ifndef GrGpu_DEFINED |
9 #define GrGpu_DEFINED | 9 #define GrGpu_DEFINED |
10 | 10 |
11 #include "GrPipelineBuilder.h" | 11 #include "GrPipelineBuilder.h" |
12 #include "GrProgramDesc.h" | 12 #include "GrProgramDesc.h" |
13 #include "GrStencil.h" | 13 #include "GrStencil.h" |
14 #include "GrXferProcessor.h" | 14 #include "GrXferProcessor.h" |
15 #include "SkMipMapLevel.h" | |
15 #include "SkPath.h" | 16 #include "SkPath.h" |
17 #include "SkTArray.h" | |
16 | 18 |
17 class GrBatchTracker; | 19 class GrBatchTracker; |
18 class GrContext; | 20 class GrContext; |
19 class GrGLContext; | 21 class GrGLContext; |
20 class GrIndexBuffer; | 22 class GrIndexBuffer; |
21 class GrNonInstancedVertices; | 23 class GrNonInstancedVertices; |
22 class GrPath; | 24 class GrPath; |
23 class GrPathRange; | 25 class GrPathRange; |
24 class GrPathRenderer; | 26 class GrPathRenderer; |
25 class GrPathRendererChain; | 27 class GrPathRendererChain; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
72 void markContextDirty(uint32_t state = kAll_GrBackendState) { fResetBits |= state; } | 74 void markContextDirty(uint32_t state = kAll_GrBackendState) { fResetBits |= state; } |
73 | 75 |
74 /** | 76 /** |
75 * Creates a texture object. If kRenderTarget_GrSurfaceFlag the texture can | 77 * Creates a texture object. If kRenderTarget_GrSurfaceFlag the texture can |
76 * be used as a render target by calling GrTexture::asRenderTarget(). Not al l | 78 * be used as a render target by calling GrTexture::asRenderTarget(). Not al l |
77 * pixel configs can be used as render targets. Support for configs as textu res | 79 * pixel configs can be used as render targets. Support for configs as textu res |
78 * or render targets can be checked using GrCaps. | 80 * or render targets can be checked using GrCaps. |
79 * | 81 * |
80 * @param desc describes the texture to be created. | 82 * @param desc describes the texture to be created. |
81 * @param budgeted does this texture count against the resource cache bud get? | 83 * @param budgeted does this texture count against the resource cache bud get? |
82 * @param srcData texel data to load texture. Begins with full-size | 84 * @param texels array of mipmap levels containing texel data to load. |
83 * palette data for paletted textures. For compressed | 85 * Begins with full-size palette data for paletted textur es. |
84 * formats it contains the compressed pixel data. Otherwi se, | 86 * For compressed formats it contains the compressed pixe l data. |
85 * it contains width*height texels. If nullptr texture da ta | 87 * Otherwise, it contains width*height texels. If there i s only one |
86 * is uninitialized. | 88 * element and it contains nullptr fTexels, texture data is |
87 * @param rowBytes the number of bytes between consecutive rows. Zero | 89 * uninitialized. |
88 * means rows are tightly packed. This field is ignored | |
89 * for compressed formats. | |
90 * | |
91 * @return The texture object if successful, otherwise nullptr. | 90 * @return The texture object if successful, otherwise nullptr. |
92 */ | 91 */ |
93 GrTexture* createTexture(const GrSurfaceDesc& desc, bool budgeted, | 92 GrTexture* createTexture(const GrSurfaceDesc& desc, bool budgeted, |
93 const SkTArray<SkMipMapLevel>& texels); | |
94 | |
95 /** | |
96 * This function is a shim which creates a SkTArray<SkMipMapLevel> of size 1 . | |
97 * It then calls createTexture() with that SkTArray. | |
98 * This is so older code which currently uses this function signature will | |
bsalomon
2015/09/15 13:14:11
-older
| |
99 * continue to work. | |
100 */ | |
101 GrTexture* createTexture(const GrSurfaceDesc& desc, bool budgeted, | |
94 const void* srcData, size_t rowBytes); | 102 const void* srcData, size_t rowBytes); |
95 | 103 |
96 /** | 104 /** |
97 * Implements GrContext::wrapBackendTexture | 105 * Implements GrContext::wrapBackendTexture |
98 */ | 106 */ |
99 GrTexture* wrapBackendTexture(const GrBackendTextureDesc&, GrWrapOwnership); | 107 GrTexture* wrapBackendTexture(const GrBackendTextureDesc&, GrWrapOwnership); |
100 | 108 |
101 /** | 109 /** |
102 * Implements GrContext::wrapBackendTexture | 110 * Implements GrContext::wrapBackendTexture |
103 */ | 111 */ |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
174 | 182 |
175 /** | 183 /** |
176 * Used to negotiate whether and how an intermediate draw should or must be performed before | 184 * Used to negotiate whether and how an intermediate draw should or must be performed before |
177 * a readPixels call. If this returns false then GrGpu could not deduce an i ntermediate draw | 185 * a readPixels call. If this returns false then GrGpu could not deduce an i ntermediate draw |
178 * that would allow a successful readPixels call. The passed width, height, and rowBytes, | 186 * that would allow a successful readPixels call. The passed width, height, and rowBytes, |
179 * must be non-zero and already reflect clipping to the src bounds. | 187 * must be non-zero and already reflect clipping to the src bounds. |
180 */ | 188 */ |
181 bool getReadPixelsInfo(GrSurface* srcSurface, int readWidth, int readHeight, size_t rowBytes, | 189 bool getReadPixelsInfo(GrSurface* srcSurface, int readWidth, int readHeight, size_t rowBytes, |
182 GrPixelConfig readConfig, DrawPreference*, ReadPixelT empDrawInfo*); | 190 GrPixelConfig readConfig, DrawPreference*, ReadPixelT empDrawInfo*); |
183 | 191 |
184 /** Info struct returned by getWritePixelsInfo about performing an intermedi ate draw in order | 192 /** Info struct returned by getWritePixelsInfo about performing an intermedi ate draw in order |
185 to write pixels to a GrSurface for either performance or correctness rea sons. */ | 193 to write pixels to a GrSurface for either performance or correctness rea sons. */ |
186 struct WritePixelTempDrawInfo { | 194 struct WritePixelTempDrawInfo { |
187 /** If the GrGpu is requesting that the caller upload to an intermediate surface and draw | 195 /** If the GrGpu is requesting that the caller upload to an intermediate surface and draw |
188 that to the dst then this is the descriptor for the intermediate sur face. The caller | 196 that to the dst then this is the descriptor for the intermediate sur face. The caller |
189 should upload the pixels such that the upper left pixel of the uploa d rect is at 0,0 in | 197 should upload the pixels such that the upper left pixel of the uploa d rect is at 0,0 in |
190 the intermediate surface.*/ | 198 the intermediate surface.*/ |
191 GrSurfaceDesc fTempSurfaceDesc; | 199 GrSurfaceDesc fTempSurfaceDesc; |
192 /** If set, fTempSurfaceDesc's config will be a R/B swap of the src pixe l config. The caller | 200 /** If set, fTempSurfaceDesc's config will be a R/B swap of the src pixe l config. The caller |
193 should upload the pixels as is such that R and B will be swapped in the intermediate | 201 should upload the pixels as is such that R and B will be swapped in the intermediate |
194 surface. When the intermediate is drawn to the dst the shader should swap R/B again | 202 surface. When the intermediate is drawn to the dst the shader should swap R/B again |
195 such that the correct swizzle results in the dst. This is done to wo rk around either | 203 such that the correct swizzle results in the dst. This is done to wo rk around either |
196 performance or API restrictions in the backend 3D API implementation . */ | 204 performance or API restrictions in the backend 3D API implementation . */ |
197 bool fSwapRAndB; | 205 bool fSwapRAndB; |
198 }; | 206 }; |
199 | 207 |
200 /** | 208 /** |
201 * Used to negotiate whether and how an intermediate surface should be used to write pixels to | 209 * Used to negotiate whether and how an intermediate surface should be used to write pixels to |
202 * a GrSurface. If this returns false then GrGpu could not deduce an interme diate draw | 210 * a GrSurface. If this returns false then GrGpu could not deduce an interme diate draw |
203 * that would allow a successful transfer of the src pixels to the dst. The passed width, | 211 * that would allow a successful transfer of the src pixels to the dst. The passed width, |
204 * height, and rowBytes, must be non-zero and already reflect clipping to th e dst bounds. | 212 * height, and rowBytes, must be non-zero and already reflect clipping to th e dst bounds. |
205 */ | 213 */ |
206 bool getWritePixelsInfo(GrSurface* dstSurface, int width, int height, size_t rowBytes, | 214 bool getWritePixelsInfo(GrSurface* dstSurface, int width, int height, |
207 GrPixelConfig srcConfig, DrawPreference*, WritePixel TempDrawInfo*); | 215 GrPixelConfig srcConfig, DrawPreference*, WritePixel TempDrawInfo*); |
208 | 216 |
209 /** | 217 /** |
210 * Reads a rectangle of pixels from a render target. | 218 * Reads a rectangle of pixels from a render target. |
211 * | 219 * |
212 * @param surface The surface to read from | 220 * @param surface The surface to read from |
213 * @param left left edge of the rectangle to read (inclusive) | 221 * @param left left edge of the rectangle to read (inclusive) |
214 * @param top top edge of the rectangle to read (inclusive) | 222 * @param top top edge of the rectangle to read (inclusive) |
215 * @param width width of rectangle to read in pixels. | 223 * @param width width of rectangle to read in pixels. |
216 * @param height height of rectangle to read in pixels. | 224 * @param height height of rectangle to read in pixels. |
(...skipping 14 matching lines...) Expand all Loading... | |
231 | 239 |
232 /** | 240 /** |
233 * Updates the pixels in a rectangle of a surface. | 241 * Updates the pixels in a rectangle of a surface. |
234 * | 242 * |
235 * @param surface The surface to write to. | 243 * @param surface The surface to write to. |
236 * @param left left edge of the rectangle to write (inclusive) | 244 * @param left left edge of the rectangle to write (inclusive) |
237 * @param top top edge of the rectangle to write (inclusive) | 245 * @param top top edge of the rectangle to write (inclusive) |
238 * @param width width of rectangle to write in pixels. | 246 * @param width width of rectangle to write in pixels. |
239 * @param height height of rectangle to write in pixels. | 247 * @param height height of rectangle to write in pixels. |
240 * @param config the pixel config of the source buffer | 248 * @param config the pixel config of the source buffer |
241 * @param buffer memory to read pixels from | 249 * @param texels array of mipmap levels containing texture data |
242 * @param rowBytes number of bytes between consecutive rows. Zero | |
243 * means rows are tightly packed. | |
244 */ | 250 */ |
245 bool writePixels(GrSurface* surface, | 251 bool writePixels(GrSurface* surface, |
246 int left, int top, int width, int height, | 252 int left, int top, int width, int height, |
253 GrPixelConfig config, | |
254 const SkTArray<SkMipMapLevel>& texels); | |
255 | |
256 /** | |
257 * This function is a shim which creates a SkTArray<SkMipMapLevel> of size 1 . | |
258 * It then calls writePixels() with that SkTArray. | |
259 * This is so older code which currently uses this function signature will | |
bsalomon
2015/09/15 13:14:11
-older
| |
260 * continue to work. | |
261 */ | |
262 bool writePixels(GrSurface* surface, | |
263 int left, int top, int width, int height, | |
247 GrPixelConfig config, const void* buffer, | 264 GrPixelConfig config, const void* buffer, |
248 size_t rowBytes); | 265 size_t rowBytes); |
249 | 266 |
250 /** | 267 /** |
251 * Clear the passed in render target. Ignores the draw state and clip. | 268 * Clear the passed in render target. Ignores the draw state and clip. |
252 */ | 269 */ |
253 void clear(const SkIRect& rect, GrColor color, GrRenderTarget* renderTarget) ; | 270 void clear(const SkIRect& rect, GrColor color, GrRenderTarget* renderTarget) ; |
254 | 271 |
255 | 272 |
256 void clearStencilClip(const SkIRect& rect, bool insideClip, GrRenderTarget* renderTarget); | 273 void clearStencilClip(const SkIRect& rect, bool insideClip, GrRenderTarget* renderTarget); |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
414 virtual void onResetContext(uint32_t resetBits) = 0; | 431 virtual void onResetContext(uint32_t resetBits) = 0; |
415 | 432 |
416 // Called before certain draws in order to guarantee coherent results from d st reads. | 433 // Called before certain draws in order to guarantee coherent results from d st reads. |
417 virtual void xferBarrier(GrRenderTarget*, GrXferBarrierType) = 0; | 434 virtual void xferBarrier(GrRenderTarget*, GrXferBarrierType) = 0; |
418 | 435 |
419 // overridden by backend-specific derived class to create objects. | 436 // overridden by backend-specific derived class to create objects. |
420 // Texture size and sample size will have already been validated in base cla ss before | 437 // Texture size and sample size will have already been validated in base cla ss before |
421 // onCreateTexture/CompressedTexture are called. | 438 // onCreateTexture/CompressedTexture are called. |
422 virtual GrTexture* onCreateTexture(const GrSurfaceDesc& desc, | 439 virtual GrTexture* onCreateTexture(const GrSurfaceDesc& desc, |
423 GrGpuResource::LifeCycle lifeCycle, | 440 GrGpuResource::LifeCycle lifeCycle, |
424 const void* srcData, size_t rowBytes) = 0 ; | 441 const SkTArray<SkMipMapLevel>& texels) = 0; |
425 virtual GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc, | 442 virtual GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc, |
426 GrGpuResource::LifeCycle lifeCy cle, | 443 GrGpuResource::LifeCycle lifeCy cle, |
427 const void* srcData) = 0; | 444 const SkTArray<SkMipMapLevel>& texels) = 0; |
445 | |
428 virtual GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&, GrWrapO wnership) = 0; | 446 virtual GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&, GrWrapO wnership) = 0; |
429 virtual GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTarge tDesc&, | 447 virtual GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTarge tDesc&, |
430 GrWrapOwnership) = 0; | 448 GrWrapOwnership) = 0; |
431 virtual GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) = 0; | 449 virtual GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) = 0; |
432 virtual GrIndexBuffer* onCreateIndexBuffer(size_t size, bool dynamic) = 0; | 450 virtual GrIndexBuffer* onCreateIndexBuffer(size_t size, bool dynamic) = 0; |
433 | 451 |
434 // overridden by backend-specific derived class to perform the clear. | 452 // overridden by backend-specific derived class to perform the clear. |
435 virtual void onClear(GrRenderTarget*, const SkIRect& rect, GrColor color) = 0; | 453 virtual void onClear(GrRenderTarget*, const SkIRect& rect, GrColor color) = 0; |
436 | 454 |
437 | 455 |
438 // Overridden by backend specific classes to perform a clear of the stencil clip bits. This is | 456 // Overridden by backend specific classes to perform a clear of the stencil clip bits. This is |
439 // ONLY used by the the clip target | 457 // ONLY used by the the clip target |
440 virtual void onClearStencilClip(GrRenderTarget*, const SkIRect& rect, bool i nsideClip) = 0; | 458 virtual void onClearStencilClip(GrRenderTarget*, const SkIRect& rect, bool i nsideClip) = 0; |
441 | 459 |
442 // overridden by backend-specific derived class to perform the draw call. | 460 // overridden by backend-specific derived class to perform the draw call. |
443 virtual void onDraw(const DrawArgs&, const GrNonInstancedVertices&) = 0; | 461 virtual void onDraw(const DrawArgs&, const GrNonInstancedVertices&) = 0; |
444 | 462 |
445 virtual bool onGetReadPixelsInfo(GrSurface* srcSurface, int readWidth, int r eadHeight, | 463 virtual bool onGetReadPixelsInfo(GrSurface* srcSurface, int readWidth, int r eadHeight, |
446 size_t rowBytes, GrPixelConfig readConfig, DrawPreference*, | 464 size_t rowBytes, GrPixelConfig readConfig, DrawPreference*, |
447 ReadPixelTempDrawInfo*) = 0; | 465 ReadPixelTempDrawInfo*) = 0; |
448 virtual bool onGetWritePixelsInfo(GrSurface* dstSurface, int width, int heig ht, size_t rowBytes, | 466 virtual bool onGetWritePixelsInfo(GrSurface* dstSurface, int width, int heig ht, |
449 GrPixelConfig srcConfig, DrawPreference*, | 467 GrPixelConfig srcConfig, DrawPreference*, |
450 WritePixelTempDrawInfo*) = 0; | 468 WritePixelTempDrawInfo*) = 0; |
451 | 469 |
452 // overridden by backend-specific derived class to perform the surface read | 470 // overridden by backend-specific derived class to perform the surface read |
453 virtual bool onReadPixels(GrSurface*, | 471 virtual bool onReadPixels(GrSurface*, |
454 int left, int top, | 472 int left, int top, |
455 int width, int height, | 473 int width, int height, |
456 GrPixelConfig, | 474 GrPixelConfig, |
457 void* buffer, | 475 void* buffer, |
458 size_t rowBytes) = 0; | 476 size_t rowBytes) = 0; |
459 | 477 |
460 // overridden by backend-specific derived class to perform the surface write | 478 // overridden by backend-specific derived class to perform the surface write |
461 virtual bool onWritePixels(GrSurface*, | 479 virtual bool onWritePixels(GrSurface*, |
462 int left, int top, int width, int height, | 480 int left, int top, int width, int height, |
463 GrPixelConfig config, const void* buffer, | 481 GrPixelConfig config, |
464 size_t rowBytes) = 0; | 482 const SkTArray<SkMipMapLevel>& texels) = 0; |
465 | 483 |
466 // overridden by backend-specific derived class to perform the resolve | 484 // overridden by backend-specific derived class to perform the resolve |
467 virtual void onResolveRenderTarget(GrRenderTarget* target) = 0; | 485 virtual void onResolveRenderTarget(GrRenderTarget* target) = 0; |
468 | 486 |
469 // overridden by backend specific derived class to perform the copy surface | 487 // overridden by backend specific derived class to perform the copy surface |
470 virtual bool onCopySurface(GrSurface* dst, | 488 virtual bool onCopySurface(GrSurface* dst, |
471 GrSurface* src, | 489 GrSurface* src, |
472 const SkIRect& srcRect, | 490 const SkIRect& srcRect, |
473 const SkIPoint& dstPoint) = 0; | 491 const SkIPoint& dstPoint) = 0; |
474 | 492 |
(...skipping 12 matching lines...) Expand all Loading... | |
487 ResetTimestamp fResetTi mestamp; | 505 ResetTimestamp fResetTi mestamp; |
488 uint32_t fResetBi ts; | 506 uint32_t fResetBi ts; |
489 // The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu. | 507 // The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu. |
490 GrContext* fContext ; | 508 GrContext* fContext ; |
491 | 509 |
492 friend class GrPathRendering; | 510 friend class GrPathRendering; |
493 typedef SkRefCnt INHERITED; | 511 typedef SkRefCnt INHERITED; |
494 }; | 512 }; |
495 | 513 |
496 #endif | 514 #endif |
OLD | NEW |