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

Side by Side Diff: src/gpu/GrAARectRenderer.cpp

Issue 25023003: Implement color filter as GrGLEffect (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: address review comments Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « src/gpu/GrAAConvexPathRenderer.cpp ('k') | src/gpu/GrDrawState.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 "GrAARectRenderer.h" 8 #include "GrAARectRenderer.h"
9 #include "GrGpu.h" 9 #include "GrGpu.h"
10 #include "gl/GrGLEffect.h" 10 #include "gl/GrGLEffect.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 builder->fsCodeAppendf( 79 builder->fsCodeAppendf(
80 "\tfloat coverage = scaleW*clamp((%s.z-abs(%s.x))/spanW, 0.0, 1. 0);\n", fsRectName, 80 "\tfloat coverage = scaleW*clamp((%s.z-abs(%s.x))/spanW, 0.0, 1. 0);\n", fsRectName,
81 fsRectName); 81 fsRectName);
82 // Compute the coverage for the rect's height and merge with the wid th 82 // Compute the coverage for the rect's height and merge with the wid th
83 builder->fsCodeAppendf( 83 builder->fsCodeAppendf(
84 "\tcoverage = coverage*scaleH*clamp((%s.w-abs(%s.y))/spanH, 0.0, 1.0);\n", 84 "\tcoverage = coverage*scaleH*clamp((%s.w-abs(%s.y))/spanH, 0.0, 1.0);\n",
85 fsRectName, fsRectName); 85 fsRectName, fsRectName);
86 86
87 87
88 builder->fsCodeAppendf("\t%s = %s;\n", outputColor, 88 builder->fsCodeAppendf("\t%s = %s;\n", outputColor,
89 (GrGLSLExpr<4>(inputColor) * GrGLSLExpr<1>("c overage")).c_str()); 89 (GrGLSLExpr4(inputColor) * GrGLSLExpr1("cover age")).c_str());
90 } 90 }
91 91
92 static inline EffectKey GenKey(const GrDrawEffect& drawEffect, const GrG LCaps&) { 92 static inline EffectKey GenKey(const GrDrawEffect& drawEffect, const GrG LCaps&) {
93 return 0; 93 return 0;
94 } 94 }
95 95
96 virtual void setData(const GrGLUniformManager& uman, const GrDrawEffect& ) SK_OVERRIDE {} 96 virtual void setData(const GrGLUniformManager& uman, const GrDrawEffect& ) SK_OVERRIDE {}
97 97
98 private: 98 private:
99 typedef GrGLVertexEffect INHERITED; 99 typedef GrGLVertexEffect INHERITED;
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 212
213 // Compute the coverage for the rect's height and merge with the wid th 213 // Compute the coverage for the rect's height and merge with the wid th
214 builder->fsCodeAppendf("\tperpDot = abs(dot(offset, %s.zw));\n", 214 builder->fsCodeAppendf("\tperpDot = abs(dot(offset, %s.zw));\n",
215 fsRectEdgeName); 215 fsRectEdgeName);
216 builder->fsCodeAppendf( 216 builder->fsCodeAppendf(
217 "\tcoverage = coverage*scaleH*clamp((%s.y-perpDot)/spanH, 0. 0, 1.0);\n", 217 "\tcoverage = coverage*scaleH*clamp((%s.y-perpDot)/spanH, 0. 0, 1.0);\n",
218 fsWidthHeightName); 218 fsWidthHeightName);
219 219
220 220
221 builder->fsCodeAppendf("\t%s = %s;\n", outputColor, 221 builder->fsCodeAppendf("\t%s = %s;\n", outputColor,
222 (GrGLSLExpr<4>(inputColor) * GrGLSLExpr<1>("c overage")).c_str()); 222 (GrGLSLExpr4(inputColor) * GrGLSLExpr1("cover age")).c_str());
223 } 223 }
224 224
225 static inline EffectKey GenKey(const GrDrawEffect& drawEffect, const GrG LCaps&) { 225 static inline EffectKey GenKey(const GrDrawEffect& drawEffect, const GrG LCaps&) {
226 return 0; 226 return 0;
227 } 227 }
228 228
229 virtual void setData(const GrGLUniformManager& uman, const GrDrawEffect& ) SK_OVERRIDE {} 229 virtual void setData(const GrGLUniformManager& uman, const GrDrawEffect& ) SK_OVERRIDE {}
230 230
231 private: 231 private:
232 typedef GrGLVertexEffect INHERITED; 232 typedef GrGLVertexEffect INHERITED;
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 // can't call mapRect for devInside since it calls sort 806 // can't call mapRect for devInside since it calls sort
807 combinedMatrix.mapPoints((SkPoint*)&devInside, (const SkPoint*)&rects[1], 2) ; 807 combinedMatrix.mapPoints((SkPoint*)&devInside, (const SkPoint*)&rects[1], 2) ;
808 808
809 if (devInside.isEmpty()) { 809 if (devInside.isEmpty()) {
810 this->fillAARect(gpu, target, devOutside, SkMatrix::I(), devOutside, use VertexCoverage); 810 this->fillAARect(gpu, target, devOutside, SkMatrix::I(), devOutside, use VertexCoverage);
811 return; 811 return;
812 } 812 }
813 813
814 this->geometryStrokeAARect(gpu, target, devOutside, devInside, useVertexCove rage); 814 this->geometryStrokeAARect(gpu, target, devOutside, devInside, useVertexCove rage);
815 } 815 }
OLDNEW
« no previous file with comments | « src/gpu/GrAAConvexPathRenderer.cpp ('k') | src/gpu/GrDrawState.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698