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 "include/core/SkBitmap.h"
12#include "include/core/SkFilterQuality.h"
13#include "include/core/SkMatrix.h"
14#include "src/core/SkBitmapCache.h"
15#include "src/core/SkMipMap.h"
16
17class SkImage_Base;
18
19/**
20 * Handles request to scale, filter, and lock a bitmap to be rasterized.
21 */
22class SkBitmapController : ::SkNoncopyable {
23public:
24 class State : ::SkNoncopyable {
25 public:
26 State(const SkImage_Base*, const SkMatrix& inv, SkFilterQuality);
27
28 const SkPixmap& pixmap() const { return fPixmap; }
29 const SkMatrix& invMatrix() const { return fInvMatrix; }
30 SkFilterQuality quality() const { return fQuality; }
31
32 private:
33 bool processHighRequest(const SkImage_Base*);
34 bool processMediumRequest(const SkImage_Base*);
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 SkImage_Base*, const SkMatrix& inverse, SkFilterQuality,
47 SkArenaAlloc*);
48
49private:
50 SkBitmapController() = delete;
51};
52
53#endif
54