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

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

Issue 374923002: Goodbye GrEffectRef. (Closed) Base URL: https://skia.googlesource.com/skia.git@noref3
Patch Set: Address comments Created 6 years, 5 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/GrDistanceFieldTextureEffect.cpp ('k') | src/gpu/effects/GrOvalEffect.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 2014 Google Inc. 2 * Copyright 2014 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 "GrDitherEffect.h" 8 #include "GrDitherEffect.h"
9 9
10 #include "gl/GrGLEffect.h" 10 #include "gl/GrGLEffect.h"
11 #include "gl/GrGLSL.h" 11 #include "gl/GrGLSL.h"
12 #include "GrTBackendEffectFactory.h" 12 #include "GrTBackendEffectFactory.h"
13 13
14 #include "SkRect.h" 14 #include "SkRect.h"
15 15
16 ////////////////////////////////////////////////////////////////////////////// 16 //////////////////////////////////////////////////////////////////////////////
17 17
18 class GLDitherEffect; 18 class GLDitherEffect;
19 19
20 class DitherEffect : public GrEffect { 20 class DitherEffect : public GrEffect {
21 public: 21 public:
22 static GrEffectRef* Create() { 22 static GrEffect* Create() {
23 GR_CREATE_STATIC_EFFECT(gDitherEffect, DitherEffect, ()) 23 GR_CREATE_STATIC_EFFECT(gDitherEffect, DitherEffect, ())
24 return SkRef(gDitherEffect); 24 return SkRef(gDitherEffect);
25 } 25 }
26 26
27 virtual ~DitherEffect() {}; 27 virtual ~DitherEffect() {};
28 static const char* Name() { return "Dither"; } 28 static const char* Name() { return "Dither"; }
29 29
30 typedef GLDitherEffect GLEffect; 30 typedef GLDitherEffect GLEffect;
31 31
32 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags ) const SK_OVERRIDE; 32 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags ) const SK_OVERRIDE;
(...skipping 16 matching lines...) Expand all
49 }; 49 };
50 50
51 void DitherEffect::getConstantColorComponents(GrColor* color, uint32_t* validFla gs) const { 51 void DitherEffect::getConstantColorComponents(GrColor* color, uint32_t* validFla gs) const {
52 *validFlags = 0; 52 *validFlags = 0;
53 } 53 }
54 54
55 ////////////////////////////////////////////////////////////////////////////// 55 //////////////////////////////////////////////////////////////////////////////
56 56
57 GR_DEFINE_EFFECT_TEST(DitherEffect); 57 GR_DEFINE_EFFECT_TEST(DitherEffect);
58 58
59 GrEffectRef* DitherEffect::TestCreate(SkRandom*, 59 GrEffect* DitherEffect::TestCreate(SkRandom*,
60 GrContext*, 60 GrContext*,
61 const GrDrawTargetCaps&, 61 const GrDrawTargetCaps&,
62 GrTexture*[]) { 62 GrTexture*[]) {
63 return DitherEffect::Create(); 63 return DitherEffect::Create();
64 } 64 }
65 65
66 ////////////////////////////////////////////////////////////////////////////// 66 //////////////////////////////////////////////////////////////////////////////
67 67
68 class GLDitherEffect : public GrGLEffect { 68 class GLDitherEffect : public GrGLEffect {
69 public: 69 public:
70 GLDitherEffect(const GrBackendEffectFactory&, const GrDrawEffect&); 70 GLDitherEffect(const GrBackendEffectFactory&, const GrDrawEffect&);
71 71
72 virtual void emitCode(GrGLShaderBuilder* builder, 72 virtual void emitCode(GrGLShaderBuilder* builder,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 // it up or let it remain constant during quantization. 104 // it up or let it remain constant during quantization.
105 builder->fsCodeAppendf("\t\tfloat r = " 105 builder->fsCodeAppendf("\t\tfloat r = "
106 "fract(sin(dot(%s.xy ,vec2(12.9898,78.233))) * 43758. 5453);\n", 106 "fract(sin(dot(%s.xy ,vec2(12.9898,78.233))) * 43758. 5453);\n",
107 builder->fragmentPosition()); 107 builder->fragmentPosition());
108 builder->fsCodeAppendf("\t\t%s = (1.0/255.0) * vec4(r, r, r, r) + %s;\n", 108 builder->fsCodeAppendf("\t\t%s = (1.0/255.0) * vec4(r, r, r, r) + %s;\n",
109 outputColor, GrGLSLExpr4(inputColor).c_str()); 109 outputColor, GrGLSLExpr4(inputColor).c_str());
110 } 110 }
111 111
112 ////////////////////////////////////////////////////////////////////////////// 112 //////////////////////////////////////////////////////////////////////////////
113 113
114 GrEffectRef* GrDitherEffect::Create() { 114 GrEffect* GrDitherEffect::Create() { return DitherEffect::Create(); }
115 return DitherEffect::Create();
116 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrDistanceFieldTextureEffect.cpp ('k') | src/gpu/effects/GrOvalEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698