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

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

Issue 22340010: Refactor GrGLUniformManager::UniformHandle to initialize itself by default (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: description 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/SkColorMatrixFilter.cpp ('k') | src/effects/SkMagnifierImageFilter.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 2012 The Android Open Source Project 2 * Copyright 2012 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 "SkLightingImageFilter.h" 8 #include "SkLightingImageFilter.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 "SkOrderedReadBuffer.h" 12 #include "SkOrderedReadBuffer.h"
13 #include "SkOrderedWriteBuffer.h" 13 #include "SkOrderedWriteBuffer.h"
14 #include "SkTypes.h" 14 #include "SkTypes.h"
15 15
16 #if SK_SUPPORT_GPU 16 #if SK_SUPPORT_GPU
17 #include "effects/GrSingleTextureEffect.h" 17 #include "effects/GrSingleTextureEffect.h"
18 #include "gl/GrGLEffect.h" 18 #include "gl/GrGLEffect.h"
19 #include "gl/GrGLEffectMatrix.h" 19 #include "gl/GrGLEffectMatrix.h"
20 #include "GrEffect.h" 20 #include "GrEffect.h"
21 #include "GrTBackendEffectFactory.h" 21 #include "GrTBackendEffectFactory.h"
22 22
23 class GrGLDiffuseLightingEffect; 23 class GrGLDiffuseLightingEffect;
24 class GrGLSpecularLightingEffect; 24 class GrGLSpecularLightingEffect;
25 25
26 // For brevity 26 // For brevity
27 typedef GrGLUniformManager::UniformHandle UniformHandle; 27 typedef GrGLUniformManager::UniformHandle UniformHandle;
28 static const UniformHandle kInvalidUniformHandle = GrGLUniformManager::kInvalidU niformHandle;
29 #endif 28 #endif
30 29
31 namespace { 30 namespace {
32 31
33 const SkScalar gOneThird = SkScalarInvert(SkIntToScalar(3)); 32 const SkScalar gOneThird = SkScalarInvert(SkIntToScalar(3));
34 const SkScalar gTwoThirds = SkScalarDiv(SkIntToScalar(2), SkIntToScalar(3)); 33 const SkScalar gTwoThirds = SkScalarDiv(SkIntToScalar(2), SkIntToScalar(3));
35 const SkScalar gOneHalf = SkFloatToScalar(0.5f); 34 const SkScalar gOneHalf = SkFloatToScalar(0.5f);
36 const SkScalar gOneQuarter = SkFloatToScalar(0.25f); 35 const SkScalar gOneQuarter = SkFloatToScalar(0.25f);
37 36
38 #if SK_SUPPORT_GPU 37 #if SK_SUPPORT_GPU
(...skipping 1104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1143 return GrDiffuseLightingEffect::Create(textures[GrEffectUnitTest::kAlphaText ureIdx], 1142 return GrDiffuseLightingEffect::Create(textures[GrEffectUnitTest::kAlphaText ureIdx],
1144 light, surfaceScale, offset, kd); 1143 light, surfaceScale, offset, kd);
1145 } 1144 }
1146 1145
1147 1146
1148 /////////////////////////////////////////////////////////////////////////////// 1147 ///////////////////////////////////////////////////////////////////////////////
1149 1148
1150 GrGLLightingEffect::GrGLLightingEffect(const GrBackendEffectFactory& factory, 1149 GrGLLightingEffect::GrGLLightingEffect(const GrBackendEffectFactory& factory,
1151 const GrDrawEffect& drawEffect) 1150 const GrDrawEffect& drawEffect)
1152 : INHERITED(factory) 1151 : INHERITED(factory)
1153 , fImageIncrementUni(kInvalidUniformHandle)
1154 , fSurfaceScaleUni(kInvalidUniformHandle)
1155 , fEffectMatrix(drawEffect.castEffect<GrLightingEffect>().coordsType()) { 1152 , fEffectMatrix(drawEffect.castEffect<GrLightingEffect>().coordsType()) {
1156 const GrLightingEffect& m = drawEffect.castEffect<GrLightingEffect>(); 1153 const GrLightingEffect& m = drawEffect.castEffect<GrLightingEffect>();
1157 fLight = m.light()->createGLLight(); 1154 fLight = m.light()->createGLLight();
1158 } 1155 }
1159 1156
1160 GrGLLightingEffect::~GrGLLightingEffect() { 1157 GrGLLightingEffect::~GrGLLightingEffect() {
1161 delete fLight; 1158 delete fLight;
1162 } 1159 }
1163 1160
1164 void GrGLLightingEffect::emitCode(GrGLShaderBuilder* builder, 1161 void GrGLLightingEffect::emitCode(GrGLShaderBuilder* builder,
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
1287 drawEffect, 1284 drawEffect,
1288 lighting.texture(0)); 1285 lighting.texture(0));
1289 } 1286 }
1290 1287
1291 /////////////////////////////////////////////////////////////////////////////// 1288 ///////////////////////////////////////////////////////////////////////////////
1292 1289
1293 /////////////////////////////////////////////////////////////////////////////// 1290 ///////////////////////////////////////////////////////////////////////////////
1294 1291
1295 GrGLDiffuseLightingEffect::GrGLDiffuseLightingEffect(const GrBackendEffectFactor y& factory, 1292 GrGLDiffuseLightingEffect::GrGLDiffuseLightingEffect(const GrBackendEffectFactor y& factory,
1296 const GrDrawEffect& drawEff ect) 1293 const GrDrawEffect& drawEff ect)
1297 : INHERITED(factory, drawEffect) 1294 : INHERITED(factory, drawEffect) {
1298 , fKDUni(kInvalidUniformHandle) {
1299 } 1295 }
1300 1296
1301 void GrGLDiffuseLightingEffect::emitLightFunc(GrGLShaderBuilder* builder, SkStri ng* funcName) { 1297 void GrGLDiffuseLightingEffect::emitLightFunc(GrGLShaderBuilder* builder, SkStri ng* funcName) {
1302 const char* kd; 1298 const char* kd;
1303 fKDUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType, 1299 fKDUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType,
1304 kFloat_GrSLType, 1300 kFloat_GrSLType,
1305 "KD", 1301 "KD",
1306 &kd); 1302 &kd);
1307 1303
1308 static const GrGLShaderVar gLightArgs[] = { 1304 static const GrGLShaderVar gLightArgs[] = {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1365 SkAutoTUnref<SkLight> light(create_random_light(random)); 1361 SkAutoTUnref<SkLight> light(create_random_light(random));
1366 SkIPoint offset = SkIPoint::Make(random->nextS(), random->nextS()); 1362 SkIPoint offset = SkIPoint::Make(random->nextS(), random->nextS());
1367 return GrSpecularLightingEffect::Create(textures[GrEffectUnitTest::kAlphaTex tureIdx], 1363 return GrSpecularLightingEffect::Create(textures[GrEffectUnitTest::kAlphaTex tureIdx],
1368 light, surfaceScale, offset, ks, shi niness); 1364 light, surfaceScale, offset, ks, shi niness);
1369 } 1365 }
1370 1366
1371 /////////////////////////////////////////////////////////////////////////////// 1367 ///////////////////////////////////////////////////////////////////////////////
1372 1368
1373 GrGLSpecularLightingEffect::GrGLSpecularLightingEffect(const GrBackendEffectFact ory& factory, 1369 GrGLSpecularLightingEffect::GrGLSpecularLightingEffect(const GrBackendEffectFact ory& factory,
1374 const GrDrawEffect& drawE ffect) 1370 const GrDrawEffect& drawE ffect)
1375 : GrGLLightingEffect(factory, drawEffect) 1371 : INHERITED(factory, drawEffect) {
1376 , fKSUni(kInvalidUniformHandle)
1377 , fShininessUni(kInvalidUniformHandle) {
1378 } 1372 }
1379 1373
1380 void GrGLSpecularLightingEffect::emitLightFunc(GrGLShaderBuilder* builder, SkStr ing* funcName) { 1374 void GrGLSpecularLightingEffect::emitLightFunc(GrGLShaderBuilder* builder, SkStr ing* funcName) {
1381 const char* ks; 1375 const char* ks;
1382 const char* shininess; 1376 const char* shininess;
1383 1377
1384 fKSUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType, 1378 fKSUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType,
1385 kFloat_GrSLType, "KS", &ks); 1379 kFloat_GrSLType, "KS", &ks);
1386 fShininessUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType, 1380 fShininessUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType,
1387 kFloat_GrSLType, "Shininess", &shininess ); 1381 kFloat_GrSLType, "Shininess", &shininess );
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
1544 1538
1545 #endif 1539 #endif
1546 1540
1547 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingImageFilter) 1541 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingImageFilter)
1548 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDiffuseLightingImageFilter) 1542 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDiffuseLightingImageFilter)
1549 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSpecularLightingImageFilter) 1543 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSpecularLightingImageFilter)
1550 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDistantLight) 1544 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDistantLight)
1551 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkPointLight) 1545 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkPointLight)
1552 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSpotLight) 1546 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSpotLight)
1553 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 1547 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
OLDNEW
« no previous file with comments | « src/effects/SkColorMatrixFilter.cpp ('k') | src/effects/SkMagnifierImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698