robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016 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 | */ |
reed | ad7604b | 2016-07-20 16:13:32 -0700 | [diff] [blame] | 7 | |
robertphillips | 83c17fa | 2016-03-18 08:14:27 -0700 | [diff] [blame] | 8 | #include "SkSpecialImage.h" |
reed | ad7604b | 2016-07-20 16:13:32 -0700 | [diff] [blame] | 9 | #include "SkBitmap.h" |
| 10 | #include "SkImage.h" |
robertphillips | 6461251 | 2016-04-08 12:10:42 -0700 | [diff] [blame] | 11 | #include "SkBitmapCache.h" |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 12 | #include "SkCanvas.h" |
bsalomon | 84a4e5a | 2016-02-29 11:41:52 -0800 | [diff] [blame] | 13 | #include "SkImage_Base.h" |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 14 | #include "SkSpecialSurface.h" |
brianosman | 898235c | 2016-04-06 07:38:23 -0700 | [diff] [blame] | 15 | #include "SkSurfacePriv.h" |
reed | ad7604b | 2016-07-20 16:13:32 -0700 | [diff] [blame] | 16 | #include "SkPixelRef.h" |
| 17 | |
| 18 | #if SK_SUPPORT_GPU |
| 19 | #include "GrContext.h" |
Robert Phillips | b66b42f | 2017-03-14 08:53:02 -0400 | [diff] [blame] | 20 | #include "GrResourceProvider.h" |
Robert Phillips | e2f7d18 | 2016-12-15 09:23:05 -0500 | [diff] [blame] | 21 | #include "GrSurfaceContext.h" |
Robert Phillips | a5fdc97 | 2017-02-18 16:58:09 -0500 | [diff] [blame] | 22 | #include "GrSurfaceProxyPriv.h" |
reed | ad7604b | 2016-07-20 16:13:32 -0700 | [diff] [blame] | 23 | #include "GrTexture.h" |
Brian Salomon | 514baff | 2016-11-17 15:17:07 -0500 | [diff] [blame] | 24 | #include "GrSamplerParams.h" |
Robert Phillips | 8bc06d0 | 2016-11-01 17:28:40 -0400 | [diff] [blame] | 25 | #include "GrTextureProxy.h" |
reed | ad7604b | 2016-07-20 16:13:32 -0700 | [diff] [blame] | 26 | #include "SkGr.h" |
Robert Phillips | 6de9904 | 2017-01-31 11:31:39 -0500 | [diff] [blame] | 27 | #include "SkImage_Gpu.h" |
reed | ad7604b | 2016-07-20 16:13:32 -0700 | [diff] [blame] | 28 | #endif |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 29 | |
reed | a2217ef | 2016-07-20 06:04:34 -0700 | [diff] [blame] | 30 | // Currently the raster imagefilters can only handle certain imageinfos. Call this to know if |
| 31 | // a given info is supported. |
| 32 | static bool valid_for_imagefilters(const SkImageInfo& info) { |
| 33 | // no support for other swizzles/depths yet |
| 34 | return info.colorType() == kN32_SkColorType; |
| 35 | } |
| 36 | |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 37 | /////////////////////////////////////////////////////////////////////////////// |
| 38 | class SkSpecialImage_Base : public SkSpecialImage { |
| 39 | public: |
robertphillips | 3e30227 | 2016-04-20 11:48:36 -0700 | [diff] [blame] | 40 | SkSpecialImage_Base(const SkIRect& subset, uint32_t uniqueID, const SkSurfaceProps* props) |
| 41 | : INHERITED(subset, uniqueID, props) { |
robertphillips | 3b087f4 | 2016-02-18 08:48:03 -0800 | [diff] [blame] | 42 | } |
robertphillips | 3e30227 | 2016-04-20 11:48:36 -0700 | [diff] [blame] | 43 | ~SkSpecialImage_Base() override { } |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 44 | |
robertphillips | e8c3497 | 2016-02-16 12:09:36 -0800 | [diff] [blame] | 45 | virtual void onDraw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*) const = 0; |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 46 | |
robertphillips | 6461251 | 2016-04-08 12:10:42 -0700 | [diff] [blame] | 47 | virtual bool onGetROPixels(SkBitmap*) const = 0; |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 48 | |
Robert Phillips | 8bc06d0 | 2016-11-01 17:28:40 -0400 | [diff] [blame] | 49 | virtual GrContext* onGetContext() const { return nullptr; } |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 50 | |
brianosman | afbf71d | 2016-07-21 07:15:37 -0700 | [diff] [blame] | 51 | virtual SkColorSpace* onGetColorSpace() const = 0; |
| 52 | |
robertphillips | c91fd34 | 2016-04-25 12:32:54 -0700 | [diff] [blame] | 53 | #if SK_SUPPORT_GPU |
Robert Phillips | 8e1c4e6 | 2017-02-19 12:27:01 -0500 | [diff] [blame] | 54 | virtual sk_sp<GrTextureProxy> onAsTextureProxyRef(GrContext* context) const = 0; |
robertphillips | c91fd34 | 2016-04-25 12:32:54 -0700 | [diff] [blame] | 55 | #endif |
robertphillips | 4418dba | 2016-03-07 12:45:14 -0800 | [diff] [blame] | 56 | |
robertphillips | b4bd11e | 2016-03-21 13:44:18 -0700 | [diff] [blame] | 57 | virtual sk_sp<SkSpecialImage> onMakeSubset(const SkIRect& subset) const = 0; |
| 58 | |
brianosman | eed6b0e | 2016-09-23 13:04:05 -0700 | [diff] [blame] | 59 | virtual sk_sp<SkSpecialSurface> onMakeSurface(const SkImageFilter::OutputProperties& outProps, |
| 60 | const SkISize& size, SkAlphaType at) const = 0; |
robertphillips | c5035e7 | 2016-03-17 06:58:39 -0700 | [diff] [blame] | 61 | |
Robert Phillips | a5fdc97 | 2017-02-18 16:58:09 -0500 | [diff] [blame] | 62 | virtual sk_sp<SkImage> onAsImage(const SkIRect* subset) const = 0; |
robertphillips | b4bd11e | 2016-03-21 13:44:18 -0700 | [diff] [blame] | 63 | |
brianosman | eed6b0e | 2016-09-23 13:04:05 -0700 | [diff] [blame] | 64 | virtual sk_sp<SkSurface> onMakeTightSurface(const SkImageFilter::OutputProperties& outProps, |
| 65 | const SkISize& size, SkAlphaType at) const = 0; |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 66 | |
| 67 | private: |
| 68 | typedef SkSpecialImage INHERITED; |
| 69 | }; |
| 70 | |
| 71 | /////////////////////////////////////////////////////////////////////////////// |
bsalomon | 84a4e5a | 2016-02-29 11:41:52 -0800 | [diff] [blame] | 72 | static inline const SkSpecialImage_Base* as_SIB(const SkSpecialImage* image) { |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 73 | return static_cast<const SkSpecialImage_Base*>(image); |
| 74 | } |
| 75 | |
robertphillips | 3e30227 | 2016-04-20 11:48:36 -0700 | [diff] [blame] | 76 | SkSpecialImage::SkSpecialImage(const SkIRect& subset, |
brianosman | 898235c | 2016-04-06 07:38:23 -0700 | [diff] [blame] | 77 | uint32_t uniqueID, |
| 78 | const SkSurfaceProps* props) |
| 79 | : fProps(SkSurfacePropsCopyOrDefault(props)) |
| 80 | , fSubset(subset) |
robertphillips | 3e30227 | 2016-04-20 11:48:36 -0700 | [diff] [blame] | 81 | , fUniqueID(kNeedNewImageUniqueID_SpecialImage == uniqueID ? SkNextID::ImageID() : uniqueID) { |
brianosman | 898235c | 2016-04-06 07:38:23 -0700 | [diff] [blame] | 82 | } |
| 83 | |
robertphillips | 3e30227 | 2016-04-20 11:48:36 -0700 | [diff] [blame] | 84 | sk_sp<SkSpecialImage> SkSpecialImage::makeTextureImage(GrContext* context) { |
robertphillips | 83c17fa | 2016-03-18 08:14:27 -0700 | [diff] [blame] | 85 | #if SK_SUPPORT_GPU |
| 86 | if (!context) { |
| 87 | return nullptr; |
| 88 | } |
Robert Phillips | 8bc06d0 | 2016-11-01 17:28:40 -0400 | [diff] [blame] | 89 | if (GrContext* curContext = as_SIB(this)->onGetContext()) { |
| 90 | return curContext == context ? sk_sp<SkSpecialImage>(SkRef(this)) : nullptr; |
robertphillips | 83c17fa | 2016-03-18 08:14:27 -0700 | [diff] [blame] | 91 | } |
| 92 | |
| 93 | SkBitmap bmp; |
reed | cf5c846 | 2016-07-20 12:28:40 -0700 | [diff] [blame] | 94 | // At this point, we are definitely not texture-backed, so we must be raster or generator |
| 95 | // backed. If we remove the special-wrapping-an-image subclass, we may be able to assert that |
| 96 | // we are strictly raster-backed (i.e. generator images become raster when they are specialized) |
| 97 | // in which case getROPixels could turn into peekPixels... |
| 98 | if (!this->getROPixels(&bmp)) { |
robertphillips | 83c17fa | 2016-03-18 08:14:27 -0700 | [diff] [blame] | 99 | return nullptr; |
| 100 | } |
| 101 | |
robertphillips | 83f2e5a | 2016-03-24 06:31:25 -0700 | [diff] [blame] | 102 | if (bmp.empty()) { |
robertphillips | 3e30227 | 2016-04-20 11:48:36 -0700 | [diff] [blame] | 103 | return SkSpecialImage::MakeFromRaster(SkIRect::MakeEmpty(), bmp, &this->props()); |
robertphillips | 83f2e5a | 2016-03-24 06:31:25 -0700 | [diff] [blame] | 104 | } |
| 105 | |
Robert Phillips | e14d305 | 2017-02-15 13:18:21 -0500 | [diff] [blame] | 106 | // TODO: this is a tight copy of 'bmp' but it doesn't have to be (given SkSpecialImage's |
| 107 | // semantics). Since this is cached though we would have to bake the fit into the cache key. |
Robert Phillips | 26c90e0 | 2017-03-14 14:39:29 -0400 | [diff] [blame] | 108 | sk_sp<GrTextureProxy> proxy = GrMakeCachedBitmapProxy(context->resourceProvider(), bmp); |
Robert Phillips | e14d305 | 2017-02-15 13:18:21 -0500 | [diff] [blame] | 109 | if (!proxy) { |
robertphillips | 83c17fa | 2016-03-18 08:14:27 -0700 | [diff] [blame] | 110 | return nullptr; |
| 111 | } |
| 112 | |
Robert Phillips | e14d305 | 2017-02-15 13:18:21 -0500 | [diff] [blame] | 113 | const SkIRect rect = SkIRect::MakeWH(proxy->width(), proxy->height()); |
| 114 | |
| 115 | // GrMakeCachedBitmapProxy has uploaded only the specified subset of 'bmp' so we need not |
| 116 | // bother with SkBitmap::getSubset |
| 117 | return SkSpecialImage::MakeDeferredFromGpu(context, |
| 118 | rect, |
| 119 | this->uniqueID(), |
| 120 | std::move(proxy), |
| 121 | sk_ref_sp(this->getColorSpace()), |
| 122 | &this->props(), |
| 123 | this->alphaType()); |
robertphillips | 83c17fa | 2016-03-18 08:14:27 -0700 | [diff] [blame] | 124 | #else |
| 125 | return nullptr; |
| 126 | #endif |
| 127 | } |
| 128 | |
robertphillips | e8c3497 | 2016-02-16 12:09:36 -0800 | [diff] [blame] | 129 | void SkSpecialImage::draw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkPaint* paint) const { |
bsalomon | 84a4e5a | 2016-02-29 11:41:52 -0800 | [diff] [blame] | 130 | return as_SIB(this)->onDraw(canvas, x, y, paint); |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 131 | } |
| 132 | |
robertphillips | 6461251 | 2016-04-08 12:10:42 -0700 | [diff] [blame] | 133 | bool SkSpecialImage::getROPixels(SkBitmap* bm) const { |
| 134 | return as_SIB(this)->onGetROPixels(bm); |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 135 | } |
| 136 | |
robertphillips | 6461251 | 2016-04-08 12:10:42 -0700 | [diff] [blame] | 137 | bool SkSpecialImage::isTextureBacked() const { |
Robert Phillips | 8bc06d0 | 2016-11-01 17:28:40 -0400 | [diff] [blame] | 138 | return SkToBool(as_SIB(this)->onGetContext()); |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 139 | } |
| 140 | |
robertphillips | 6461251 | 2016-04-08 12:10:42 -0700 | [diff] [blame] | 141 | GrContext* SkSpecialImage::getContext() const { |
Robert Phillips | 8bc06d0 | 2016-11-01 17:28:40 -0400 | [diff] [blame] | 142 | return as_SIB(this)->onGetContext(); |
robertphillips | 6461251 | 2016-04-08 12:10:42 -0700 | [diff] [blame] | 143 | } |
| 144 | |
brianosman | afbf71d | 2016-07-21 07:15:37 -0700 | [diff] [blame] | 145 | SkColorSpace* SkSpecialImage::getColorSpace() const { |
| 146 | return as_SIB(this)->onGetColorSpace(); |
| 147 | } |
| 148 | |
robertphillips | c91fd34 | 2016-04-25 12:32:54 -0700 | [diff] [blame] | 149 | #if SK_SUPPORT_GPU |
Robert Phillips | 8e1c4e6 | 2017-02-19 12:27:01 -0500 | [diff] [blame] | 150 | sk_sp<GrTextureProxy> SkSpecialImage::asTextureProxyRef(GrContext* context) const { |
| 151 | return as_SIB(this)->onAsTextureProxyRef(context); |
Robert Phillips | 8bc06d0 | 2016-11-01 17:28:40 -0400 | [diff] [blame] | 152 | } |
robertphillips | c91fd34 | 2016-04-25 12:32:54 -0700 | [diff] [blame] | 153 | #endif |
robertphillips | 4418dba | 2016-03-07 12:45:14 -0800 | [diff] [blame] | 154 | |
brianosman | eed6b0e | 2016-09-23 13:04:05 -0700 | [diff] [blame] | 155 | sk_sp<SkSpecialSurface> SkSpecialImage::makeSurface(const SkImageFilter::OutputProperties& outProps, |
| 156 | const SkISize& size, SkAlphaType at) const { |
| 157 | return as_SIB(this)->onMakeSurface(outProps, size, at); |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 158 | } |
| 159 | |
brianosman | eed6b0e | 2016-09-23 13:04:05 -0700 | [diff] [blame] | 160 | sk_sp<SkSurface> SkSpecialImage::makeTightSurface(const SkImageFilter::OutputProperties& outProps, |
| 161 | const SkISize& size, SkAlphaType at) const { |
| 162 | return as_SIB(this)->onMakeTightSurface(outProps, size, at); |
robertphillips | b4bd11e | 2016-03-21 13:44:18 -0700 | [diff] [blame] | 163 | } |
| 164 | |
robertphillips | 37bd7c3 | 2016-03-17 14:31:39 -0700 | [diff] [blame] | 165 | sk_sp<SkSpecialImage> SkSpecialImage::makeSubset(const SkIRect& subset) const { |
| 166 | return as_SIB(this)->onMakeSubset(subset); |
robertphillips | c5035e7 | 2016-03-17 06:58:39 -0700 | [diff] [blame] | 167 | } |
| 168 | |
Robert Phillips | a5fdc97 | 2017-02-18 16:58:09 -0500 | [diff] [blame] | 169 | sk_sp<SkImage> SkSpecialImage::asImage(const SkIRect* subset) const { |
| 170 | return as_SIB(this)->onAsImage(subset); |
robertphillips | b4bd11e | 2016-03-21 13:44:18 -0700 | [diff] [blame] | 171 | } |
| 172 | |
Robert Phillips | a5fdc97 | 2017-02-18 16:58:09 -0500 | [diff] [blame] | 173 | |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 174 | #ifdef SK_DEBUG |
| 175 | static bool rect_fits(const SkIRect& rect, int width, int height) { |
robertphillips | 4418dba | 2016-03-07 12:45:14 -0800 | [diff] [blame] | 176 | if (0 == width && 0 == height) { |
| 177 | SkASSERT(0 == rect.fLeft && 0 == rect.fRight && 0 == rect.fTop && 0 == rect.fBottom); |
| 178 | return true; |
| 179 | } |
| 180 | |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 181 | return rect.fLeft >= 0 && rect.fLeft < width && rect.fLeft < rect.fRight && |
| 182 | rect.fRight >= 0 && rect.fRight <= width && |
| 183 | rect.fTop >= 0 && rect.fTop < height && rect.fTop < rect.fBottom && |
| 184 | rect.fBottom >= 0 && rect.fBottom <= height; |
| 185 | } |
| 186 | #endif |
| 187 | |
robertphillips | 3e30227 | 2016-04-20 11:48:36 -0700 | [diff] [blame] | 188 | sk_sp<SkSpecialImage> SkSpecialImage::MakeFromImage(const SkIRect& subset, |
brianosman | 898235c | 2016-04-06 07:38:23 -0700 | [diff] [blame] | 189 | sk_sp<SkImage> image, |
Brian Osman | 61624f0 | 2016-12-09 14:51:59 -0500 | [diff] [blame] | 190 | SkColorSpace* dstColorSpace, |
brianosman | 898235c | 2016-04-06 07:38:23 -0700 | [diff] [blame] | 191 | const SkSurfaceProps* props) { |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 192 | SkASSERT(rect_fits(subset, image->width(), image->height())); |
robertphillips | 37bd7c3 | 2016-03-17 14:31:39 -0700 | [diff] [blame] | 193 | |
reed | ad7604b | 2016-07-20 16:13:32 -0700 | [diff] [blame] | 194 | #if SK_SUPPORT_GPU |
Robert Phillips | 6de9904 | 2017-01-31 11:31:39 -0500 | [diff] [blame] | 195 | if (sk_sp<GrTextureProxy> proxy = as_IB(image)->asTextureProxyRef()) { |
| 196 | GrContext* context = ((SkImage_Gpu*) as_IB(image))->context(); |
| 197 | |
| 198 | return MakeDeferredFromGpu(context, subset, image->uniqueID(), std::move(proxy), |
Robert Phillips | 256c37b | 2017-03-01 14:32:46 -0500 | [diff] [blame] | 199 | as_IB(image)->onImageInfo().refColorSpace(), props); |
reed | ad7604b | 2016-07-20 16:13:32 -0700 | [diff] [blame] | 200 | } else |
| 201 | #endif |
| 202 | { |
| 203 | SkBitmap bm; |
Brian Osman | 61624f0 | 2016-12-09 14:51:59 -0500 | [diff] [blame] | 204 | if (as_IB(image)->getROPixels(&bm, dstColorSpace)) { |
reed | ad7604b | 2016-07-20 16:13:32 -0700 | [diff] [blame] | 205 | return MakeFromRaster(subset, bm, props); |
| 206 | } |
reed | a2217ef | 2016-07-20 06:04:34 -0700 | [diff] [blame] | 207 | } |
reed | ad7604b | 2016-07-20 16:13:32 -0700 | [diff] [blame] | 208 | return nullptr; |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 209 | } |
| 210 | |
| 211 | /////////////////////////////////////////////////////////////////////////////// |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 212 | |
| 213 | class SkSpecialImage_Raster : public SkSpecialImage_Base { |
| 214 | public: |
robertphillips | 3e30227 | 2016-04-20 11:48:36 -0700 | [diff] [blame] | 215 | SkSpecialImage_Raster(const SkIRect& subset, const SkBitmap& bm, const SkSurfaceProps* props) |
| 216 | : INHERITED(subset, bm.getGenerationID(), props) |
reed | bd2bd5c | 2016-07-25 14:26:02 -0700 | [diff] [blame] | 217 | , fBitmap(bm) |
| 218 | { |
| 219 | SkASSERT(bm.pixelRef()); |
| 220 | |
| 221 | // We have to lock now, while bm is still in scope, since it may have come from our |
| 222 | // cache, which means we need to keep it locked until we (the special) are done, since |
| 223 | // we cannot re-generate the cache entry (if bm came from a generator). |
| 224 | fBitmap.lockPixels(); |
| 225 | SkASSERT(fBitmap.getPixels()); |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 226 | } |
| 227 | |
brianosman | 80e9608 | 2016-08-16 07:09:47 -0700 | [diff] [blame] | 228 | SkAlphaType alphaType() const override { return fBitmap.alphaType(); } |
robertphillips | 3b087f4 | 2016-02-18 08:48:03 -0800 | [diff] [blame] | 229 | |
| 230 | size_t getSize() const override { return fBitmap.getSize(); } |
| 231 | |
robertphillips | e8c3497 | 2016-02-16 12:09:36 -0800 | [diff] [blame] | 232 | void onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkPaint* paint) const override { |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 233 | SkRect dst = SkRect::MakeXYWH(x, y, |
| 234 | this->subset().width(), this->subset().height()); |
| 235 | |
| 236 | canvas->drawBitmapRect(fBitmap, this->subset(), |
| 237 | dst, paint, SkCanvas::kStrict_SrcRectConstraint); |
| 238 | } |
| 239 | |
robertphillips | 6461251 | 2016-04-08 12:10:42 -0700 | [diff] [blame] | 240 | bool onGetROPixels(SkBitmap* bm) const override { |
| 241 | *bm = fBitmap; |
robertphillips | 3b087f4 | 2016-02-18 08:48:03 -0800 | [diff] [blame] | 242 | return true; |
| 243 | } |
| 244 | |
brianosman | afbf71d | 2016-07-21 07:15:37 -0700 | [diff] [blame] | 245 | SkColorSpace* onGetColorSpace() const override { |
| 246 | return fBitmap.colorSpace(); |
| 247 | } |
| 248 | |
robertphillips | 6461251 | 2016-04-08 12:10:42 -0700 | [diff] [blame] | 249 | #if SK_SUPPORT_GPU |
Robert Phillips | 8e1c4e6 | 2017-02-19 12:27:01 -0500 | [diff] [blame] | 250 | sk_sp<GrTextureProxy> onAsTextureProxyRef(GrContext* context) const override { |
Robert Phillips | 8bc06d0 | 2016-11-01 17:28:40 -0400 | [diff] [blame] | 251 | if (context) { |
Robert Phillips | 26c90e0 | 2017-03-14 14:39:29 -0400 | [diff] [blame] | 252 | return GrMakeCachedBitmapProxy(context->resourceProvider(), fBitmap); |
Robert Phillips | 8bc06d0 | 2016-11-01 17:28:40 -0400 | [diff] [blame] | 253 | } |
| 254 | |
| 255 | return nullptr; |
| 256 | } |
robertphillips | c91fd34 | 2016-04-25 12:32:54 -0700 | [diff] [blame] | 257 | #endif |
robertphillips | 6461251 | 2016-04-08 12:10:42 -0700 | [diff] [blame] | 258 | |
brianosman | eed6b0e | 2016-09-23 13:04:05 -0700 | [diff] [blame] | 259 | // TODO: The raster implementations of image filters all currently assume that the pixels are |
| 260 | // legacy N32. Until they actually check the format and operate on sRGB or F16 data appropriately, |
| 261 | // we can't enable this. (They will continue to produce incorrect results, but less-so). |
| 262 | #define RASTER_IMAGE_FILTERS_SUPPORT_SRGB_AND_F16 0 |
| 263 | |
| 264 | sk_sp<SkSpecialSurface> onMakeSurface(const SkImageFilter::OutputProperties& outProps, |
| 265 | const SkISize& size, SkAlphaType at) const override { |
| 266 | #if RASTER_IMAGE_FILTERS_SUPPORT_SRGB_AND_F16 |
| 267 | SkColorSpace* colorSpace = outProps.colorSpace(); |
| 268 | #else |
| 269 | SkColorSpace* colorSpace = nullptr; |
| 270 | #endif |
| 271 | SkColorType colorType = colorSpace && colorSpace->gammaIsLinear() |
| 272 | ? kRGBA_F16_SkColorType : kN32_SkColorType; |
| 273 | SkImageInfo info = SkImageInfo::Make(size.width(), size.height(), colorType, at, |
| 274 | sk_ref_sp(colorSpace)); |
robertphillips | 3e30227 | 2016-04-20 11:48:36 -0700 | [diff] [blame] | 275 | return SkSpecialSurface::MakeRaster(info, nullptr); |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 276 | } |
| 277 | |
robertphillips | 37bd7c3 | 2016-03-17 14:31:39 -0700 | [diff] [blame] | 278 | sk_sp<SkSpecialImage> onMakeSubset(const SkIRect& subset) const override { |
robertphillips | c5035e7 | 2016-03-17 06:58:39 -0700 | [diff] [blame] | 279 | SkBitmap subsetBM; |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 280 | |
robertphillips | c5035e7 | 2016-03-17 06:58:39 -0700 | [diff] [blame] | 281 | if (!fBitmap.extractSubset(&subsetBM, subset)) { |
| 282 | return nullptr; |
| 283 | } |
| 284 | |
robertphillips | 3e30227 | 2016-04-20 11:48:36 -0700 | [diff] [blame] | 285 | return SkSpecialImage::MakeFromRaster(SkIRect::MakeWH(subset.width(), subset.height()), |
brianosman | 898235c | 2016-04-06 07:38:23 -0700 | [diff] [blame] | 286 | subsetBM, |
| 287 | &this->props()); |
robertphillips | c5035e7 | 2016-03-17 06:58:39 -0700 | [diff] [blame] | 288 | } |
| 289 | |
Robert Phillips | a5fdc97 | 2017-02-18 16:58:09 -0500 | [diff] [blame] | 290 | sk_sp<SkImage> onAsImage(const SkIRect* subset) const override { |
| 291 | if (subset) { |
| 292 | SkBitmap subsetBM; |
robertphillips | b4bd11e | 2016-03-21 13:44:18 -0700 | [diff] [blame] | 293 | |
Robert Phillips | a5fdc97 | 2017-02-18 16:58:09 -0500 | [diff] [blame] | 294 | if (!fBitmap.extractSubset(&subsetBM, *subset)) { |
| 295 | return nullptr; |
| 296 | } |
| 297 | |
| 298 | return SkImage::MakeFromBitmap(subsetBM); |
robertphillips | b4bd11e | 2016-03-21 13:44:18 -0700 | [diff] [blame] | 299 | } |
| 300 | |
Robert Phillips | a5fdc97 | 2017-02-18 16:58:09 -0500 | [diff] [blame] | 301 | return SkImage::MakeFromBitmap(fBitmap); |
robertphillips | b4bd11e | 2016-03-21 13:44:18 -0700 | [diff] [blame] | 302 | } |
| 303 | |
brianosman | eed6b0e | 2016-09-23 13:04:05 -0700 | [diff] [blame] | 304 | sk_sp<SkSurface> onMakeTightSurface(const SkImageFilter::OutputProperties& outProps, |
| 305 | const SkISize& size, SkAlphaType at) const override { |
| 306 | #if RASTER_IMAGE_FILTERS_SUPPORT_SRGB_AND_F16 |
| 307 | SkColorSpace* colorSpace = outProps.colorSpace(); |
| 308 | #else |
| 309 | SkColorSpace* colorSpace = nullptr; |
| 310 | #endif |
| 311 | SkColorType colorType = colorSpace && colorSpace->gammaIsLinear() |
| 312 | ? kRGBA_F16_SkColorType : kN32_SkColorType; |
| 313 | SkImageInfo info = SkImageInfo::Make(size.width(), size.height(), colorType, at, |
| 314 | sk_ref_sp(colorSpace)); |
reed | e8f3062 | 2016-03-23 18:59:25 -0700 | [diff] [blame] | 315 | return SkSurface::MakeRaster(info); |
robertphillips | b4bd11e | 2016-03-21 13:44:18 -0700 | [diff] [blame] | 316 | } |
| 317 | |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 318 | private: |
| 319 | SkBitmap fBitmap; |
| 320 | |
| 321 | typedef SkSpecialImage_Base INHERITED; |
| 322 | }; |
| 323 | |
robertphillips | 3e30227 | 2016-04-20 11:48:36 -0700 | [diff] [blame] | 324 | sk_sp<SkSpecialImage> SkSpecialImage::MakeFromRaster(const SkIRect& subset, |
brianosman | 898235c | 2016-04-06 07:38:23 -0700 | [diff] [blame] | 325 | const SkBitmap& bm, |
| 326 | const SkSurfaceProps* props) { |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 327 | SkASSERT(rect_fits(subset, bm.width(), bm.height())); |
robertphillips | 37bd7c3 | 2016-03-17 14:31:39 -0700 | [diff] [blame] | 328 | |
reed | bd2bd5c | 2016-07-25 14:26:02 -0700 | [diff] [blame] | 329 | if (!bm.pixelRef()) { |
| 330 | return nullptr; |
| 331 | } |
| 332 | |
reed | a2217ef | 2016-07-20 06:04:34 -0700 | [diff] [blame] | 333 | const SkBitmap* srcBM = &bm; |
| 334 | SkBitmap tmpStorage; |
| 335 | // ImageFilters only handle N32 at the moment, so force our src to be that |
| 336 | if (!valid_for_imagefilters(bm.info())) { |
| 337 | if (!bm.copyTo(&tmpStorage, kN32_SkColorType)) { |
| 338 | return nullptr; |
| 339 | } |
| 340 | srcBM = &tmpStorage; |
| 341 | } |
| 342 | return sk_make_sp<SkSpecialImage_Raster>(subset, *srcBM, props); |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 343 | } |
| 344 | |
| 345 | #if SK_SUPPORT_GPU |
| 346 | /////////////////////////////////////////////////////////////////////////////// |
robertphillips | ed086ca | 2016-04-26 15:02:25 -0700 | [diff] [blame] | 347 | #include "GrTexture.h" |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 348 | |
Robert Phillips | 0ae6faa | 2017-03-21 16:22:00 -0400 | [diff] [blame^] | 349 | static sk_sp<SkImage> wrap_proxy_in_image(GrContext* context, sk_sp<GrTextureProxy> proxy, |
Robert Phillips | e2f7d18 | 2016-12-15 09:23:05 -0500 | [diff] [blame] | 350 | SkAlphaType alphaType, sk_sp<SkColorSpace> colorSpace) { |
Robert Phillips | 0ae6faa | 2017-03-21 16:22:00 -0400 | [diff] [blame^] | 351 | return sk_make_sp<SkImage_Gpu>(context, kNeedNewImageUniqueID, alphaType, |
| 352 | std::move(proxy), std::move(colorSpace), SkBudgeted::kYes); |
Robert Phillips | e2f7d18 | 2016-12-15 09:23:05 -0500 | [diff] [blame] | 353 | } |
| 354 | |
robertphillips | ed086ca | 2016-04-26 15:02:25 -0700 | [diff] [blame] | 355 | class SkSpecialImage_Gpu : public SkSpecialImage_Base { |
| 356 | public: |
Robert Phillips | 8bc06d0 | 2016-11-01 17:28:40 -0400 | [diff] [blame] | 357 | SkSpecialImage_Gpu(GrContext* context, const SkIRect& subset, |
Robert Phillips | 63c6746 | 2017-02-15 14:19:01 -0500 | [diff] [blame] | 358 | uint32_t uniqueID, sk_sp<GrTextureProxy> proxy, SkAlphaType at, |
Robert Phillips | 8bc06d0 | 2016-11-01 17:28:40 -0400 | [diff] [blame] | 359 | sk_sp<SkColorSpace> colorSpace, const SkSurfaceProps* props) |
| 360 | : INHERITED(subset, uniqueID, props) |
| 361 | , fContext(context) |
Robert Phillips | 63c6746 | 2017-02-15 14:19:01 -0500 | [diff] [blame] | 362 | , fTextureProxy(std::move(proxy)) |
robertphillips | ed086ca | 2016-04-26 15:02:25 -0700 | [diff] [blame] | 363 | , fAlphaType(at) |
brianosman | afbf71d | 2016-07-21 07:15:37 -0700 | [diff] [blame] | 364 | , fColorSpace(std::move(colorSpace)) |
robertphillips | ed086ca | 2016-04-26 15:02:25 -0700 | [diff] [blame] | 365 | , fAddedRasterVersionToCache(false) { |
| 366 | } |
| 367 | |
| 368 | ~SkSpecialImage_Gpu() override { |
| 369 | if (fAddedRasterVersionToCache.load()) { |
| 370 | SkNotifyBitmapGenIDIsStale(this->uniqueID()); |
| 371 | } |
| 372 | } |
| 373 | |
brianosman | 80e9608 | 2016-08-16 07:09:47 -0700 | [diff] [blame] | 374 | SkAlphaType alphaType() const override { return fAlphaType; } |
robertphillips | ed086ca | 2016-04-26 15:02:25 -0700 | [diff] [blame] | 375 | |
Robert Phillips | 63c6746 | 2017-02-15 14:19:01 -0500 | [diff] [blame] | 376 | size_t getSize() const override { return fTextureProxy->gpuMemorySize(); } |
robertphillips | ed086ca | 2016-04-26 15:02:25 -0700 | [diff] [blame] | 377 | |
| 378 | void onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkPaint* paint) const override { |
| 379 | SkRect dst = SkRect::MakeXYWH(x, y, |
| 380 | this->subset().width(), this->subset().height()); |
| 381 | |
Robert Phillips | 7f6cd90 | 2016-11-10 17:03:43 -0500 | [diff] [blame] | 382 | // TODO: In this instance we know we're going to draw a sub-portion of the backing |
| 383 | // texture into the canvas so it is okay to wrap it in an SkImage. This poses |
| 384 | // some problems for full deferral however in that when the deferred SkImage_Gpu |
| 385 | // instantiates itself it is going to have to either be okay with having a larger |
Robert Phillips | 63c6746 | 2017-02-15 14:19:01 -0500 | [diff] [blame] | 386 | // than expected backing texture (unlikely) or the 'fit' of the SurfaceProxy needs |
Robert Phillips | 7f6cd90 | 2016-11-10 17:03:43 -0500 | [diff] [blame] | 387 | // to be tightened (if it is deferred). |
Robert Phillips | 0ae6faa | 2017-03-21 16:22:00 -0400 | [diff] [blame^] | 388 | sk_sp<SkImage> img = sk_sp<SkImage>(new SkImage_Gpu(canvas->getGrContext(), |
| 389 | this->uniqueID(), fAlphaType, |
| 390 | fTextureProxy, |
| 391 | fColorSpace, SkBudgeted::kNo)); |
robertphillips | ed086ca | 2016-04-26 15:02:25 -0700 | [diff] [blame] | 392 | |
reed | 77d6f7d | 2016-07-13 12:24:48 -0700 | [diff] [blame] | 393 | canvas->drawImageRect(img, this->subset(), |
Robert Phillips | 7f6cd90 | 2016-11-10 17:03:43 -0500 | [diff] [blame] | 394 | dst, paint, SkCanvas::kStrict_SrcRectConstraint); |
robertphillips | ed086ca | 2016-04-26 15:02:25 -0700 | [diff] [blame] | 395 | } |
| 396 | |
Robert Phillips | 8bc06d0 | 2016-11-01 17:28:40 -0400 | [diff] [blame] | 397 | GrContext* onGetContext() const override { return fContext; } |
robertphillips | ed086ca | 2016-04-26 15:02:25 -0700 | [diff] [blame] | 398 | |
Robert Phillips | 8e1c4e6 | 2017-02-19 12:27:01 -0500 | [diff] [blame] | 399 | sk_sp<GrTextureProxy> onAsTextureProxyRef(GrContext*) const override { |
Robert Phillips | 63c6746 | 2017-02-15 14:19:01 -0500 | [diff] [blame] | 400 | return fTextureProxy; |
Robert Phillips | 8bc06d0 | 2016-11-01 17:28:40 -0400 | [diff] [blame] | 401 | } |
robertphillips | ed086ca | 2016-04-26 15:02:25 -0700 | [diff] [blame] | 402 | |
| 403 | bool onGetROPixels(SkBitmap* dst) const override { |
| 404 | if (SkBitmapCache::Find(this->uniqueID(), dst)) { |
| 405 | SkASSERT(dst->getGenerationID() == this->uniqueID()); |
| 406 | SkASSERT(dst->isImmutable()); |
| 407 | SkASSERT(dst->getPixels()); |
| 408 | return true; |
| 409 | } |
| 410 | |
| 411 | SkImageInfo info = SkImageInfo::MakeN32(this->width(), this->height(), |
brianosman | 80e9608 | 2016-08-16 07:09:47 -0700 | [diff] [blame] | 412 | this->alphaType(), fColorSpace); |
robertphillips | ed086ca | 2016-04-26 15:02:25 -0700 | [diff] [blame] | 413 | |
| 414 | if (!dst->tryAllocPixels(info)) { |
| 415 | return false; |
| 416 | } |
| 417 | |
Robert Phillips | 8bc06d0 | 2016-11-01 17:28:40 -0400 | [diff] [blame] | 418 | // Reading back to an SkBitmap ends deferral |
Brian Osman | 32342f0 | 2017-03-04 08:12:46 -0500 | [diff] [blame] | 419 | GrTexture* texture = fTextureProxy->instantiate(fContext->resourceProvider()); |
Robert Phillips | 63c6746 | 2017-02-15 14:19:01 -0500 | [diff] [blame] | 420 | if (!texture) { |
Robert Phillips | e60ad62 | 2016-11-17 10:22:48 -0500 | [diff] [blame] | 421 | return false; |
| 422 | } |
Robert Phillips | 8bc06d0 | 2016-11-01 17:28:40 -0400 | [diff] [blame] | 423 | |
Robert Phillips | 63c6746 | 2017-02-15 14:19:01 -0500 | [diff] [blame] | 424 | if (!texture->readPixels(0, 0, dst->width(), dst->height(), kSkia8888_GrPixelConfig, |
Robert Phillips | 8bc06d0 | 2016-11-01 17:28:40 -0400 | [diff] [blame] | 425 | dst->getPixels(), dst->rowBytes())) { |
robertphillips | ed086ca | 2016-04-26 15:02:25 -0700 | [diff] [blame] | 426 | return false; |
| 427 | } |
| 428 | |
| 429 | dst->pixelRef()->setImmutableWithID(this->uniqueID()); |
| 430 | SkBitmapCache::Add(this->uniqueID(), *dst); |
| 431 | fAddedRasterVersionToCache.store(true); |
| 432 | return true; |
| 433 | } |
| 434 | |
brianosman | afbf71d | 2016-07-21 07:15:37 -0700 | [diff] [blame] | 435 | SkColorSpace* onGetColorSpace() const override { |
| 436 | return fColorSpace.get(); |
| 437 | } |
| 438 | |
brianosman | eed6b0e | 2016-09-23 13:04:05 -0700 | [diff] [blame] | 439 | sk_sp<SkSpecialSurface> onMakeSurface(const SkImageFilter::OutputProperties& outProps, |
| 440 | const SkISize& size, SkAlphaType at) const override { |
Robert Phillips | 8bc06d0 | 2016-11-01 17:28:40 -0400 | [diff] [blame] | 441 | if (!fContext) { |
robertphillips | ed086ca | 2016-04-26 15:02:25 -0700 | [diff] [blame] | 442 | return nullptr; |
| 443 | } |
| 444 | |
brianosman | eed6b0e | 2016-09-23 13:04:05 -0700 | [diff] [blame] | 445 | SkColorSpace* colorSpace = outProps.colorSpace(); |
| 446 | return SkSpecialSurface::MakeRenderTarget( |
Robert Phillips | 8bc06d0 | 2016-11-01 17:28:40 -0400 | [diff] [blame] | 447 | fContext, size.width(), size.height(), |
brianosman | eed6b0e | 2016-09-23 13:04:05 -0700 | [diff] [blame] | 448 | GrRenderableConfigForColorSpace(colorSpace), sk_ref_sp(colorSpace)); |
robertphillips | ed086ca | 2016-04-26 15:02:25 -0700 | [diff] [blame] | 449 | } |
| 450 | |
| 451 | sk_sp<SkSpecialImage> onMakeSubset(const SkIRect& subset) const override { |
Robert Phillips | 8bc06d0 | 2016-11-01 17:28:40 -0400 | [diff] [blame] | 452 | return SkSpecialImage::MakeDeferredFromGpu(fContext, |
| 453 | subset, |
| 454 | this->uniqueID(), |
Robert Phillips | 63c6746 | 2017-02-15 14:19:01 -0500 | [diff] [blame] | 455 | fTextureProxy, |
Robert Phillips | 8bc06d0 | 2016-11-01 17:28:40 -0400 | [diff] [blame] | 456 | fColorSpace, |
| 457 | &this->props(), |
| 458 | fAlphaType); |
robertphillips | ed086ca | 2016-04-26 15:02:25 -0700 | [diff] [blame] | 459 | } |
| 460 | |
Robert Phillips | e2f7d18 | 2016-12-15 09:23:05 -0500 | [diff] [blame] | 461 | // TODO: move all the logic here into the subset-flavor GrSurfaceProxy::copy? |
Robert Phillips | a5fdc97 | 2017-02-18 16:58:09 -0500 | [diff] [blame] | 462 | sk_sp<SkImage> onAsImage(const SkIRect* subset) const override { |
| 463 | if (subset) { |
| 464 | // TODO: if this becomes a bottle neck we could base this logic on what the size |
| 465 | // will be when it is finally instantiated - but that is more fraught. |
Robert Phillips | b66b42f | 2017-03-14 08:53:02 -0400 | [diff] [blame] | 466 | if (GrResourceProvider::IsFunctionallyExact(fTextureProxy.get()) && |
Robert Phillips | a5fdc97 | 2017-02-18 16:58:09 -0500 | [diff] [blame] | 467 | 0 == subset->fLeft && 0 == subset->fTop && |
| 468 | fTextureProxy->width() == subset->width() && |
| 469 | fTextureProxy->height() == subset->height()) { |
| 470 | // The existing GrTexture is already tight so reuse it in the SkImage |
Robert Phillips | 0ae6faa | 2017-03-21 16:22:00 -0400 | [diff] [blame^] | 471 | return wrap_proxy_in_image(fContext, fTextureProxy, fAlphaType, fColorSpace); |
Robert Phillips | a5fdc97 | 2017-02-18 16:58:09 -0500 | [diff] [blame] | 472 | } |
| 473 | |
| 474 | sk_sp<GrTextureProxy> subsetProxy(GrSurfaceProxy::Copy(fContext, fTextureProxy.get(), |
| 475 | *subset, SkBudgeted::kYes)); |
Robert Phillips | 0ae6faa | 2017-03-21 16:22:00 -0400 | [diff] [blame^] | 476 | if (!subsetProxy) { |
| 477 | return nullptr; |
| 478 | } |
Robert Phillips | a5fdc97 | 2017-02-18 16:58:09 -0500 | [diff] [blame] | 479 | |
Robert Phillips | 0ae6faa | 2017-03-21 16:22:00 -0400 | [diff] [blame^] | 480 | SkASSERT(subsetProxy->priv().isExact()); |
| 481 | // MDB: this is acceptable (wrapping subsetProxy in an SkImage) bc Copy will |
| 482 | // return a kExact-backed proxy |
| 483 | return wrap_proxy_in_image(fContext, std::move(subsetProxy), fAlphaType, fColorSpace); |
robertphillips | ed086ca | 2016-04-26 15:02:25 -0700 | [diff] [blame] | 484 | } |
| 485 | |
Robert Phillips | 0ae6faa | 2017-03-21 16:22:00 -0400 | [diff] [blame^] | 486 | fTextureProxy->priv().exactify(); |
| 487 | |
| 488 | return wrap_proxy_in_image(fContext, fTextureProxy, fAlphaType, fColorSpace); |
robertphillips | ed086ca | 2016-04-26 15:02:25 -0700 | [diff] [blame] | 489 | } |
| 490 | |
brianosman | eed6b0e | 2016-09-23 13:04:05 -0700 | [diff] [blame] | 491 | sk_sp<SkSurface> onMakeTightSurface(const SkImageFilter::OutputProperties& outProps, |
| 492 | const SkISize& size, SkAlphaType at) const override { |
| 493 | SkColorSpace* colorSpace = outProps.colorSpace(); |
| 494 | SkColorType colorType = colorSpace && colorSpace->gammaIsLinear() |
| 495 | ? kRGBA_F16_SkColorType : kRGBA_8888_SkColorType; |
| 496 | SkImageInfo info = SkImageInfo::Make(size.width(), size.height(), colorType, at, |
| 497 | sk_ref_sp(colorSpace)); |
Robert Phillips | 8bc06d0 | 2016-11-01 17:28:40 -0400 | [diff] [blame] | 498 | return SkSurface::MakeRenderTarget(fContext, SkBudgeted::kYes, info); |
robertphillips | ed086ca | 2016-04-26 15:02:25 -0700 | [diff] [blame] | 499 | } |
| 500 | |
| 501 | private: |
Robert Phillips | 8bc06d0 | 2016-11-01 17:28:40 -0400 | [diff] [blame] | 502 | GrContext* fContext; |
Robert Phillips | 63c6746 | 2017-02-15 14:19:01 -0500 | [diff] [blame] | 503 | sk_sp<GrTextureProxy> fTextureProxy; |
robertphillips | ed086ca | 2016-04-26 15:02:25 -0700 | [diff] [blame] | 504 | const SkAlphaType fAlphaType; |
brianosman | afbf71d | 2016-07-21 07:15:37 -0700 | [diff] [blame] | 505 | sk_sp<SkColorSpace> fColorSpace; |
robertphillips | ed086ca | 2016-04-26 15:02:25 -0700 | [diff] [blame] | 506 | mutable SkAtomic<bool> fAddedRasterVersionToCache; |
| 507 | |
| 508 | typedef SkSpecialImage_Base INHERITED; |
| 509 | }; |
| 510 | |
Robert Phillips | 8bc06d0 | 2016-11-01 17:28:40 -0400 | [diff] [blame] | 511 | sk_sp<SkSpecialImage> SkSpecialImage::MakeDeferredFromGpu(GrContext* context, |
| 512 | const SkIRect& subset, |
| 513 | uint32_t uniqueID, |
Robert Phillips | 63c6746 | 2017-02-15 14:19:01 -0500 | [diff] [blame] | 514 | sk_sp<GrTextureProxy> proxy, |
Robert Phillips | 8bc06d0 | 2016-11-01 17:28:40 -0400 | [diff] [blame] | 515 | sk_sp<SkColorSpace> colorSpace, |
| 516 | const SkSurfaceProps* props, |
| 517 | SkAlphaType at) { |
| 518 | SkASSERT(rect_fits(subset, proxy->width(), proxy->height())); |
| 519 | return sk_make_sp<SkSpecialImage_Gpu>(context, subset, uniqueID, std::move(proxy), at, |
| 520 | std::move(colorSpace), props); |
| 521 | } |
robertphillips | b6c65e9 | 2016-02-04 10:52:42 -0800 | [diff] [blame] | 522 | #endif |