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 "GrDrawTarget.h" | 11 #include "GrDrawTarget.h" |
12 #include "GrClipMaskManager.h" | 12 #include "GrClipMaskManager.h" |
| 13 #include "GrPathRendering.h" |
13 #include "SkPath.h" | 14 #include "SkPath.h" |
14 | 15 |
15 class GrContext; | 16 class GrContext; |
16 class GrIndexBufferAllocPool; | 17 class GrIndexBufferAllocPool; |
17 class GrPath; | 18 class GrPath; |
18 class GrPathRange; | 19 class GrPathRange; |
19 class GrPathRenderer; | 20 class GrPathRenderer; |
20 class GrPathRendererChain; | 21 class GrPathRendererChain; |
21 class GrStencilBuffer; | 22 class GrStencilBuffer; |
22 class GrVertexBufferAllocPool; | 23 class GrVertexBufferAllocPool; |
(...skipping 24 matching lines...) Expand all Loading... |
47 static GrGpu* Create(GrBackend, GrBackendContext, GrContext* context); | 48 static GrGpu* Create(GrBackend, GrBackendContext, GrContext* context); |
48 | 49 |
49 //////////////////////////////////////////////////////////////////////////// | 50 //////////////////////////////////////////////////////////////////////////// |
50 | 51 |
51 GrGpu(GrContext* context); | 52 GrGpu(GrContext* context); |
52 virtual ~GrGpu(); | 53 virtual ~GrGpu(); |
53 | 54 |
54 GrContext* getContext() { return this->INHERITED::getContext(); } | 55 GrContext* getContext() { return this->INHERITED::getContext(); } |
55 const GrContext* getContext() const { return this->INHERITED::getContext();
} | 56 const GrContext* getContext() const { return this->INHERITED::getContext();
} |
56 | 57 |
| 58 GrPathRendering* pathRendering() { |
| 59 return fPathRendering.get(); |
| 60 } |
| 61 |
57 /** | 62 /** |
58 * The GrGpu object normally assumes that no outsider is setting state | 63 * The GrGpu object normally assumes that no outsider is setting state |
59 * within the underlying 3D API's context/device/whatever. This call informs | 64 * within the underlying 3D API's context/device/whatever. This call informs |
60 * the GrGpu that the state was modified and it shouldn't make assumptions | 65 * the GrGpu that the state was modified and it shouldn't make assumptions |
61 * about the state. | 66 * about the state. |
62 */ | 67 */ |
63 void markContextDirty(uint32_t state = kAll_GrBackendState) { | 68 void markContextDirty(uint32_t state = kAll_GrBackendState) { |
64 fResetBits |= state; | 69 fResetBits |= state; |
65 } | 70 } |
66 | 71 |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 SkIRect fRect; | 408 SkIRect fRect; |
404 } fScissorState; | 409 } fScissorState; |
405 | 410 |
406 // The final stencil settings to use as determined by the clip manager. | 411 // The final stencil settings to use as determined by the clip manager. |
407 GrStencilSettings fStencilSettings; | 412 GrStencilSettings fStencilSettings; |
408 | 413 |
409 // Helpers for setting up geometry state | 414 // Helpers for setting up geometry state |
410 void finalizeReservedVertices(); | 415 void finalizeReservedVertices(); |
411 void finalizeReservedIndices(); | 416 void finalizeReservedIndices(); |
412 | 417 |
| 418 SkAutoTDelete<GrPathRendering> fPathRendering; |
| 419 |
413 private: | 420 private: |
414 // GrDrawTarget overrides | 421 // GrDrawTarget overrides |
415 virtual bool onReserveVertexSpace(size_t vertexSize, int vertexCount, void**
vertices) SK_OVERRIDE; | 422 virtual bool onReserveVertexSpace(size_t vertexSize, int vertexCount, void**
vertices) SK_OVERRIDE; |
416 virtual bool onReserveIndexSpace(int indexCount, void** indices) SK_OVERRIDE
; | 423 virtual bool onReserveIndexSpace(int indexCount, void** indices) SK_OVERRIDE
; |
417 virtual void releaseReservedVertexSpace() SK_OVERRIDE; | 424 virtual void releaseReservedVertexSpace() SK_OVERRIDE; |
418 virtual void releaseReservedIndexSpace() SK_OVERRIDE; | 425 virtual void releaseReservedIndexSpace() SK_OVERRIDE; |
419 virtual void onSetVertexSourceToArray(const void* vertexArray, int vertexCou
nt) SK_OVERRIDE; | 426 virtual void onSetVertexSourceToArray(const void* vertexArray, int vertexCou
nt) SK_OVERRIDE; |
420 virtual void onSetIndexSourceToArray(const void* indexArray, int indexCount)
SK_OVERRIDE; | 427 virtual void onSetIndexSourceToArray(const void* indexArray, int indexCount)
SK_OVERRIDE; |
421 virtual void releaseVertexArray() SK_OVERRIDE; | 428 virtual void releaseVertexArray() SK_OVERRIDE; |
422 virtual void releaseIndexArray() SK_OVERRIDE; | 429 virtual void releaseIndexArray() SK_OVERRIDE; |
423 virtual void geometrySourceWillPush() SK_OVERRIDE; | 430 virtual void geometrySourceWillPush() SK_OVERRIDE; |
424 virtual void geometrySourceWillPop(const GeometrySrcState& restoredState) SK
_OVERRIDE; | 431 virtual void geometrySourceWillPop(const GeometrySrcState& restoredState) SK
_OVERRIDE; |
425 | 432 |
426 | 433 |
427 // called when the 3D context state is unknown. Subclass should emit any | 434 // called when the 3D context state is unknown. Subclass should emit any |
428 // assumed 3D context state and dirty any state cache. | 435 // assumed 3D context state and dirty any state cache. |
429 virtual void onResetContext(uint32_t resetBits) = 0; | 436 virtual void onResetContext(uint32_t resetBits) = 0; |
430 | 437 |
431 // overridden by backend-specific derived class to create objects. | 438 // overridden by backend-specific derived class to create objects. |
432 virtual GrTexture* onCreateTexture(const GrTextureDesc& desc, | 439 virtual GrTexture* onCreateTexture(const GrTextureDesc& desc, |
433 const void* srcData, | 440 const void* srcData, |
434 size_t rowBytes) = 0; | 441 size_t rowBytes) = 0; |
435 virtual GrTexture* onCreateCompressedTexture(const GrTextureDesc& desc, | 442 virtual GrTexture* onCreateCompressedTexture(const GrTextureDesc& desc, |
436 const void* srcData) = 0; | 443 const void* srcData) = 0; |
437 virtual GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&) = 0; | 444 virtual GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&) = 0; |
438 virtual GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTarge
tDesc&) = 0; | 445 virtual GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTarge
tDesc&) = 0; |
439 virtual GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) = 0; | 446 virtual GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) = 0; |
440 virtual GrIndexBuffer* onCreateIndexBuffer(size_t size, bool dynamic) = 0; | 447 virtual GrIndexBuffer* onCreateIndexBuffer(size_t size, bool dynamic) = 0; |
441 virtual GrPath* onCreatePath(const SkPath& path, const SkStrokeRec&) = 0; | |
442 virtual GrPathRange* onCreatePathRange(size_t size, const SkStrokeRec&) = 0; | |
443 | 448 |
444 // overridden by backend-specific derived class to perform the clear and | 449 // overridden by backend-specific derived class to perform the clear and |
445 // clearRect. NULL rect means clear whole target. If canIgnoreRect is | 450 // clearRect. NULL rect means clear whole target. If canIgnoreRect is |
446 // true, it is okay to perform a full clear instead of a partial clear | 451 // true, it is okay to perform a full clear instead of a partial clear |
447 virtual void onClear(const SkIRect* rect, GrColor color, bool canIgnoreRect)
= 0; | 452 virtual void onClear(const SkIRect* rect, GrColor color, bool canIgnoreRect)
= 0; |
448 | 453 |
449 // overridden by backend-specific derived class to perform the draw call. | 454 // overridden by backend-specific derived class to perform the draw call. |
450 virtual void onGpuDraw(const DrawInfo&) = 0; | 455 virtual void onGpuDraw(const DrawInfo&) = 0; |
451 | 456 |
452 // overridden by backend-specific derived class to perform the path stencili
ng. | |
453 virtual void onGpuStencilPath(const GrPath*, SkPath::FillType) = 0; | |
454 virtual void onGpuDrawPath(const GrPath*, SkPath::FillType) = 0; | |
455 virtual void onGpuDrawPaths(const GrPathRange*, | |
456 const uint32_t indices[], int count, | |
457 const float transforms[], PathTransformType, | |
458 SkPath::FillType) = 0; | |
459 | |
460 // overridden by backend-specific derived class to perform the read pixels. | 457 // overridden by backend-specific derived class to perform the read pixels. |
461 virtual bool onReadPixels(GrRenderTarget* target, | 458 virtual bool onReadPixels(GrRenderTarget* target, |
462 int left, int top, int width, int height, | 459 int left, int top, int width, int height, |
463 GrPixelConfig, | 460 GrPixelConfig, |
464 void* buffer, | 461 void* buffer, |
465 size_t rowBytes) = 0; | 462 size_t rowBytes) = 0; |
466 | 463 |
467 // overridden by backend-specific derived class to perform the texture updat
e | 464 // overridden by backend-specific derived class to perform the texture updat
e |
468 virtual bool onWriteTexturePixels(GrTexture* texture, | 465 virtual bool onWriteTexturePixels(GrTexture* texture, |
469 int left, int top, int width, int height, | 466 int left, int top, int width, int height, |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 // these are mutable so they can be created on-demand | 535 // these are mutable so they can be created on-demand |
539 mutable GrIndexBuffer* fQuadInd
exBuffer; | 536 mutable GrIndexBuffer* fQuadInd
exBuffer; |
540 // Used to abandon/release all resources created by this GrGpu. TODO: Move t
his | 537 // Used to abandon/release all resources created by this GrGpu. TODO: Move t
his |
541 // functionality to GrResourceCache. | 538 // functionality to GrResourceCache. |
542 ObjectList fObjectL
ist; | 539 ObjectList fObjectL
ist; |
543 | 540 |
544 typedef GrDrawTarget INHERITED; | 541 typedef GrDrawTarget INHERITED; |
545 }; | 542 }; |
546 | 543 |
547 #endif | 544 #endif |
OLD | NEW |