OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file | 5 * found in the LICENSE file |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkSpecialImage_DEFINED | 8 #ifndef SkSpecialImage_DEFINED |
9 #define SkSpecialImage_DEFINED | 9 #define SkSpecialImage_DEFINED |
10 | 10 |
(...skipping 21 matching lines...) Expand all Loading... |
32 * - it can only be backed by raster or gpu (no generators) | 32 * - it can only be backed by raster or gpu (no generators) |
33 * - it can be backed by a GrTexture larger than its nominal bounds | 33 * - it can be backed by a GrTexture larger than its nominal bounds |
34 * - it can't be drawn tiled | 34 * - it can't be drawn tiled |
35 * - it can't be drawn with MIPMAPs | 35 * - it can't be drawn with MIPMAPs |
36 * It is similar to SkImage in that it abstracts how the pixels are stored/repre
sented. | 36 * It is similar to SkImage in that it abstracts how the pixels are stored/repre
sented. |
37 * | 37 * |
38 * Note: the contents of the backing storage outside of the subset rect are unde
fined. | 38 * Note: the contents of the backing storage outside of the subset rect are unde
fined. |
39 */ | 39 */ |
40 class SkSpecialImage : public SkRefCnt { | 40 class SkSpecialImage : public SkRefCnt { |
41 public: | 41 public: |
| 42 typedef void* ReleaseContext; |
| 43 typedef void(*RasterReleaseProc)(void* pixels, ReleaseContext); |
| 44 |
42 int width() const { return fSubset.width(); } | 45 int width() const { return fSubset.width(); } |
43 int height() const { return fSubset.height(); } | 46 int height() const { return fSubset.height(); } |
44 const SkIRect& subset() const { return fSubset; } | 47 const SkIRect& subset() const { return fSubset; } |
45 | 48 |
46 uint32_t uniqueID() const { return fUniqueID; } | 49 uint32_t uniqueID() const { return fUniqueID; } |
47 virtual bool isOpaque() const { return false; } | 50 virtual bool isOpaque() const { return false; } |
48 virtual size_t getSize() const = 0; | 51 virtual size_t getSize() const = 0; |
49 | 52 |
50 /** | 53 /** |
51 * Draw this SpecialImage into the canvas. | 54 * Draw this SpecialImage into the canvas. |
52 */ | 55 */ |
53 void draw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*) const; | 56 void draw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*) const; |
54 | 57 |
55 static SkSpecialImage* NewFromImage(SkImageFilter::Proxy*, | 58 static sk_sp<SkSpecialImage> MakeFromImage(SkImageFilter::Proxy*, |
56 const SkIRect& subset, | 59 const SkIRect& subset, |
57 const SkImage*); | 60 sk_sp<SkImage>); |
58 static SkSpecialImage* NewFromRaster(SkImageFilter::Proxy*, | 61 static sk_sp<SkSpecialImage> MakeFromRaster(SkImageFilter::Proxy*, |
59 const SkIRect& subset, | 62 const SkIRect& subset, |
60 const SkBitmap&); | 63 const SkBitmap&); |
61 static SkSpecialImage* NewFromGpu(SkImageFilter::Proxy*, | 64 static sk_sp<SkSpecialImage> MakeFromGpu(SkImageFilter::Proxy*, |
62 const SkIRect& subset, | 65 const SkIRect& subset, |
63 uint32_t uniqueID, | 66 uint32_t uniqueID, |
64 GrTexture*, | 67 GrTexture*, |
65 SkAlphaType at = kPremul_SkAlphaType); | 68 SkAlphaType at = kPremul_SkAlphaTyp
e); |
66 static SkSpecialImage* NewFromPixmap(SkImageFilter::Proxy*, | 69 static sk_sp<SkSpecialImage> MakeFromPixmap(SkImageFilter::Proxy*, |
67 const SkIRect& subset, | 70 const SkIRect& subset, |
68 const SkPixmap&, | 71 const SkPixmap&, |
69 void (*releaseProc)(void* addr, void* c
ontext), | 72 RasterReleaseProc, |
70 void* context); | 73 ReleaseContext); |
71 | 74 |
72 /** | 75 /** |
73 * Create a new surface with a backend that is compatible with this image. | 76 * Create a new surface with a backend that is compatible with this image. |
74 */ | 77 */ |
75 SkSpecialSurface* newSurface(const SkImageInfo&) const; | 78 sk_sp<SkSpecialSurface> makeSurface(const SkImageInfo&) const; |
76 | 79 |
77 /** | 80 /** |
78 * Extract a subset of this special image and return it as a special image. | 81 * Extract a subset of this special image and return it as a special image. |
79 * It may or may not point to the same backing memory. | 82 * It may or may not point to the same backing memory. |
80 */ | 83 */ |
81 SkSpecialImage* extractSubset(const SkIRect& subset) const; | 84 sk_sp<SkSpecialImage> makeSubset(const SkIRect& subset) const; |
82 | 85 |
83 // These three internal methods will go away (see skbug.com/4965) | 86 // These three internal methods will go away (see skbug.com/4965) |
84 bool internal_getBM(SkBitmap* result); | 87 bool internal_getBM(SkBitmap* result); |
85 static SkSpecialImage* internal_fromBM(SkImageFilter::Proxy*, const SkBitmap
&); | 88 static sk_sp<SkSpecialImage> internal_fromBM(SkImageFilter::Proxy*, const Sk
Bitmap&); |
86 SkImageFilter::Proxy* internal_getProxy() const; | 89 SkImageFilter::Proxy* internal_getProxy() const; |
87 | 90 |
88 // TODO: hide this when GrLayerHoister uses SkSpecialImages more fully (see
skbug.com/5063) | 91 // TODO: hide this when GrLayerHoister uses SkSpecialImages more fully (see
skbug.com/5063) |
89 /** | 92 /** |
90 * If the SpecialImage is backed by a gpu texture, return that texture. | 93 * If the SpecialImage is backed by a gpu texture, return that texture. |
91 * The active portion of the texture can be retrieved via 'subset'. | 94 * The active portion of the texture can be retrieved via 'subset'. |
92 */ | 95 */ |
93 GrTexture* peekTexture() const; | 96 GrTexture* peekTexture() const; |
94 | 97 |
95 // TODO: hide this whe the imagefilter all have a consistent draw path (see
skbug.com/5063) | 98 // TODO: hide this whe the imagefilter all have a consistent draw path (see
skbug.com/5063) |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 const uint32_t fUniqueID; | 133 const uint32_t fUniqueID; |
131 | 134 |
132 // TODO: remove this ASAP (see skbug.com/4965) | 135 // TODO: remove this ASAP (see skbug.com/4965) |
133 SkImageFilter::Proxy* fProxy; | 136 SkImageFilter::Proxy* fProxy; |
134 | 137 |
135 typedef SkRefCnt INHERITED; | 138 typedef SkRefCnt INHERITED; |
136 }; | 139 }; |
137 | 140 |
138 #endif | 141 #endif |
139 | 142 |
OLD | NEW |