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

Side by Side Diff: src/effects/SkBicubicImageFilter.cpp

Issue 23018003: Rename GrGLUniformManager to GrGLUniform and ref GrGLUniforms directly Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 4 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/effects/SkArithmeticMode.cpp ('k') | src/effects/SkColorMatrixFilter.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 2013 The Android Open Source Project 2 * Copyright 2013 The Android Open Source Project
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 "SkBicubicImageFilter.h" 8 #include "SkBicubicImageFilter.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
11 #include "SkFlattenableBuffers.h" 11 #include "SkFlattenableBuffers.h"
12 #include "SkMatrix.h" 12 #include "SkMatrix.h"
13 #include "SkRect.h" 13 #include "SkRect.h"
14 #include "SkUnPreMultiply.h" 14 #include "SkUnPreMultiply.h"
15 15
16 #if SK_SUPPORT_GPU 16 #if SK_SUPPORT_GPU
17 #include "gl/GrGLEffectMatrix.h" 17 #include "gl/GrGLEffectMatrix.h"
18 #include "gl/GrGLShaderBuilder.h"
18 #include "effects/GrSingleTextureEffect.h" 19 #include "effects/GrSingleTextureEffect.h"
19 #include "GrTBackendEffectFactory.h" 20 #include "GrTBackendEffectFactory.h"
20 #include "GrContext.h" 21 #include "GrContext.h"
21 #include "GrTexture.h" 22 #include "GrTexture.h"
22 #include "SkImageFilterUtils.h" 23 #include "SkImageFilterUtils.h"
23 #endif 24 #endif
24 25
25 SkBicubicImageFilter::SkBicubicImageFilter(const SkSize& scale, const SkScalar c oefficients[16], SkImageFilter* input) 26 SkBicubicImageFilter::SkBicubicImageFilter(const SkSize& scale, const SkScalar c oefficients[16], SkImageFilter* input)
26 : INHERITED(input), 27 : INHERITED(input),
27 fScale(scale) { 28 fScale(scale) {
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 const GrDrawEffect&); 193 const GrDrawEffect&);
193 virtual void emitCode(GrGLShaderBuilder*, 194 virtual void emitCode(GrGLShaderBuilder*,
194 const GrDrawEffect&, 195 const GrDrawEffect&,
195 EffectKey, 196 EffectKey,
196 const char* outputColor, 197 const char* outputColor,
197 const char* inputColor, 198 const char* inputColor,
198 const TextureSamplerArray&) SK_OVERRIDE; 199 const TextureSamplerArray&) SK_OVERRIDE;
199 200
200 static inline EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&); 201 static inline EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&);
201 202
202 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVER RIDE; 203 virtual void setData(const GrGLContext&, const GrDrawEffect&) SK_OVERRIDE;
203 204
204 private: 205 private:
205 typedef GrGLUniformManager::UniformHandle UniformHandle; 206 GrGLUniform* fCoefficientsUni;
206 207 GrGLUniform* fImageIncrementUni;
207 UniformHandle fCoefficientsUni;
208 UniformHandle fImageIncrementUni;
209 208
210 GrGLEffectMatrix fEffectMatrix; 209 GrGLEffectMatrix fEffectMatrix;
211 210
212 typedef GrGLEffect INHERITED; 211 typedef GrGLEffect INHERITED;
213 }; 212 };
214 213
215 GrGLBicubicEffect::GrGLBicubicEffect(const GrBackendEffectFactory& factory, 214 GrGLBicubicEffect::GrGLBicubicEffect(const GrBackendEffectFactory& factory,
216 const GrDrawEffect& drawEffect) 215 const GrDrawEffect& drawEffect)
217 : INHERITED(factory) 216 : INHERITED(factory)
218 , fCoefficientsUni(GrGLUniformManager::kInvalidUniformHandle) 217 , fCoefficientsUni(NULL)
219 , fImageIncrementUni(GrGLUniformManager::kInvalidUniformHandle) 218 , fImageIncrementUni(NULL)
220 , fEffectMatrix(drawEffect.castEffect<GrBicubicEffect>().coordsType()) { 219 , fEffectMatrix(drawEffect.castEffect<GrBicubicEffect>().coordsType()) {
221 } 220 }
222 221
223 void GrGLBicubicEffect::emitCode(GrGLShaderBuilder* builder, 222 void GrGLBicubicEffect::emitCode(GrGLShaderBuilder* builder,
224 const GrDrawEffect&, 223 const GrDrawEffect&,
225 EffectKey key, 224 EffectKey key,
226 const char* outputColor, 225 const char* outputColor,
227 const char* inputColor, 226 const char* inputColor,
228 const TextureSamplerArray& samplers) { 227 const TextureSamplerArray& samplers) {
229 const char* coords; 228 const char* coords;
230 fEffectMatrix.emitCodeMakeFSCoords2D(builder, key, &coords); 229 fEffectMatrix.emitCodeMakeFSCoords2D(builder, key, &coords);
231 fCoefficientsUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderTy pe, 230 GrGLShaderBuilder::Uniform* coefficientsUni =
232 kMat44f_GrSLType, "Coefficients"); 231 builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType, kMat44f_GrS LType, "Coefficients");
233 fImageIncrementUni = builder->addUniform(GrGLShaderBuilder::kFragment_Shader Type, 232 fCoefficientsUni = coefficientsUni->glUniform();
234 kVec2f_GrSLType, "ImageIncrement");
235 233
236 const char* imgInc = builder->getUniformCStr(fImageIncrementUni); 234 GrGLShaderBuilder::Uniform* imageIncrementUni =
237 const char* coeff = builder->getUniformCStr(fCoefficientsUni); 235 builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType, kVec2f_GrSL Type, "ImageIncrement");
236 fImageIncrementUni = imageIncrementUni->glUniform();
237
238 const char* imgInc = imageIncrementUni->c_str();
239 const char* coeff = coefficientsUni->c_str();
238 240
239 SkString cubicBlendName; 241 SkString cubicBlendName;
240 242
241 static const GrGLShaderVar gCubicBlendArgs[] = { 243 static const GrGLShaderVar gCubicBlendArgs[] = {
242 GrGLShaderVar("coefficients", kMat44f_GrSLType), 244 GrGLShaderVar("coefficients", kMat44f_GrSLType),
243 GrGLShaderVar("t", kFloat_GrSLType), 245 GrGLShaderVar("t", kFloat_GrSLType),
244 GrGLShaderVar("c0", kVec4f_GrSLType), 246 GrGLShaderVar("c0", kVec4f_GrSLType),
245 GrGLShaderVar("c1", kVec4f_GrSLType), 247 GrGLShaderVar("c1", kVec4f_GrSLType),
246 GrGLShaderVar("c2", kVec4f_GrSLType), 248 GrGLShaderVar("c2", kVec4f_GrSLType),
247 GrGLShaderVar("c3", kVec4f_GrSLType), 249 GrGLShaderVar("c3", kVec4f_GrSLType),
(...skipping 26 matching lines...) Expand all
274 276
275 GrGLEffect::EffectKey GrGLBicubicEffect::GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&) { 277 GrGLEffect::EffectKey GrGLBicubicEffect::GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&) {
276 const GrBicubicEffect& bicubic = drawEffect.castEffect<GrBicubicEffect>(); 278 const GrBicubicEffect& bicubic = drawEffect.castEffect<GrBicubicEffect>();
277 EffectKey matrixKey = GrGLEffectMatrix::GenKey(bicubic.getMatrix(), 279 EffectKey matrixKey = GrGLEffectMatrix::GenKey(bicubic.getMatrix(),
278 drawEffect, 280 drawEffect,
279 bicubic.coordsType(), 281 bicubic.coordsType(),
280 bicubic.texture(0)); 282 bicubic.texture(0));
281 return matrixKey; 283 return matrixKey;
282 } 284 }
283 285
284 void GrGLBicubicEffect::setData(const GrGLUniformManager& uman, 286 void GrGLBicubicEffect::setData(const GrGLContext& context,
285 const GrDrawEffect& drawEffect) { 287 const GrDrawEffect& drawEffect) {
286 const GrBicubicEffect& effect = drawEffect.castEffect<GrBicubicEffect>(); 288 const GrBicubicEffect& effect = drawEffect.castEffect<GrBicubicEffect>();
287 GrTexture& texture = *effect.texture(0); 289 GrTexture& texture = *effect.texture(0);
288 float imageIncrement[2]; 290 float imageIncrement[2];
289 imageIncrement[0] = 1.0f / texture.width(); 291 imageIncrement[0] = 1.0f / texture.width();
290 imageIncrement[1] = 1.0f / texture.height(); 292 imageIncrement[1] = 1.0f / texture.height();
291 uman.set2fv(fImageIncrementUni, 0, 1, imageIncrement); 293 fImageIncrementUni->set2fv(context, 0, 1, imageIncrement);
292 uman.setMatrix4f(fCoefficientsUni, effect.coefficients()); 294 fCoefficientsUni->setMatrix4f(context, effect.coefficients());
293 fEffectMatrix.setData(uman, 295 fEffectMatrix.setData(context,
294 effect.getMatrix(), 296 effect.getMatrix(),
295 drawEffect, 297 drawEffect,
296 effect.texture(0)); 298 effect.texture(0));
297 } 299 }
298 300
299 GrBicubicEffect::GrBicubicEffect(GrTexture* texture, 301 GrBicubicEffect::GrBicubicEffect(GrTexture* texture,
300 const SkScalar coefficients[16]) 302 const SkScalar coefficients[16])
301 : INHERITED(texture, MakeDivByTextureWHMatrix(texture)) { 303 : INHERITED(texture, MakeDivByTextureWHMatrix(texture)) {
302 for (int y = 0; y < 4; y++) { 304 for (int y = 0; y < 4; y++) {
303 for (int x = 0; x < 4; x++) { 305 for (int x = 0; x < 4; x++) {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 GrPaint paint; 370 GrPaint paint;
369 paint.addColorEffect(GrBicubicEffect::Create(srcTexture, fCoefficients))->un ref(); 371 paint.addColorEffect(GrBicubicEffect::Create(srcTexture, fCoefficients))->un ref();
370 SkRect srcRect; 372 SkRect srcRect;
371 srcBM.getBounds(&srcRect); 373 srcBM.getBounds(&srcRect);
372 context->drawRectToRect(paint, dstRect, srcRect); 374 context->drawRectToRect(paint, dstRect, srcRect);
373 return SkImageFilterUtils::WrapTexture(dst, desc.fWidth, desc.fHeight, resul t); 375 return SkImageFilterUtils::WrapTexture(dst, desc.fWidth, desc.fHeight, resul t);
374 } 376 }
375 #endif 377 #endif
376 378
377 /////////////////////////////////////////////////////////////////////////////// 379 ///////////////////////////////////////////////////////////////////////////////
OLDNEW
« no previous file with comments | « src/effects/SkArithmeticMode.cpp ('k') | src/effects/SkColorMatrixFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698