Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(210)

Side by Side Diff: src/gpu/GrDrawState.h

Issue 739673002: Create GrOptDrawState before recording draw in GrInOrderDrawBuffer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: remove unused function in pendingprogramelement Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/gpu/SkGr.h ('k') | src/gpu/GrDrawState.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 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 GrDrawState_DEFINED 8 #ifndef GrDrawState_DEFINED
9 #define GrDrawState_DEFINED 9 #define GrDrawState_DEFINED
10 10
11 11
12 #include "GrBlend.h" 12 #include "GrBlend.h"
13 #include "GrDrawTargetCaps.h" 13 #include "GrDrawTargetCaps.h"
14 #include "GrGeometryProcessor.h" 14 #include "GrGeometryProcessor.h"
15 #include "GrGpuResourceRef.h" 15 #include "GrGpuResourceRef.h"
16 #include "GrProcessorStage.h" 16 #include "GrFragmentStage.h"
17 #include "GrProcOptInfo.h" 17 #include "GrProcOptInfo.h"
18 #include "GrRenderTarget.h" 18 #include "GrRenderTarget.h"
19 #include "GrStencil.h" 19 #include "GrStencil.h"
20 #include "SkMatrix.h" 20 #include "SkMatrix.h"
21 #include "effects/GrSimpleTextureEffect.h" 21 #include "effects/GrSimpleTextureEffect.h"
22 22
23 class GrDrawTargetCaps; 23 class GrDrawTargetCaps;
24 class GrOptDrawState; 24 class GrOptDrawState;
25 class GrPaint; 25 class GrPaint;
26 class GrTexture; 26 class GrTexture;
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 * 533 *
534 * @return The currently set render target. 534 * @return The currently set render target.
535 */ 535 */
536 GrRenderTarget* getRenderTarget() const { return fRenderTarget.get(); } 536 GrRenderTarget* getRenderTarget() const { return fRenderTarget.get(); }
537 537
538 /** 538 /**
539 * Sets the render-target used at the next drawing call 539 * Sets the render-target used at the next drawing call
540 * 540 *
541 * @param target The render target to set. 541 * @param target The render target to set.
542 */ 542 */
543 void setRenderTarget(GrRenderTarget* target) { 543 void setRenderTarget(GrRenderTarget* target) { fRenderTarget.reset(SkSafeRef (target)); }
544 fRenderTarget.set(SkSafeRef(target), kWrite_GrIOType);
545 }
546 544
547 /// @} 545 /// @}
548 546
549 /////////////////////////////////////////////////////////////////////////// 547 ///////////////////////////////////////////////////////////////////////////
550 /// @name Stencil 548 /// @name Stencil
551 //// 549 ////
552 550
553 const GrStencilSettings& getStencil() const { return fStencilSettings; } 551 const GrStencilSettings& getStencil() const { return fStencilSettings; }
554 552
555 /** 553 /**
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 }; 710 };
713 711
714 void setHint(Hints hint, bool value) { fHints = value ? (fHints | hint) : (f Hints & ~hint); } 712 void setHint(Hints hint, bool value) { fHints = value ? (fHints | hint) : (f Hints & ~hint); }
715 713
716 bool vertexColorsAreOpaque() const { return kVertexColorsAreOpaque_Hint & fH ints; } 714 bool vertexColorsAreOpaque() const { return kVertexColorsAreOpaque_Hint & fH ints; }
717 715
718 /// @} 716 /// @}
719 717
720 /////////////////////////////////////////////////////////////////////////// 718 ///////////////////////////////////////////////////////////////////////////
721 719
722 /** Return type for CombineIfPossible. */
723 enum CombinedState {
724 /** The GrDrawStates cannot be combined. */
725 kIncompatible_CombinedState,
726 /** Either draw state can be used in place of the other. */
727 kAOrB_CombinedState,
728 /** Use the first draw state. */
729 kA_CombinedState,
730 /** Use the second draw state. */
731 kB_CombinedState,
732 };
733
734 /** This function determines whether the GrDrawStates used for two draws can be combined into
735 a single GrDrawState. This is used to avoid storing redundant GrDrawStat es and to determine
736 if draws can be batched. The return value indicates whether combining is possible and, if
737 so, which of the two inputs should be used. */
738 static CombinedState CombineIfPossible(const GrDrawState& a, const GrDrawSta te& b,
739 const GrDrawTargetCaps& caps);
740
741 GrDrawState& operator= (const GrDrawState& that); 720 GrDrawState& operator= (const GrDrawState& that);
742 721
743 private: 722 private:
744 /**
745 * Converts refs on GrGpuResources owned directly or indirectly by this GrDr awState into
746 * pending reads and writes. This should be called when a GrDrawState is rec orded into
747 * a GrDrawTarget for later execution. Subclasses of GrDrawState may add set ters. However,
748 * once this call has been made the GrDrawState is immutable. It is also no longer copyable.
749 * In the future this conversion will automatically happen when converting a GrDrawState into
750 * an optimized draw state.
751 */
752 void convertToPendingExec();
753
754 friend class GrDrawTarget;
755
756 bool isEqual(const GrDrawState& that) const; 723 bool isEqual(const GrDrawState& that) const;
757 724
758 /** 725 /**
759 * Optimizations for blending / coverage to that can be applied based on the current state. 726 * Optimizations for blending / coverage to that can be applied based on the current state.
760 */ 727 */
761 enum BlendOptFlags { 728 enum BlendOptFlags {
762 /** 729 /**
763 * No optimization 730 * No optimization
764 */ 731 */
765 kNone_BlendOpt = 0, 732 kNone_BlendOpt = 0,
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 void calcCoverageInvariantOutput() const; 796 void calcCoverageInvariantOutput() const;
830 797
831 void onReset(const SkMatrix* initialViewMatrix); 798 void onReset(const SkMatrix* initialViewMatrix);
832 799
833 // Some of the auto restore objects assume that no effects are removed durin g their lifetime. 800 // Some of the auto restore objects assume that no effects are removed durin g their lifetime.
834 // This is used to assert that this condition holds. 801 // This is used to assert that this condition holds.
835 SkDEBUGCODE(int fBlockEffectRemovalCnt;) 802 SkDEBUGCODE(int fBlockEffectRemovalCnt;)
836 803
837 void internalSetVertexAttribs(const GrVertexAttrib attribs[], int count, siz e_t stride); 804 void internalSetVertexAttribs(const GrVertexAttrib attribs[], int count, siz e_t stride);
838 805
839 typedef GrTGpuResourceRef<GrRenderTarget> ProgramRenderTarget; 806 typedef SkSTArray<4, GrFragmentStage> FragmentStageArray;
840 // These fields are roughly sorted by decreasing likelihood of being differe nt in op==
841 ProgramRenderTarget fRenderTarget;
842 GrColor fColor;
843 SkMatrix fViewMatrix;
844 GrColor fBlendConstant;
845 uint32_t fFlagBits;
846 const GrVertexAttrib* fVAPtr;
847 int fVACount;
848 size_t fVAStride;
849 GrStencilSettings fStencilSettings;
850 uint8_t fCoverage;
851 DrawFace fDrawFace;
852 GrBlendCoeff fSrcBlend;
853 GrBlendCoeff fDstBlend;
854 807
855 typedef SkSTArray<4, GrFragmentStage> FragmentStageArray; 808 SkAutoTUnref<GrRenderTarget> fRenderTarget;
856 typedef GrProgramElementRef<const GrGeometryProcessor> ProgramGeometryProces sor; 809 GrColor fColor;
857 ProgramGeometryProcessor fGeometryProcessor; 810 SkMatrix fViewMatrix;
858 FragmentStageArray fColorStages; 811 GrColor fBlendConstant;
859 FragmentStageArray fCoverageStages; 812 uint32_t fFlagBits;
860 813 const GrVertexAttrib* fVAPtr;
861 uint32_t fHints; 814 int fVACount;
815 size_t fVAStride;
816 GrStencilSettings fStencilSettings;
817 uint8_t fCoverage;
818 DrawFace fDrawFace;
819 GrBlendCoeff fSrcBlend;
820 GrBlendCoeff fDstBlend;
821 SkAutoTUnref<const GrGeometryProcessor> fGeometryProcessor;
822 FragmentStageArray fColorStages;
823 FragmentStageArray fCoverageStages;
824 uint32_t fHints;
862 825
863 // This is simply a different representation of info in fVertexAttribs and t hus does 826 // This is simply a different representation of info in fVertexAttribs and t hus does
864 // not need to be compared in op==. 827 // not need to be compared in op==.
865 int fFixedFunctionVertexAttribIndices[kGrFixedFunctionVertexAttribBindingCnt ]; 828 int fFixedFunctionVertexAttribIndices[kGrFixedFunctionVertexAttribBindingCnt ];
866 829
867 mutable GrProcOptInfo fColorProcInfo; 830 mutable GrProcOptInfo fColorProcInfo;
868 mutable GrProcOptInfo fCoverageProcInfo; 831 mutable GrProcOptInfo fCoverageProcInfo;
869 mutable bool fColorProcInfoValid; 832 mutable bool fColorProcInfoValid;
870 mutable bool fCoverageProcInfoValid; 833 mutable bool fCoverageProcInfoValid;
871 834
872 friend class GrOptDrawState; 835 friend class GrOptDrawState;
873 }; 836 };
874 837
875 GR_MAKE_BITFIELD_OPS(GrDrawState::BlendOptFlags); 838 GR_MAKE_BITFIELD_OPS(GrDrawState::BlendOptFlags);
876 839
877 #endif 840 #endif
OLDNEW
« no previous file with comments | « include/gpu/SkGr.h ('k') | src/gpu/GrDrawState.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698