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

Side by Side Diff: src/gpu/gl/GrGLProgramEffects.cpp

Issue 365853002: Rename GrGLUniformManager to GrGLProgramResourceManager (Closed) Base URL: https://skia.googlesource.com/skia.git@02-path-program-fragment
Patch Set: rebase Created 6 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
« no previous file with comments | « src/gpu/gl/GrGLProgramEffects.h ('k') | src/gpu/gl/GrGLShaderBuilder.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 2013 Google Inc. 2 * Copyright 2013 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 "GrGLProgramEffects.h" 8 #include "GrGLProgramEffects.h"
9 #include "GrDrawEffect.h" 9 #include "GrDrawEffect.h"
10 #include "gl/GrGLEffect.h" 10 #include "gl/GrGLEffect.h"
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 for (int t = 0; t < numTextures; ++t) { 211 for (int t = 0; t < numTextures; ++t) {
212 name.printf("Sampler%d", t); 212 name.printf("Sampler%d", t);
213 samplers[t].fUniform = builder->addUniform(GrGLShaderBuilder::kFragment_ Visibility, 213 samplers[t].fUniform = builder->addUniform(GrGLShaderBuilder::kFragment_ Visibility,
214 kSampler2D_GrSLType, 214 kSampler2D_GrSLType,
215 name.c_str()); 215 name.c_str());
216 SkNEW_APPEND_TO_TARRAY(outSamplers, TextureSampler, 216 SkNEW_APPEND_TO_TARRAY(outSamplers, TextureSampler,
217 (samplers[t].fUniform, effect->textureAccess(t))) ; 217 (samplers[t].fUniform, effect->textureAccess(t))) ;
218 } 218 }
219 } 219 }
220 220
221 void GrGLProgramEffects::initSamplers(const GrGLUniformManager& uniformManager, int* texUnitIdx) { 221 void GrGLProgramEffects::initSamplers(const GrGLProgramDataManager& programResou rceManager, int* texUnitIdx) {
222 int numEffects = fGLEffects.count(); 222 int numEffects = fGLEffects.count();
223 SkASSERT(numEffects == fSamplers.count()); 223 SkASSERT(numEffects == fSamplers.count());
224 for (int e = 0; e < numEffects; ++e) { 224 for (int e = 0; e < numEffects; ++e) {
225 SkTArray<Sampler, true>& samplers = fSamplers[e]; 225 SkTArray<Sampler, true>& samplers = fSamplers[e];
226 int numSamplers = samplers.count(); 226 int numSamplers = samplers.count();
227 for (int s = 0; s < numSamplers; ++s) { 227 for (int s = 0; s < numSamplers; ++s) {
228 SkASSERT(samplers[s].fUniform.isValid()); 228 SkASSERT(samplers[s].fUniform.isValid());
229 uniformManager.setSampler(samplers[s].fUniform, *texUnitIdx); 229 programResourceManager.setSampler(samplers[s].fUniform, *texUnitIdx) ;
230 samplers[s].fTextureUnit = (*texUnitIdx)++; 230 samplers[s].fTextureUnit = (*texUnitIdx)++;
231 } 231 }
232 } 232 }
233 } 233 }
234 234
235 void GrGLProgramEffects::bindTextures(GrGpuGL* gpu, const GrEffect* effect, int effectIdx) { 235 void GrGLProgramEffects::bindTextures(GrGpuGL* gpu, const GrEffect* effect, int effectIdx) {
236 const SkTArray<Sampler, true>& samplers = fSamplers[effectIdx]; 236 const SkTArray<Sampler, true>& samplers = fSamplers[effectIdx];
237 int numSamplers = samplers.count(); 237 int numSamplers = samplers.count();
238 SkASSERT(numSamplers == effect->numTextures()); 238 SkASSERT(numSamplers == effect->numTextures());
239 for (int s = 0; s < numSamplers; ++s) { 239 for (int s = 0; s < numSamplers; ++s) {
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 } else { 351 } else {
352 builder->vsCodeAppendf("\t%s = %s * vec3(%s, 1);\n", 352 builder->vsCodeAppendf("\t%s = %s * vec3(%s, 1);\n",
353 vsVaryingName, uniName, coords.c_str()); 353 vsVaryingName, uniName, coords.c_str());
354 } 354 }
355 SkNEW_APPEND_TO_TARRAY(outCoords, TransformedCoords, 355 SkNEW_APPEND_TO_TARRAY(outCoords, TransformedCoords,
356 (SkString(fsVaryingName), varyingType)); 356 (SkString(fsVaryingName), varyingType));
357 } 357 }
358 } 358 }
359 359
360 void GrGLVertexProgramEffects::setData(GrGpuGL* gpu, 360 void GrGLVertexProgramEffects::setData(GrGpuGL* gpu,
361 const GrGLUniformManager& uniformManager, 361 const GrGLProgramDataManager& programReso urceManager,
362 const GrEffectStage* effectStages[]) { 362 const GrEffectStage* effectStages[]) {
363 int numEffects = fGLEffects.count(); 363 int numEffects = fGLEffects.count();
364 SkASSERT(numEffects == fTransforms.count()); 364 SkASSERT(numEffects == fTransforms.count());
365 SkASSERT(numEffects == fSamplers.count()); 365 SkASSERT(numEffects == fSamplers.count());
366 for (int e = 0; e < numEffects; ++e) { 366 for (int e = 0; e < numEffects; ++e) {
367 GrDrawEffect drawEffect(*effectStages[e], fHasExplicitLocalCoords); 367 GrDrawEffect drawEffect(*effectStages[e], fHasExplicitLocalCoords);
368 fGLEffects[e]->setData(uniformManager, drawEffect); 368 fGLEffects[e]->setData(programResourceManager, drawEffect);
369 this->setTransformData(uniformManager, drawEffect, e); 369 this->setTransformData(programResourceManager, drawEffect, e);
370 this->bindTextures(gpu, drawEffect.effect(), e); 370 this->bindTextures(gpu, drawEffect.effect(), e);
371 } 371 }
372 } 372 }
373 373
374 void GrGLVertexProgramEffects::setTransformData(const GrGLUniformManager& unifor mManager, 374 void GrGLVertexProgramEffects::setTransformData(const GrGLProgramDataManager& pr ogramResourceManager,
375 const GrDrawEffect& drawEffect, 375 const GrDrawEffect& drawEffect,
376 int effectIdx) { 376 int effectIdx) {
377 SkTArray<Transform, true>& transforms = fTransforms[effectIdx]; 377 SkTArray<Transform, true>& transforms = fTransforms[effectIdx];
378 int numTransforms = transforms.count(); 378 int numTransforms = transforms.count();
379 SkASSERT(numTransforms == drawEffect.effect()->numTransforms()); 379 SkASSERT(numTransforms == drawEffect.effect()->numTransforms());
380 for (int t = 0; t < numTransforms; ++t) { 380 for (int t = 0; t < numTransforms; ++t) {
381 SkASSERT(transforms[t].fHandle.isValid()); 381 SkASSERT(transforms[t].fHandle.isValid());
382 const SkMatrix& matrix = get_transform_matrix(drawEffect, t); 382 const SkMatrix& matrix = get_transform_matrix(drawEffect, t);
383 if (!transforms[t].fCurrentValue.cheapEqualTo(matrix)) { 383 if (!transforms[t].fCurrentValue.cheapEqualTo(matrix)) {
384 uniformManager.setSkMatrix(transforms[t].fHandle, matrix); 384 programResourceManager.setSkMatrix(transforms[t].fHandle, matrix);
385 transforms[t].fCurrentValue = matrix; 385 transforms[t].fCurrentValue = matrix;
386 } 386 }
387 } 387 }
388 } 388 }
389 389
390 GrGLVertexProgramEffectsBuilder::GrGLVertexProgramEffectsBuilder(GrGLFullShaderB uilder* builder, 390 GrGLVertexProgramEffectsBuilder::GrGLVertexProgramEffectsBuilder(GrGLFullShaderB uilder* builder,
391 int reserveCoun t) 391 int reserveCoun t)
392 : fBuilder(builder) 392 : fBuilder(builder)
393 , fProgramEffects(SkNEW_ARGS(GrGLVertexProgramEffects, 393 , fProgramEffects(SkNEW_ARGS(GrGLVertexProgramEffects,
394 (reserveCount, fBuilder->hasExplicitLocalCoords ()))) { 394 (reserveCount, fBuilder->hasExplicitLocalCoords ()))) {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 for (int t = 0; t < numTransforms; ++t) { 445 for (int t = 0; t < numTransforms; ++t) {
446 GrSLType type = kGeneral_MatrixType == get_matrix_type(totalKey, t) ? 446 GrSLType type = kGeneral_MatrixType == get_matrix_type(totalKey, t) ?
447 kVec3f_GrSLType : 447 kVec3f_GrSLType :
448 kVec2f_GrSLType; 448 kVec2f_GrSLType;
449 name.printf("%s(gl_TexCoord[%i])", GrGLSLTypeString(type), texCoordIndex ++); 449 name.printf("%s(gl_TexCoord[%i])", GrGLSLTypeString(type), texCoordIndex ++);
450 SkNEW_APPEND_TO_TARRAY(outCoords, TransformedCoords, (name, type)); 450 SkNEW_APPEND_TO_TARRAY(outCoords, TransformedCoords, (name, type));
451 } 451 }
452 } 452 }
453 453
454 void GrGLPathTexGenProgramEffects::setData(GrGpuGL* gpu, 454 void GrGLPathTexGenProgramEffects::setData(GrGpuGL* gpu,
455 const GrGLUniformManager& uniformManager, 455 const GrGLProgramDataManager& programReso urceManager,
456 const GrEffectStage* effectStages[]) { 456 const GrEffectStage* effectStages[]) {
457 int numEffects = fGLEffects.count(); 457 int numEffects = fGLEffects.count();
458 SkASSERT(numEffects == fTransforms.count()); 458 SkASSERT(numEffects == fTransforms.count());
459 SkASSERT(numEffects == fSamplers.count()); 459 SkASSERT(numEffects == fSamplers.count());
460 for (int e = 0; e < numEffects; ++e) { 460 for (int e = 0; e < numEffects; ++e) {
461 GrDrawEffect drawEffect(*effectStages[e], false); 461 GrDrawEffect drawEffect(*effectStages[e], false);
462 fGLEffects[e]->setData(uniformManager, drawEffect); 462 fGLEffects[e]->setData(programResourceManager, drawEffect);
463 this->setPathTexGenState(gpu, drawEffect, e); 463 this->setPathTexGenState(gpu, drawEffect, e);
464 this->bindTextures(gpu, drawEffect.effect(), e); 464 this->bindTextures(gpu, drawEffect.effect(), e);
465 } 465 }
466 } 466 }
467 467
468 void GrGLPathTexGenProgramEffects::setPathTexGenState(GrGpuGL* gpu, 468 void GrGLPathTexGenProgramEffects::setPathTexGenState(GrGpuGL* gpu,
469 const GrDrawEffect& drawEffect, 469 const GrDrawEffect& drawEffect,
470 int effectIdx) { 470 int effectIdx) {
471 uint32_t totalKey = fTransforms[effectIdx].fTransformKey; 471 uint32_t totalKey = fTransforms[effectIdx].fTransformKey;
472 int texCoordIndex = fTransforms[effectIdx].fTexCoordIndex; 472 int texCoordIndex = fTransforms[effectIdx].fTexCoordIndex;
(...skipping 28 matching lines...) Expand all
501 } 501 }
502 502
503 void GrGLPathTexGenProgramEffectsBuilder::emitEffect(const GrEffectStage& stage, 503 void GrGLPathTexGenProgramEffectsBuilder::emitEffect(const GrEffectStage& stage,
504 const GrEffectKey& key, 504 const GrEffectKey& key,
505 const char* outColor, 505 const char* outColor,
506 const char* inColor, 506 const char* inColor,
507 int stageIndex) { 507 int stageIndex) {
508 SkASSERT(NULL != fProgramEffects.get()); 508 SkASSERT(NULL != fProgramEffects.get());
509 fProgramEffects->emitEffect(fBuilder, stage, key, outColor, inColor, stageIn dex); 509 fProgramEffects->emitEffect(fBuilder, stage, key, outColor, inColor, stageIn dex);
510 } 510 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLProgramEffects.h ('k') | src/gpu/gl/GrGLShaderBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698