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

Side by Side Diff: src/gpu/effects/GrConfigConversionEffect.cpp

Issue 778453002: Remove backend factories (Closed) Base URL: https://skia.googlesource.com/skia.git@unichoice
Patch Set: cleanup Created 6 years 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
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 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 #include "GrConfigConversionEffect.h" 8 #include "GrConfigConversionEffect.h"
9 #include "GrContext.h" 9 #include "GrContext.h"
10 #include "GrInvariantOutput.h" 10 #include "GrInvariantOutput.h"
11 #include "GrTBackendProcessorFactory.h"
12 #include "GrSimpleTextureEffect.h" 11 #include "GrSimpleTextureEffect.h"
12 #include "SkMatrix.h"
13 #include "gl/GrGLProcessor.h" 13 #include "gl/GrGLProcessor.h"
14 #include "gl/builders/GrGLProgramBuilder.h" 14 #include "gl/builders/GrGLProgramBuilder.h"
15 #include "SkMatrix.h"
16 15
17 class GrGLConfigConversionEffect : public GrGLFragmentProcessor { 16 class GrGLConfigConversionEffect : public GrGLFragmentProcessor {
18 public: 17 public:
19 GrGLConfigConversionEffect(const GrBackendProcessorFactory& factory, 18 GrGLConfigConversionEffect(const GrProcessor& processor) {
20 const GrProcessor& processor)
21 : INHERITED (factory) {
22 const GrConfigConversionEffect& configConversionEffect = 19 const GrConfigConversionEffect& configConversionEffect =
23 processor.cast<GrConfigConversionEffect>(); 20 processor.cast<GrConfigConversionEffect>();
24 fSwapRedAndBlue = configConversionEffect.swapsRedAndBlue(); 21 fSwapRedAndBlue = configConversionEffect.swapsRedAndBlue();
25 fPMConversion = configConversionEffect.pmConversion(); 22 fPMConversion = configConversionEffect.pmConversion();
26 } 23 }
27 24
28 virtual void emitCode(GrGLFPBuilder* builder, 25 virtual void emitCode(GrGLFPBuilder* builder,
29 const GrFragmentProcessor&, 26 const GrFragmentProcessor&,
30 const char* outputColor, 27 const char* outputColor,
31 const char* inputColor, 28 const char* inputColor,
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 const SkMatrix& matrix) 105 const SkMatrix& matrix)
109 : GrSingleTextureEffect(texture, matrix) 106 : GrSingleTextureEffect(texture, matrix)
110 , fSwapRedAndBlue(swapRedAndBlue) 107 , fSwapRedAndBlue(swapRedAndBlue)
111 , fPMConversion(pmConversion) { 108 , fPMConversion(pmConversion) {
112 SkASSERT(kRGBA_8888_GrPixelConfig == texture->config() || 109 SkASSERT(kRGBA_8888_GrPixelConfig == texture->config() ||
113 kBGRA_8888_GrPixelConfig == texture->config()); 110 kBGRA_8888_GrPixelConfig == texture->config());
114 // Why did we pollute our texture cache instead of using a GrSingleTextureEf fect? 111 // Why did we pollute our texture cache instead of using a GrSingleTextureEf fect?
115 SkASSERT(swapRedAndBlue || kNone_PMConversion != pmConversion); 112 SkASSERT(swapRedAndBlue || kNone_PMConversion != pmConversion);
116 } 113 }
117 114
118 const GrBackendFragmentProcessorFactory& GrConfigConversionEffect::getFactory() const {
119 return GrTBackendFragmentProcessorFactory<GrConfigConversionEffect>::getInst ance();
120 }
121
122 bool GrConfigConversionEffect::onIsEqual(const GrFragmentProcessor& s) const { 115 bool GrConfigConversionEffect::onIsEqual(const GrFragmentProcessor& s) const {
123 const GrConfigConversionEffect& other = s.cast<GrConfigConversionEffect>(); 116 const GrConfigConversionEffect& other = s.cast<GrConfigConversionEffect>();
124 return other.fSwapRedAndBlue == fSwapRedAndBlue && 117 return other.fSwapRedAndBlue == fSwapRedAndBlue &&
125 other.fPMConversion == fPMConversion; 118 other.fPMConversion == fPMConversion;
126 } 119 }
127 120
128 void GrConfigConversionEffect::onComputeInvariantOutput(GrInvariantOutput* inout ) const { 121 void GrConfigConversionEffect::onComputeInvariantOutput(GrInvariantOutput* inout ) const {
129 this->updateInvariantOutputForModulation(inout); 122 this->updateInvariantOutputForModulation(inout);
130 } 123 }
131 124
(...skipping 13 matching lines...) Expand all
145 swapRB = random->nextBool(); 138 swapRB = random->nextBool();
146 } 139 }
147 return SkNEW_ARGS(GrConfigConversionEffect, 140 return SkNEW_ARGS(GrConfigConversionEffect,
148 (textures[GrProcessorUnitTest::kSkiaPMText ureIdx], 141 (textures[GrProcessorUnitTest::kSkiaPMText ureIdx],
149 swapRB, 142 swapRB,
150 pmConv, 143 pmConv,
151 GrProcessorUnitTest::TestMatrix(random))) ; 144 GrProcessorUnitTest::TestMatrix(random))) ;
152 } 145 }
153 146
154 /////////////////////////////////////////////////////////////////////////////// 147 ///////////////////////////////////////////////////////////////////////////////
148
149 void GrConfigConversionEffect::getGLProcessorKey(const GrGLCaps& caps,
150 GrProcessorKeyBuilder* b) const {
151 GrGLConfigConversionEffect::GenKey(*this, caps, b);
152 }
153
154 GrGLFragmentProcessor* GrConfigConversionEffect::createGLInstance() const {
155 return SkNEW_ARGS(GrGLConfigConversionEffect, (*this));
156 }
157
155 void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context , 158 void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context ,
156 PMConversion* pmTo UPMRule, 159 PMConversion* pmTo UPMRule,
157 PMConversion* upmT oPMRule) { 160 PMConversion* upmT oPMRule) {
158 *pmToUPMRule = kNone_PMConversion; 161 *pmToUPMRule = kNone_PMConversion;
159 *upmToPMRule = kNone_PMConversion; 162 *upmToPMRule = kNone_PMConversion;
160 SkAutoTMalloc<uint32_t> data(256 * 256 * 3); 163 SkAutoTMalloc<uint32_t> data(256 * 256 * 3);
161 uint32_t* srcData = data.get(); 164 uint32_t* srcData = data.get();
162 uint32_t* firstRead = data.get() + 256 * 256; 165 uint32_t* firstRead = data.get() + 256 * 256;
163 uint32_t* secondRead = data.get() + 2 * 256 * 256; 166 uint32_t* secondRead = data.get() + 2 * 256 * 256;
164 167
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 kNone_PMConversion != pmConversion) { 277 kNone_PMConversion != pmConversion) {
275 // The PM conversions assume colors are 0..255 278 // The PM conversions assume colors are 0..255
276 return NULL; 279 return NULL;
277 } 280 }
278 return SkNEW_ARGS(GrConfigConversionEffect, (texture, 281 return SkNEW_ARGS(GrConfigConversionEffect, (texture,
279 swapRedAndBlue, 282 swapRedAndBlue,
280 pmConversion, 283 pmConversion,
281 matrix)); 284 matrix));
282 } 285 }
283 } 286 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698