| 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 "SkStrokeRec.h" | 20 #include "SkStrokeRec.h" |
| 19 #include "SkTArray.h" | 21 #include "SkTArray.h" |
| 20 #include "SkTLazy.h" | 22 #include "SkTLazy.h" |
| 21 #include "SkTypes.h" | 23 #include "SkTypes.h" |
| 22 #include "SkXfermode.h" | 24 #include "SkXfermode.h" |
| 23 | 25 |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 * clip and all other draw state (blend mode, stages, etc). Clears the | 431 * clip and all other draw state (blend mode, stages, etc). Clears the |
| 430 * whole thing if rect is NULL, otherwise just the rect. If canIgnoreRect | 432 * whole thing if rect is NULL, otherwise just the rect. If canIgnoreRect |
| 431 * is set then the entire render target can be optionally cleared. | 433 * is set then the entire render target can be optionally cleared. |
| 432 */ | 434 */ |
| 433 virtual void clear(const SkIRect* rect, | 435 virtual void clear(const SkIRect* rect, |
| 434 GrColor color, | 436 GrColor color, |
| 435 bool canIgnoreRect, | 437 bool canIgnoreRect, |
| 436 GrRenderTarget* renderTarget = NULL) = 0; | 438 GrRenderTarget* renderTarget = NULL) = 0; |
| 437 | 439 |
| 438 /** | 440 /** |
| 439 * instantGpuTraceEvent places a single "sign post" type marker into command
stream. The | 441 * Called at start and end of gpu trace marking |
| 440 * argument marker will be the name of the annotation that is added. | 442 * GR_CREATE_GPU_TRACE_MARKER(marker_str, target) will automatically call th
ese at the start |
| 443 * and end of a code block respectively |
| 441 */ | 444 */ |
| 442 void instantGpuTraceEvent(const char* marker); | 445 void addGpuTraceMarker(GrGpuTraceMarker* marker); |
| 443 /** | 446 void removeGpuTraceMarker(GrGpuTraceMarker* marker); |
| 444 * The following two functions are used for marking groups of commands. Use
pushGpuTraceEvent | |
| 445 * to set the beginning of a command set, and popGpuTraceEvent is be called
at end of the | |
| 446 * command set. The argument marker is the name for the annotation that is a
dded. The push and | |
| 447 * pops can be used hierarchically, but every push must have a match pop. | |
| 448 */ | |
| 449 void pushGpuTraceEvent(const char* marker); | |
| 450 void popGpuTraceEvent(); | |
| 451 | 447 |
| 452 /** | 448 /** |
| 453 * Copies a pixel rectangle from one surface to another. This call may final
ize | 449 * Copies a pixel rectangle from one surface to another. This call may final
ize |
| 454 * reserved vertex/index data (as though a draw call was made). The src pixe
ls | 450 * reserved vertex/index data (as though a draw call was made). The src pixe
ls |
| 455 * copied are specified by srcRect. They are copied to a rect of the same | 451 * copied are specified by srcRect. They are copied to a rect of the same |
| 456 * size in dst with top left at dstPoint. If the src rect is clipped by the | 452 * size in dst with top left at dstPoint. If the src rect is clipped by the |
| 457 * src bounds then pixel values in the dst rect corresponding to area clipp
ed | 453 * src bounds then pixel values in the dst rect corresponding to area clipp
ed |
| 458 * by the src rect are not overwritten. This method can fail and return fals
e | 454 * by the src rect are not overwritten. This method can fail and return fals
e |
| 459 * depending on the type of surface, configs, etc, and the backend-specific | 455 * depending on the type of surface, configs, etc, and the backend-specific |
| 460 * limitations. If rect is clipped out entirely by the src or dst bounds the
n | 456 * limitations. If rect is clipped out entirely by the src or dst bounds the
n |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 | 498 |
| 503 /** | 499 /** |
| 504 * For subclass internal use to invoke a call to onDrawPaths(). | 500 * For subclass internal use to invoke a call to onDrawPaths(). |
| 505 */ | 501 */ |
| 506 void executeDrawPaths(size_t pathCount, const GrPath** paths, | 502 void executeDrawPaths(size_t pathCount, const GrPath** paths, |
| 507 const SkMatrix* transforms, SkPath::FillType fill, | 503 const SkMatrix* transforms, SkPath::FillType fill, |
| 508 SkStrokeRec::Style stroke, | 504 SkStrokeRec::Style stroke, |
| 509 const GrDeviceCoordTexture* dstCopy) { | 505 const GrDeviceCoordTexture* dstCopy) { |
| 510 this->onDrawPaths(pathCount, paths, transforms, fill, stroke, dstCopy); | 506 this->onDrawPaths(pathCount, paths, transforms, fill, stroke, dstCopy); |
| 511 } | 507 } |
| 508 |
| 509 inline bool isGpuTracingEnabled() const { |
| 510 return this->getContext()->isGpuTracingEnabled(); |
| 511 } |
| 512 | 512 |
| 513 //////////////////////////////////////////////////////////////////////////// | 513 //////////////////////////////////////////////////////////////////////////// |
| 514 | 514 |
| 515 /** | 515 /** |
| 516 * See AutoStateRestore below. | 516 * See AutoStateRestore below. |
| 517 */ | 517 */ |
| 518 enum ASRInit { | 518 enum ASRInit { |
| 519 kPreserve_ASRInit, | 519 kPreserve_ASRInit, |
| 520 kReset_ASRInit | 520 kReset_ASRInit |
| 521 }; | 521 }; |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 779 // it is preferable to call this rather than getGeomSrc()->fVertexSize becau
se of the assert. | 779 // it is preferable to call this rather than getGeomSrc()->fVertexSize becau
se of the assert. |
| 780 size_t getVertexSize() const { | 780 size_t getVertexSize() const { |
| 781 // the vertex layout is only valid if a vertex source has been specified
. | 781 // the vertex layout is only valid if a vertex source has been specified
. |
| 782 SkASSERT(this->getGeomSrc().fVertexSrc != kNone_GeometrySrcType); | 782 SkASSERT(this->getGeomSrc().fVertexSrc != kNone_GeometrySrcType); |
| 783 return this->getGeomSrc().fVertexSize; | 783 return this->getGeomSrc().fVertexSize; |
| 784 } | 784 } |
| 785 | 785 |
| 786 // Subclass must initialize this in its constructor. | 786 // Subclass must initialize this in its constructor. |
| 787 SkAutoTUnref<const GrDrawTargetCaps> fCaps; | 787 SkAutoTUnref<const GrDrawTargetCaps> fCaps; |
| 788 | 788 |
| 789 const GrTraceMarkerSet& getActiveTraceMarkers() { return fActiveTraceMarkers
; } |
| 790 |
| 789 /** | 791 /** |
| 790 * Used to communicate draws to subclass's onDraw function. | 792 * Used to communicate draws to subclass's onDraw function. |
| 791 */ | 793 */ |
| 792 class DrawInfo { | 794 class DrawInfo { |
| 793 public: | 795 public: |
| 794 DrawInfo(const DrawInfo& di) { (*this) = di; } | 796 DrawInfo(const DrawInfo& di) { (*this) = di; } |
| 795 DrawInfo& operator =(const DrawInfo& di); | 797 DrawInfo& operator =(const DrawInfo& di); |
| 796 | 798 |
| 797 GrPrimitiveType primitiveType() const { return fPrimitiveType; } | 799 GrPrimitiveType primitiveType() const { return fPrimitiveType; } |
| 798 int startVertex() const { return fStartVertex; } | 800 int startVertex() const { return fStartVertex; } |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 887 const SkRect* localRect, | 889 const SkRect* localRect, |
| 888 const SkMatrix* localMatrix); | 890 const SkMatrix* localMatrix); |
| 889 | 891 |
| 890 virtual void onStencilPath(const GrPath*, SkPath::FillType) = 0; | 892 virtual void onStencilPath(const GrPath*, SkPath::FillType) = 0; |
| 891 virtual void onDrawPath(const GrPath*, SkPath::FillType, | 893 virtual void onDrawPath(const GrPath*, SkPath::FillType, |
| 892 const GrDeviceCoordTexture* dstCopy) = 0; | 894 const GrDeviceCoordTexture* dstCopy) = 0; |
| 893 virtual void onDrawPaths(size_t, const GrPath**, const SkMatrix*, | 895 virtual void onDrawPaths(size_t, const GrPath**, const SkMatrix*, |
| 894 SkPath::FillType, SkStrokeRec::Style, | 896 SkPath::FillType, SkStrokeRec::Style, |
| 895 const GrDeviceCoordTexture* dstCopy) = 0; | 897 const GrDeviceCoordTexture* dstCopy) = 0; |
| 896 | 898 |
| 897 virtual void onInstantGpuTraceEvent(const char* marker) = 0; | 899 virtual void didAddGpuTraceMarker() = 0; |
| 898 virtual void onPushGpuTraceEvent(const char* marker) = 0; | 900 virtual void didRemoveGpuTraceMarker() = 0; |
| 899 virtual void onPopGpuTraceEvent() = 0; | |
| 900 | 901 |
| 901 // helpers for reserving vertex and index space. | 902 // helpers for reserving vertex and index space. |
| 902 bool reserveVertexSpace(size_t vertexSize, | 903 bool reserveVertexSpace(size_t vertexSize, |
| 903 int vertexCount, | 904 int vertexCount, |
| 904 void** vertices); | 905 void** vertices); |
| 905 bool reserveIndexSpace(int indexCount, void** indices); | 906 bool reserveIndexSpace(int indexCount, void** indices); |
| 906 | 907 |
| 907 // called by drawIndexed and drawNonIndexed. Use a negative indexCount to | 908 // called by drawIndexed and drawNonIndexed. Use a negative indexCount to |
| 908 // indicate non-indexed drawing. | 909 // indicate non-indexed drawing. |
| 909 bool checkDraw(GrPrimitiveType type, int startVertex, | 910 bool checkDraw(GrPrimitiveType type, int startVertex, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 925 | 926 |
| 926 enum { | 927 enum { |
| 927 kPreallocGeoSrcStateStackCnt = 4, | 928 kPreallocGeoSrcStateStackCnt = 4, |
| 928 }; | 929 }; |
| 929 SkSTArray<kPreallocGeoSrcStateStackCnt, GeometrySrcState, true> fGeoSrcState
Stack; | 930 SkSTArray<kPreallocGeoSrcStateStackCnt, GeometrySrcState, true> fGeoSrcState
Stack; |
| 930 const GrClipData* fClip; | 931 const GrClipData* fClip; |
| 931 GrDrawState* fDrawState; | 932 GrDrawState* fDrawState; |
| 932 GrDrawState fDefaultDraw
State; | 933 GrDrawState fDefaultDraw
State; |
| 933 // The context owns us, not vice-versa, so this ptr is not ref'ed by DrawTar
get. | 934 // The context owns us, not vice-versa, so this ptr is not ref'ed by DrawTar
get. |
| 934 GrContext* fContext; | 935 GrContext* fContext; |
| 935 // To keep track that we always have at least as many debug marker pushes as
pops | 936 // To keep track that we always have at least as many debug marker adds as r
emoves |
| 936 int fPushGpuTrac
eCount; | 937 int fGpuTraceMar
kerCount; |
| 938 GrTraceMarkerSet fActiveTrace
Markers; |
| 937 | 939 |
| 938 typedef SkRefCnt INHERITED; | 940 typedef SkRefCnt INHERITED; |
| 939 }; | 941 }; |
| 940 | 942 |
| 941 #endif | 943 #endif |
| OLD | NEW |