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

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

Issue 1416423003: Make GrGLSLProgramBuilder base class for ProgramBuilder (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: nit Created 5 years, 1 month 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/GrPorterDuffXferProcessor.cpp ('k') | src/gpu/gl/GrGLCaps.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 "GrTextureDomain.h" 8 #include "GrTextureDomain.h"
9 #include "GrInvariantOutput.h" 9 #include "GrInvariantOutput.h"
10 #include "GrSimpleTextureEffect.h" 10 #include "GrSimpleTextureEffect.h"
11 #include "SkFloatingPoint.h" 11 #include "SkFloatingPoint.h"
12 #include "gl/GrGLContext.h" 12 #include "gl/GrGLContext.h"
13 #include "gl/GrGLFragmentProcessor.h" 13 #include "gl/GrGLFragmentProcessor.h"
14 #include "gl/builders/GrGLProgramBuilder.h" 14 #include "glsl/GrGLSLProgramBuilder.h"
15 #include "glsl/GrGLSLProgramDataManager.h" 15 #include "glsl/GrGLSLProgramDataManager.h"
16 #include "glsl/GrGLSLTextureSampler.h" 16 #include "glsl/GrGLSLTextureSampler.h"
17 17
18 GrTextureDomain::GrTextureDomain(const SkRect& domain, Mode mode, int index) 18 GrTextureDomain::GrTextureDomain(const SkRect& domain, Mode mode, int index)
19 : fIndex(index) { 19 : fIndex(index) {
20 20
21 static const SkRect kFullRect = {0, 0, SK_Scalar1, SK_Scalar1}; 21 static const SkRect kFullRect = {0, 0, SK_Scalar1, SK_Scalar1};
22 if (domain.contains(kFullRect) && kClamp_Mode == mode) { 22 if (domain.contains(kFullRect) && kClamp_Mode == mode) {
23 fMode = kIgnore_Mode; 23 fMode = kIgnore_Mode;
24 } else { 24 } else {
(...skipping 19 matching lines...) Expand all
44 44
45 void GrTextureDomain::GLDomain::sampleTexture(GrGLShaderBuilder* builder, 45 void GrTextureDomain::GLDomain::sampleTexture(GrGLShaderBuilder* builder,
46 const GrTextureDomain& textureDoma in, 46 const GrTextureDomain& textureDoma in,
47 const char* outColor, 47 const char* outColor,
48 const SkString& inCoords, 48 const SkString& inCoords,
49 const GrGLSLTextureSampler& sample r, 49 const GrGLSLTextureSampler& sample r,
50 const char* inModulateColor) { 50 const char* inModulateColor) {
51 SkASSERT((Mode)-1 == fMode || textureDomain.mode() == fMode); 51 SkASSERT((Mode)-1 == fMode || textureDomain.mode() == fMode);
52 SkDEBUGCODE(fMode = textureDomain.mode();) 52 SkDEBUGCODE(fMode = textureDomain.mode();)
53 53
54 GrGLProgramBuilder* program = builder->getProgramBuilder(); 54 GrGLSLProgramBuilder* program = builder->getProgramBuilder();
55 55
56 if (textureDomain.mode() != kIgnore_Mode && !fDomainUni.isValid()) { 56 if (textureDomain.mode() != kIgnore_Mode && !fDomainUni.isValid()) {
57 const char* name; 57 const char* name;
58 SkString uniName("TexDom"); 58 SkString uniName("TexDom");
59 if (textureDomain.fIndex >= 0) { 59 if (textureDomain.fIndex >= 0) {
60 uniName.appendS32(textureDomain.fIndex); 60 uniName.appendS32(textureDomain.fIndex);
61 } 61 }
62 fDomainUni = program->addUniform(GrGLProgramBuilder::kFragment_Visibilit y, 62 fDomainUni = program->addUniform(GrGLSLProgramBuilder::kFragment_Visibil ity,
63 kVec4f_GrSLType, kDefault_GrSLPrecision , 63 kVec4f_GrSLType, kDefault_GrSLPrecision ,
64 uniName.c_str(), &name); 64 uniName.c_str(), &name);
65 fDomainName = name; 65 fDomainName = name;
66 } 66 }
67 67
68 switch (textureDomain.mode()) { 68 switch (textureDomain.mode()) {
69 case kIgnore_Mode: { 69 case kIgnore_Mode: {
70 builder->codeAppendf("%s = ", outColor); 70 builder->codeAppendf("%s = ", outColor);
71 builder->appendTextureLookupAndModulate(inModulateColor, sampler, 71 builder->appendTextureLookupAndModulate(inModulateColor, sampler,
72 inCoords.c_str()); 72 inCoords.c_str());
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 bool bilerp = mode != GrTextureDomain::kRepeat_Mode ? d->fRandom->nextBool() : false; 292 bool bilerp = mode != GrTextureDomain::kRepeat_Mode ? d->fRandom->nextBool() : false;
293 GrCoordSet coords = d->fRandom->nextBool() ? kLocal_GrCoordSet : kDevice_GrC oordSet; 293 GrCoordSet coords = d->fRandom->nextBool() ? kLocal_GrCoordSet : kDevice_GrC oordSet;
294 return GrTextureDomainEffect::Create( 294 return GrTextureDomainEffect::Create(
295 d->fTextures[texIdx], 295 d->fTextures[texIdx],
296 matrix, 296 matrix,
297 domain, 297 domain,
298 mode, 298 mode,
299 bilerp ? GrTextureParams::kBilerp_FilterMode : GrTextureParams::kNone_Fi lterMode, 299 bilerp ? GrTextureParams::kBilerp_FilterMode : GrTextureParams::kNone_Fi lterMode,
300 coords); 300 coords);
301 } 301 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrPorterDuffXferProcessor.cpp ('k') | src/gpu/gl/GrGLCaps.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698