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

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

Issue 2041113004: sk_sp for gpu. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Reserve correctly. Created 4 years, 6 months 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 | « src/gpu/GrPaint.cpp ('k') | src/gpu/GrPipelineBuilder.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 2015 Google Inc. 2 * Copyright 2015 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 GrPipelineBuilder_DEFINED 8 #ifndef GrPipelineBuilder_DEFINED
9 #define GrPipelineBuilder_DEFINED 9 #define GrPipelineBuilder_DEFINED
10 10
11 #include "GrBlend.h" 11 #include "GrBlend.h"
12 #include "GrCaps.h" 12 #include "GrCaps.h"
13 #include "GrGpuResourceRef.h" 13 #include "GrGpuResourceRef.h"
14 #include "GrProcOptInfo.h" 14 #include "GrProcOptInfo.h"
15 #include "GrRenderTarget.h" 15 #include "GrRenderTarget.h"
16 #include "GrUserStencilSettings.h" 16 #include "GrUserStencilSettings.h"
17 #include "GrXferProcessor.h" 17 #include "GrXferProcessor.h"
18 #include "SkMatrix.h" 18 #include "SkMatrix.h"
19 #include "SkRefCnt.h"
19 #include "effects/GrCoverageSetOpXP.h" 20 #include "effects/GrCoverageSetOpXP.h"
20 #include "effects/GrDisableColorXP.h" 21 #include "effects/GrDisableColorXP.h"
21 #include "effects/GrPorterDuffXferProcessor.h" 22 #include "effects/GrPorterDuffXferProcessor.h"
22 #include "effects/GrSimpleTextureEffect.h" 23 #include "effects/GrSimpleTextureEffect.h"
23 24
24 class GrDrawBatch; 25 class GrDrawBatch;
25 class GrCaps; 26 class GrCaps;
26 class GrPaint; 27 class GrPaint;
27 class GrTexture; 28 class GrTexture;
28 29
(...skipping 20 matching lines...) Expand all
49 /// color/coverage which is fed to the next FP in the chain. The last color and coverage FPs 50 /// color/coverage which is fed to the next FP in the chain. The last color and coverage FPs
50 /// feed their output to the GrXferProcessor which controls blending. 51 /// feed their output to the GrXferProcessor which controls blending.
51 //// 52 ////
52 53
53 int numColorFragmentProcessors() const { return fColorFragmentProcessors.cou nt(); } 54 int numColorFragmentProcessors() const { return fColorFragmentProcessors.cou nt(); }
54 int numCoverageFragmentProcessors() const { return fCoverageFragmentProcesso rs.count(); } 55 int numCoverageFragmentProcessors() const { return fCoverageFragmentProcesso rs.count(); }
55 int numFragmentProcessors() const { return this->numColorFragmentProcessors( ) + 56 int numFragmentProcessors() const { return this->numColorFragmentProcessors( ) +
56 this->numCoverageFragmentProcesso rs(); } 57 this->numCoverageFragmentProcesso rs(); }
57 58
58 const GrFragmentProcessor* getColorFragmentProcessor(int idx) const { 59 const GrFragmentProcessor* getColorFragmentProcessor(int idx) const {
59 return fColorFragmentProcessors[idx]; 60 return fColorFragmentProcessors[idx].get();
60 } 61 }
61 const GrFragmentProcessor* getCoverageFragmentProcessor(int idx) const { 62 const GrFragmentProcessor* getCoverageFragmentProcessor(int idx) const {
62 return fCoverageFragmentProcessors[idx]; 63 return fCoverageFragmentProcessors[idx].get();
63 } 64 }
64 65
65 const GrFragmentProcessor* addColorFragmentProcessor(const GrFragmentProcess or* processor) { 66 void addColorFragmentProcessor(sk_sp<GrFragmentProcessor> processor) {
66 SkASSERT(processor); 67 SkASSERT(processor);
67 fColorFragmentProcessors.push_back(SkRef(processor)); 68 fColorFragmentProcessors.push_back(std::move(processor));
68 return processor;
69 } 69 }
70 70
71 const GrFragmentProcessor* addCoverageFragmentProcessor(const GrFragmentProc essor* processor) { 71 void addCoverageFragmentProcessor(sk_sp<GrFragmentProcessor> processor) {
72 SkASSERT(processor); 72 SkASSERT(processor);
73 fCoverageFragmentProcessors.push_back(SkRef(processor)); 73 fCoverageFragmentProcessors.push_back(std::move(processor));
74 return processor;
75 } 74 }
76 75
77 /** 76 /**
78 * Creates a GrSimpleTextureEffect that uses local coords as texture coordin ates. 77 * Creates a GrSimpleTextureEffect that uses local coords as texture coordin ates.
79 */ 78 */
80 void addColorTextureProcessor(GrTexture* texture, const SkMatrix& matrix) { 79 void addColorTextureProcessor(GrTexture* texture, const SkMatrix& matrix) {
81 this->addColorFragmentProcessor(GrSimpleTextureEffect::Create(texture, m atrix))->unref(); 80 this->addColorFragmentProcessor(GrSimpleTextureEffect::Make(texture, mat rix));
82 } 81 }
83 82
84 void addCoverageTextureProcessor(GrTexture* texture, const SkMatrix& matrix) { 83 void addCoverageTextureProcessor(GrTexture* texture, const SkMatrix& matrix) {
85 this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Create(texture , matrix))->unref(); 84 this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(texture, matrix));
86 } 85 }
87 86
88 void addColorTextureProcessor(GrTexture* texture, 87 void addColorTextureProcessor(GrTexture* texture,
89 const SkMatrix& matrix, 88 const SkMatrix& matrix,
90 const GrTextureParams& params) { 89 const GrTextureParams& params) {
91 this->addColorFragmentProcessor(GrSimpleTextureEffect::Create(texture, m atrix, 90 this->addColorFragmentProcessor(GrSimpleTextureEffect::Make(texture, mat rix, params));
92 params))-> unref();
93 } 91 }
94 92
95 void addCoverageTextureProcessor(GrTexture* texture, 93 void addCoverageTextureProcessor(GrTexture* texture,
96 const SkMatrix& matrix, 94 const SkMatrix& matrix,
97 const GrTextureParams& params) { 95 const GrTextureParams& params) {
98 this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Create(texture , matrix, 96 this->addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(texture, matrix, params));
99 params) )->unref();
100 } 97 }
101 98
102 /** 99 /**
103 * When this object is destroyed it will remove any color/coverage FPs from the pipeline builder 100 * When this object is destroyed it will remove any color/coverage FPs from the pipeline builder
104 * that were added after its constructor. 101 * that were added after its constructor.
105 * This class can transiently modify its "const" GrPipelineBuilder object bu t will restore it 102 * This class can transiently modify its "const" GrPipelineBuilder object bu t will restore it
106 * when done - so it is notionally "const" correct. 103 * when done - so it is notionally "const" correct.
107 */ 104 */
108 class AutoRestoreFragmentProcessorState : public ::SkNoncopyable { 105 class AutoRestoreFragmentProcessorState : public ::SkNoncopyable {
109 public: 106 public:
110 AutoRestoreFragmentProcessorState() 107 AutoRestoreFragmentProcessorState()
111 : fPipelineBuilder(nullptr) 108 : fPipelineBuilder(nullptr)
112 , fColorEffectCnt(0) 109 , fColorEffectCnt(0)
113 , fCoverageEffectCnt(0) {} 110 , fCoverageEffectCnt(0) {}
114 111
115 AutoRestoreFragmentProcessorState(const GrPipelineBuilder& ds) 112 AutoRestoreFragmentProcessorState(const GrPipelineBuilder& ds)
116 : fPipelineBuilder(nullptr) 113 : fPipelineBuilder(nullptr)
117 , fColorEffectCnt(0) 114 , fColorEffectCnt(0)
118 , fCoverageEffectCnt(0) { 115 , fCoverageEffectCnt(0) {
119 this->set(&ds); 116 this->set(&ds);
120 } 117 }
121 118
122 ~AutoRestoreFragmentProcessorState() { this->set(nullptr); } 119 ~AutoRestoreFragmentProcessorState() { this->set(nullptr); }
123 120
124 void set(const GrPipelineBuilder* ds); 121 void set(const GrPipelineBuilder* ds);
125 122
126 bool isSet() const { return SkToBool(fPipelineBuilder); } 123 bool isSet() const { return SkToBool(fPipelineBuilder); }
127 124
128 const GrFragmentProcessor* addCoverageFragmentProcessor( 125 void addCoverageFragmentProcessor(sk_sp<GrFragmentProcessor> processor) {
129 const GrFragmentProcessor* processor) {
130 SkASSERT(this->isSet()); 126 SkASSERT(this->isSet());
131 return fPipelineBuilder->addCoverageFragmentProcessor(processor); 127 return fPipelineBuilder->addCoverageFragmentProcessor(std::move(proc essor));
132 } 128 }
133 129
134 private: 130 private:
135 // notionally const (as marginalia) 131 // notionally const (as marginalia)
136 GrPipelineBuilder* fPipelineBuilder; 132 GrPipelineBuilder* fPipelineBuilder;
137 int fColorEffectCnt; 133 int fColorEffectCnt;
138 int fCoverageEffectCnt; 134 int fCoverageEffectCnt;
139 }; 135 };
140 136
141 /// @} 137 /// @}
142 138
143 /////////////////////////////////////////////////////////////////////////// 139 ///////////////////////////////////////////////////////////////////////////
144 /// @name Blending 140 /// @name Blending
145 //// 141 ////
146 142
147 /** 143 /**
148 * Installs a GrXPFactory. This object controls how src color, fractional pi xel coverage, 144 * Installs a GrXPFactory. This object controls how src color, fractional pi xel coverage,
149 * and the dst color are blended. 145 * and the dst color are blended.
150 */ 146 */
151 const GrXPFactory* setXPFactory(const GrXPFactory* xpFactory) { 147 void setXPFactory(sk_sp<GrXPFactory> xpFactory) {
152 fXPFactory.reset(SkSafeRef(xpFactory)); 148 fXPFactory = std::move(xpFactory);
153 return xpFactory;
154 } 149 }
155 150
156 /** 151 /**
157 * Sets a GrXPFactory that disables color writes to the destination. This is useful when 152 * Sets a GrXPFactory that disables color writes to the destination. This is useful when
158 * rendering to the stencil buffer. 153 * rendering to the stencil buffer.
159 */ 154 */
160 void setDisableColorXPFactory() { 155 void setDisableColorXPFactory() {
161 fXPFactory.reset(GrDisableColorXPFactory::Create()); 156 fXPFactory = GrDisableColorXPFactory::Make();
162 } 157 }
163 158
164 const GrXPFactory* getXPFactory() const { 159 const GrXPFactory* getXPFactory() const {
165 return fXPFactory; 160 return fXPFactory.get();
166 } 161 }
167 162
168 /** 163 /**
169 * Checks whether the xp will need destination in a texture to correctly ble nd. 164 * Checks whether the xp will need destination in a texture to correctly ble nd.
170 */ 165 */
171 bool willXPNeedDstTexture(const GrCaps& caps, 166 bool willXPNeedDstTexture(const GrCaps& caps,
172 const GrPipelineOptimizations& optimizations) cons t; 167 const GrPipelineOptimizations& optimizations) cons t;
173 168
174 /// @} 169 /// @}
175 170
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 292
298 /////////////////////////////////////////////////////////////////////////// 293 ///////////////////////////////////////////////////////////////////////////
299 294
300 bool usePLSDstRead(const GrDrawBatch* batch) const; 295 bool usePLSDstRead(const GrDrawBatch* batch) const;
301 296
302 private: 297 private:
303 // Some of the auto restore objects assume that no effects are removed durin g their lifetime. 298 // Some of the auto restore objects assume that no effects are removed durin g their lifetime.
304 // This is used to assert that this condition holds. 299 // This is used to assert that this condition holds.
305 SkDEBUGCODE(mutable int fBlockEffectRemovalCnt;) 300 SkDEBUGCODE(mutable int fBlockEffectRemovalCnt;)
306 301
307 typedef SkSTArray<4, const GrFragmentProcessor*, true> FragmentProcessorArra y; 302 typedef SkSTArray<4, sk_sp<GrFragmentProcessor>> FragmentProcessorArray;
308 303
309 uint32_t fFlags; 304 uint32_t fFlags;
310 const GrUserStencilSettings* fUserStencilSettings; 305 const GrUserStencilSettings* fUserStencilSettings;
311 DrawFace fDrawFace; 306 DrawFace fDrawFace;
312 mutable SkAutoTUnref<const GrXPFactory> fXPFactory; 307 mutable sk_sp<GrXPFactory> fXPFactory;
313 FragmentProcessorArray fColorFragmentProcessors; 308 FragmentProcessorArray fColorFragmentProcessors;
314 FragmentProcessorArray fCoverageFragmentProcessors; 309 FragmentProcessorArray fCoverageFragmentProcessors;
315 310
316 friend class GrPipeline; 311 friend class GrPipeline;
317 friend class GrDrawTarget; 312 friend class GrDrawTarget;
318 }; 313 };
319 314
320 #endif 315 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrPaint.cpp ('k') | src/gpu/GrPipelineBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698