| 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 |
| 11 #include "GrClipData.h" | 11 #include "GrClipData.h" |
| 12 #include "GrContext.h" |
| 12 #include "GrDrawState.h" | 13 #include "GrDrawState.h" |
| 13 #include "GrIndexBuffer.h" | 14 #include "GrIndexBuffer.h" |
| 15 #include "GrTraceMarker.h" |
| 14 | 16 |
| 15 #include "SkClipStack.h" | 17 #include "SkClipStack.h" |
| 16 #include "SkMatrix.h" | 18 #include "SkMatrix.h" |
| 17 #include "SkPath.h" | 19 #include "SkPath.h" |
| 18 #include "SkTArray.h" | 20 #include "SkTArray.h" |
| 19 #include "SkTLazy.h" | 21 #include "SkTLazy.h" |
| 20 #include "SkTypes.h" | 22 #include "SkTypes.h" |
| 21 #include "SkXfermode.h" | 23 #include "SkXfermode.h" |
| 22 | 24 |
| 23 class GrClipData; | 25 class GrClipData; |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 * clip and all other draw state (blend mode, stages, etc). Clears the | 418 * clip and all other draw state (blend mode, stages, etc). Clears the |
| 417 * whole thing if rect is NULL, otherwise just the rect. If canIgnoreRect | 419 * whole thing if rect is NULL, otherwise just the rect. If canIgnoreRect |
| 418 * is set then the entire render target can be optionally cleared. | 420 * is set then the entire render target can be optionally cleared. |
| 419 */ | 421 */ |
| 420 virtual void clear(const SkIRect* rect, | 422 virtual void clear(const SkIRect* rect, |
| 421 GrColor color, | 423 GrColor color, |
| 422 bool canIgnoreRect, | 424 bool canIgnoreRect, |
| 423 GrRenderTarget* renderTarget = NULL) = 0; | 425 GrRenderTarget* renderTarget = NULL) = 0; |
| 424 | 426 |
| 425 /** | 427 /** |
| 426 * instantGpuTraceEvent places a single "sign post" type marker into command
stream. The | 428 * Called at start and end of gpu trace marking |
| 427 * argument marker will be the name of the annotation that is added. | 429 * GR_CREATE_GPU_TRACE_MARKER(marker_str, target) will automatically call th
ese at the start |
| 430 * and end of a code block respectively |
| 428 */ | 431 */ |
| 429 void instantGpuTraceEvent(const char* marker); | 432 void addGpuTraceMarker(GrGpuTraceMarker* marker); |
| 430 /** | 433 void removeGpuTraceMarker(GrGpuTraceMarker* marker); |
| 431 * The following two functions are used for marking groups of commands. Use
pushGpuTraceEvent | |
| 432 * to set the beginning of a command set, and popGpuTraceEvent is be called
at end of the | |
| 433 * command set. The argument marker is the name for the annotation that is a
dded. The push and | |
| 434 * pops can be used hierarchically, but every push must have a match pop. | |
| 435 */ | |
| 436 void pushGpuTraceEvent(const char* marker); | |
| 437 void popGpuTraceEvent(); | |
| 438 | 434 |
| 439 /** | 435 /** |
| 440 * Copies a pixel rectangle from one surface to another. This call may final
ize | 436 * Copies a pixel rectangle from one surface to another. This call may final
ize |
| 441 * reserved vertex/index data (as though a draw call was made). The src pixe
ls | 437 * reserved vertex/index data (as though a draw call was made). The src pixe
ls |
| 442 * copied are specified by srcRect. They are copied to a rect of the same | 438 * copied are specified by srcRect. They are copied to a rect of the same |
| 443 * size in dst with top left at dstPoint. If the src rect is clipped by the | 439 * size in dst with top left at dstPoint. If the src rect is clipped by the |
| 444 * src bounds then pixel values in the dst rect corresponding to area clipp
ed | 440 * src bounds then pixel values in the dst rect corresponding to area clipp
ed |
| 445 * by the src rect are not overwritten. This method can fail and return fals
e | 441 * by the src rect are not overwritten. This method can fail and return fals
e |
| 446 * depending on the type of surface, configs, etc, and the backend-specific | 442 * depending on the type of surface, configs, etc, and the backend-specific |
| 447 * limitations. If rect is clipped out entirely by the src or dst bounds the
n | 443 * limitations. If rect is clipped out entirely by the src or dst bounds the
n |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 void executeDraw(const DrawInfo& info) { this->onDraw(info); } | 476 void executeDraw(const DrawInfo& info) { this->onDraw(info); } |
| 481 | 477 |
| 482 /** | 478 /** |
| 483 * For subclass internal use to invoke a call to onDrawPath(). | 479 * For subclass internal use to invoke a call to onDrawPath(). |
| 484 */ | 480 */ |
| 485 void executeDrawPath(const GrPath* path, SkPath::FillType fill, | 481 void executeDrawPath(const GrPath* path, SkPath::FillType fill, |
| 486 const GrDeviceCoordTexture* dstCopy) { | 482 const GrDeviceCoordTexture* dstCopy) { |
| 487 this->onDrawPath(path, fill, dstCopy); | 483 this->onDrawPath(path, fill, dstCopy); |
| 488 } | 484 } |
| 489 | 485 |
| 486 inline bool isGpuTracingEnabled() const { |
| 487 return this->getContext()->isGpuTracingEnabled(); |
| 488 } |
| 489 |
| 490 //////////////////////////////////////////////////////////////////////////// | 490 //////////////////////////////////////////////////////////////////////////// |
| 491 | 491 |
| 492 /** | 492 /** |
| 493 * See AutoStateRestore below. | 493 * See AutoStateRestore below. |
| 494 */ | 494 */ |
| 495 enum ASRInit { | 495 enum ASRInit { |
| 496 kPreserve_ASRInit, | 496 kPreserve_ASRInit, |
| 497 kReset_ASRInit | 497 kReset_ASRInit |
| 498 }; | 498 }; |
| 499 | 499 |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 // it is preferable to call this rather than getGeomSrc()->fVertexSize becau
se of the assert. | 756 // it is preferable to call this rather than getGeomSrc()->fVertexSize becau
se of the assert. |
| 757 size_t getVertexSize() const { | 757 size_t getVertexSize() const { |
| 758 // the vertex layout is only valid if a vertex source has been specified
. | 758 // the vertex layout is only valid if a vertex source has been specified
. |
| 759 SkASSERT(this->getGeomSrc().fVertexSrc != kNone_GeometrySrcType); | 759 SkASSERT(this->getGeomSrc().fVertexSrc != kNone_GeometrySrcType); |
| 760 return this->getGeomSrc().fVertexSize; | 760 return this->getGeomSrc().fVertexSize; |
| 761 } | 761 } |
| 762 | 762 |
| 763 // Subclass must initialize this in its constructor. | 763 // Subclass must initialize this in its constructor. |
| 764 SkAutoTUnref<const GrDrawTargetCaps> fCaps; | 764 SkAutoTUnref<const GrDrawTargetCaps> fCaps; |
| 765 | 765 |
| 766 const GrTraceMarkerSet& getActiveTraceMarkers() { return fActiveTraceMarkers
; } |
| 767 |
| 766 /** | 768 /** |
| 767 * Used to communicate draws to subclass's onDraw function. | 769 * Used to communicate draws to subclass's onDraw function. |
| 768 */ | 770 */ |
| 769 class DrawInfo { | 771 class DrawInfo { |
| 770 public: | 772 public: |
| 771 DrawInfo(const DrawInfo& di) { (*this) = di; } | 773 DrawInfo(const DrawInfo& di) { (*this) = di; } |
| 772 DrawInfo& operator =(const DrawInfo& di); | 774 DrawInfo& operator =(const DrawInfo& di); |
| 773 | 775 |
| 774 GrPrimitiveType primitiveType() const { return fPrimitiveType; } | 776 GrPrimitiveType primitiveType() const { return fPrimitiveType; } |
| 775 int startVertex() const { return fStartVertex; } | 777 int startVertex() const { return fStartVertex; } |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 861 // drawNonIndexed from reserved vertex space. | 863 // drawNonIndexed from reserved vertex space. |
| 862 virtual void onDrawRect(const SkRect& rect, | 864 virtual void onDrawRect(const SkRect& rect, |
| 863 const SkMatrix* matrix, | 865 const SkMatrix* matrix, |
| 864 const SkRect* localRect, | 866 const SkRect* localRect, |
| 865 const SkMatrix* localMatrix); | 867 const SkMatrix* localMatrix); |
| 866 | 868 |
| 867 virtual void onStencilPath(const GrPath*, SkPath::FillType) = 0; | 869 virtual void onStencilPath(const GrPath*, SkPath::FillType) = 0; |
| 868 virtual void onDrawPath(const GrPath*, SkPath::FillType, | 870 virtual void onDrawPath(const GrPath*, SkPath::FillType, |
| 869 const GrDeviceCoordTexture* dstCopy) = 0; | 871 const GrDeviceCoordTexture* dstCopy) = 0; |
| 870 | 872 |
| 871 virtual void onInstantGpuTraceEvent(const char* marker) = 0; | 873 virtual void didAddGpuTraceMarker() = 0; |
| 872 virtual void onPushGpuTraceEvent(const char* marker) = 0; | 874 virtual void didRemoveGpuTraceMarker() = 0; |
| 873 virtual void onPopGpuTraceEvent() = 0; | |
| 874 | 875 |
| 875 // helpers for reserving vertex and index space. | 876 // helpers for reserving vertex and index space. |
| 876 bool reserveVertexSpace(size_t vertexSize, | 877 bool reserveVertexSpace(size_t vertexSize, |
| 877 int vertexCount, | 878 int vertexCount, |
| 878 void** vertices); | 879 void** vertices); |
| 879 bool reserveIndexSpace(int indexCount, void** indices); | 880 bool reserveIndexSpace(int indexCount, void** indices); |
| 880 | 881 |
| 881 // called by drawIndexed and drawNonIndexed. Use a negative indexCount to | 882 // called by drawIndexed and drawNonIndexed. Use a negative indexCount to |
| 882 // indicate non-indexed drawing. | 883 // indicate non-indexed drawing. |
| 883 bool checkDraw(GrPrimitiveType type, int startVertex, | 884 bool checkDraw(GrPrimitiveType type, int startVertex, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 899 | 900 |
| 900 enum { | 901 enum { |
| 901 kPreallocGeoSrcStateStackCnt = 4, | 902 kPreallocGeoSrcStateStackCnt = 4, |
| 902 }; | 903 }; |
| 903 SkSTArray<kPreallocGeoSrcStateStackCnt, GeometrySrcState, true> fGeoSrcState
Stack; | 904 SkSTArray<kPreallocGeoSrcStateStackCnt, GeometrySrcState, true> fGeoSrcState
Stack; |
| 904 const GrClipData* fClip; | 905 const GrClipData* fClip; |
| 905 GrDrawState* fDrawState; | 906 GrDrawState* fDrawState; |
| 906 GrDrawState fDefaultDraw
State; | 907 GrDrawState fDefaultDraw
State; |
| 907 // The context owns us, not vice-versa, so this ptr is not ref'ed by DrawTar
get. | 908 // The context owns us, not vice-versa, so this ptr is not ref'ed by DrawTar
get. |
| 908 GrContext* fContext; | 909 GrContext* fContext; |
| 909 // To keep track that we always have at least as many debug marker pushes as
pops | 910 // To keep track that we always have at least as many debug marker adds as r
emoves |
| 910 int fPushGpuTrac
eCount; | 911 int fGpuTraceMar
kerCount; |
| 912 GrTraceMarkerSet fActiveTrace
Markers; |
| 911 | 913 |
| 912 typedef SkRefCnt INHERITED; | 914 typedef SkRefCnt INHERITED; |
| 913 }; | 915 }; |
| 914 | 916 |
| 915 #endif | 917 #endif |
| OLD | NEW |