Chromium Code Reviews| 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 , | |
|
bsalomon
2015/02/12 21:39:26
can we bury these constructors in the cpp?
| |
| 689 const GrPrimitiveProcessor* primProc, const SkRect* devBoun ds, | |
| 690 GrDrawTarget* target) | |
| 691 : fPipelineBuilder(pipelineBuilder) | |
| 692 , fScissor(scissor) { | |
| 693 fColorPOI = fPipelineBuilder->colorProcInfo(primProc); | |
| 694 fCoveragePOI = fPipelineBuilder->coverageProcInfo(primProc); | |
| 695 if (!target->setupDstReadIfNecessary(*fPipelineBuilder, fColorPOI, f CoveragePOI, | |
| 696 &fDstCopy, devBounds)) { | |
| 697 fPipelineBuilder = NULL; | |
| 698 } | |
| 699 } | |
| 700 | |
| 701 PipelineInfo(GrPipelineBuilder* pipelineBuilder, GrScissorState* scissor , | |
| 702 const GrBatch* batch, const SkRect* devBounds, | |
| 703 GrDrawTarget* target) | |
| 704 : fPipelineBuilder(pipelineBuilder) | |
| 705 , fScissor(scissor) { | |
| 706 fColorPOI = fPipelineBuilder->colorProcInfo(batch); | |
| 707 fCoveragePOI = fPipelineBuilder->coverageProcInfo(batch); | |
| 708 if (!target->setupDstReadIfNecessary(*fPipelineBuilder, fColorPOI, f CoveragePOI, | |
| 709 &fDstCopy, devBounds)) { | |
| 710 fPipelineBuilder = NULL; | |
| 711 } | |
| 712 } | |
| 713 | |
| 714 bool willBlendWithDst(const GrPrimitiveProcessor* primProc) const { | |
| 715 return fPipelineBuilder->willBlendWithDst(primProc); | |
| 716 } | |
| 717 private: | |
| 718 friend class GrDrawTarget; | |
| 719 | |
| 720 bool mustSkipDraw() const { return (NULL == fPipelineBuilder); } | |
| 721 | |
| 722 GrPipelineBuilder* fPipelineBuilder; | |
| 723 GrScissorState* fScissor; | |
| 724 GrProcOptInfo fColorPOI; | |
| 725 GrProcOptInfo fCoveragePOI; | |
| 726 GrDeviceCoordTexture fDstCopy; | |
| 727 }; | |
| 728 | |
| 729 void setupPipeline(const PipelineInfo& pipelineInfo, GrPipeline* pipeline); | |
| 684 private: | 730 private: |
|
bsalomon
2015/02/12 21:39:26
\n
| |
| 685 /** | 731 /** |
| 686 * This will be called before allocating a texture as a dst for copySurface. This function | 732 * 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 | 733 * populates the dstDesc's config, flags, and origin so as to maximize effic iency and guarantee |
| 688 * success of the copySurface call. | 734 * success of the copySurface call. |
| 689 */ | 735 */ |
| 690 void initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* dstDesc) { | 736 void initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* dstDesc) { |
| 691 if (!this->onInitCopySurfaceDstDesc(src, dstDesc)) { | 737 if (!this->onInitCopySurfaceDstDesc(src, dstDesc)) { |
| 692 dstDesc->fOrigin = kDefault_GrSurfaceOrigin; | 738 dstDesc->fOrigin = kDefault_GrSurfaceOrigin; |
| 693 dstDesc->fFlags = kRenderTarget_GrSurfaceFlag | kNoStencil_GrSurface Flag; | 739 dstDesc->fFlags = kRenderTarget_GrSurfaceFlag | kNoStencil_GrSurface Flag; |
| 694 dstDesc->fConfig = src->config(); | 740 dstDesc->fConfig = src->config(); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 710 // implemented by subclass to allocate space for reserved geom | 756 // implemented by subclass to allocate space for reserved geom |
| 711 virtual bool onReserveVertexSpace(size_t vertexSize, int vertexCount, void** vertices) = 0; | 757 virtual bool onReserveVertexSpace(size_t vertexSize, int vertexCount, void** vertices) = 0; |
| 712 virtual bool onReserveIndexSpace(int indexCount, void** indices) = 0; | 758 virtual bool onReserveIndexSpace(int indexCount, void** indices) = 0; |
| 713 // implemented by subclass to handle release of reserved geom space | 759 // implemented by subclass to handle release of reserved geom space |
| 714 virtual void releaseReservedVertexSpace() = 0; | 760 virtual void releaseReservedVertexSpace() = 0; |
| 715 virtual void releaseReservedIndexSpace() = 0; | 761 virtual void releaseReservedIndexSpace() = 0; |
| 716 // subclass overrides to be notified just before geo src state is pushed/pop ped. | 762 // subclass overrides to be notified just before geo src state is pushed/pop ped. |
| 717 virtual void geometrySourceWillPush() = 0; | 763 virtual void geometrySourceWillPush() = 0; |
| 718 virtual void geometrySourceWillPop(const GeometrySrcState& restoredState) = 0; | 764 virtual void geometrySourceWillPop(const GeometrySrcState& restoredState) = 0; |
| 719 // subclass called to perform drawing | 765 // subclass called to perform drawing |
| 720 virtual void onDraw(const GrPipelineBuilder&, | 766 virtual void onDraw(const GrGeometryProcessor*, |
| 721 const GrGeometryProcessor*, | |
| 722 const DrawInfo&, | 767 const DrawInfo&, |
| 723 const GrScissorState&) = 0; | 768 const PipelineInfo&) = 0; |
| 724 virtual void onDrawBatch(GrBatch*, | 769 virtual void onDrawBatch(GrBatch*, |
| 725 const GrPipelineBuilder&, | 770 const PipelineInfo&) = 0; |
| 726 const GrScissorState&, | |
| 727 const SkRect* devBounds) = 0; | |
| 728 // TODO copy in order drawbuffer onDrawRect to here | 771 // TODO copy in order drawbuffer onDrawRect to here |
| 729 virtual void onDrawRect(GrPipelineBuilder*, | 772 virtual void onDrawRect(GrPipelineBuilder*, |
| 730 GrColor color, | 773 GrColor color, |
| 731 const SkMatrix& viewMatrix, | 774 const SkMatrix& viewMatrix, |
| 732 const SkRect& rect, | 775 const SkRect& rect, |
| 733 const SkRect* localRect, | 776 const SkRect* localRect, |
| 734 const SkMatrix* localMatrix) = 0; | 777 const SkMatrix* localMatrix) = 0; |
| 735 | 778 |
| 736 virtual void onStencilPath(const GrPipelineBuilder&, | 779 virtual void onStencilPath(const GrPipelineBuilder&, |
| 737 const GrPathProcessor*, | 780 const GrPathProcessor*, |
| 738 const GrPath*, | 781 const GrPath*, |
| 739 const GrScissorState&, | 782 const GrScissorState&, |
| 740 const GrStencilSettings&) = 0; | 783 const GrStencilSettings&) = 0; |
| 741 virtual void onDrawPath(const GrPipelineBuilder&, | 784 virtual void onDrawPath(const GrPathProcessor*, |
| 742 const GrPathProcessor*, | |
| 743 const GrPath*, | 785 const GrPath*, |
| 744 const GrScissorState&, | |
| 745 const GrStencilSettings&, | 786 const GrStencilSettings&, |
| 746 const SkRect* devBounds) = 0; | 787 const PipelineInfo&) = 0; |
| 747 virtual void onDrawPaths(const GrPipelineBuilder&, | 788 virtual void onDrawPaths(const GrPathProcessor*, |
| 748 const GrPathProcessor*, | |
| 749 const GrPathRange*, | 789 const GrPathRange*, |
| 750 const void* indices, | 790 const void* indices, |
| 751 PathIndexType, | 791 PathIndexType, |
| 752 const float transformValues[], | 792 const float transformValues[], |
| 753 PathTransformType, | 793 PathTransformType, |
| 754 int count, | 794 int count, |
| 755 const GrScissorState&, | |
| 756 const GrStencilSettings&, | 795 const GrStencilSettings&, |
| 757 const SkRect* devBounds) = 0; | 796 const PipelineInfo&) = 0; |
| 758 | 797 |
| 759 virtual void onClear(const SkIRect* rect, GrColor color, bool canIgnoreRect, | 798 virtual void onClear(const SkIRect* rect, GrColor color, bool canIgnoreRect, |
| 760 GrRenderTarget* renderTarget) = 0; | 799 GrRenderTarget* renderTarget) = 0; |
| 761 | 800 |
| 762 /** The subclass will get a chance to copy the surface for falling back to t he default | 801 /** 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 | 802 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 | 803 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. */ | 804 be called if the copy can be skipped. */ |
| 766 virtual bool onCopySurface(GrSurface* dst, | 805 virtual bool onCopySurface(GrSurface* dst, |
| 767 GrSurface* src, | 806 GrSurface* src, |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 871 virtual bool setupClip(GrPipelineBuilder*, | 910 virtual bool setupClip(GrPipelineBuilder*, |
| 872 GrPipelineBuilder::AutoRestoreEffects* are, | 911 GrPipelineBuilder::AutoRestoreEffects* are, |
| 873 GrPipelineBuilder::AutoRestoreStencil* ars, | 912 GrPipelineBuilder::AutoRestoreStencil* ars, |
| 874 GrScissorState* scissorState, | 913 GrScissorState* scissorState, |
| 875 const SkRect* devBounds) SK_OVERRIDE; | 914 const SkRect* devBounds) SK_OVERRIDE; |
| 876 | 915 |
| 877 typedef GrDrawTarget INHERITED; | 916 typedef GrDrawTarget INHERITED; |
| 878 }; | 917 }; |
| 879 | 918 |
| 880 #endif | 919 #endif |
| OLD | NEW |