OLD | NEW |
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 | 13 #ifdef SK_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, GrRenderTarget* dst) { |
20 this->reset(texture, params); | 20 this->reset(texture, params, dst); |
21 } | 21 } |
22 | 22 |
23 GrTextureAccess::GrTextureAccess(GrTexture* texture, | 23 GrTextureAccess::GrTextureAccess(GrTexture* texture, |
24 GrTextureParams::FilterMode filterMode, | 24 GrTextureParams::FilterMode filterMode, |
25 SkShader::TileMode tileXAndY) { | 25 SkShader::TileMode tileXAndY, |
26 this->reset(texture, filterMode, tileXAndY); | 26 GrRenderTarget* dst) { |
| 27 this->reset(texture, filterMode, tileXAndY, dst); |
27 } | 28 } |
28 | 29 |
29 GrTextureAccess::GrTextureAccess(GrTexture* texture, | 30 GrTextureAccess::GrTextureAccess(GrTexture* texture, |
30 const char* swizzle, | 31 const char* swizzle, |
31 const GrTextureParams& params) { | 32 const GrTextureParams& params, |
32 this->reset(texture, swizzle, params); | 33 GrRenderTarget* dst) { |
| 34 this->reset(texture, swizzle, params, dst); |
33 } | 35 } |
34 | 36 |
35 GrTextureAccess::GrTextureAccess(GrTexture* texture, | 37 GrTextureAccess::GrTextureAccess(GrTexture* texture, |
36 const char* swizzle, | 38 const char* swizzle, |
37 GrTextureParams::FilterMode filterMode, | 39 GrTextureParams::FilterMode filterMode, |
38 SkShader::TileMode tileXAndY) { | 40 SkShader::TileMode tileXAndY, |
39 this->reset(texture, swizzle, filterMode, tileXAndY); | 41 GrRenderTarget* dst) { |
| 42 this->reset(texture, swizzle, filterMode, tileXAndY, dst); |
40 } | 43 } |
41 | 44 |
42 void GrTextureAccess::reset(GrTexture* texture, | 45 void GrTextureAccess::reset(GrTexture* texture, |
43 const char* swizzle, | 46 const char* swizzle, |
44 const GrTextureParams& params) { | 47 const GrTextureParams& params, |
| 48 GrRenderTarget* dst) { |
45 SkASSERT(texture); | 49 SkASSERT(texture); |
46 SkASSERT(strlen(swizzle) >= 1 && strlen(swizzle) <= 4); | 50 SkASSERT(strlen(swizzle) >= 1 && strlen(swizzle) <= 4); |
47 | 51 |
48 fParams = params; | 52 fParams = params; |
49 fTexture.set(SkRef(texture), kRead_GrIOType); | 53 fTexture.set(SkRef(texture), kRead_GrIOType, dst); |
50 this->setSwizzle(swizzle); | 54 this->setSwizzle(swizzle); |
51 } | 55 } |
52 | 56 |
53 void GrTextureAccess::reset(GrTexture* texture, | 57 void GrTextureAccess::reset(GrTexture* texture, |
54 const char* swizzle, | 58 const char* swizzle, |
55 GrTextureParams::FilterMode filterMode, | 59 GrTextureParams::FilterMode filterMode, |
56 SkShader::TileMode tileXAndY) { | 60 SkShader::TileMode tileXAndY, |
| 61 GrRenderTarget* dst) { |
57 SkASSERT(texture); | 62 SkASSERT(texture); |
58 SkASSERT(strlen(swizzle) >= 1 && strlen(swizzle) <= 4); | 63 SkASSERT(strlen(swizzle) >= 1 && strlen(swizzle) <= 4); |
59 | 64 |
60 fParams.reset(tileXAndY, filterMode); | 65 fParams.reset(tileXAndY, filterMode); |
61 fTexture.set(SkRef(texture), kRead_GrIOType); | 66 fTexture.set(SkRef(texture), kRead_GrIOType, dst); |
62 this->setSwizzle(swizzle); | 67 this->setSwizzle(swizzle); |
63 } | 68 } |
64 | 69 |
65 void GrTextureAccess::reset(GrTexture* texture, | 70 void GrTextureAccess::reset(GrTexture* texture, |
66 const GrTextureParams& params) { | 71 const GrTextureParams& params, |
| 72 GrRenderTarget* dst) { |
67 SkASSERT(texture); | 73 SkASSERT(texture); |
68 fTexture.set(SkRef(texture), kRead_GrIOType); | 74 fTexture.set(SkRef(texture), kRead_GrIOType, dst); |
69 fParams = params; | 75 fParams = params; |
70 memcpy(fSwizzle, "rgba", 5); | 76 memcpy(fSwizzle, "rgba", 5); |
71 fSwizzleMask = kRGBA_GrColorComponentFlags; | 77 fSwizzleMask = kRGBA_GrColorComponentFlags; |
72 } | 78 } |
73 | 79 |
74 void GrTextureAccess::reset(GrTexture* texture, | 80 void GrTextureAccess::reset(GrTexture* texture, |
75 GrTextureParams::FilterMode filterMode, | 81 GrTextureParams::FilterMode filterMode, |
76 SkShader::TileMode tileXAndY) { | 82 SkShader::TileMode tileXAndY, |
| 83 GrRenderTarget* dst) { |
77 SkASSERT(texture); | 84 SkASSERT(texture); |
78 fTexture.set(SkRef(texture), kRead_GrIOType); | 85 fTexture.set(SkRef(texture), kRead_GrIOType, dst); |
79 fParams.reset(tileXAndY, filterMode); | 86 fParams.reset(tileXAndY, filterMode); |
80 memcpy(fSwizzle, "rgba", 5); | 87 memcpy(fSwizzle, "rgba", 5); |
81 fSwizzleMask = kRGBA_GrColorComponentFlags; | 88 fSwizzleMask = kRGBA_GrColorComponentFlags; |
82 } | 89 } |
83 | 90 |
84 void GrTextureAccess::setSwizzle(const char* swizzle) { | 91 void GrTextureAccess::setSwizzle(const char* swizzle) { |
85 fSwizzleMask = 0; | 92 fSwizzleMask = 0; |
86 memset(fSwizzle, '\0', 5); | 93 memset(fSwizzle, '\0', 5); |
87 for (int i = 0; i < 4 && '\0' != swizzle[i]; ++i) { | 94 for (int i = 0; i < 4 && '\0' != swizzle[i]; ++i) { |
88 fSwizzle[i] = swizzle[i]; | 95 fSwizzle[i] = swizzle[i]; |
89 switch (swizzle[i]) { | 96 switch (swizzle[i]) { |
90 case 'r': | 97 case 'r': |
91 fSwizzleMask |= kR_GrColorComponentFlag; | 98 fSwizzleMask |= kR_GrColorComponentFlag; |
92 break; | 99 break; |
93 case 'g': | 100 case 'g': |
94 fSwizzleMask |= kG_GrColorComponentFlag; | 101 fSwizzleMask |= kG_GrColorComponentFlag; |
95 break; | 102 break; |
96 case 'b': | 103 case 'b': |
97 fSwizzleMask |= kB_GrColorComponentFlag; | 104 fSwizzleMask |= kB_GrColorComponentFlag; |
98 break; | 105 break; |
99 case 'a': | 106 case 'a': |
100 fSwizzleMask |= kA_GrColorComponentFlag; | 107 fSwizzleMask |= kA_GrColorComponentFlag; |
101 break; | 108 break; |
102 default: | 109 default: |
103 SkFAIL("Unexpected swizzle string character."); | 110 SkFAIL("Unexpected swizzle string character."); |
104 break; | 111 break; |
105 } | 112 } |
106 } | 113 } |
107 } | 114 } |
OLD | NEW |