reed | 6404542 | 2015-06-04 06:31:31 -0700 | [diff] [blame] | 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 SkBitmapController_DEFINED |
| 9 | #define SkBitmapController_DEFINED |
| 10 | |
| 11 | #include "SkBitmap.h" |
reed | 98ed7b6 | 2015-09-15 12:38:12 -0700 | [diff] [blame] | 12 | #include "SkBitmapCache.h" |
reed | 6404542 | 2015-06-04 06:31:31 -0700 | [diff] [blame] | 13 | #include "SkFilterQuality.h" |
| 14 | #include "SkMatrix.h" |
| 15 | |
reed | 013e9e3 | 2015-09-15 14:46:27 -0700 | [diff] [blame] | 16 | class SkBitmapProvider; |
reed | 98ed7b6 | 2015-09-15 12:38:12 -0700 | [diff] [blame] | 17 | |
reed | 6404542 | 2015-06-04 06:31:31 -0700 | [diff] [blame] | 18 | /** |
| 19 | * Handles request to scale, filter, and lock a bitmap to be rasterized. |
| 20 | */ |
| 21 | class SkBitmapController : ::SkNoncopyable { |
| 22 | public: |
| 23 | class State : ::SkNoncopyable { |
| 24 | public: |
| 25 | virtual ~State() {} |
| 26 | |
reed | ad7ae6c | 2015-06-04 14:12:25 -0700 | [diff] [blame] | 27 | const SkPixmap& pixmap() const { return fPixmap; } |
reed | 6404542 | 2015-06-04 06:31:31 -0700 | [diff] [blame] | 28 | const SkMatrix& invMatrix() const { return fInvMatrix; } |
| 29 | SkFilterQuality quality() const { return fQuality; } |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 30 | |
reed | 6404542 | 2015-06-04 06:31:31 -0700 | [diff] [blame] | 31 | protected: |
reed | ad7ae6c | 2015-06-04 14:12:25 -0700 | [diff] [blame] | 32 | SkPixmap fPixmap; |
reed | 6404542 | 2015-06-04 06:31:31 -0700 | [diff] [blame] | 33 | SkMatrix fInvMatrix; |
| 34 | SkFilterQuality fQuality; |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 35 | |
reed | 6404542 | 2015-06-04 06:31:31 -0700 | [diff] [blame] | 36 | private: |
| 37 | friend class SkBitmapController; |
| 38 | }; |
| 39 | |
| 40 | virtual ~SkBitmapController() {} |
| 41 | |
reed | 98ed7b6 | 2015-09-15 12:38:12 -0700 | [diff] [blame] | 42 | State* requestBitmap(const SkBitmapProvider&, const SkMatrix& inverse, SkFilterQuality, |
reed | 6404542 | 2015-06-04 06:31:31 -0700 | [diff] [blame] | 43 | void* storage, size_t storageSize); |
| 44 | |
reed | 98ed7b6 | 2015-09-15 12:38:12 -0700 | [diff] [blame] | 45 | State* requestBitmap(const SkBitmapProvider& bp, const SkMatrix& inv, SkFilterQuality quality) { |
| 46 | return this->requestBitmap(bp, inv, quality, nullptr, 0); |
reed | 6404542 | 2015-06-04 06:31:31 -0700 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | protected: |
reed | 98ed7b6 | 2015-09-15 12:38:12 -0700 | [diff] [blame] | 50 | virtual State* onRequestBitmap(const SkBitmapProvider&, const SkMatrix& inv, SkFilterQuality, |
reed | 6404542 | 2015-06-04 06:31:31 -0700 | [diff] [blame] | 51 | void* storage, size_t storageSize) = 0; |
| 52 | }; |
| 53 | |
| 54 | /////////////////////////////////////////////////////////////////////////////////////////////////// |
| 55 | |
reed | 6644d93 | 2016-06-10 11:41:47 -0700 | [diff] [blame] | 56 | #include "SkMipMap.h" |
| 57 | |
reed | 6404542 | 2015-06-04 06:31:31 -0700 | [diff] [blame] | 58 | class SkDefaultBitmapController : public SkBitmapController { |
| 59 | public: |
reed | 6644d93 | 2016-06-10 11:41:47 -0700 | [diff] [blame] | 60 | SkDefaultBitmapController(SkSourceGammaTreatment treatment) : fSrcGammaTreatment(treatment) {} |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 61 | |
reed | 6404542 | 2015-06-04 06:31:31 -0700 | [diff] [blame] | 62 | protected: |
reed | 98ed7b6 | 2015-09-15 12:38:12 -0700 | [diff] [blame] | 63 | State* onRequestBitmap(const SkBitmapProvider&, const SkMatrix& inverse, SkFilterQuality, |
reed | 6404542 | 2015-06-04 06:31:31 -0700 | [diff] [blame] | 64 | void* storage, size_t storageSize) override; |
reed | 6644d93 | 2016-06-10 11:41:47 -0700 | [diff] [blame] | 65 | |
| 66 | private: |
| 67 | const SkSourceGammaTreatment fSrcGammaTreatment; |
reed | 6404542 | 2015-06-04 06:31:31 -0700 | [diff] [blame] | 68 | }; |
| 69 | |
| 70 | #endif |