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

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

Issue 1569393002: Revert of Add a class representing texture swizzle. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 11 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/GrSwizzle.h ('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 "GrTextureAccess.h" 8 #include "GrTextureAccess.h"
9 #include "GrColor.h" 9 #include "GrColor.h"
10 #include "GrTexture.h" 10 #include "GrTexture.h"
11 11
12 GrTextureAccess::GrTextureAccess() {} 12 GrTextureAccess::GrTextureAccess() {
13 #ifdef SK_DEBUG
14 memcpy(fSwizzle, "void", 5);
15 fSwizzleMask = 0xbeeffeed;
16 #endif
17 }
13 18
14 GrTextureAccess::GrTextureAccess(GrTexture* texture, const GrTextureParams& para ms) { 19 GrTextureAccess::GrTextureAccess(GrTexture* texture, const GrTextureParams& para ms) {
15 this->reset(texture, params); 20 this->reset(texture, params);
16 } 21 }
17 22
18 GrTextureAccess::GrTextureAccess(GrTexture* texture, 23 GrTextureAccess::GrTextureAccess(GrTexture* texture,
19 GrTextureParams::FilterMode filterMode, 24 GrTextureParams::FilterMode filterMode,
20 SkShader::TileMode tileXAndY) { 25 SkShader::TileMode tileXAndY) {
21 this->reset(texture, filterMode, tileXAndY); 26 this->reset(texture, filterMode, tileXAndY);
22 } 27 }
23 28
29 GrTextureAccess::GrTextureAccess(GrTexture* texture,
30 const char* swizzle,
31 const GrTextureParams& params) {
32 this->reset(texture, swizzle, params);
33 }
34
35 GrTextureAccess::GrTextureAccess(GrTexture* texture,
36 const char* swizzle,
37 GrTextureParams::FilterMode filterMode,
38 SkShader::TileMode tileXAndY) {
39 this->reset(texture, swizzle, filterMode, tileXAndY);
40 }
41
42 void GrTextureAccess::reset(GrTexture* texture,
43 const char* swizzle,
44 const GrTextureParams& params) {
45 SkASSERT(texture);
46 SkASSERT(strlen(swizzle) >= 1 && strlen(swizzle) <= 4);
47
48 fParams = params;
49 fTexture.set(SkRef(texture), kRead_GrIOType);
50 this->setSwizzle(swizzle);
51 }
52
53 void GrTextureAccess::reset(GrTexture* texture,
54 const char* swizzle,
55 GrTextureParams::FilterMode filterMode,
56 SkShader::TileMode tileXAndY) {
57 SkASSERT(texture);
58 SkASSERT(strlen(swizzle) >= 1 && strlen(swizzle) <= 4);
59
60 fParams.reset(tileXAndY, filterMode);
61 fTexture.set(SkRef(texture), kRead_GrIOType);
62 this->setSwizzle(swizzle);
63 }
24 64
25 void GrTextureAccess::reset(GrTexture* texture, 65 void GrTextureAccess::reset(GrTexture* texture,
26 const GrTextureParams& params) { 66 const GrTextureParams& params) {
27 SkASSERT(texture); 67 SkASSERT(texture);
28 fTexture.set(SkRef(texture), kRead_GrIOType); 68 fTexture.set(SkRef(texture), kRead_GrIOType);
29 fParams = params; 69 fParams = params;
70 memcpy(fSwizzle, "rgba", 5);
71 fSwizzleMask = kRGBA_GrColorComponentFlags;
30 } 72 }
31 73
32 void GrTextureAccess::reset(GrTexture* texture, 74 void GrTextureAccess::reset(GrTexture* texture,
33 GrTextureParams::FilterMode filterMode, 75 GrTextureParams::FilterMode filterMode,
34 SkShader::TileMode tileXAndY) { 76 SkShader::TileMode tileXAndY) {
35 SkASSERT(texture); 77 SkASSERT(texture);
36 fTexture.set(SkRef(texture), kRead_GrIOType); 78 fTexture.set(SkRef(texture), kRead_GrIOType);
37 fParams.reset(tileXAndY, filterMode); 79 fParams.reset(tileXAndY, filterMode);
80 memcpy(fSwizzle, "rgba", 5);
81 fSwizzleMask = kRGBA_GrColorComponentFlags;
38 } 82 }
83
84 void GrTextureAccess::setSwizzle(const char* swizzle) {
85 fSwizzleMask = 0;
86 memset(fSwizzle, '\0', 5);
87 for (int i = 0; i < 4 && '\0' != swizzle[i]; ++i) {
88 fSwizzle[i] = swizzle[i];
89 switch (swizzle[i]) {
90 case 'r':
91 fSwizzleMask |= kR_GrColorComponentFlag;
92 break;
93 case 'g':
94 fSwizzleMask |= kG_GrColorComponentFlag;
95 break;
96 case 'b':
97 fSwizzleMask |= kB_GrColorComponentFlag;
98 break;
99 case 'a':
100 fSwizzleMask |= kA_GrColorComponentFlag;
101 break;
102 default:
103 SkFAIL("Unexpected swizzle string character.");
104 break;
105 }
106 }
107 }
OLDNEW
« no previous file with comments | « src/gpu/GrSwizzle.h ('k') | src/gpu/gl/GrGLCaps.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698