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

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

Issue 1495693003: Index8 GPU and CPU raster support. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: revert SkImageGenerator&SkImageCacherator changes. Created 5 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/GrIndex8toRGBEffect.h ('k') | tests/Index8Test.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "GrIndex8toRGBEffect.h"
9
10 #include "GrCoordTransform.h"
11 #include "GrInvariantOutput.h"
12 #include "GrProcessor.h"
13 #include "gl/GrGLFragmentProcessor.h"
14 #include "gl/builders/GrGLProgramBuilder.h"
15 #include "glsl/GrGLSLProgramDataManager.h"
16
17 namespace {
18
19 class Index8toRGBEffect : public GrSingleTextureEffect {
20 public:
21 static GrFragmentProcessor* Create(GrTexture* tex, GrTexture* colorMapTe xture,
22 const SkMatrix& matrix, GrCoordSet co ordSet = kLocal_GrCoordSet) {
23 return new Index8toRGBEffect(tex, colorMapTexture, matrix, coordSet) ;
24 }
25
26 const char* name() const override { return "Index8 to RGB"; }
27
28 class GLProcessor : public GrGLFragmentProcessor {
29 public:
30 // this class always generates the same code.
31 static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcesso rKeyBuilder*) {}
32
33 GLProcessor(const GrProcessor&) {}
34
35 virtual void emitCode(EmitArgs& args) override {
36 GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentSha derBuilder();
37 // float a = texture2D(sampler, texC).a;
38 // gl_FragColor = texture2D(paletteSampler, vec2(a, .5));
39 fsBuilder->codeAppend("\tfloat a = ");
40 fsBuilder->appendTextureLookup(args.fSamplers[0], args.fCoords[0 ].c_str());
41 fsBuilder->codeAppend(".a;\n");
42
43 fsBuilder->codeAppendf("\t%s = ", args.fOutputColor);
44 fsBuilder->appendTextureLookup(args.fSamplers[1], "vec2(a, .5)") ;
45 fsBuilder->codeAppend(";\n");
46 }
47
48 private:
49 typedef GrGLFragmentProcessor INHERITED;
50 };
51
52 private:
53 Index8toRGBEffect(GrTexture* tex, GrTexture* colorMapTexture,
54 const SkMatrix& matrix, GrCoordSet coordSet)
55 : GrSingleTextureEffect(tex, matrix, GrTextureParams::kNone_FilterMo de, coordSet)
56 , fColorMapTextureAccess(colorMapTexture) {
57 this->initClassID<Index8toRGBEffect>();
58 this->addTextureAccess(&fColorMapTextureAccess);
59 }
60
61 GrGLFragmentProcessor* onCreateGLInstance() const override { return new GLProcessor(*this); }
62
63 virtual void onGetGLProcessorKey(const GrGLSLCaps& caps,
64 GrProcessorKeyBuilder* b) const override {
65 GLProcessor::GenKey(*this, caps, b);
66 }
67
68 void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
69 updateInvariantOutputForModulation(inout);
70 }
71
72 bool onIsEqual(const GrFragmentProcessor& other) const override { return true; }
73
74 GrTextureAccess fColorMapTextureAccess;
75
76 typedef GrFragmentProcessor INHERITED;
77 };
78 }
79 //////////////////////////////////////////////////////////////////////////////
80
81 GrFragmentProcessor* GrIndex8toRGBEffect::Create(GrTexture* tex, GrTexture* colo rMapTexture,
82 const SkMatrix& matrix, GrCoord Set coordSet) {
83 SkASSERT(tex && colorMapTexture);
84 return Index8toRGBEffect::Create(tex, colorMapTexture, matrix, coordSet);
85 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrIndex8toRGBEffect.h ('k') | tests/Index8Test.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698