blob: c32bdb18a09d8b778c0dd85d63349e933397e551 (
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
/*
* 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 GrImageIDTextureAdjuster_DEFINED
#define GrImageIDTextureAdjuster_DEFINED
#include "GrTextureParamsAdjuster.h"
#include "SkImage.h"
class SkBitmap;
class SkImage_Base;
class SkImageCacherator;
/** Implementation for texture-backed SkBitmaps. The bitmap must stay in scope and unmodified
while this object exists. */
class GrBitmapTextureAdjuster : public GrTextureAdjuster {
public:
explicit GrBitmapTextureAdjuster(const SkBitmap* bmp);
protected:
SkColorSpace* getColorSpace() override;
private:
void makeCopyKey(const CopyParams& params, GrUniqueKey* copyKey) override;
void didCacheCopy(const GrUniqueKey& copyKey) override;
const SkBitmap* fBmp;
typedef GrTextureAdjuster INHERITED;
};
/** Implementation for texture-backed SkImages. The image must stay in scope and unmodified while
this object exists. */
class GrImageTextureAdjuster : public GrTextureAdjuster {
public:
explicit GrImageTextureAdjuster(const SkImage_Base* img);
protected:
SkColorSpace* getColorSpace() override;
private:
void makeCopyKey(const CopyParams& params, GrUniqueKey* copyKey) override;
void didCacheCopy(const GrUniqueKey& copyKey) override;
const SkImage_Base* fImageBase;
typedef GrTextureAdjuster INHERITED;
};
/** This class manages the conversion of SW-backed bitmaps to GrTextures. If the input bitmap is
non-volatile the texture is cached using a key created from the pixels' image id and the
subset of the pixelref specified by the bitmap. */
class GrBitmapTextureMaker : public GrTextureMaker {
public:
GrBitmapTextureMaker(GrContext* context, const SkBitmap& bitmap);
protected:
GrTexture* refOriginalTexture(bool willBeMipped, SkSourceGammaTreatment) override;
void makeCopyKey(const CopyParams& copyParams, GrUniqueKey* copyKey) override;
void didCacheCopy(const GrUniqueKey& copyKey) override;
SkColorSpace* getColorSpace() override;
private:
const SkBitmap fBitmap;
GrUniqueKey fOriginalKey;
typedef GrTextureMaker INHERITED;
};
/** This class manages the conversion of generator-backed images to GrTextures. If the caching hint
is kAllow the image's ID is used for the cache key. */
class GrImageTextureMaker : public GrTextureMaker {
public:
GrImageTextureMaker(GrContext* context, SkImageCacherator* cacher, const SkImage* client,
SkImage::CachingHint chint);
protected:
// TODO: consider overriding this, for the case where the underlying generator might be
// able to efficiently produce a "stretched" texture natively (e.g. picture-backed)
// GrTexture* generateTextureForParams(const CopyParams&) override;
GrTexture* refOriginalTexture(bool willBeMipped, SkSourceGammaTreatment) override;
void makeCopyKey(const CopyParams& stretch, GrUniqueKey* paramsCopyKey) override;
void didCacheCopy(const GrUniqueKey& copyKey) override;
SkColorSpace* getColorSpace() override;
private:
SkImageCacherator* fCacher;
const SkImage* fClient;
GrUniqueKey fOriginalKey;
SkImage::CachingHint fCachingHint;
typedef GrTextureMaker INHERITED;
};
#endif
|