| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2010 Google Inc. | 2 * Copyright 2010 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 GrDrawTarget_DEFINED | 8 #ifndef GrDrawTarget_DEFINED |
| 9 #define GrDrawTarget_DEFINED | 9 #define GrDrawTarget_DEFINED |
| 10 | 10 |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 const SkRect* devBounds = NULL); | 322 const SkRect* devBounds = NULL); |
| 323 | 323 |
| 324 /** | 324 /** |
| 325 * Draws path into the stencil buffer. The fill must be either even/odd or | 325 * Draws path into the stencil buffer. The fill must be either even/odd or |
| 326 * winding (not inverse or hairline). It will respect the HW antialias flag | 326 * winding (not inverse or hairline). It will respect the HW antialias flag |
| 327 * on the draw state (if possible in the 3D API). | 327 * on the draw state (if possible in the 3D API). |
| 328 */ | 328 */ |
| 329 void stencilPath(const GrPath*, const SkStrokeRec& stroke, SkPath::FillType
fill); | 329 void stencilPath(const GrPath*, const SkStrokeRec& stroke, SkPath::FillType
fill); |
| 330 | 330 |
| 331 /** | 331 /** |
| 332 * Fills a path. Fill must not be a hairline. It will respect the HW |
| 333 * antialias flag on the draw state (if possible in the 3D API). |
| 334 */ |
| 335 void fillPath(const GrPath*, const SkStrokeRec& stroke, SkPath::FillType fil
l); |
| 336 |
| 337 /** |
| 332 * Helper function for drawing rects. It performs a geometry src push and po
p | 338 * Helper function for drawing rects. It performs a geometry src push and po
p |
| 333 * and thus will finalize any reserved geometry. | 339 * and thus will finalize any reserved geometry. |
| 334 * | 340 * |
| 335 * @param rect the rect to draw | 341 * @param rect the rect to draw |
| 336 * @param matrix optional matrix applied to rect (before viewMatrix) | 342 * @param matrix optional matrix applied to rect (before viewMatrix) |
| 337 * @param localRect optional rect that specifies local coords to map onto | 343 * @param localRect optional rect that specifies local coords to map onto |
| 338 * rect. If NULL then rect serves as the local coords. | 344 * rect. If NULL then rect serves as the local coords. |
| 339 * @param localMatrix optional matrix applied to localRect. If | 345 * @param localMatrix optional matrix applied to localRect. If |
| 340 * srcRect is non-NULL and srcMatrix is non-NULL | 346 * srcRect is non-NULL and srcMatrix is non-NULL |
| 341 * then srcRect will be transformed by srcMatrix. | 347 * then srcRect will be transformed by srcMatrix. |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 * Release any resources that are cached but not currently in use. This | 447 * Release any resources that are cached but not currently in use. This |
| 442 * is intended to give an application some recourse when resources are low. | 448 * is intended to give an application some recourse when resources are low. |
| 443 */ | 449 */ |
| 444 virtual void purgeResources() {}; | 450 virtual void purgeResources() {}; |
| 445 | 451 |
| 446 /** | 452 /** |
| 447 * For subclass internal use to invoke a call to onDraw(). See DrawInfo belo
w. | 453 * For subclass internal use to invoke a call to onDraw(). See DrawInfo belo
w. |
| 448 */ | 454 */ |
| 449 void executeDraw(const DrawInfo& info) { this->onDraw(info); } | 455 void executeDraw(const DrawInfo& info) { this->onDraw(info); } |
| 450 | 456 |
| 457 /** |
| 458 * For subclass internal use to invoke a call to onFillPath(). |
| 459 */ |
| 460 void executeFillPath(const GrPath* path, const SkStrokeRec& stroke, |
| 461 SkPath::FillType fill, const GrDeviceCoordTexture* dstC
opy) { |
| 462 this->onFillPath(path, stroke, fill, dstCopy); |
| 463 } |
| 464 |
| 451 //////////////////////////////////////////////////////////////////////////// | 465 //////////////////////////////////////////////////////////////////////////// |
| 452 | 466 |
| 453 /** | 467 /** |
| 454 * See AutoStateRestore below. | 468 * See AutoStateRestore below. |
| 455 */ | 469 */ |
| 456 enum ASRInit { | 470 enum ASRInit { |
| 457 kPreserve_ASRInit, | 471 kPreserve_ASRInit, |
| 458 kReset_ASRInit | 472 kReset_ASRInit |
| 459 }; | 473 }; |
| 460 | 474 |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 754 void adjustStartVertex(int vertexOffset); | 768 void adjustStartVertex(int vertexOffset); |
| 755 // shifts the start index | 769 // shifts the start index |
| 756 void adjustStartIndex(int indexOffset); | 770 void adjustStartIndex(int indexOffset); |
| 757 | 771 |
| 758 void setDevBounds(const SkRect& bounds) { | 772 void setDevBounds(const SkRect& bounds) { |
| 759 fDevBoundsStorage = bounds; | 773 fDevBoundsStorage = bounds; |
| 760 fDevBounds = &fDevBoundsStorage; | 774 fDevBounds = &fDevBoundsStorage; |
| 761 } | 775 } |
| 762 const SkRect* getDevBounds() const { return fDevBounds; } | 776 const SkRect* getDevBounds() const { return fDevBounds; } |
| 763 | 777 |
| 764 bool getDevIBounds(SkIRect* bounds) const { | |
| 765 if (NULL != fDevBounds) { | |
| 766 fDevBounds->roundOut(bounds); | |
| 767 return true; | |
| 768 } else { | |
| 769 return false; | |
| 770 } | |
| 771 } | |
| 772 | |
| 773 // NULL if no copy of the dst is needed for the draw. | 778 // NULL if no copy of the dst is needed for the draw. |
| 774 const GrDeviceCoordTexture* getDstCopy() const { | 779 const GrDeviceCoordTexture* getDstCopy() const { |
| 775 if (NULL != fDstCopy.texture()) { | 780 if (NULL != fDstCopy.texture()) { |
| 776 return &fDstCopy; | 781 return &fDstCopy; |
| 777 } else { | 782 } else { |
| 778 return NULL; | 783 return NULL; |
| 779 } | 784 } |
| 780 } | 785 } |
| 781 | 786 |
| 782 private: | 787 private: |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 827 // be saved before this is called and restored afterwards. A subclass may ov
erride | 832 // be saved before this is called and restored afterwards. A subclass may ov
erride |
| 828 // this to perform more optimal rect rendering. Its draws should be funneled
through | 833 // this to perform more optimal rect rendering. Its draws should be funneled
through |
| 829 // one of the public GrDrawTarget draw methods (e.g. drawNonIndexed, | 834 // one of the public GrDrawTarget draw methods (e.g. drawNonIndexed, |
| 830 // drawIndexedInstances, ...). The base class draws a two triangle fan using | 835 // drawIndexedInstances, ...). The base class draws a two triangle fan using |
| 831 // drawNonIndexed from reserved vertex space. | 836 // drawNonIndexed from reserved vertex space. |
| 832 virtual void onDrawRect(const SkRect& rect, | 837 virtual void onDrawRect(const SkRect& rect, |
| 833 const SkMatrix* matrix, | 838 const SkMatrix* matrix, |
| 834 const SkRect* localRect, | 839 const SkRect* localRect, |
| 835 const SkMatrix* localMatrix); | 840 const SkMatrix* localMatrix); |
| 836 virtual void onStencilPath(const GrPath*, const SkStrokeRec& stroke, SkPath:
:FillType fill) = 0; | 841 virtual void onStencilPath(const GrPath*, const SkStrokeRec& stroke, SkPath:
:FillType fill) = 0; |
| 842 virtual void onFillPath(const GrPath*, const SkStrokeRec& stroke, SkPath::Fi
llType fill, |
| 843 const GrDeviceCoordTexture* dstCopy) = 0; |
| 837 | 844 |
| 838 // helpers for reserving vertex and index space. | 845 // helpers for reserving vertex and index space. |
| 839 bool reserveVertexSpace(size_t vertexSize, | 846 bool reserveVertexSpace(size_t vertexSize, |
| 840 int vertexCount, | 847 int vertexCount, |
| 841 void** vertices); | 848 void** vertices); |
| 842 bool reserveIndexSpace(int indexCount, void** indices); | 849 bool reserveIndexSpace(int indexCount, void** indices); |
| 843 | 850 |
| 844 // called by drawIndexed and drawNonIndexed. Use a negative indexCount to | 851 // called by drawIndexed and drawNonIndexed. Use a negative indexCount to |
| 845 // indicate non-indexed drawing. | 852 // indicate non-indexed drawing. |
| 846 bool checkDraw(GrPrimitiveType type, int startVertex, | 853 bool checkDraw(GrPrimitiveType type, int startVertex, |
| 847 int startIndex, int vertexCount, | 854 int startIndex, int vertexCount, |
| 848 int indexCount) const; | 855 int indexCount) const; |
| 849 // called when setting a new vert/idx source to unref prev vb/ib | 856 // called when setting a new vert/idx source to unref prev vb/ib |
| 850 void releasePreviousVertexSource(); | 857 void releasePreviousVertexSource(); |
| 851 void releasePreviousIndexSource(); | 858 void releasePreviousIndexSource(); |
| 852 | 859 |
| 853 // Makes a copy of the dst if it is necessary for the draw. Returns false if
a copy is required | 860 // Makes a copy of the dst if it is necessary for the draw. Returns false if
a copy is required |
| 854 // but couldn't be made. Otherwise, returns true. | 861 // but couldn't be made. Otherwise, returns true. |
| 855 bool setupDstReadIfNecessary(DrawInfo* info); | 862 bool setupDstReadIfNecessary(DrawInfo* info) { |
| 863 return this->setupDstReadIfNecessary(&info->fDstCopy, info->getDevBounds
()); |
| 864 } |
| 865 bool setupDstReadIfNecessary(GrDeviceCoordTexture* dstCopy, const SkRect* dr
awBounds); |
| 856 | 866 |
| 857 // Check to see if this set of draw commands has been sent out | 867 // Check to see if this set of draw commands has been sent out |
| 858 virtual bool isIssued(uint32_t drawID) { return true; } | 868 virtual bool isIssued(uint32_t drawID) { return true; } |
| 859 | 869 |
| 860 enum { | 870 enum { |
| 861 kPreallocGeoSrcStateStackCnt = 4, | 871 kPreallocGeoSrcStateStackCnt = 4, |
| 862 }; | 872 }; |
| 863 SkSTArray<kPreallocGeoSrcStateStackCnt, GeometrySrcState, true> fGeoSrcState
Stack; | 873 SkSTArray<kPreallocGeoSrcStateStackCnt, GeometrySrcState, true> fGeoSrcState
Stack; |
| 864 const GrClipData* fClip; | 874 const GrClipData* fClip; |
| 865 GrDrawState* fDrawState; | 875 GrDrawState* fDrawState; |
| 866 GrDrawState fDefaultDraw
State; | 876 GrDrawState fDefaultDraw
State; |
| 867 // The context owns us, not vice-versa, so this ptr is not ref'ed by DrawTar
get. | 877 // The context owns us, not vice-versa, so this ptr is not ref'ed by DrawTar
get. |
| 868 GrContext* fContext; | 878 GrContext* fContext; |
| 869 | 879 |
| 870 typedef SkRefCnt INHERITED; | 880 typedef SkRefCnt INHERITED; |
| 871 }; | 881 }; |
| 872 | 882 |
| 873 #endif | 883 #endif |
| OLD | NEW |