| 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" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 GrTextureAccess::GrTextureAccess(GrTexture* texture, | 35 GrTextureAccess::GrTextureAccess(GrTexture* texture, |
| 36 const char* swizzle, | 36 const char* swizzle, |
| 37 GrTextureParams::FilterMode filterMode, | 37 GrTextureParams::FilterMode filterMode, |
| 38 SkShader::TileMode tileXAndY) { | 38 SkShader::TileMode tileXAndY) { |
| 39 this->reset(texture, swizzle, filterMode, tileXAndY); | 39 this->reset(texture, swizzle, filterMode, tileXAndY); |
| 40 } | 40 } |
| 41 | 41 |
| 42 void GrTextureAccess::reset(GrTexture* texture, | 42 void GrTextureAccess::reset(GrTexture* texture, |
| 43 const char* swizzle, | 43 const char* swizzle, |
| 44 const GrTextureParams& params) { | 44 const GrTextureParams& params) { |
| 45 GrAssert(NULL != texture); | 45 SkASSERT(NULL != texture); |
| 46 GrAssert(strlen(swizzle) >= 1 && strlen(swizzle) <= 4); | 46 SkASSERT(strlen(swizzle) >= 1 && strlen(swizzle) <= 4); |
| 47 | 47 |
| 48 fParams = params; | 48 fParams = params; |
| 49 fTexture.reset(SkRef(texture)); | 49 fTexture.reset(SkRef(texture)); |
| 50 this->setSwizzle(swizzle); | 50 this->setSwizzle(swizzle); |
| 51 } | 51 } |
| 52 | 52 |
| 53 void GrTextureAccess::reset(GrTexture* texture, | 53 void GrTextureAccess::reset(GrTexture* texture, |
| 54 const char* swizzle, | 54 const char* swizzle, |
| 55 GrTextureParams::FilterMode filterMode, | 55 GrTextureParams::FilterMode filterMode, |
| 56 SkShader::TileMode tileXAndY) { | 56 SkShader::TileMode tileXAndY) { |
| 57 GrAssert(NULL != texture); | 57 SkASSERT(NULL != texture); |
| 58 GrAssert(strlen(swizzle) >= 1 && strlen(swizzle) <= 4); | 58 SkASSERT(strlen(swizzle) >= 1 && strlen(swizzle) <= 4); |
| 59 | 59 |
| 60 fParams.reset(tileXAndY, filterMode); | 60 fParams.reset(tileXAndY, filterMode); |
| 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 SkASSERT(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 = kRGBA_GrColorComponentFlags; | 71 fSwizzleMask = kRGBA_GrColorComponentFlags; |
| 72 } | 72 } |
| 73 | 73 |
| 74 void GrTextureAccess::reset(GrTexture* texture, | 74 void GrTextureAccess::reset(GrTexture* texture, |
| 75 GrTextureParams::FilterMode filterMode, | 75 GrTextureParams::FilterMode filterMode, |
| 76 SkShader::TileMode tileXAndY) { | 76 SkShader::TileMode tileXAndY) { |
| 77 GrAssert(NULL != texture); | 77 SkASSERT(NULL != texture); |
| 78 fTexture.reset(SkRef(texture)); | 78 fTexture.reset(SkRef(texture)); |
| 79 fParams.reset(tileXAndY, filterMode); | 79 fParams.reset(tileXAndY, filterMode); |
| 80 memcpy(fSwizzle, "rgba", 5); | 80 memcpy(fSwizzle, "rgba", 5); |
| 81 fSwizzleMask = kRGBA_GrColorComponentFlags; | 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) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 98 break; | 98 break; |
| 99 case 'a': | 99 case 'a': |
| 100 fSwizzleMask |= kA_GrColorComponentFlag; | 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 } |
| OLD | NEW |