| 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 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 * GrIndexBuffer::updateData. | 117 * GrIndexBuffer::updateData. |
| 118 * | 118 * |
| 119 * @return The index buffer if successful, otherwise NULL. | 119 * @return The index buffer if successful, otherwise NULL. |
| 120 */ | 120 */ |
| 121 GrIndexBuffer* createIndexBuffer(uint32_t size, bool dynamic); | 121 GrIndexBuffer* createIndexBuffer(uint32_t size, bool dynamic); |
| 122 | 122 |
| 123 /** | 123 /** |
| 124 * Creates a path object that can be stenciled using stencilPath(). It is | 124 * Creates a path object that can be stenciled using stencilPath(). It is |
| 125 * only legal to call this if the caps report support for path stenciling. | 125 * only legal to call this if the caps report support for path stenciling. |
| 126 */ | 126 */ |
| 127 GrPath* createPath(const SkPath& path); | 127 GrPath* createPath(const SkPath& path, const SkStrokeRec& stroke); |
| 128 | 128 |
| 129 /** | 129 /** |
| 130 * Returns an index buffer that can be used to render quads. | 130 * Returns an index buffer that can be used to render quads. |
| 131 * Six indices per quad: 0, 1, 2, 0, 2, 3, etc. | 131 * Six indices per quad: 0, 1, 2, 0, 2, 3, etc. |
| 132 * The max number of quads can be queried using GrIndexBuffer::maxQuads(). | 132 * The max number of quads can be queried using GrIndexBuffer::maxQuads(). |
| 133 * Draw with kTriangles_GrPrimitiveType | 133 * Draw with kTriangles_GrPrimitiveType |
| 134 * @ return the quad index buffer | 134 * @ return the quad index buffer |
| 135 */ | 135 */ |
| 136 const GrIndexBuffer* getQuadIndexBuffer() const; | 136 const GrIndexBuffer* getQuadIndexBuffer() const; |
| 137 | 137 |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 | 341 |
| 342 // overridden by backend-specific derived class to perform the path stencili
ng. | 342 // overridden by backend-specific derived class to perform the path stencili
ng. |
| 343 virtual const GrStencilSettings& getPathStencilSettingsForFillType(SkPath::F
illType) = 0; | 343 virtual const GrStencilSettings& getPathStencilSettingsForFillType(SkPath::F
illType) = 0; |
| 344 | 344 |
| 345 protected: | 345 protected: |
| 346 enum DrawType { | 346 enum DrawType { |
| 347 kDrawPoints_DrawType, | 347 kDrawPoints_DrawType, |
| 348 kDrawLines_DrawType, | 348 kDrawLines_DrawType, |
| 349 kDrawTriangles_DrawType, | 349 kDrawTriangles_DrawType, |
| 350 kStencilPath_DrawType, | 350 kStencilPath_DrawType, |
| 351 kFillPath_DrawType, | 351 kDrawPath_DrawType, |
| 352 }; | 352 }; |
| 353 | 353 |
| 354 DrawType PrimTypeToDrawType(GrPrimitiveType type) { | 354 DrawType PrimTypeToDrawType(GrPrimitiveType type) { |
| 355 switch (type) { | 355 switch (type) { |
| 356 case kTriangles_GrPrimitiveType: | 356 case kTriangles_GrPrimitiveType: |
| 357 case kTriangleStrip_GrPrimitiveType: | 357 case kTriangleStrip_GrPrimitiveType: |
| 358 case kTriangleFan_GrPrimitiveType: | 358 case kTriangleFan_GrPrimitiveType: |
| 359 return kDrawTriangles_DrawType; | 359 return kDrawTriangles_DrawType; |
| 360 case kPoints_GrPrimitiveType: | 360 case kPoints_GrPrimitiveType: |
| 361 return kDrawPoints_DrawType; | 361 return kDrawPoints_DrawType; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 virtual void onResetContext(uint32_t resetBits) = 0; | 435 virtual void onResetContext(uint32_t resetBits) = 0; |
| 436 | 436 |
| 437 // overridden by backend-specific derived class to create objects. | 437 // overridden by backend-specific derived class to create objects. |
| 438 virtual GrTexture* onCreateTexture(const GrTextureDesc& desc, | 438 virtual GrTexture* onCreateTexture(const GrTextureDesc& desc, |
| 439 const void* srcData, | 439 const void* srcData, |
| 440 size_t rowBytes) = 0; | 440 size_t rowBytes) = 0; |
| 441 virtual GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&) = 0; | 441 virtual GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&) = 0; |
| 442 virtual GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTarge
tDesc&) = 0; | 442 virtual GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTarge
tDesc&) = 0; |
| 443 virtual GrVertexBuffer* onCreateVertexBuffer(uint32_t size, bool dynamic) =
0; | 443 virtual GrVertexBuffer* onCreateVertexBuffer(uint32_t size, bool dynamic) =
0; |
| 444 virtual GrIndexBuffer* onCreateIndexBuffer(uint32_t size, bool dynamic) = 0; | 444 virtual GrIndexBuffer* onCreateIndexBuffer(uint32_t size, bool dynamic) = 0; |
| 445 virtual GrPath* onCreatePath(const SkPath& path) = 0; | 445 virtual GrPath* onCreatePath(const SkPath& path, const SkStrokeRec& stroke)
= 0; |
| 446 | 446 |
| 447 // overridden by backend-specific derived class to perform the clear and | 447 // overridden by backend-specific derived class to perform the clear and |
| 448 // clearRect. NULL rect means clear whole target. | 448 // clearRect. NULL rect means clear whole target. |
| 449 virtual void onClear(const SkIRect* rect, GrColor color) = 0; | 449 virtual void onClear(const SkIRect* rect, GrColor color) = 0; |
| 450 | 450 |
| 451 // overridden by backend-specific derived class to perform the draw call. | 451 // overridden by backend-specific derived class to perform the draw call. |
| 452 virtual void onGpuDraw(const DrawInfo&) = 0; | 452 virtual void onGpuDraw(const DrawInfo&) = 0; |
| 453 | 453 |
| 454 // overridden by backend-specific derived class to perform the path stencili
ng. | 454 // overridden by backend-specific derived class to perform the path stencili
ng. |
| 455 virtual void onGpuStencilPath(const GrPath*, SkPath::FillType) = 0; | 455 virtual void onGpuStencilPath(const GrPath*, SkPath::FillType) = 0; |
| 456 virtual void onGpuFillPath(const GrPath*, SkPath::FillType) = 0; | 456 virtual void onGpuDrawPath(const GrPath*, const SkStrokeRec& stroke, SkPath:
:FillType) = 0; |
| 457 | 457 |
| 458 // overridden by backend-specific derived class to perform flush | 458 // overridden by backend-specific derived class to perform flush |
| 459 virtual void onForceRenderTargetFlush() = 0; | 459 virtual void onForceRenderTargetFlush() = 0; |
| 460 | 460 |
| 461 // overridden by backend-specific derived class to perform the read pixels. | 461 // overridden by backend-specific derived class to perform the read pixels. |
| 462 virtual bool onReadPixels(GrRenderTarget* target, | 462 virtual bool onReadPixels(GrRenderTarget* target, |
| 463 int left, int top, int width, int height, | 463 int left, int top, int width, int height, |
| 464 GrPixelConfig, | 464 GrPixelConfig, |
| 465 void* buffer, | 465 void* buffer, |
| 466 size_t rowBytes) = 0; | 466 size_t rowBytes) = 0; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 492 virtual void clearStencil() = 0; | 492 virtual void clearStencil() = 0; |
| 493 | 493 |
| 494 // Given a rt, find or create a stencil buffer and attach it | 494 // Given a rt, find or create a stencil buffer and attach it |
| 495 bool attachStencilBufferToRenderTarget(GrRenderTarget* target); | 495 bool attachStencilBufferToRenderTarget(GrRenderTarget* target); |
| 496 | 496 |
| 497 // GrDrawTarget overrides | 497 // GrDrawTarget overrides |
| 498 virtual void onDraw(const DrawInfo&) SK_OVERRIDE; | 498 virtual void onDraw(const DrawInfo&) SK_OVERRIDE; |
| 499 virtual void onStencilPath(const GrPath* path, const SkStrokeRec& stroke, | 499 virtual void onStencilPath(const GrPath* path, const SkStrokeRec& stroke, |
| 500 SkPath::FillType) SK_OVERRIDE; | 500 SkPath::FillType) SK_OVERRIDE; |
| 501 | 501 |
| 502 virtual void onFillPath(const GrPath* path, const SkStrokeRec& stroke, | 502 virtual void onDrawPath(const GrPath* path, const SkStrokeRec& stroke, |
| 503 SkPath::FillType) SK_OVERRIDE; | 503 SkPath::FillType) SK_OVERRIDE; |
| 504 | 504 |
| 505 // readies the pools to provide vertex/index data. | 505 // readies the pools to provide vertex/index data. |
| 506 void prepareVertexPool(); | 506 void prepareVertexPool(); |
| 507 void prepareIndexPool(); | 507 void prepareIndexPool(); |
| 508 | 508 |
| 509 void resetContext() { | 509 void resetContext() { |
| 510 // We call this because the client may have messed with the | 510 // We call this because the client may have messed with the |
| 511 // stencil buffer. Perhaps we should detect whether it is a | 511 // stencil buffer. Perhaps we should detect whether it is a |
| 512 // internally created stencil buffer and if so skip the invalidate. | 512 // internally created stencil buffer and if so skip the invalidate. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 537 // these are mutable so they can be created on-demand | 537 // these are mutable so they can be created on-demand |
| 538 mutable GrIndexBuffer* fQuadInd
exBuffer; | 538 mutable GrIndexBuffer* fQuadInd
exBuffer; |
| 539 // Used to abandon/release all resources created by this GrGpu. TODO: Move t
his | 539 // Used to abandon/release all resources created by this GrGpu. TODO: Move t
his |
| 540 // functionality to GrResourceCache. | 540 // functionality to GrResourceCache. |
| 541 ResourceList fResourc
eList; | 541 ResourceList fResourc
eList; |
| 542 | 542 |
| 543 typedef GrDrawTarget INHERITED; | 543 typedef GrDrawTarget INHERITED; |
| 544 }; | 544 }; |
| 545 | 545 |
| 546 #endif | 546 #endif |
| OLD | NEW |