Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(507)

Side by Side Diff: src/core/SkBitmapController.h

Issue 1340223003: create SkBitmapProvider to abstract images and bitmaps (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: remove obsolete comments Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/core/SkBitmapCache.cpp ('k') | src/core/SkBitmapController.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "SkFilterQuality.h" 13 #include "SkFilterQuality.h"
14 #include "SkImage.h"
13 #include "SkMatrix.h" 15 #include "SkMatrix.h"
14 16
17 class SkBitmapProvider {
18 public:
19 SkBitmapProvider(const SkBitmap& bm) : fBitmap(bm) {}
20 SkBitmapProvider(const SkImage* img) : fImage(SkRef(img)) {}
21
22 int width() const;
23 int height() const;
24 uint32_t getID() const;
25
26 bool validForDrawing() const;
27 SkImageInfo info() const;
28
29 SkBitmapCacheDesc makeCacheDesc(int w, int h) const;
30 SkBitmapCacheDesc makeCacheDesc() const;
31 void notifyAddedToCache() const;
32
33 // Only call this if you're sure you need the bits, since it make be expensi ve
34 // ... cause a decode and cache, or gpu-readback
35 bool asBitmap(SkBitmap*) const;
36
37 private:
38 SkBitmap fBitmap;
39 SkAutoTUnref<const SkImage> fImage;
40 };
41
15 /** 42 /**
16 * Handles request to scale, filter, and lock a bitmap to be rasterized. 43 * Handles request to scale, filter, and lock a bitmap to be rasterized.
17 */ 44 */
18 class SkBitmapController : ::SkNoncopyable { 45 class SkBitmapController : ::SkNoncopyable {
19 public: 46 public:
20 class State : ::SkNoncopyable { 47 class State : ::SkNoncopyable {
21 public: 48 public:
22 virtual ~State() {} 49 virtual ~State() {}
23 50
24 const SkPixmap& pixmap() const { return fPixmap; } 51 const SkPixmap& pixmap() const { return fPixmap; }
25 const SkMatrix& invMatrix() const { return fInvMatrix; } 52 const SkMatrix& invMatrix() const { return fInvMatrix; }
26 SkFilterQuality quality() const { return fQuality; } 53 SkFilterQuality quality() const { return fQuality; }
27 54
28 protected: 55 protected:
29 SkPixmap fPixmap; 56 SkPixmap fPixmap;
30 SkMatrix fInvMatrix; 57 SkMatrix fInvMatrix;
31 SkFilterQuality fQuality; 58 SkFilterQuality fQuality;
32 59
33 private: 60 private:
34 friend class SkBitmapController; 61 friend class SkBitmapController;
35 }; 62 };
36 63
37 virtual ~SkBitmapController() {} 64 virtual ~SkBitmapController() {}
38 65
39 State* requestBitmap(const SkBitmap&, const SkMatrix& inverse, SkFilterQuali ty, 66 State* requestBitmap(const SkBitmapProvider&, const SkMatrix& inverse, SkFil terQuality,
40 void* storage, size_t storageSize); 67 void* storage, size_t storageSize);
41 68
42 State* requestBitmap(const SkBitmap& bm, const SkMatrix& inverse, SkFilterQu ality quality) { 69 State* requestBitmap(const SkBitmapProvider& bp, const SkMatrix& inv, SkFilt erQuality quality) {
43 return this->requestBitmap(bm, inverse, quality, nullptr, 0); 70 return this->requestBitmap(bp, inv, quality, nullptr, 0);
44 } 71 }
45 72
46 protected: 73 protected:
47 virtual State* onRequestBitmap(const SkBitmap&, const SkMatrix& inverse, SkF ilterQuality, 74 virtual State* onRequestBitmap(const SkBitmapProvider&, const SkMatrix& inv, SkFilterQuality,
48 void* storage, size_t storageSize) = 0; 75 void* storage, size_t storageSize) = 0;
49 }; 76 };
50 77
51 //////////////////////////////////////////////////////////////////////////////// /////////////////// 78 //////////////////////////////////////////////////////////////////////////////// ///////////////////
52 79
53 class SkDefaultBitmapController : public SkBitmapController { 80 class SkDefaultBitmapController : public SkBitmapController {
54 public: 81 public:
55 SkDefaultBitmapController() {} 82 SkDefaultBitmapController() {}
56 83
57 protected: 84 protected:
58 State* onRequestBitmap(const SkBitmap&, const SkMatrix& inverse, SkFilterQua lity, 85 State* onRequestBitmap(const SkBitmapProvider&, const SkMatrix& inverse, SkF ilterQuality,
59 void* storage, size_t storageSize) override; 86 void* storage, size_t storageSize) override;
60 }; 87 };
61 88
62 #endif 89 #endif
OLDNEW
« no previous file with comments | « src/core/SkBitmapCache.cpp ('k') | src/core/SkBitmapController.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698