• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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"
12 #include "SkBitmapCache.h"
13 #include "SkFilterQuality.h"
14 #include "SkMatrix.h"
15 #include "SkMipMap.h"
16 
17 class SkBitmapProvider;
18 
19 /**
20  *  Handles request to scale, filter, and lock a bitmap to be rasterized.
21  */
22 class SkBitmapController : ::SkNoncopyable {
23 public:
24     class State : ::SkNoncopyable {
25     public:
26         State(const SkBitmapProvider&, const SkMatrix& inv, SkFilterQuality);
27 
pixmap()28         const SkPixmap& pixmap() const { return fPixmap; }
invMatrix()29         const SkMatrix& invMatrix() const { return fInvMatrix; }
quality()30         SkFilterQuality quality() const { return fQuality; }
31 
32     private:
33         bool processHighRequest(const SkBitmapProvider&);
34         bool processMediumRequest(const SkBitmapProvider&);
35 
36         SkPixmap              fPixmap;
37         SkMatrix              fInvMatrix;
38         SkFilterQuality       fQuality;
39 
40         // Pixmap storage.
41         SkBitmap              fResultBitmap;
42         sk_sp<const SkMipMap> fCurrMip;
43 
44     };
45 
46     static State* RequestBitmap(const SkBitmapProvider&, const SkMatrix& inverse, SkFilterQuality,
47                                 SkArenaAlloc*);
48 
49 private:
50     SkBitmapController() = delete;
51 };
52 
53 #endif
54