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

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

Issue 13121002: Make GrGLShaderBuilder::TextureSampler extract only required info from GrTextureAccess. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 8 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
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 "GrTextureAccess.h" 8 #include "GrTextureAccess.h"
9 9 #include "GrColor.h"
10 #include "GrTexture.h" 10 #include "GrTexture.h"
11 11
12 GrTextureAccess::GrTextureAccess() { 12 GrTextureAccess::GrTextureAccess() {
13 #if GR_DEBUG 13 #if GR_DEBUG
14 memcpy(fSwizzle, "void", 5); 14 memcpy(fSwizzle, "void", 5);
15 fSwizzleMask = 0xbeeffeed; 15 fSwizzleMask = 0xbeeffeed;
16 #endif 16 #endif
17 } 17 }
18 18
19 GrTextureAccess::GrTextureAccess(GrTexture* texture, const GrTextureParams& para ms) { 19 GrTextureAccess::GrTextureAccess(GrTexture* texture, const GrTextureParams& para ms) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 fTexture.reset(SkRef(texture)); 61 fTexture.reset(SkRef(texture));
62 this->setSwizzle(swizzle); 62 this->setSwizzle(swizzle);
63 } 63 }
64 64
65 void GrTextureAccess::reset(GrTexture* texture, 65 void GrTextureAccess::reset(GrTexture* texture,
66 const GrTextureParams& params) { 66 const GrTextureParams& params) {
67 GrAssert(NULL != texture); 67 GrAssert(NULL != texture);
68 fTexture.reset(SkRef(texture)); 68 fTexture.reset(SkRef(texture));
69 fParams = params; 69 fParams = params;
70 memcpy(fSwizzle, "rgba", 5); 70 memcpy(fSwizzle, "rgba", 5);
71 fSwizzleMask = (kRGB_SwizzleMask | kA_SwizzleFlag); 71 fSwizzleMask = kRGBA_GrColorComponentFlags;
72 } 72 }
73 73
74 void GrTextureAccess::reset(GrTexture* texture, 74 void GrTextureAccess::reset(GrTexture* texture,
75 bool bilerp, 75 bool bilerp,
76 SkShader::TileMode tileXAndY) { 76 SkShader::TileMode tileXAndY) {
77 GrAssert(NULL != texture); 77 GrAssert(NULL != texture);
78 fTexture.reset(SkRef(texture)); 78 fTexture.reset(SkRef(texture));
79 fParams.reset(tileXAndY, bilerp); 79 fParams.reset(tileXAndY, bilerp);
80 memcpy(fSwizzle, "rgba", 5); 80 memcpy(fSwizzle, "rgba", 5);
81 fSwizzleMask = (kRGB_SwizzleMask | kA_SwizzleFlag); 81 fSwizzleMask = kRGBA_GrColorComponentFlags;
82 } 82 }
83 83
84 void GrTextureAccess::setSwizzle(const char* swizzle) { 84 void GrTextureAccess::setSwizzle(const char* swizzle) {
85 fSwizzleMask = 0; 85 fSwizzleMask = 0;
86 memset(fSwizzle, '\0', 5); 86 memset(fSwizzle, '\0', 5);
87 for (int i = 0; i < 4 && '\0' != swizzle[i]; ++i) { 87 for (int i = 0; i < 4 && '\0' != swizzle[i]; ++i) {
88 fSwizzle[i] = swizzle[i]; 88 fSwizzle[i] = swizzle[i];
89 switch (swizzle[i]) { 89 switch (swizzle[i]) {
90 case 'r': 90 case 'r':
91 fSwizzleMask |= kR_SwizzleFlag; 91 fSwizzleMask |= kR_GrColorComponentFlag;
92 break; 92 break;
93 case 'g': 93 case 'g':
94 fSwizzleMask |= kG_SwizzleFlag; 94 fSwizzleMask |= kG_GrColorComponentFlag;
95 break; 95 break;
96 case 'b': 96 case 'b':
97 fSwizzleMask |= kB_SwizzleFlag; 97 fSwizzleMask |= kB_GrColorComponentFlag;
98 break; 98 break;
99 case 'a': 99 case 'a':
100 fSwizzleMask |= kA_SwizzleFlag; 100 fSwizzleMask |= kA_GrColorComponentFlag;
101 break; 101 break;
102 default: 102 default:
103 GrCrash("Unexpected swizzle string character."); 103 GrCrash("Unexpected swizzle string character.");
104 break; 104 break;
105 } 105 }
106 } 106 }
107 } 107 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698