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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 | 56 |
57 uint32_t uniqueID() const { return fUniqueID; } | 57 uint32_t uniqueID() const { return fUniqueID; } |
58 virtual bool isOpaque() const { return false; } | 58 virtual bool isOpaque() const { return false; } |
59 virtual size_t getSize() const = 0; | 59 virtual size_t getSize() const = 0; |
60 | 60 |
61 /** | 61 /** |
62 * Ensures that a special image is backed by a texture (when GrContext is n
on-null). If no | 62 * Ensures that a special image is backed by a texture (when GrContext is n
on-null). If no |
63 * transformation is required, the returned image may be the same as this s
pecial image. | 63 * transformation is required, the returned image may be the same as this s
pecial image. |
64 * If this special image is from a different GrContext, this will fail. | 64 * If this special image is from a different GrContext, this will fail. |
65 */ | 65 */ |
66 sk_sp<SkSpecialImage> makeTextureImage(SkImageFilter::Proxy*, GrContext*); | 66 sk_sp<SkSpecialImage> makeTextureImage(GrContext*); |
67 | 67 |
68 /** | 68 /** |
69 * Draw this SpecialImage into the canvas. | 69 * Draw this SpecialImage into the canvas. |
70 */ | 70 */ |
71 void draw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*) const; | 71 void draw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*) const; |
72 | 72 |
73 static sk_sp<SkSpecialImage> MakeFromImage(SkImageFilter::Proxy*, | 73 static sk_sp<SkSpecialImage> MakeFromImage(const SkIRect& subset, |
74 const SkIRect& subset, | |
75 sk_sp<SkImage>, | 74 sk_sp<SkImage>, |
76 const SkSurfaceProps* = nullptr); | 75 const SkSurfaceProps* = nullptr); |
77 static sk_sp<SkSpecialImage> MakeFromRaster(SkImageFilter::Proxy*, | 76 static sk_sp<SkSpecialImage> MakeFromRaster(const SkIRect& subset, |
78 const SkIRect& subset, | |
79 const SkBitmap&, | 77 const SkBitmap&, |
80 const SkSurfaceProps* = nullptr)
; | 78 const SkSurfaceProps* = nullptr)
; |
81 static sk_sp<SkSpecialImage> MakeFromGpu(SkImageFilter::Proxy*, | 79 static sk_sp<SkSpecialImage> MakeFromGpu(const SkIRect& subset, |
82 const SkIRect& subset, | |
83 uint32_t uniqueID, | 80 uint32_t uniqueID, |
84 GrTexture*, | 81 GrTexture*, |
85 const SkSurfaceProps* = nullptr, | 82 const SkSurfaceProps* = nullptr, |
86 SkAlphaType at = kPremul_SkAlphaTyp
e); | 83 SkAlphaType at = kPremul_SkAlphaTyp
e); |
87 static sk_sp<SkSpecialImage> MakeFromPixmap(SkImageFilter::Proxy*, | 84 static sk_sp<SkSpecialImage> MakeFromPixmap(const SkIRect& subset, |
88 const SkIRect& subset, | |
89 const SkPixmap&, | 85 const SkPixmap&, |
90 RasterReleaseProc, | 86 RasterReleaseProc, |
91 ReleaseContext, | 87 ReleaseContext, |
92 const SkSurfaceProps* = nullptr)
; | 88 const SkSurfaceProps* = nullptr)
; |
93 | 89 |
94 /** | 90 /** |
95 * Create a new special surface with a backend that is compatible with this
special image. | 91 * Create a new special surface with a backend that is compatible with this
special image. |
96 */ | 92 */ |
97 sk_sp<SkSpecialSurface> makeSurface(const SkImageInfo&) const; | 93 sk_sp<SkSpecialSurface> makeSurface(const SkImageInfo&) const; |
98 | 94 |
(...skipping 11 matching lines...) Expand all Loading... |
110 | 106 |
111 /** | 107 /** |
112 * Extract a subset of this special image and return it as an SkImage. | 108 * Extract a subset of this special image and return it as an SkImage. |
113 * It may or may not point to the same backing memory. | 109 * It may or may not point to the same backing memory. |
114 * TODO: switch this to makeSurface once we resolved the naming issue | 110 * TODO: switch this to makeSurface once we resolved the naming issue |
115 */ | 111 */ |
116 sk_sp<SkImage> makeTightSubset(const SkIRect& subset) const; | 112 sk_sp<SkImage> makeTightSubset(const SkIRect& subset) const; |
117 | 113 |
118 // These three internal methods will go away (see skbug.com/4965) | 114 // These three internal methods will go away (see skbug.com/4965) |
119 bool internal_getBM(SkBitmap* result); | 115 bool internal_getBM(SkBitmap* result); |
120 static sk_sp<SkSpecialImage> internal_fromBM(SkImageFilter::Proxy*, const Sk
Bitmap&, | 116 static sk_sp<SkSpecialImage> internal_fromBM(const SkBitmap&, const SkSurfac
eProps*); |
121 const SkSurfaceProps*); | |
122 SkImageFilter::Proxy* internal_getProxy() const; | |
123 | 117 |
124 // TODO: hide this when GrLayerHoister uses SkSpecialImages more fully (see
skbug.com/5063) | 118 // TODO: hide this when GrLayerHoister uses SkSpecialImages more fully (see
skbug.com/5063) |
125 /** | 119 /** |
126 * If the SpecialImage is backed by a gpu texture, return true. | 120 * If the SpecialImage is backed by a gpu texture, return true. |
127 */ | 121 */ |
128 bool isTextureBacked() const; | 122 bool isTextureBacked() const; |
129 | 123 |
130 /** | 124 /** |
131 * Return the GrContext if the SkSpecialImage is GrTexture-backed | 125 * Return the GrContext if the SkSpecialImage is GrTexture-backed |
132 */ | 126 */ |
133 GrContext* getContext() const; | 127 GrContext* getContext() const; |
134 | 128 |
135 /** | 129 /** |
136 * Regardless of the underlying backing store, return the contents as a GrT
exture. | 130 * Regardless of the underlying backing store, return the contents as a GrT
exture. |
137 * The active portion of the texture can be retrieved via 'subset'. | 131 * The active portion of the texture can be retrieved via 'subset'. |
138 */ | 132 */ |
139 GrTexture* asTextureRef(GrContext*) const; | 133 GrTexture* asTextureRef(GrContext*) const; |
140 | 134 |
141 // TODO: hide this whe the imagefilter all have a consistent draw path (see
skbug.com/5063) | 135 // TODO: hide this whe the imagefilter all have a consistent draw path (see
skbug.com/5063) |
142 /** | 136 /** |
143 * Regardless of the underlying backing store, return the contents as an Sk
Bitmap | 137 * Regardless of the underlying backing store, return the contents as an Sk
Bitmap |
144 * | 138 * |
145 * The returned ImageInfo represents the backing memory. Use 'subset' | 139 * The returned ImageInfo represents the backing memory. Use 'subset' |
146 * to get the active portion's dimensions. | 140 * to get the active portion's dimensions. |
147 */ | 141 */ |
148 bool getROPixels(SkBitmap*) const; | 142 bool getROPixels(SkBitmap*) const; |
149 | 143 |
150 protected: | 144 protected: |
151 SkSpecialImage(SkImageFilter::Proxy*, const SkIRect& subset, uint32_t unique
ID, | 145 SkSpecialImage(const SkIRect& subset, uint32_t uniqueID, const SkSurfaceProp
s*); |
152 const SkSurfaceProps*); | |
153 | |
154 // The following 2 are for testing and shouldn't be used. | |
155 friend class TestingSpecialImageAccess; | |
156 friend class TestingSpecialSurfaceAccess; | |
157 | |
158 // TODO: remove this ASAP (see skbug.com/4965) | |
159 SkImageFilter::Proxy* proxy() const { return fProxy; } | |
160 | 146 |
161 private: | 147 private: |
162 const SkSurfaceProps fProps; | 148 const SkSurfaceProps fProps; |
163 const SkIRect fSubset; | 149 const SkIRect fSubset; |
164 const uint32_t fUniqueID; | 150 const uint32_t fUniqueID; |
165 | 151 |
166 // TODO: remove this ASAP (see skbug.com/4965) | |
167 SkImageFilter::Proxy* fProxy; | |
168 | |
169 typedef SkRefCnt INHERITED; | 152 typedef SkRefCnt INHERITED; |
170 }; | 153 }; |
171 | 154 |
172 #endif | 155 #endif |
OLD | NEW |