aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkBitmapController.h
blob: 32e73e813d33f01f84406ea70d27b9949e011c12 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
 * Copyright 2015 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef SkBitmapController_DEFINED
#define SkBitmapController_DEFINED

#include "SkBitmap.h"
#include "SkBitmapCache.h"
#include "SkFilterQuality.h"
#include "SkMatrix.h"

class SkBitmapProvider;

/**
 *  Handles request to scale, filter, and lock a bitmap to be rasterized.
 */
class SkBitmapController : ::SkNoncopyable {
public:
    class State : ::SkNoncopyable {
    public:
        virtual ~State() {}

        const SkPixmap& pixmap() const { return fPixmap; }
        const SkMatrix& invMatrix() const { return fInvMatrix; }
        SkFilterQuality quality() const { return fQuality; }
    
    protected:
        SkPixmap        fPixmap;
        SkMatrix        fInvMatrix;
        SkFilterQuality fQuality;
    
    private:
        friend class SkBitmapController;
    };

    virtual ~SkBitmapController() {}

    State* requestBitmap(const SkBitmapProvider&, const SkMatrix& inverse, SkFilterQuality,
                         void* storage, size_t storageSize);

    State* requestBitmap(const SkBitmapProvider& bp, const SkMatrix& inv, SkFilterQuality quality) {
        return this->requestBitmap(bp, inv, quality, nullptr, 0);
    }

protected:
    virtual State* onRequestBitmap(const SkBitmapProvider&, const SkMatrix& inv, SkFilterQuality,
                                   void* storage, size_t storageSize) = 0;
};

///////////////////////////////////////////////////////////////////////////////////////////////////

class SkDefaultBitmapController : public SkBitmapController {
public:
    SkDefaultBitmapController() {}
    
protected:
    State* onRequestBitmap(const SkBitmapProvider&, const SkMatrix& inverse, SkFilterQuality,
                           void* storage, size_t storageSize) override;
};

#endif