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

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

Issue 778453002: Remove backend factories (Closed) Base URL: https://skia.googlesource.com/skia.git@unichoice
Patch Set: more clang warnings 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
« no previous file with comments | « src/gpu/effects/GrTextureDomain.h ('k') | src/gpu/effects/GrYUVtoRGBEffect.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 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 "gl/builders/GrGLProgramBuilder.h"
9 #include "GrTextureDomain.h" 8 #include "GrTextureDomain.h"
10 #include "GrInvariantOutput.h" 9 #include "GrInvariantOutput.h"
11 #include "GrSimpleTextureEffect.h" 10 #include "GrSimpleTextureEffect.h"
12 #include "GrTBackendProcessorFactory.h" 11 #include "SkFloatingPoint.h"
13 #include "gl/GrGLProcessor.h" 12 #include "gl/GrGLProcessor.h"
14 #include "SkFloatingPoint.h" 13 #include "gl/builders/GrGLProgramBuilder.h"
15
16 14
17 GrTextureDomain::GrTextureDomain(const SkRect& domain, Mode mode, int index) 15 GrTextureDomain::GrTextureDomain(const SkRect& domain, Mode mode, int index)
18 : fIndex(index) { 16 : fIndex(index) {
19 17
20 static const SkRect kFullRect = {0, 0, SK_Scalar1, SK_Scalar1}; 18 static const SkRect kFullRect = {0, 0, SK_Scalar1, SK_Scalar1};
21 if (domain.contains(kFullRect) && kClamp_Mode == mode) { 19 if (domain.contains(kFullRect) && kClamp_Mode == mode) {
22 fMode = kIgnore_Mode; 20 fMode = kIgnore_Mode;
23 } else { 21 } else {
24 fMode = mode; 22 fMode = mode;
25 } 23 }
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 memcpy(fPrevDomain, values, 4 * sizeof(GrGLfloat)); 159 memcpy(fPrevDomain, values, 4 * sizeof(GrGLfloat));
162 } 160 }
163 } 161 }
164 } 162 }
165 163
166 164
167 ////////////////////////////////////////////////////////////////////////////// 165 //////////////////////////////////////////////////////////////////////////////
168 166
169 class GrGLTextureDomainEffect : public GrGLFragmentProcessor { 167 class GrGLTextureDomainEffect : public GrGLFragmentProcessor {
170 public: 168 public:
171 GrGLTextureDomainEffect(const GrBackendProcessorFactory&, const GrProcessor& ); 169 GrGLTextureDomainEffect(const GrProcessor&);
172 170
173 virtual void emitCode(GrGLFPBuilder*, 171 virtual void emitCode(GrGLFPBuilder*,
174 const GrFragmentProcessor&, 172 const GrFragmentProcessor&,
175 const char* outputColor, 173 const char* outputColor,
176 const char* inputColor, 174 const char* inputColor,
177 const TransformedCoordsArray&, 175 const TransformedCoordsArray&,
178 const TextureSamplerArray&) SK_OVERRIDE; 176 const TextureSamplerArray&) SK_OVERRIDE;
179 177
180 virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_O VERRIDE; 178 virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_O VERRIDE;
181 179
182 static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKe yBuilder*); 180 static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKe yBuilder*);
183 181
184 private: 182 private:
185 GrTextureDomain::GLDomain fGLDomain; 183 GrTextureDomain::GLDomain fGLDomain;
186 typedef GrGLFragmentProcessor INHERITED; 184 typedef GrGLFragmentProcessor INHERITED;
187 }; 185 };
188 186
189 GrGLTextureDomainEffect::GrGLTextureDomainEffect(const GrBackendProcessorFactory & factory, 187 GrGLTextureDomainEffect::GrGLTextureDomainEffect(const GrProcessor&) {
190 const GrProcessor&)
191 : INHERITED(factory) {
192 } 188 }
193 189
194 void GrGLTextureDomainEffect::emitCode(GrGLFPBuilder* builder, 190 void GrGLTextureDomainEffect::emitCode(GrGLFPBuilder* builder,
195 const GrFragmentProcessor& fp, 191 const GrFragmentProcessor& fp,
196 const char* outputColor, 192 const char* outputColor,
197 const char* inputColor, 193 const char* inputColor,
198 const TransformedCoordsArray& coords, 194 const TransformedCoordsArray& coords,
199 const TextureSamplerArray& samplers) { 195 const TextureSamplerArray& samplers) {
200 const GrTextureDomainEffect& textureDomainEffect = fp.cast<GrTextureDomainEf fect>(); 196 const GrTextureDomainEffect& textureDomainEffect = fp.cast<GrTextureDomainEf fect>();
201 const GrTextureDomain& domain = textureDomainEffect.textureDomain(); 197 const GrTextureDomain& domain = textureDomainEffect.textureDomain();
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 GrTextureDomainEffect::GrTextureDomainEffect(GrTexture* texture, 241 GrTextureDomainEffect::GrTextureDomainEffect(GrTexture* texture,
246 const SkMatrix& matrix, 242 const SkMatrix& matrix,
247 const SkRect& domain, 243 const SkRect& domain,
248 GrTextureDomain::Mode mode, 244 GrTextureDomain::Mode mode,
249 GrTextureParams::FilterMode filterM ode, 245 GrTextureParams::FilterMode filterM ode,
250 GrCoordSet coordSet) 246 GrCoordSet coordSet)
251 : GrSingleTextureEffect(texture, matrix, filterMode, coordSet) 247 : GrSingleTextureEffect(texture, matrix, filterMode, coordSet)
252 , fTextureDomain(domain, mode) { 248 , fTextureDomain(domain, mode) {
253 SkASSERT(mode != GrTextureDomain::kRepeat_Mode || 249 SkASSERT(mode != GrTextureDomain::kRepeat_Mode ||
254 filterMode == GrTextureParams::kNone_FilterMode); 250 filterMode == GrTextureParams::kNone_FilterMode);
251 this->initClassID<GrTextureDomainEffect>();
255 } 252 }
256 253
257 GrTextureDomainEffect::~GrTextureDomainEffect() { 254 GrTextureDomainEffect::~GrTextureDomainEffect() {
258 255
259 } 256 }
260 257
261 const GrBackendFragmentProcessorFactory& GrTextureDomainEffect::getFactory() con st { 258 void GrTextureDomainEffect::getGLProcessorKey(const GrGLCaps& caps,
262 return GrTBackendFragmentProcessorFactory<GrTextureDomainEffect>::getInstanc e(); 259 GrProcessorKeyBuilder* b) const {
260 GrGLTextureDomainEffect::GenKey(*this, caps, b);
261 }
262
263 GrGLFragmentProcessor* GrTextureDomainEffect::createGLInstance() const {
264 return SkNEW_ARGS(GrGLTextureDomainEffect, (*this));
263 } 265 }
264 266
265 bool GrTextureDomainEffect::onIsEqual(const GrFragmentProcessor& sBase) const { 267 bool GrTextureDomainEffect::onIsEqual(const GrFragmentProcessor& sBase) const {
266 const GrTextureDomainEffect& s = sBase.cast<GrTextureDomainEffect>(); 268 const GrTextureDomainEffect& s = sBase.cast<GrTextureDomainEffect>();
267 return this->fTextureDomain == s.fTextureDomain; 269 return this->fTextureDomain == s.fTextureDomain;
268 } 270 }
269 271
270 void GrTextureDomainEffect::onComputeInvariantOutput(GrInvariantOutput* inout) c onst { 272 void GrTextureDomainEffect::onComputeInvariantOutput(GrInvariantOutput* inout) c onst {
271 if (GrTextureDomain::kDecal_Mode == fTextureDomain.mode()) { // TODO: helper 273 if (GrTextureDomain::kDecal_Mode == fTextureDomain.mode()) { // TODO: helper
272 if (GrPixelConfigIsAlphaOnly(this->texture(0)->config())) { 274 if (GrPixelConfigIsAlphaOnly(this->texture(0)->config())) {
(...skipping 26 matching lines...) Expand all
299 const SkMatrix& matrix = GrProcessorUnitTest::TestMatrix(random); 301 const SkMatrix& matrix = GrProcessorUnitTest::TestMatrix(random);
300 bool bilerp = mode != GrTextureDomain::kRepeat_Mode ? random->nextBool() : f alse; 302 bool bilerp = mode != GrTextureDomain::kRepeat_Mode ? random->nextBool() : f alse;
301 GrCoordSet coords = random->nextBool() ? kLocal_GrCoordSet : kPosition_GrCoo rdSet; 303 GrCoordSet coords = random->nextBool() ? kLocal_GrCoordSet : kPosition_GrCoo rdSet;
302 return GrTextureDomainEffect::Create(textures[texIdx], 304 return GrTextureDomainEffect::Create(textures[texIdx],
303 matrix, 305 matrix,
304 domain, 306 domain,
305 mode, 307 mode,
306 bilerp ? GrTextureParams::kBilerp_Filte rMode : GrTextureParams::kNone_FilterMode, 308 bilerp ? GrTextureParams::kBilerp_Filte rMode : GrTextureParams::kNone_FilterMode,
307 coords); 309 coords);
308 } 310 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrTextureDomain.h ('k') | src/gpu/effects/GrYUVtoRGBEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698