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 SkBitmapProvider_DEFINED |
| 9 #define SkBitmapProvider_DEFINED |
| 10 |
| 11 #include "SkBitmap.h" |
| 12 #include "SkImage.h" |
| 13 #include "SkBitmapCache.h" |
| 14 |
| 15 class SkBitmapProvider { |
| 16 public: |
| 17 explicit SkBitmapProvider(const SkBitmap& bm) : fBitmap(bm) {} |
| 18 explicit SkBitmapProvider(const SkImage* img) : fImage(SkSafeRef(img)) {} |
| 19 SkBitmapProvider(const SkBitmapProvider& other) |
| 20 : fBitmap(other.fBitmap) |
| 21 , fImage(SkSafeRef(other.fImage.get())) |
| 22 {} |
| 23 |
| 24 int width() const; |
| 25 int height() const; |
| 26 uint32_t getID() const; |
| 27 |
| 28 bool validForDrawing() const; |
| 29 SkImageInfo info() const; |
| 30 |
| 31 SkBitmapCacheDesc makeCacheDesc(int w, int h) const; |
| 32 SkBitmapCacheDesc makeCacheDesc() const; |
| 33 void notifyAddedToCache() const; |
| 34 |
| 35 // Only call this if you're sure you need the bits, since it maybe expensive |
| 36 // ... cause a decode and cache, or gpu-readback |
| 37 bool asBitmap(SkBitmap*) const; |
| 38 |
| 39 private: |
| 40 SkBitmap fBitmap; |
| 41 SkAutoTUnref<const SkImage> fImage; |
| 42 }; |
| 43 |
| 44 #endif |
OLD | NEW |