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 SkBitmapController_DEFINED | 8 #ifndef SkBitmapController_DEFINED |
9 #define SkBitmapController_DEFINED | 9 #define SkBitmapController_DEFINED |
10 | 10 |
11 #include "SkBitmap.h" | 11 #include "SkBitmap.h" |
12 #include "SkBitmapCache.h" | 12 #include "SkBitmapCache.h" |
13 #include "SkFilterQuality.h" | 13 #include "SkFilterQuality.h" |
14 #include "SkImage.h" | |
15 #include "SkMatrix.h" | 14 #include "SkMatrix.h" |
16 | 15 |
17 class SkBitmapProvider { | 16 class SkBitmapProvider; |
18 public: | |
19 explicit SkBitmapProvider(const SkBitmap& bm) : fBitmap(bm) {} | |
20 explicit SkBitmapProvider(const SkImage* img) : fImage(SkSafeRef(img)) {} | |
21 SkBitmapProvider(const SkBitmapProvider& other) | |
22 : fBitmap(other.fBitmap) | |
23 , fImage(SkSafeRef(other.fImage.get())) | |
24 {} | |
25 | |
26 int width() const; | |
27 int height() const; | |
28 uint32_t getID() const; | |
29 | |
30 bool validForDrawing() const; | |
31 SkImageInfo info() const; | |
32 | |
33 SkBitmapCacheDesc makeCacheDesc(int w, int h) const; | |
34 SkBitmapCacheDesc makeCacheDesc() const; | |
35 void notifyAddedToCache() const; | |
36 | |
37 // Only call this if you're sure you need the bits, since it make be expensi
ve | |
38 // ... cause a decode and cache, or gpu-readback | |
39 bool asBitmap(SkBitmap*) const; | |
40 | |
41 private: | |
42 SkBitmap fBitmap; | |
43 SkAutoTUnref<const SkImage> fImage; | |
44 }; | |
45 | 17 |
46 /** | 18 /** |
47 * Handles request to scale, filter, and lock a bitmap to be rasterized. | 19 * Handles request to scale, filter, and lock a bitmap to be rasterized. |
48 */ | 20 */ |
49 class SkBitmapController : ::SkNoncopyable { | 21 class SkBitmapController : ::SkNoncopyable { |
50 public: | 22 public: |
51 class State : ::SkNoncopyable { | 23 class State : ::SkNoncopyable { |
52 public: | 24 public: |
53 virtual ~State() {} | 25 virtual ~State() {} |
54 | 26 |
(...skipping 29 matching lines...) Expand all Loading... |
84 class SkDefaultBitmapController : public SkBitmapController { | 56 class SkDefaultBitmapController : public SkBitmapController { |
85 public: | 57 public: |
86 SkDefaultBitmapController() {} | 58 SkDefaultBitmapController() {} |
87 | 59 |
88 protected: | 60 protected: |
89 State* onRequestBitmap(const SkBitmapProvider&, const SkMatrix& inverse, SkF
ilterQuality, | 61 State* onRequestBitmap(const SkBitmapProvider&, const SkMatrix& inverse, SkF
ilterQuality, |
90 void* storage, size_t storageSize) override; | 62 void* storage, size_t storageSize) override; |
91 }; | 63 }; |
92 | 64 |
93 #endif | 65 #endif |
OLD | NEW |