OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2015 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 SkImageCacherator_DEFINED |
| 9 #define SkImageCacherator_DEFINED |
| 10 |
| 11 #include "SkImageGenerator.h" |
| 12 |
| 13 class GrContext; |
| 14 class SkBitmap; |
| 15 |
| 16 /* |
| 17 * Internal class to manage caching the output of an ImageGenerator. |
| 18 */ |
| 19 class SkImageCacherator { |
| 20 public: |
| 21 // Takes ownership of the generator |
| 22 SkImageCacherator(SkImageGenerator* gen); |
| 23 ~SkImageCacherator(); |
| 24 |
| 25 const SkImageInfo& info() const { return fGenerator->getInfo(); } |
| 26 SkImageGenerator* generator() const { return fGenerator; } |
| 27 |
| 28 /** |
| 29 * On success (true), bitmap will point to the pixels for this generator. I
f this returns |
| 30 * false, the bitmap will be reset to empty. |
| 31 * |
| 32 * The cached bitmap is valid until it goes out of scope. |
| 33 */ |
| 34 bool lockAsBitmap(SkBitmap*); |
| 35 |
| 36 /** |
| 37 * Returns a ref() on the texture produced by this generator. The caller mu
st call unref() |
| 38 * when it is done. Will return NULL on failure. |
| 39 * |
| 40 * The cached texture is valid until it is unref'd. |
| 41 */ |
| 42 GrTexture* lockAsTexture(GrContext*, SkImageUsageType); |
| 43 |
| 44 private: |
| 45 bool tryLockAsBitmap(SkBitmap*); |
| 46 GrTexture* tryLockAsTexture(GrContext*, SkImageUsageType); |
| 47 |
| 48 SkImageGenerator* fGenerator; |
| 49 }; |
| 50 |
| 51 #endif |
OLD | NEW |