| 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 "GrTraceMarker.h" | 14 #include "GrTraceMarker.h" |
| 15 #include "GrXferProcessor.h" | 15 #include "GrXferProcessor.h" |
| 16 #include "SkMipMapLevel.h" |
| 16 #include "SkPath.h" | 17 #include "SkPath.h" |
| 18 #include "SkTArray.h" |
| 17 | 19 |
| 18 class GrBatchTracker; | 20 class GrBatchTracker; |
| 19 class GrContext; | 21 class GrContext; |
| 20 class GrGLContext; | 22 class GrGLContext; |
| 21 class GrIndexBuffer; | 23 class GrIndexBuffer; |
| 22 class GrNonInstancedVertices; | 24 class GrNonInstancedVertices; |
| 23 class GrPath; | 25 class GrPath; |
| 24 class GrPathRange; | 26 class GrPathRange; |
| 25 class GrPathRenderer; | 27 class GrPathRenderer; |
| 26 class GrPathRendererChain; | 28 class GrPathRendererChain; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 void markContextDirty(uint32_t state = kAll_GrBackendState) { fResetBits |=
state; } | 75 void markContextDirty(uint32_t state = kAll_GrBackendState) { fResetBits |=
state; } |
| 74 | 76 |
| 75 /** | 77 /** |
| 76 * Creates a texture object. If kRenderTarget_GrSurfaceFlag the texture can | 78 * Creates a texture object. If kRenderTarget_GrSurfaceFlag the texture can |
| 77 * be used as a render target by calling GrTexture::asRenderTarget(). Not al
l | 79 * be used as a render target by calling GrTexture::asRenderTarget(). Not al
l |
| 78 * pixel configs can be used as render targets. Support for configs as textu
res | 80 * pixel configs can be used as render targets. Support for configs as textu
res |
| 79 * or render targets can be checked using GrCaps. | 81 * or render targets can be checked using GrCaps. |
| 80 * | 82 * |
| 81 * @param desc describes the texture to be created. | 83 * @param desc describes the texture to be created. |
| 82 * @param budgeted does this texture count against the resource cache bud
get? | 84 * @param budgeted does this texture count against the resource cache bud
get? |
| 83 * @param srcData texel data to load texture. Begins with full-size | 85 * @param texels array of mipmap levels containing texel data to load. |
| 84 * palette data for paletted textures. For compressed | 86 * Begins with full-size palette data for paletted textur
es. |
| 85 * formats it contains the compressed pixel data. Otherwi
se, | 87 * For compressed formats it contains the compressed pixe
l data. |
| 86 * it contains width*height texels. If NULL texture data | 88 * Otherwise, it contains width*height texels. If there i
s only one |
| 87 * is uninitialized. | 89 * element and it contains NULL fTexels, texture data is |
| 88 * @param rowBytes the number of bytes between consecutive rows. Zero | 90 * uninitialized. |
| 89 * means rows are tightly packed. This field is ignored | |
| 90 * for compressed formats. | |
| 91 * | 91 * |
| 92 * @return The texture object if successful, otherwise NULL. | 92 * @return The texture object if successful, otherwise NULL. |
| 93 */ | 93 */ |
| 94 GrTexture* createTexture(const GrSurfaceDesc& desc, bool budgeted, | 94 GrTexture* createTexture(const GrSurfaceDesc& desc, bool budgeted, |
| 95 SkTArray<SkMipMapLevel>& texels); |
| 96 |
| 97 /* |
| 98 * This function is a shim which creates a SkTArray<SkMipMapLevel> of size 1
. |
| 99 * It then calls createTexture() with that SkTArray. |
| 100 * This is so older code which currently uses this function signature will |
| 101 * continue to work. |
| 102 */ |
| 103 GrTexture* createTexture(const GrSurfaceDesc& desc, bool budgeted, |
| 95 const void* srcData, size_t rowBytes); | 104 const void* srcData, size_t rowBytes); |
| 96 | 105 |
| 97 /** | 106 /** |
| 98 * Implements GrContext::wrapBackendTexture | 107 * Implements GrContext::wrapBackendTexture |
| 99 */ | 108 */ |
| 100 GrTexture* wrapBackendTexture(const GrBackendTextureDesc&, GrWrapOwnership); | 109 GrTexture* wrapBackendTexture(const GrBackendTextureDesc&, GrWrapOwnership); |
| 101 | 110 |
| 102 /** | 111 /** |
| 103 * Implements GrContext::wrapBackendTexture | 112 * Implements GrContext::wrapBackendTexture |
| 104 */ | 113 */ |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 GrPixelConfig config, void* buffer, size_t rowBytes); | 216 GrPixelConfig config, void* buffer, size_t rowBytes); |
| 208 | 217 |
| 209 /** | 218 /** |
| 210 * Updates the pixels in a rectangle of a texture. | 219 * Updates the pixels in a rectangle of a texture. |
| 211 * | 220 * |
| 212 * @param left left edge of the rectangle to write (inclusive) | 221 * @param left left edge of the rectangle to write (inclusive) |
| 213 * @param top top edge of the rectangle to write (inclusive) | 222 * @param top top edge of the rectangle to write (inclusive) |
| 214 * @param width width of rectangle to write in pixels. | 223 * @param width width of rectangle to write in pixels. |
| 215 * @param height height of rectangle to write in pixels. | 224 * @param height height of rectangle to write in pixels. |
| 216 * @param config the pixel config of the source buffer | 225 * @param config the pixel config of the source buffer |
| 217 * @param buffer memory to read pixels from | 226 * @param texels array of mipmap levels containing texture data |
| 218 * @param rowBytes number of bytes between consecutive rows. Zero | |
| 219 * means rows are tightly packed. | |
| 220 */ | 227 */ |
| 221 bool writeTexturePixels(GrTexture* texture, | 228 bool writeTexturePixels(GrTexture* texture, |
| 222 int left, int top, int width, int height, | 229 int left, int top, int width, int height, |
| 230 GrPixelConfig config, |
| 231 SkTArray<SkMipMapLevel>& texels); |
| 232 |
| 233 /* |
| 234 * This function is a shim which creates a SkTArray<SkMipMapLEvel> of size 1
. |
| 235 * It then calls writeTexturePixels() with that SkTArray. |
| 236 * This is so older code which currently uses this function signature will |
| 237 * continue to work. |
| 238 */ |
| 239 bool writeTexturePixels(GrTexture* texture, |
| 240 int left, int top, int width, int height, |
| 223 GrPixelConfig config, const void* buffer, | 241 GrPixelConfig config, const void* buffer, |
| 224 size_t rowBytes); | 242 size_t rowBytes); |
| 225 | 243 |
| 226 /** | 244 /** |
| 227 * Clear the passed in render target. Ignores the draw state and clip. Clear
s the whole thing if | 245 * Clear the passed in render target. Ignores the draw state and clip. Clear
s the whole thing if |
| 228 * rect is NULL, otherwise just the rect. If canIgnoreRect is set then the e
ntire render target | 246 * rect is NULL, otherwise just the rect. If canIgnoreRect is set then the e
ntire render target |
| 229 * can be optionally cleared. | 247 * can be optionally cleared. |
| 230 */ | 248 */ |
| 231 void clear(const SkIRect* rect, GrColor color, bool canIgnoreRect,GrRenderTa
rget* renderTarget); | 249 void clear(const SkIRect* rect, GrColor color, bool canIgnoreRect, |
| 250 GrRenderTarget* renderTarget); |
| 232 | 251 |
| 233 | 252 |
| 234 void clearStencilClip(const SkIRect& rect, bool insideClip, GrRenderTarget*
renderTarget); | 253 void clearStencilClip(const SkIRect& rect, bool insideClip, GrRenderTarget*
renderTarget); |
| 235 | 254 |
| 236 /** | 255 /** |
| 237 * Discards the contents render target. NULL indicates that the current rend
er target should | 256 * Discards the contents render target. NULL indicates that the current rend
er target should |
| 238 * be discarded. | 257 * be discarded. |
| 239 **/ | 258 **/ |
| 240 virtual void discard(GrRenderTarget* = NULL) = 0; | 259 virtual void discard(GrRenderTarget* = NULL) = 0; |
| 241 | 260 |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 private: | 416 private: |
| 398 // called when the 3D context state is unknown. Subclass should emit any | 417 // called when the 3D context state is unknown. Subclass should emit any |
| 399 // assumed 3D context state and dirty any state cache. | 418 // assumed 3D context state and dirty any state cache. |
| 400 virtual void onResetContext(uint32_t resetBits) = 0; | 419 virtual void onResetContext(uint32_t resetBits) = 0; |
| 401 | 420 |
| 402 // overridden by backend-specific derived class to create objects. | 421 // overridden by backend-specific derived class to create objects. |
| 403 // Texture size and sample size will have already been validated in base cla
ss before | 422 // Texture size and sample size will have already been validated in base cla
ss before |
| 404 // onCreateTexture/CompressedTexture are called. | 423 // onCreateTexture/CompressedTexture are called. |
| 405 virtual GrTexture* onCreateTexture(const GrSurfaceDesc& desc, | 424 virtual GrTexture* onCreateTexture(const GrSurfaceDesc& desc, |
| 406 GrGpuResource::LifeCycle lifeCycle, | 425 GrGpuResource::LifeCycle lifeCycle, |
| 407 const void* srcData, size_t rowBytes) = 0
; | 426 SkTArray<SkMipMapLevel>& texels) = 0; |
| 408 virtual GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc, | 427 virtual GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc, |
| 409 GrGpuResource::LifeCycle lifeCy
cle, | 428 GrGpuResource::LifeCycle lifeCy
cle, |
| 410 const void* srcData) = 0; | 429 SkTArray<SkMipMapLevel>& texels
) = 0; |
| 430 |
| 411 virtual GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&, GrWrapO
wnership) = 0; | 431 virtual GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&, GrWrapO
wnership) = 0; |
| 412 virtual GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTarge
tDesc&, | 432 virtual GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTarge
tDesc&, |
| 413 GrWrapOwnership) = 0; | 433 GrWrapOwnership) = 0; |
| 414 virtual GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) = 0; | 434 virtual GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) = 0; |
| 415 virtual GrIndexBuffer* onCreateIndexBuffer(size_t size, bool dynamic) = 0; | 435 virtual GrIndexBuffer* onCreateIndexBuffer(size_t size, bool dynamic) = 0; |
| 416 | 436 |
| 417 // overridden by backend-specific derived class to perform the clear. | 437 // overridden by backend-specific derived class to perform the clear. |
| 418 virtual void onClear(GrRenderTarget*, const SkIRect* rect, GrColor color, | 438 virtual void onClear(GrRenderTarget*, const SkIRect* rect, GrColor color, |
| 419 bool canIgnoreRect) = 0; | 439 bool canIgnoreRect) = 0; |
| 420 | 440 |
| 421 | 441 |
| 422 // Overridden by backend specific classes to perform a clear of the stencil
clip bits. This is | 442 // Overridden by backend specific classes to perform a clear of the stencil
clip bits. This is |
| 423 // ONLY used by the the clip target | 443 // ONLY used by the the clip target |
| 424 virtual void onClearStencilClip(GrRenderTarget*, const SkIRect& rect, bool i
nsideClip) = 0; | 444 virtual void onClearStencilClip(GrRenderTarget*, const SkIRect& rect, bool i
nsideClip) = 0; |
| 425 | 445 |
| 426 // overridden by backend-specific derived class to perform the draw call. | 446 // overridden by backend-specific derived class to perform the draw call. |
| 427 virtual void onDraw(const DrawArgs&, const GrNonInstancedVertices&) = 0; | 447 virtual void onDraw(const DrawArgs&, const GrNonInstancedVertices&) = 0; |
| 428 | 448 |
| 429 virtual bool onReadPixels(GrRenderTarget* target, | 449 virtual bool onReadPixels(GrRenderTarget* target, |
| 430 int left, int top, int width, int height, | 450 int left, int top, int width, int height, |
| 431 GrPixelConfig, | 451 GrPixelConfig, |
| 432 void* buffer, | 452 void* buffer, |
| 433 size_t rowBytes) = 0; | 453 size_t rowBytes) = 0; |
| 434 | 454 |
| 435 // overridden by backend-specific derived class to perform the texture updat
e | 455 // overridden by backend-specific derived class to perform the texture updat
e |
| 436 virtual bool onWriteTexturePixels(GrTexture* texture, | 456 virtual bool onWriteTexturePixels(GrTexture* texture, |
| 437 int left, int top, int width, int height, | 457 int left, int top, int width, int height, |
| 438 GrPixelConfig config, const void* buffer, | 458 GrPixelConfig config, |
| 439 size_t rowBytes) = 0; | 459 SkTArray<SkMipMapLevel>& texel) = 0; |
| 440 | 460 |
| 441 // overridden by backend-specific derived class to perform the resolve | 461 // overridden by backend-specific derived class to perform the resolve |
| 442 virtual void onResolveRenderTarget(GrRenderTarget* target) = 0; | 462 virtual void onResolveRenderTarget(GrRenderTarget* target) = 0; |
| 443 | 463 |
| 444 // width and height may be larger than rt (if underlying API allows it). | 464 // width and height may be larger than rt (if underlying API allows it). |
| 445 // Should attach the SB to the RT. Returns false if compatible sb could | 465 // Should attach the SB to the RT. Returns false if compatible sb could |
| 446 // not be created. | 466 // not be created. |
| 447 virtual bool createStencilAttachmentForRenderTarget(GrRenderTarget*, int wid
th, int height) = 0; | 467 virtual bool createStencilAttachmentForRenderTarget(GrRenderTarget*, int wid
th, int height) = 0; |
| 448 | 468 |
| 449 // attaches an existing SB to an existing RT. | 469 // attaches an existing SB to an existing RT. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 474 GrTraceMarkerSet fActiveT
raceMarkers; | 494 GrTraceMarkerSet fActiveT
raceMarkers; |
| 475 GrTraceMarkerSet fStoredT
raceMarkers; | 495 GrTraceMarkerSet fStoredT
raceMarkers; |
| 476 // The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu. | 496 // The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu. |
| 477 GrContext* fContext
; | 497 GrContext* fContext
; |
| 478 | 498 |
| 479 friend class GrPathRendering; | 499 friend class GrPathRendering; |
| 480 typedef SkRefCnt INHERITED; | 500 typedef SkRefCnt INHERITED; |
| 481 }; | 501 }; |
| 482 | 502 |
| 483 #endif | 503 #endif |
| OLD | NEW |