| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #ifndef GrTexture_DEFINED | 9 #ifndef GrTexture_DEFINED |
| 10 #define GrTexture_DEFINED | 10 #define GrTexture_DEFINED |
| 11 | 11 |
| 12 #include "GrSurface.h" | 12 #include "GrSurface.h" |
| 13 #include "SkPoint.h" |
| 13 | 14 |
| 14 class GrRenderTarget; | 15 class GrRenderTarget; |
| 15 class GrResourceKey; | 16 class GrResourceKey; |
| 16 class GrTextureParams; | 17 class GrTextureParams; |
| 17 | 18 |
| 18 class GrTexture : public GrSurface { | 19 class GrTexture : public GrSurface { |
| 19 | 20 |
| 20 public: | 21 public: |
| 21 SK_DECLARE_INST_COUNT(GrTexture) | 22 SK_DECLARE_INST_COUNT(GrTexture) |
| 22 // from GrResource | 23 // from GrResource |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 // these two shift a fixed-point value into normalized coordinates | 160 // these two shift a fixed-point value into normalized coordinates |
| 160 // for this texture if the texture is power of two sized. | 161 // for this texture if the texture is power of two sized. |
| 161 int fShiftFixedX; | 162 int fShiftFixedX; |
| 162 int fShiftFixedY; | 163 int fShiftFixedY; |
| 163 | 164 |
| 164 virtual void internal_dispose() const SK_OVERRIDE; | 165 virtual void internal_dispose() const SK_OVERRIDE; |
| 165 | 166 |
| 166 typedef GrSurface INHERITED; | 167 typedef GrSurface INHERITED; |
| 167 }; | 168 }; |
| 168 | 169 |
| 170 /** |
| 171 * Represents a texture that is intended to be accessed in device coords with an
offset. |
| 172 */ |
| 173 class GrDeviceCoordTexture { |
| 174 public: |
| 175 GrDeviceCoordTexture() { fOffset.set(0, 0); } |
| 176 |
| 177 GrDeviceCoordTexture(const GrDeviceCoordTexture& other) { |
| 178 *this = other; |
| 179 } |
| 180 |
| 181 GrDeviceCoordTexture(GrTexture* texture, const SkIPoint& offset) |
| 182 : fTexture(SkSafeRef(texture)) |
| 183 , fOffset(offset) { |
| 184 } |
| 185 |
| 186 GrDeviceCoordTexture& operator=(const GrDeviceCoordTexture& other) { |
| 187 fTexture.reset(SkSafeRef(other.fTexture.get())); |
| 188 fOffset = other.fOffset; |
| 189 return *this; |
| 190 } |
| 191 |
| 192 const SkIPoint& offset() const { return fOffset; } |
| 193 |
| 194 void setOffset(const SkIPoint& offset) { fOffset = offset; } |
| 195 void setOffset(int ox, int oy) { fOffset.set(ox, oy); } |
| 196 |
| 197 GrTexture* texture() const { return fTexture.get(); } |
| 198 |
| 199 GrTexture* setTexture(GrTexture* texture) { |
| 200 fTexture.reset(SkSafeRef(texture)); |
| 201 return texture; |
| 202 } |
| 203 private: |
| 204 SkAutoTUnref<GrTexture> fTexture; |
| 205 SkIPoint fOffset; |
| 206 }; |
| 207 |
| 169 #endif | 208 #endif |
| OLD | NEW |