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 13 matching lines...) Expand all Loading... |
24 #include "SkTArray.h" | 24 #include "SkTArray.h" |
25 #include "SkTLazy.h" | 25 #include "SkTLazy.h" |
26 #include "SkTypes.h" | 26 #include "SkTypes.h" |
27 #include "SkXfermode.h" | 27 #include "SkXfermode.h" |
28 | 28 |
29 class GrBatch; | 29 class GrBatch; |
30 class GrClipData; | 30 class GrClipData; |
31 class GrDrawTargetCaps; | 31 class GrDrawTargetCaps; |
32 class GrPath; | 32 class GrPath; |
33 class GrPathRange; | 33 class GrPathRange; |
| 34 class GrPipeline; |
34 | 35 |
35 class GrDrawTarget : public SkRefCnt { | 36 class GrDrawTarget : public SkRefCnt { |
36 public: | 37 public: |
37 SK_DECLARE_INST_COUNT(GrDrawTarget) | 38 SK_DECLARE_INST_COUNT(GrDrawTarget) |
38 | 39 |
39 typedef GrPathRange::PathIndexType PathIndexType; | 40 typedef GrPathRange::PathIndexType PathIndexType; |
40 typedef GrPathRendering::PathTransformType PathTransformType; | 41 typedef GrPathRendering::PathTransformType PathTransformType; |
41 | 42 |
42 /////////////////////////////////////////////////////////////////////////// | 43 /////////////////////////////////////////////////////////////////////////// |
43 | 44 |
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
671 | 672 |
672 // Subclass must initialize this in its constructor. | 673 // Subclass must initialize this in its constructor. |
673 SkAutoTUnref<const GrDrawTargetCaps> fCaps; | 674 SkAutoTUnref<const GrDrawTargetCaps> fCaps; |
674 | 675 |
675 const GrTraceMarkerSet& getActiveTraceMarkers() { return fActiveTraceMarkers
; } | 676 const GrTraceMarkerSet& getActiveTraceMarkers() { return fActiveTraceMarkers
; } |
676 | 677 |
677 // Makes a copy of the dst if it is necessary for the draw. Returns false if
a copy is required | 678 // Makes a copy of the dst if it is necessary for the draw. Returns false if
a copy is required |
678 // but couldn't be made. Otherwise, returns true. This method needs to be p
rotected because it | 679 // but couldn't be made. Otherwise, returns true. This method needs to be p
rotected because it |
679 // needs to be accessed by GLPrograms to setup a correct drawstate | 680 // needs to be accessed by GLPrograms to setup a correct drawstate |
680 bool setupDstReadIfNecessary(const GrPipelineBuilder&, | 681 bool setupDstReadIfNecessary(const GrPipelineBuilder&, |
| 682 const GrProcOptInfo& colorPOI, |
| 683 const GrProcOptInfo& coveragePOI, |
681 GrDeviceCoordTexture* dstCopy, | 684 GrDeviceCoordTexture* dstCopy, |
682 const SkRect* drawBounds); | 685 const SkRect* drawBounds); |
683 | 686 |
| 687 struct PipelineInfo { |
| 688 PipelineInfo(GrPipelineBuilder* pipelineBuilder, GrScissorState* scissor
, |
| 689 const GrPrimitiveProcessor* primProc, const SkRect* devBoun
ds, |
| 690 GrDrawTarget* target); |
| 691 |
| 692 PipelineInfo(GrPipelineBuilder* pipelineBuilder, GrScissorState* scissor
, |
| 693 const GrBatch* batch, const SkRect* devBounds, GrDrawTarget
* target); |
| 694 |
| 695 bool willBlendWithDst(const GrPrimitiveProcessor* primProc) const { |
| 696 return fPipelineBuilder->willBlendWithDst(primProc); |
| 697 } |
| 698 private: |
| 699 friend class GrDrawTarget; |
| 700 |
| 701 bool mustSkipDraw() const { return (NULL == fPipelineBuilder); } |
| 702 |
| 703 GrPipelineBuilder* fPipelineBuilder; |
| 704 GrScissorState* fScissor; |
| 705 GrProcOptInfo fColorPOI; |
| 706 GrProcOptInfo fCoveragePOI; |
| 707 GrDeviceCoordTexture fDstCopy; |
| 708 }; |
| 709 |
| 710 void setupPipeline(const PipelineInfo& pipelineInfo, GrPipeline* pipeline); |
| 711 |
684 private: | 712 private: |
685 /** | 713 /** |
686 * This will be called before allocating a texture as a dst for copySurface.
This function | 714 * This will be called before allocating a texture as a dst for copySurface.
This function |
687 * populates the dstDesc's config, flags, and origin so as to maximize effic
iency and guarantee | 715 * populates the dstDesc's config, flags, and origin so as to maximize effic
iency and guarantee |
688 * success of the copySurface call. | 716 * success of the copySurface call. |
689 */ | 717 */ |
690 void initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* dstDesc) { | 718 void initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* dstDesc) { |
691 if (!this->onInitCopySurfaceDstDesc(src, dstDesc)) { | 719 if (!this->onInitCopySurfaceDstDesc(src, dstDesc)) { |
692 dstDesc->fOrigin = kDefault_GrSurfaceOrigin; | 720 dstDesc->fOrigin = kDefault_GrSurfaceOrigin; |
693 dstDesc->fFlags = kRenderTarget_GrSurfaceFlag | kNoStencil_GrSurface
Flag; | 721 dstDesc->fFlags = kRenderTarget_GrSurfaceFlag | kNoStencil_GrSurface
Flag; |
(...skipping 16 matching lines...) Expand all Loading... |
710 // implemented by subclass to allocate space for reserved geom | 738 // implemented by subclass to allocate space for reserved geom |
711 virtual bool onReserveVertexSpace(size_t vertexSize, int vertexCount, void**
vertices) = 0; | 739 virtual bool onReserveVertexSpace(size_t vertexSize, int vertexCount, void**
vertices) = 0; |
712 virtual bool onReserveIndexSpace(int indexCount, void** indices) = 0; | 740 virtual bool onReserveIndexSpace(int indexCount, void** indices) = 0; |
713 // implemented by subclass to handle release of reserved geom space | 741 // implemented by subclass to handle release of reserved geom space |
714 virtual void releaseReservedVertexSpace() = 0; | 742 virtual void releaseReservedVertexSpace() = 0; |
715 virtual void releaseReservedIndexSpace() = 0; | 743 virtual void releaseReservedIndexSpace() = 0; |
716 // subclass overrides to be notified just before geo src state is pushed/pop
ped. | 744 // subclass overrides to be notified just before geo src state is pushed/pop
ped. |
717 virtual void geometrySourceWillPush() = 0; | 745 virtual void geometrySourceWillPush() = 0; |
718 virtual void geometrySourceWillPop(const GeometrySrcState& restoredState) =
0; | 746 virtual void geometrySourceWillPop(const GeometrySrcState& restoredState) =
0; |
719 // subclass called to perform drawing | 747 // subclass called to perform drawing |
720 virtual void onDraw(const GrPipelineBuilder&, | 748 virtual void onDraw(const GrGeometryProcessor*, const DrawInfo&, const Pipel
ineInfo&) = 0; |
721 const GrGeometryProcessor*, | 749 virtual void onDrawBatch(GrBatch*, const PipelineInfo&) = 0; |
722 const DrawInfo&, | |
723 const GrScissorState&) = 0; | |
724 virtual void onDrawBatch(GrBatch*, | |
725 const GrPipelineBuilder&, | |
726 const GrScissorState&, | |
727 const SkRect* devBounds) = 0; | |
728 // TODO copy in order drawbuffer onDrawRect to here | 750 // TODO copy in order drawbuffer onDrawRect to here |
729 virtual void onDrawRect(GrPipelineBuilder*, | 751 virtual void onDrawRect(GrPipelineBuilder*, |
730 GrColor color, | 752 GrColor color, |
731 const SkMatrix& viewMatrix, | 753 const SkMatrix& viewMatrix, |
732 const SkRect& rect, | 754 const SkRect& rect, |
733 const SkRect* localRect, | 755 const SkRect* localRect, |
734 const SkMatrix* localMatrix) = 0; | 756 const SkMatrix* localMatrix) = 0; |
735 | 757 |
736 virtual void onStencilPath(const GrPipelineBuilder&, | 758 virtual void onStencilPath(const GrPipelineBuilder&, |
737 const GrPathProcessor*, | 759 const GrPathProcessor*, |
738 const GrPath*, | 760 const GrPath*, |
739 const GrScissorState&, | 761 const GrScissorState&, |
740 const GrStencilSettings&) = 0; | 762 const GrStencilSettings&) = 0; |
741 virtual void onDrawPath(const GrPipelineBuilder&, | 763 virtual void onDrawPath(const GrPathProcessor*, |
742 const GrPathProcessor*, | |
743 const GrPath*, | 764 const GrPath*, |
744 const GrScissorState&, | |
745 const GrStencilSettings&, | 765 const GrStencilSettings&, |
746 const SkRect* devBounds) = 0; | 766 const PipelineInfo&) = 0; |
747 virtual void onDrawPaths(const GrPipelineBuilder&, | 767 virtual void onDrawPaths(const GrPathProcessor*, |
748 const GrPathProcessor*, | |
749 const GrPathRange*, | 768 const GrPathRange*, |
750 const void* indices, | 769 const void* indices, |
751 PathIndexType, | 770 PathIndexType, |
752 const float transformValues[], | 771 const float transformValues[], |
753 PathTransformType, | 772 PathTransformType, |
754 int count, | 773 int count, |
755 const GrScissorState&, | |
756 const GrStencilSettings&, | 774 const GrStencilSettings&, |
757 const SkRect* devBounds) = 0; | 775 const PipelineInfo&) = 0; |
758 | 776 |
759 virtual void onClear(const SkIRect* rect, GrColor color, bool canIgnoreRect, | 777 virtual void onClear(const SkIRect* rect, GrColor color, bool canIgnoreRect, |
760 GrRenderTarget* renderTarget) = 0; | 778 GrRenderTarget* renderTarget) = 0; |
761 | 779 |
762 /** The subclass will get a chance to copy the surface for falling back to t
he default | 780 /** The subclass will get a chance to copy the surface for falling back to t
he default |
763 implementation, which simply draws a rectangle (and fails if dst isn't a
render target). It | 781 implementation, which simply draws a rectangle (and fails if dst isn't a
render target). It |
764 should assume that any clipping has already been performed on the rect a
nd point. It won't | 782 should assume that any clipping has already been performed on the rect a
nd point. It won't |
765 be called if the copy can be skipped. */ | 783 be called if the copy can be skipped. */ |
766 virtual bool onCopySurface(GrSurface* dst, | 784 virtual bool onCopySurface(GrSurface* dst, |
767 GrSurface* src, | 785 GrSurface* src, |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
871 virtual bool setupClip(GrPipelineBuilder*, | 889 virtual bool setupClip(GrPipelineBuilder*, |
872 GrPipelineBuilder::AutoRestoreEffects* are, | 890 GrPipelineBuilder::AutoRestoreEffects* are, |
873 GrPipelineBuilder::AutoRestoreStencil* ars, | 891 GrPipelineBuilder::AutoRestoreStencil* ars, |
874 GrScissorState* scissorState, | 892 GrScissorState* scissorState, |
875 const SkRect* devBounds) SK_OVERRIDE; | 893 const SkRect* devBounds) SK_OVERRIDE; |
876 | 894 |
877 typedef GrDrawTarget INHERITED; | 895 typedef GrDrawTarget INHERITED; |
878 }; | 896 }; |
879 | 897 |
880 #endif | 898 #endif |
OLD | NEW |