| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 #ifndef SkImageCacherator_DEFINED | 8 #ifndef SkImageCacherator_DEFINED |
| 9 #define SkImageCacherator_DEFINED | 9 #define SkImageCacherator_DEFINED |
| 10 | 10 |
| 11 #include "SkImageGenerator.h" | 11 #include "SkImageGenerator.h" |
| 12 | 12 |
| 13 class GrContext; | 13 class GrContext; |
| 14 class SkBitmap; | 14 class SkBitmap; |
| 15 | 15 |
| 16 /* | 16 /* |
| 17 * Internal class to manage caching the output of an ImageGenerator. | 17 * Internal class to manage caching the output of an ImageGenerator. |
| 18 */ | 18 */ |
| 19 class SkImageCacherator { | 19 class SkImageCacherator { |
| 20 public: | 20 public: |
| 21 // Takes ownership of the generator | 21 // Takes ownership of the generator |
| 22 static SkImageCacherator* NewFromGenerator(SkImageGenerator*); | 22 static SkImageCacherator* NewFromGenerator(SkImageGenerator*, const SkIRect*
subset = nullptr); |
| 23 | 23 |
| 24 ~SkImageCacherator(); | 24 ~SkImageCacherator(); |
| 25 | 25 |
| 26 const SkImageInfo& info() const { return fGenerator->getInfo(); } | 26 const SkImageInfo& info() const { return fInfo; } |
| 27 SkImageGenerator* generator() const { return fGenerator; } | 27 uint32_t uniqueID() const { return fUniqueID; } |
| 28 | 28 |
| 29 /** | 29 /** |
| 30 * On success (true), bitmap will point to the pixels for this generator. I
f this returns | 30 * On success (true), bitmap will point to the pixels for this generator. I
f this returns |
| 31 * false, the bitmap will be reset to empty. | 31 * false, the bitmap will be reset to empty. |
| 32 */ | 32 */ |
| 33 bool lockAsBitmap(SkBitmap*); | 33 bool lockAsBitmap(SkBitmap*); |
| 34 | 34 |
| 35 /** | 35 /** |
| 36 * Returns a ref() on the texture produced by this generator. The caller mu
st call unref() | 36 * Returns a ref() on the texture produced by this generator. The caller mu
st call unref() |
| 37 * when it is done. Will return NULL on failure. | 37 * when it is done. Will return NULL on failure. |
| 38 * | 38 * |
| 39 * The caller is responsible for calling texture->unref() when they are don
e. | 39 * The caller is responsible for calling texture->unref() when they are don
e. |
| 40 */ | 40 */ |
| 41 GrTexture* lockAsTexture(GrContext*, SkImageUsageType); | 41 GrTexture* lockAsTexture(GrContext*, SkImageUsageType); |
| 42 | 42 |
| 43 private: | 43 private: |
| 44 SkImageCacherator(SkImageGenerator* gen); | 44 SkImageCacherator(SkImageGenerator*, const SkImageInfo&, const SkIPoint&, ui
nt32_t uniqueID); |
| 45 | 45 |
| 46 bool tryLockAsBitmap(SkBitmap*); | 46 bool tryLockAsBitmap(SkBitmap*); |
| 47 GrTexture* tryLockAsTexture(GrContext*, SkImageUsageType); | 47 GrTexture* tryLockAsTexture(GrContext*, SkImageUsageType); |
| 48 | 48 |
| 49 SkImageGenerator* fGenerator; | 49 SkImageGenerator* fGenerator; |
| 50 const SkImageInfo fInfo; |
| 51 const SkIPoint fOrigin; |
| 52 const uint32_t fUniqueID; |
| 50 }; | 53 }; |
| 51 | 54 |
| 52 #endif | 55 #endif |
| OLD | NEW |