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

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

Issue 582963002: Solo gp (Closed) Base URL: https://skia.googlesource.com/skia.git@no_peb
Patch Set: rebase Created 6 years, 3 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/effects/GrSimpleTextureEffect.h ('k') | src/gpu/effects/GrSingleTextureEffect.h » ('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" 8 #include "gl/builders/GrGLProgramBuilder.h"
9 #include "GrSimpleTextureEffect.h" 9 #include "GrSimpleTextureEffect.h"
10 #include "gl/GrGLEffect.h" 10 #include "gl/GrGLProcessor.h"
11 #include "gl/GrGLSL.h" 11 #include "gl/GrGLSL.h"
12 #include "gl/GrGLTexture.h" 12 #include "gl/GrGLTexture.h"
13 #include "GrTBackendEffectFactory.h" 13 #include "GrTBackendProcessorFactory.h"
14 #include "GrTexture.h" 14 #include "GrTexture.h"
15 15
16 class GrGLSimpleTextureEffect : public GrGLEffect { 16 class GrGLSimpleTextureEffect : public GrGLFragmentProcessor {
17 public: 17 public:
18 GrGLSimpleTextureEffect(const GrBackendEffectFactory& factory, const GrEffec t&) 18 GrGLSimpleTextureEffect(const GrBackendProcessorFactory& factory, const GrPr ocessor&)
19 : INHERITED (factory) { 19 : INHERITED (factory) {
20 } 20 }
21 21
22 virtual void emitCode(GrGLProgramBuilder* builder, 22 virtual void emitCode(GrGLProgramBuilder* builder,
23 const GrEffect& effect, 23 const GrFragmentProcessor& fp,
24 const GrEffectKey& key, 24 const GrProcessorKey& key,
25 const char* outputColor, 25 const char* outputColor,
26 const char* inputColor, 26 const char* inputColor,
27 const TransformedCoordsArray& coords, 27 const TransformedCoordsArray& coords,
28 const TextureSamplerArray& samplers) SK_OVERRIDE { 28 const TextureSamplerArray& samplers) SK_OVERRIDE {
29 GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder (); 29 GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder ();
30 fsBuilder->codeAppendf("\t%s = ", outputColor); 30 fsBuilder->codeAppendf("\t%s = ", outputColor);
31 fsBuilder->appendTextureLookupAndModulate(inputColor, 31 fsBuilder->appendTextureLookupAndModulate(inputColor,
32 samplers[0], 32 samplers[0],
33 coords[0].c_str(), 33 coords[0].c_str(),
34 coords[0].getType()); 34 coords[0].getType());
35 fsBuilder->codeAppend(";\n"); 35 fsBuilder->codeAppend(";\n");
36 } 36 }
37 37
38 private: 38 private:
39 typedef GrGLEffect INHERITED; 39 typedef GrGLFragmentProcessor INHERITED;
40 }; 40 };
41 41
42 /////////////////////////////////////////////////////////////////////////////// 42 ///////////////////////////////////////////////////////////////////////////////
43 43
44 void GrSimpleTextureEffect::getConstantColorComponents(GrColor* color, uint32_t* validFlags) const { 44 void GrSimpleTextureEffect::getConstantColorComponents(GrColor* color, uint32_t* validFlags) const {
45 this->updateConstantColorComponentsForModulation(color, validFlags); 45 this->updateConstantColorComponentsForModulation(color, validFlags);
46 } 46 }
47 47
48 const GrBackendEffectFactory& GrSimpleTextureEffect::getFactory() const { 48 const GrBackendFragmentProcessorFactory& GrSimpleTextureEffect::getFactory() con st {
49 return GrTBackendEffectFactory<GrSimpleTextureEffect>::getInstance(); 49 return GrTBackendFragmentProcessorFactory<GrSimpleTextureEffect>::getInstanc e();
50 } 50 }
51 51
52 /////////////////////////////////////////////////////////////////////////////// 52 ///////////////////////////////////////////////////////////////////////////////
53 53
54 GR_DEFINE_EFFECT_TEST(GrSimpleTextureEffect); 54 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrSimpleTextureEffect);
55 55
56 GrEffect* GrSimpleTextureEffect::TestCreate(SkRandom* random, 56 GrFragmentProcessor* GrSimpleTextureEffect::TestCreate(SkRandom* random,
57 GrContext*, 57 GrContext*,
58 const GrDrawTargetCaps&, 58 const GrDrawTargetCaps&,
59 GrTexture* textures[]) { 59 GrTexture* textures[]) {
60 int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx : 60 int texIdx = random->nextBool() ? GrProcessorUnitTest::kSkiaPMTextureIdx :
61 GrEffectUnitTest::kAlphaTextureIdx; 61 GrProcessorUnitTest::kAlphaTextureIdx;
62 static const SkShader::TileMode kTileModes[] = { 62 static const SkShader::TileMode kTileModes[] = {
63 SkShader::kClamp_TileMode, 63 SkShader::kClamp_TileMode,
64 SkShader::kRepeat_TileMode, 64 SkShader::kRepeat_TileMode,
65 SkShader::kMirror_TileMode, 65 SkShader::kMirror_TileMode,
66 }; 66 };
67 SkShader::TileMode tileModes[] = { 67 SkShader::TileMode tileModes[] = {
68 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], 68 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))],
69 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))], 69 kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))],
70 }; 70 };
71 GrTextureParams params(tileModes, random->nextBool() ? GrTextureParams::kBil erp_FilterMode : 71 GrTextureParams params(tileModes, random->nextBool() ? GrTextureParams::kBil erp_FilterMode :
72 GrTextureParams::kNon e_FilterMode); 72 GrTextureParams::kNon e_FilterMode);
73 73
74 static const GrCoordSet kCoordSets[] = { 74 static const GrCoordSet kCoordSets[] = {
75 kLocal_GrCoordSet, 75 kLocal_GrCoordSet,
76 kPosition_GrCoordSet 76 kPosition_GrCoordSet
77 }; 77 };
78 GrCoordSet coordSet = kCoordSets[random->nextULessThan(SK_ARRAY_COUNT(kCoord Sets))]; 78 GrCoordSet coordSet = kCoordSets[random->nextULessThan(SK_ARRAY_COUNT(kCoord Sets))];
79 79
80 const SkMatrix& matrix = GrEffectUnitTest::TestMatrix(random); 80 const SkMatrix& matrix = GrProcessorUnitTest::TestMatrix(random);
81 return GrSimpleTextureEffect::Create(textures[texIdx], matrix, coordSet); 81 return GrSimpleTextureEffect::Create(textures[texIdx], matrix, coordSet);
82 } 82 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrSimpleTextureEffect.h ('k') | src/gpu/effects/GrSingleTextureEffect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698