bsalomon@google.com | 047696c | 2012-09-11 13:29:29 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2012 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #ifndef GrTextureAccess_DEFINED |
| 9 | #define GrTextureAccess_DEFINED |
| 10 | |
| 11 | #include "GrTypes.h" |
| 12 | |
| 13 | class GrTexture; |
| 14 | class SkString; |
| 15 | |
| 16 | /** A class representing the swizzle access pattern for a texture. |
| 17 | */ |
| 18 | class GrTextureAccess { |
| 19 | public: |
| 20 | typedef char Swizzle[4]; |
| 21 | |
| 22 | GrTextureAccess(const GrTexture* texture, const SkString& swizzle); |
| 23 | |
| 24 | const GrTexture* getTexture() const { return fTexture; } |
| 25 | const Swizzle& getSwizzle() const { return fSwizzle; } |
| 26 | |
| 27 | bool referencesAlpha() const { |
| 28 | return fSwizzle[0] == 'a' || fSwizzle[1] == 'a' || fSwizzle[2] == 'a' || fSwizzle[3] == 'a'; |
| 29 | } |
| 30 | |
| 31 | private: |
| 32 | const GrTexture* fTexture; |
| 33 | Swizzle fSwizzle; |
| 34 | }; |
| 35 | |
| 36 | #endif |