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