blob: 8a27836ee75675882e85418e338472079e8d7259 [file] [log] [blame]
reed@google.com5d4ba882012-07-31 15:45:27 +00001/*
2 * Copyright 2012 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 */
7
cblume33e0cb52016-08-30 12:09:23 -07008#include <cstddef>
9#include <cstring>
10#include <type_traits>
11
robertphillipsc5035e72016-03-17 06:58:39 -070012#include "SkAutoPixmapStorage.h"
Brian Osman3b66ab62016-11-28 09:26:31 -050013#include "GrBitmapTextureMaker.h"
reed856e9d92015-09-30 12:21:45 -070014#include "GrCaps.h"
robertphillips@google.com97b6b072012-10-31 14:48:39 +000015#include "GrContext.h"
Robert Phillipse2f7d182016-12-15 09:23:05 -050016#include "GrContextPriv.h"
Brian Osman3b66ab62016-11-28 09:26:31 -050017#include "GrImageTextureMaker.h"
Brian Osman11052242016-10-27 14:47:55 -040018#include "GrRenderTargetContext.h"
Brian Osmane8e54582016-11-28 10:06:27 -050019#include "GrTextureAdjuster.h"
cblume33e0cb52016-08-30 12:09:23 -070020#include "GrTexturePriv.h"
Robert Phillipsbc7a4fb2017-01-23 15:30:35 -050021#include "GrTextureProxy.h"
bsalomonf267c1e2016-02-01 13:16:14 -080022#include "effects/GrYUVEffect.h"
bsalomon993a4212015-05-29 11:37:25 -070023#include "SkCanvas.h"
reed262a71b2015-12-05 13:07:27 -080024#include "SkBitmapCache.h"
bsalomon89fe56b2015-10-29 10:49:28 -070025#include "SkGrPriv.h"
reed262a71b2015-12-05 13:07:27 -080026#include "SkImage_Gpu.h"
Brian Osman7992da32016-11-18 11:28:24 -050027#include "SkImageCacherator.h"
Matt Sarettcb6266b2017-01-17 10:48:53 -050028#include "SkImageInfoPriv.h"
ericrkb4da01d2016-06-13 11:18:14 -070029#include "SkMipMap.h"
reed6f1216a2015-08-04 08:10:13 -070030#include "SkPixelRef.h"
Matt Sarett03dd6d52017-01-23 12:15:09 -050031#include "SkReadPixelsRec.h"
bsalomon993a4212015-05-29 11:37:25 -070032
bungeman6bd52842016-10-27 09:30:08 -070033SkImage_Gpu::SkImage_Gpu(int w, int h, uint32_t uniqueID, SkAlphaType at, sk_sp<GrTexture> tex,
brianosmandddbe382016-07-20 13:55:39 -070034 sk_sp<SkColorSpace> colorSpace, SkBudgeted budgeted)
reedaf3fbfc2015-10-04 11:28:36 -070035 : INHERITED(w, h, uniqueID)
bungeman6bd52842016-10-27 09:30:08 -070036 , fTexture(std::move(tex))
reed8b26b992015-05-07 15:36:17 -070037 , fAlphaType(at)
bsalomoneaaaf0b2015-01-23 08:08:04 -080038 , fBudgeted(budgeted)
brianosmandddbe382016-07-20 13:55:39 -070039 , fColorSpace(std::move(colorSpace))
bsalomon1cd63112015-08-05 06:58:39 -070040 , fAddedRasterVersionToCache(false)
reedc9b5f8b2015-10-22 13:20:20 -070041{
bungeman6bd52842016-10-27 09:30:08 -070042 SkASSERT(fTexture->width() == w);
43 SkASSERT(fTexture->height() == h);
reedc9b5f8b2015-10-22 13:20:20 -070044}
piotaixrcef04f82014-07-14 07:48:04 -070045
reed6f1216a2015-08-04 08:10:13 -070046SkImage_Gpu::~SkImage_Gpu() {
47 if (fAddedRasterVersionToCache.load()) {
48 SkNotifyBitmapGenIDIsStale(this->uniqueID());
49 }
50}
51
bsalomoneaaaf0b2015-01-23 08:08:04 -080052extern void SkTextureImageApplyBudgetedDecision(SkImage* image) {
robertphillipsea70c4b2016-07-20 08:54:31 -070053 if (image->isTextureBacked()) {
reed8b26b992015-05-07 15:36:17 -070054 ((SkImage_Gpu*)image)->applyBudgetDecision();
55 }
56}
57
brianosman396fcdb2016-07-22 06:26:11 -070058SkImageInfo SkImage_Gpu::onImageInfo() const {
59 SkColorType ct;
60 if (!GrPixelConfigToColorType(fTexture->config(), &ct)) {
61 ct = kUnknown_SkColorType;
62 }
63 return SkImageInfo::Make(fTexture->width(), fTexture->height(), ct, fAlphaType, fColorSpace);
64}
65
brianosman69c166d2016-08-17 14:01:05 -070066static SkImageInfo make_info(int w, int h, SkAlphaType at, sk_sp<SkColorSpace> colorSpace) {
67 return SkImageInfo::MakeN32(w, h, at, std::move(colorSpace));
reed88d064d2015-10-12 11:30:02 -070068}
69
Brian Osman61624f02016-12-09 14:51:59 -050070bool SkImage_Gpu::getROPixels(SkBitmap* dst, SkColorSpace* dstColorSpace,
Brian Osman7992da32016-11-18 11:28:24 -050071 CachingHint chint) const {
reed6f1216a2015-08-04 08:10:13 -070072 if (SkBitmapCache::Find(this->uniqueID(), dst)) {
73 SkASSERT(dst->getGenerationID() == this->uniqueID());
74 SkASSERT(dst->isImmutable());
75 SkASSERT(dst->getPixels());
76 return true;
77 }
78
brianosman69c166d2016-08-17 14:01:05 -070079 if (!dst->tryAllocPixels(make_info(this->width(), this->height(), this->alphaType(),
brianosmandddbe382016-07-20 13:55:39 -070080 this->fColorSpace))) {
reed8b26b992015-05-07 15:36:17 -070081 return false;
82 }
83 if (!fTexture->readPixels(0, 0, dst->width(), dst->height(), kSkia8888_GrPixelConfig,
84 dst->getPixels(), dst->rowBytes())) {
85 return false;
86 }
reed6f1216a2015-08-04 08:10:13 -070087
88 dst->pixelRef()->setImmutableWithID(this->uniqueID());
reed09553032015-11-23 12:32:16 -080089 if (kAllow_CachingHint == chint) {
90 SkBitmapCache::Add(this->uniqueID(), *dst);
91 fAddedRasterVersionToCache.store(true);
92 }
reed8b26b992015-05-07 15:36:17 -070093 return true;
94}
95
Robert Phillips2c862492017-01-18 10:08:39 -050096sk_sp<GrSurfaceProxy> SkImage_Gpu::refProxy() const {
97 return GrSurfaceProxy::MakeWrapped(fTexture);
98}
99
Brian Salomon514baff2016-11-17 15:17:07 -0500100GrTexture* SkImage_Gpu::asTextureRef(GrContext* ctx, const GrSamplerParams& params,
Brian Osman61624f02016-12-09 14:51:59 -0500101 SkColorSpace* dstColorSpace,
Robert Phillips67c18d62017-01-20 12:44:06 -0500102 sk_sp<SkColorSpace>* texColorSpace,
103 SkScalar scaleAdjust[2]) const {
Brian Osman7992da32016-11-18 11:28:24 -0500104 if (texColorSpace) {
105 *texColorSpace = this->fColorSpace;
106 }
107 GrTextureAdjuster adjuster(this->peekTexture(), this->alphaType(), this->bounds(),
108 this->uniqueID(), this->fColorSpace.get());
Robert Phillips67c18d62017-01-20 12:44:06 -0500109 return adjuster.refTextureSafeForParams(params, nullptr, scaleAdjust);
reed85d91782015-09-10 14:33:38 -0700110}
111
reed8b26b992015-05-07 15:36:17 -0700112static void apply_premul(const SkImageInfo& info, void* pixels, size_t rowBytes) {
113 switch (info.colorType()) {
114 case kRGBA_8888_SkColorType:
115 case kBGRA_8888_SkColorType:
116 break;
117 default:
118 return; // nothing to do
119 }
120
121 // SkColor is not necesarily RGBA or BGRA, but it is one of them on little-endian,
122 // and in either case, the alpha-byte is always in the same place, so we can safely call
123 // SkPreMultiplyColor()
124 //
125 SkColor* row = (SkColor*)pixels;
126 for (int y = 0; y < info.height(); ++y) {
127 for (int x = 0; x < info.width(); ++x) {
128 row[x] = SkPreMultiplyColor(row[x]);
129 }
130 }
131}
132
Matt Sarett03dd6d52017-01-23 12:15:09 -0500133bool SkImage_Gpu::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRB,
reed09553032015-11-23 12:32:16 -0800134 int srcX, int srcY, CachingHint) const {
Matt Sarett03dd6d52017-01-23 12:15:09 -0500135 if (!SkImageInfoValidConversion(dstInfo, this->onImageInfo())) {
Matt Sarettcb6266b2017-01-17 10:48:53 -0500136 return false;
137 }
138
Matt Sarett03dd6d52017-01-23 12:15:09 -0500139 SkReadPixelsRec rec(dstInfo, dstPixels, dstRB, srcX, srcY);
140 if (!rec.trim(this->width(), this->height())) {
141 return false;
142 }
143
144 GrPixelConfig config = SkImageInfo2GrPixelConfig(rec.fInfo, *fTexture->getContext()->caps());
reed8b26b992015-05-07 15:36:17 -0700145 uint32_t flags = 0;
Matt Sarett03dd6d52017-01-23 12:15:09 -0500146 if (kUnpremul_SkAlphaType == rec.fInfo.alphaType() && kPremul_SkAlphaType == fAlphaType) {
reed8b26b992015-05-07 15:36:17 -0700147 // let the GPU perform this transformation for us
148 flags = GrContext::kUnpremul_PixelOpsFlag;
149 }
Matt Sarett03dd6d52017-01-23 12:15:09 -0500150 if (!fTexture->readPixels(fColorSpace.get(), rec.fX, rec.fY, rec.fInfo.width(),
151 rec.fInfo.height(), config, rec.fInfo.colorSpace(), rec.fPixels,
152 rec.fRowBytes, flags)) {
reed8b26b992015-05-07 15:36:17 -0700153 return false;
154 }
155 // do we have to manually fix-up the alpha channel?
156 // src dst
157 // unpremul premul fix manually
158 // premul unpremul done by kUnpremul_PixelOpsFlag
159 // all other combos need to change.
160 //
161 // Should this be handled by Ganesh? todo:?
162 //
Matt Sarett03dd6d52017-01-23 12:15:09 -0500163 if (kPremul_SkAlphaType == rec.fInfo.alphaType() && kUnpremul_SkAlphaType == fAlphaType) {
164 apply_premul(rec.fInfo, rec.fPixels, rec.fRowBytes);
reed8b26b992015-05-07 15:36:17 -0700165 }
166 return true;
167}
168
reed7fb4f8b2016-03-11 04:33:52 -0800169sk_sp<SkImage> SkImage_Gpu::onMakeSubset(const SkIRect& subset) const {
reed7b6945b2015-09-24 00:50:58 -0700170 GrContext* ctx = fTexture->getContext();
171 GrSurfaceDesc desc = fTexture->desc();
172 desc.fWidth = subset.width();
173 desc.fHeight = subset.height();
174
Robert Phillipse2f7d182016-12-15 09:23:05 -0500175 sk_sp<GrSurfaceContext> sContext(ctx->contextPriv().makeDeferredSurfaceContext(
176 desc,
177 SkBackingFit::kExact,
178 fBudgeted));
179 if (!sContext) {
180 return nullptr;
181 }
182
183 // TODO: make gpu images be proxy-backed so we don't need to do this
184 sk_sp<GrSurfaceProxy> tmpSrc(GrSurfaceProxy::MakeWrapped(fTexture));
185 if (!tmpSrc) {
186 return nullptr;
187 }
188
189 if (!sContext->copy(tmpSrc.get(), subset, SkIPoint::Make(0, 0))) {
190 return nullptr;
191 }
192
193 // TODO: make gpu images be proxy-backed so we don't need to do this
194 GrSurface* subTx = sContext->asDeferredSurface()->instantiate(ctx->textureProvider());
reed7b6945b2015-09-24 00:50:58 -0700195 if (!subTx) {
196 return nullptr;
197 }
Robert Phillipse2f7d182016-12-15 09:23:05 -0500198
reed7fb4f8b2016-03-11 04:33:52 -0800199 return sk_make_sp<SkImage_Gpu>(desc.fWidth, desc.fHeight, kNeedNewImageUniqueID,
Robert Phillipse2f7d182016-12-15 09:23:05 -0500200 fAlphaType, sk_ref_sp(subTx->asTexture()),
201 fColorSpace, fBudgeted);
reed7b6945b2015-09-24 00:50:58 -0700202}
203
reed8b26b992015-05-07 15:36:17 -0700204///////////////////////////////////////////////////////////////////////////////////////////////////
205
reed7fb4f8b2016-03-11 04:33:52 -0800206static sk_sp<SkImage> new_wrapped_texture_common(GrContext* ctx, const GrBackendTextureDesc& desc,
brianosmandddbe382016-07-20 13:55:39 -0700207 SkAlphaType at, sk_sp<SkColorSpace> colorSpace,
208 GrWrapOwnership ownership,
reed7fb4f8b2016-03-11 04:33:52 -0800209 SkImage::TextureReleaseProc releaseProc,
210 SkImage::ReleaseContext releaseCtx) {
reed8b26b992015-05-07 15:36:17 -0700211 if (desc.fWidth <= 0 || desc.fHeight <= 0) {
halcanary96fcdcc2015-08-27 07:41:13 -0700212 return nullptr;
reed8b26b992015-05-07 15:36:17 -0700213 }
bungeman6bd52842016-10-27 09:30:08 -0700214 sk_sp<GrTexture> tex = ctx->textureProvider()->wrapBackendTexture(desc, ownership);
reed8b26b992015-05-07 15:36:17 -0700215 if (!tex) {
halcanary96fcdcc2015-08-27 07:41:13 -0700216 return nullptr;
reed8b26b992015-05-07 15:36:17 -0700217 }
reedde499882015-06-18 13:41:40 -0700218 if (releaseProc) {
219 tex->setRelease(releaseProc, releaseCtx);
220 }
221
bsalomon5ec26ae2016-02-25 08:33:02 -0800222 const SkBudgeted budgeted = SkBudgeted::kNo;
reed7fb4f8b2016-03-11 04:33:52 -0800223 return sk_make_sp<SkImage_Gpu>(desc.fWidth, desc.fHeight, kNeedNewImageUniqueID,
bungeman6bd52842016-10-27 09:30:08 -0700224 at, std::move(tex), std::move(colorSpace), budgeted);
bsalomon6dc6f5f2015-06-18 09:12:16 -0700225}
226
reed7fb4f8b2016-03-11 04:33:52 -0800227sk_sp<SkImage> SkImage::MakeFromTexture(GrContext* ctx, const GrBackendTextureDesc& desc,
brianosmandddbe382016-07-20 13:55:39 -0700228 SkAlphaType at, sk_sp<SkColorSpace> cs,
229 TextureReleaseProc releaseP, ReleaseContext releaseC) {
230 return new_wrapped_texture_common(ctx, desc, at, std::move(cs), kBorrow_GrWrapOwnership,
231 releaseP, releaseC);
bsalomon6dc6f5f2015-06-18 09:12:16 -0700232}
233
reed7fb4f8b2016-03-11 04:33:52 -0800234sk_sp<SkImage> SkImage::MakeFromAdoptedTexture(GrContext* ctx, const GrBackendTextureDesc& desc,
brianosmandddbe382016-07-20 13:55:39 -0700235 SkAlphaType at, sk_sp<SkColorSpace> cs) {
236 return new_wrapped_texture_common(ctx, desc, at, std::move(cs), kAdopt_GrWrapOwnership,
237 nullptr, nullptr);
reed8b26b992015-05-07 15:36:17 -0700238}
239
jbaumanb445a572016-06-09 13:24:48 -0700240static sk_sp<SkImage> make_from_yuv_textures_copy(GrContext* ctx, SkYUVColorSpace colorSpace,
241 bool nv12,
242 const GrBackendObject yuvTextureHandles[],
243 const SkISize yuvSizes[],
brianosmandddbe382016-07-20 13:55:39 -0700244 GrSurfaceOrigin origin,
245 sk_sp<SkColorSpace> imageColorSpace) {
bsalomon5ec26ae2016-02-25 08:33:02 -0800246 const SkBudgeted budgeted = SkBudgeted::kYes;
bsalomon993a4212015-05-29 11:37:25 -0700247
jbaumanb445a572016-06-09 13:24:48 -0700248 if (yuvSizes[0].fWidth <= 0 || yuvSizes[0].fHeight <= 0 || yuvSizes[1].fWidth <= 0 ||
249 yuvSizes[1].fHeight <= 0) {
halcanary96fcdcc2015-08-27 07:41:13 -0700250 return nullptr;
bsalomon993a4212015-05-29 11:37:25 -0700251 }
jbaumanb445a572016-06-09 13:24:48 -0700252 if (!nv12 && (yuvSizes[2].fWidth <= 0 || yuvSizes[2].fHeight <= 0)) {
253 return nullptr;
254 }
255
256 const GrPixelConfig kConfig = nv12 ? kRGBA_8888_GrPixelConfig : kAlpha_8_GrPixelConfig;
257
bsalomon993a4212015-05-29 11:37:25 -0700258 GrBackendTextureDesc yDesc;
259 yDesc.fConfig = kConfig;
260 yDesc.fOrigin = origin;
261 yDesc.fSampleCnt = 0;
262 yDesc.fTextureHandle = yuvTextureHandles[0];
263 yDesc.fWidth = yuvSizes[0].fWidth;
264 yDesc.fHeight = yuvSizes[0].fHeight;
265
266 GrBackendTextureDesc uDesc;
267 uDesc.fConfig = kConfig;
268 uDesc.fOrigin = origin;
269 uDesc.fSampleCnt = 0;
270 uDesc.fTextureHandle = yuvTextureHandles[1];
271 uDesc.fWidth = yuvSizes[1].fWidth;
272 uDesc.fHeight = yuvSizes[1].fHeight;
273
Robert Phillips26caf892017-01-27 10:58:31 -0500274 sk_sp<GrSurfaceProxy> yProxy = GrSurfaceProxy::MakeWrappedBackend(ctx, yDesc);
275 sk_sp<GrSurfaceProxy> uProxy = GrSurfaceProxy::MakeWrappedBackend(ctx, uDesc);
Robert Phillipsbc7a4fb2017-01-23 15:30:35 -0500276 sk_sp<GrSurfaceProxy> vProxy;
277
jbaumanb445a572016-06-09 13:24:48 -0700278 if (nv12) {
Robert Phillipsbc7a4fb2017-01-23 15:30:35 -0500279 vProxy = uProxy;
jbaumanb445a572016-06-09 13:24:48 -0700280 } else {
281 GrBackendTextureDesc vDesc;
282 vDesc.fConfig = kConfig;
283 vDesc.fOrigin = origin;
284 vDesc.fSampleCnt = 0;
285 vDesc.fTextureHandle = yuvTextureHandles[2];
286 vDesc.fWidth = yuvSizes[2].fWidth;
287 vDesc.fHeight = yuvSizes[2].fHeight;
bsalomon993a4212015-05-29 11:37:25 -0700288
Robert Phillips26caf892017-01-27 10:58:31 -0500289 vProxy = GrSurfaceProxy::MakeWrappedBackend(ctx, vDesc);
jbaumanb445a572016-06-09 13:24:48 -0700290 }
Robert Phillipsbc7a4fb2017-01-23 15:30:35 -0500291 if (!yProxy || !uProxy || !vProxy) {
halcanary96fcdcc2015-08-27 07:41:13 -0700292 return nullptr;
bsalomon993a4212015-05-29 11:37:25 -0700293 }
294
robertphillipsd4c741e2016-04-28 09:55:15 -0700295 const int width = yuvSizes[0].fWidth;
296 const int height = yuvSizes[0].fHeight;
robertphillipsaa19a5f2016-04-28 06:21:55 -0700297
robertphillipsd4c741e2016-04-28 09:55:15 -0700298 // Needs to be a render target in order to draw to it for the yuv->rgb conversion.
Brian Osman11052242016-10-27 14:47:55 -0400299 sk_sp<GrRenderTargetContext> renderTargetContext(ctx->makeRenderTargetContext(
300 SkBackingFit::kExact,
301 width, height,
302 kRGBA_8888_GrPixelConfig,
303 std::move(imageColorSpace),
304 0,
305 origin));
306 if (!renderTargetContext) {
halcanary96fcdcc2015-08-27 07:41:13 -0700307 return nullptr;
bsalomon993a4212015-05-29 11:37:25 -0700308 }
309
310 GrPaint paint;
Mike Reed7d954ad2016-10-28 15:42:34 -0400311 paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
jbaumanb445a572016-06-09 13:24:48 -0700312 paint.addColorFragmentProcessor(
Robert Phillipsbc7a4fb2017-01-23 15:30:35 -0500313 GrYUVEffect::MakeYUVToRGB(ctx,
314 sk_ref_sp(yProxy->asTextureProxy()),
315 sk_ref_sp(uProxy->asTextureProxy()),
316 sk_ref_sp(vProxy->asTextureProxy()), yuvSizes, colorSpace, nv12));
bsalomon993a4212015-05-29 11:37:25 -0700317
robertphillipsd4c741e2016-04-28 09:55:15 -0700318 const SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height));
robertphillipsc9a37062015-09-01 08:34:28 -0700319
Brian Salomon82f44312017-01-11 13:42:54 -0500320 renderTargetContext->drawRect(GrNoClip(), std::move(paint), GrAA::kNo, SkMatrix::I(), rect);
Robert Phillipse60ad622016-11-17 10:22:48 -0500321
322 if (!renderTargetContext->accessRenderTarget()) {
323 return nullptr;
324 }
Brian Osman11052242016-10-27 14:47:55 -0400325 ctx->flushSurfaceWrites(renderTargetContext->accessRenderTarget());
robertphillipsd4c741e2016-04-28 09:55:15 -0700326 return sk_make_sp<SkImage_Gpu>(width, height, kNeedNewImageUniqueID,
Brian Osman11052242016-10-27 14:47:55 -0400327 kOpaque_SkAlphaType, renderTargetContext->asTexture(),
Robert Phillips75a475c2017-01-13 09:18:59 -0500328 renderTargetContext->refColorSpace(), budgeted);
bsalomon993a4212015-05-29 11:37:25 -0700329}
reed56179002015-07-07 06:11:19 -0700330
jbaumanb445a572016-06-09 13:24:48 -0700331sk_sp<SkImage> SkImage::MakeFromYUVTexturesCopy(GrContext* ctx, SkYUVColorSpace colorSpace,
332 const GrBackendObject yuvTextureHandles[3],
brianosmandddbe382016-07-20 13:55:39 -0700333 const SkISize yuvSizes[3], GrSurfaceOrigin origin,
334 sk_sp<SkColorSpace> imageColorSpace) {
335 return make_from_yuv_textures_copy(ctx, colorSpace, false, yuvTextureHandles, yuvSizes, origin,
336 std::move(imageColorSpace));
jbaumanb445a572016-06-09 13:24:48 -0700337}
338
339sk_sp<SkImage> SkImage::MakeFromNV12TexturesCopy(GrContext* ctx, SkYUVColorSpace colorSpace,
340 const GrBackendObject yuvTextureHandles[2],
341 const SkISize yuvSizes[2],
brianosmandddbe382016-07-20 13:55:39 -0700342 GrSurfaceOrigin origin,
343 sk_sp<SkColorSpace> imageColorSpace) {
344 return make_from_yuv_textures_copy(ctx, colorSpace, true, yuvTextureHandles, yuvSizes, origin,
345 std::move(imageColorSpace));
jbaumanb445a572016-06-09 13:24:48 -0700346}
347
bsalomon634b4302016-07-12 18:11:17 -0700348sk_sp<SkImage> SkImage::makeNonTextureImage() const {
brianosman396fcdb2016-07-22 06:26:11 -0700349 if (!this->isTextureBacked()) {
bsalomon634b4302016-07-12 18:11:17 -0700350 return sk_ref_sp(const_cast<SkImage*>(this));
351 }
brianosman396fcdb2016-07-22 06:26:11 -0700352 SkImageInfo info = as_IB(this)->onImageInfo();
bsalomon634b4302016-07-12 18:11:17 -0700353 size_t rowBytes = info.minRowBytes();
354 size_t size = info.getSafeSize(rowBytes);
355 auto data = SkData::MakeUninitialized(size);
356 if (!data) {
357 return nullptr;
358 }
359 SkPixmap pm(info, data->writable_data(), rowBytes);
360 if (!this->readPixels(pm, 0, 0, kDisallow_CachingHint)) {
361 return nullptr;
362 }
363 return MakeRasterData(info, data, rowBytes);
364}
365
Brian Osmanb92234a2017-01-25 14:13:00 +0000366sk_sp<SkImage> SkImage::MakeTextureFromPixmap(GrContext* ctx, const SkPixmap& pixmap,
367 SkBudgeted budgeted) {
368 if (!ctx) {
369 return nullptr;
370 }
371 sk_sp<GrTexture> texture(GrUploadPixmapToTexture(ctx, pixmap, budgeted));
372 if (!texture) {
373 return nullptr;
374 }
375 return sk_make_sp<SkImage_Gpu>(texture->width(), texture->height(), kNeedNewImageUniqueID,
376 pixmap.alphaType(), std::move(texture),
377 sk_ref_sp(pixmap.info().colorSpace()), budgeted);
378}
379
reed56179002015-07-07 06:11:19 -0700380///////////////////////////////////////////////////////////////////////////////////////////////////
381
bsalomon4d516a62016-07-28 13:37:31 -0700382namespace {
383struct MipMapLevelData {
384 void* fPixelData;
385 size_t fRowBytes;
bsalomon41b952c2016-03-11 06:46:33 -0800386};
387
bsalomon4d516a62016-07-28 13:37:31 -0700388struct DeferredTextureImage {
Brian Osman7b8400d2016-11-08 17:08:54 -0500389 uint32_t fContextUniqueID;
390 // Right now, the destination color mode is only considered when generating mipmaps
391 SkDestinationSurfaceColorMode fColorMode;
bsalomon4d516a62016-07-28 13:37:31 -0700392 // We don't store a SkImageInfo because it contains a ref-counted SkColorSpace.
Brian Osman7b8400d2016-11-08 17:08:54 -0500393 int fWidth;
394 int fHeight;
395 SkColorType fColorType;
396 SkAlphaType fAlphaType;
397 void* fColorSpace;
398 size_t fColorSpaceSize;
Brian Osman7b8400d2016-11-08 17:08:54 -0500399 int fMipMapLevelCount;
bsalomon4d516a62016-07-28 13:37:31 -0700400 // The fMipMapLevelData array may contain more than 1 element.
401 // It contains fMipMapLevelCount elements.
402 // That means this struct's size is not known at compile-time.
Brian Osman7b8400d2016-11-08 17:08:54 -0500403 MipMapLevelData fMipMapLevelData[1];
bsalomon4d516a62016-07-28 13:37:31 -0700404};
405} // anonymous namespace
406
cblume33e0cb52016-08-30 12:09:23 -0700407static bool should_use_mip_maps(const SkImage::DeferredTextureImageUsageParams & param) {
Eric Karla422d702016-11-30 11:09:29 -0800408 // There is a bug in the mipmap pre-generation logic in use in getDeferredTextureImageData.
409 // This can cause runaway memory leaks, so we are disabling this path until we can
410 // investigate further. crbug.com/669775
411 return false;
cblume33e0cb52016-08-30 12:09:23 -0700412}
413
414namespace {
415
416class DTIBufferFiller
417{
418public:
cblume921bc672016-09-22 05:25:26 -0700419 explicit DTIBufferFiller(char* bufferAsCharPtr)
420 : bufferAsCharPtr_(bufferAsCharPtr) {}
cblume33e0cb52016-08-30 12:09:23 -0700421
422 void fillMember(const void* source, size_t memberOffset, size_t size) {
cblume921bc672016-09-22 05:25:26 -0700423 memcpy(bufferAsCharPtr_ + memberOffset, source, size);
cblume33e0cb52016-08-30 12:09:23 -0700424 }
425
426private:
427
cblume921bc672016-09-22 05:25:26 -0700428 char* bufferAsCharPtr_;
cblume33e0cb52016-08-30 12:09:23 -0700429};
430}
431
432#define FILL_MEMBER(bufferFiller, member, source) \
433 bufferFiller.fillMember(source, \
434 offsetof(DeferredTextureImage, member), \
435 sizeof(DeferredTextureImage::member));
436
bsalomon41b952c2016-03-11 06:46:33 -0800437size_t SkImage::getDeferredTextureImageData(const GrContextThreadSafeProxy& proxy,
ericrkb4da01d2016-06-13 11:18:14 -0700438 const DeferredTextureImageUsageParams params[],
cblume33e0cb52016-08-30 12:09:23 -0700439 int paramCnt, void* buffer,
Brian Osman6c15cc72016-10-17 09:51:37 -0400440 SkColorSpace* dstColorSpace) const {
ericrkb4da01d2016-06-13 11:18:14 -0700441 // Extract relevant min/max values from the params array.
442 int lowestPreScaleMipLevel = params[0].fPreScaleMipLevel;
443 SkFilterQuality highestFilterQuality = params[0].fQuality;
cblume33e0cb52016-08-30 12:09:23 -0700444 bool useMipMaps = should_use_mip_maps(params[0]);
ericrkb4da01d2016-06-13 11:18:14 -0700445 for (int i = 1; i < paramCnt; ++i) {
446 if (lowestPreScaleMipLevel > params[i].fPreScaleMipLevel)
447 lowestPreScaleMipLevel = params[i].fPreScaleMipLevel;
448 if (highestFilterQuality < params[i].fQuality)
449 highestFilterQuality = params[i].fQuality;
cblume33e0cb52016-08-30 12:09:23 -0700450 useMipMaps |= should_use_mip_maps(params[i]);
ericrkb4da01d2016-06-13 11:18:14 -0700451 }
452
bsalomon41b952c2016-03-11 06:46:33 -0800453 const bool fillMode = SkToBool(buffer);
454 if (fillMode && !SkIsAlign8(reinterpret_cast<intptr_t>(buffer))) {
455 return 0;
456 }
457
ericrkb4da01d2016-06-13 11:18:14 -0700458 // Calculate scaling parameters.
459 bool isScaled = lowestPreScaleMipLevel != 0;
460
461 SkISize scaledSize;
462 if (isScaled) {
463 // SkMipMap::ComputeLevelSize takes an index into an SkMipMap. SkMipMaps don't contain the
464 // base level, so to get an SkMipMap index we must subtract one from the GL MipMap level.
465 scaledSize = SkMipMap::ComputeLevelSize(this->width(), this->height(),
466 lowestPreScaleMipLevel - 1);
467 } else {
468 scaledSize = SkISize::Make(this->width(), this->height());
469 }
470
471 // We never want to scale at higher than SW medium quality, as SW medium matches GPU high.
472 SkFilterQuality scaleFilterQuality = highestFilterQuality;
473 if (scaleFilterQuality > kMedium_SkFilterQuality) {
474 scaleFilterQuality = kMedium_SkFilterQuality;
475 }
476
ericrkc429baf2016-03-24 15:35:45 -0700477 const int maxTextureSize = proxy.fCaps->maxTextureSize();
ericrkb4da01d2016-06-13 11:18:14 -0700478 if (scaledSize.width() > maxTextureSize || scaledSize.height() > maxTextureSize) {
ericrkc429baf2016-03-24 15:35:45 -0700479 return 0;
480 }
481
bsalomon41b952c2016-03-11 06:46:33 -0800482 SkAutoPixmapStorage pixmap;
483 SkImageInfo info;
484 size_t pixelSize = 0;
Brian Osmanaaedae72017-01-20 13:21:56 -0500485 if (!isScaled && this->peekPixels(&pixmap) && !pixmap.ctable()) {
bsalomon41b952c2016-03-11 06:46:33 -0800486 info = pixmap.info();
487 pixelSize = SkAlign8(pixmap.getSafeSize());
bsalomon41b952c2016-03-11 06:46:33 -0800488 } else {
489 // Here we're just using presence of data to know whether there is a codec behind the image.
490 // In the future we will access the cacherator and get the exact data that we want to (e.g.
491 // yuv planes) upload.
bungemanffae30d2016-08-03 13:32:32 -0700492 sk_sp<SkData> data(this->refEncoded());
ericrkb4da01d2016-06-13 11:18:14 -0700493 if (!data && !this->peekPixels(nullptr)) {
bsalomon41b952c2016-03-11 06:46:33 -0800494 return 0;
495 }
Brian Osman7992da32016-11-18 11:28:24 -0500496 if (SkImageCacherator* cacher = as_IB(this)->peekCacherator()) {
497 // Generator backed image. Tweak info to trigger correct kind of decode.
Brian Osman7992da32016-11-18 11:28:24 -0500498 SkImageCacherator::CachedFormat cacheFormat = cacher->chooseCacheFormat(
Brian Osman61624f02016-12-09 14:51:59 -0500499 dstColorSpace, proxy.fCaps.get());
Brian Osman7992da32016-11-18 11:28:24 -0500500 info = cacher->buildCacheInfo(cacheFormat).makeWH(scaledSize.width(),
501 scaledSize.height());
Brian Osman7992da32016-11-18 11:28:24 -0500502 } else {
503 info = as_IB(this)->onImageInfo().makeWH(scaledSize.width(), scaledSize.height());
504 }
Brian Osmanaaedae72017-01-20 13:21:56 -0500505 if (kIndex_8_SkColorType == info.colorType()) {
506 // Force Index8 to be N32 instead. Index8 is unsupported in Ganesh.
507 info = info.makeColorType(kN32_SkColorType);
508 }
bsalomon41b952c2016-03-11 06:46:33 -0800509 pixelSize = SkAlign8(SkAutoPixmapStorage::AllocSize(info, nullptr));
510 if (fillMode) {
511 pixmap.alloc(info);
ericrkb4da01d2016-06-13 11:18:14 -0700512 if (isScaled) {
513 if (!this->scalePixels(pixmap, scaleFilterQuality,
514 SkImage::kDisallow_CachingHint)) {
515 return 0;
516 }
517 } else {
518 if (!this->readPixels(pixmap, 0, 0, SkImage::kDisallow_CachingHint)) {
519 return 0;
520 }
bsalomon41b952c2016-03-11 06:46:33 -0800521 }
522 SkASSERT(!pixmap.ctable());
523 }
524 }
cblume2c052802016-05-31 09:55:08 -0700525 int mipMapLevelCount = 1;
cblume33e0cb52016-08-30 12:09:23 -0700526 if (useMipMaps) {
527 // SkMipMap only deals with the mipmap levels it generates, which does
528 // not include the base level.
529 // That means it generates and holds levels 1-x instead of 0-x.
530 // So the total mipmap level count is 1 more than what
531 // SkMipMap::ComputeLevelCount returns.
532 mipMapLevelCount = SkMipMap::ComputeLevelCount(scaledSize.width(), scaledSize.height()) + 1;
533
534 // We already initialized pixelSize to the size of the base level.
535 // SkMipMap will generate the extra mipmap levels. Their sizes need to
536 // be added to the total.
537 // Index 0 here does not refer to the base mipmap level -- it is
538 // SkMipMap's first generated mipmap level (level 1).
539 for (int currentMipMapLevelIndex = mipMapLevelCount - 2; currentMipMapLevelIndex >= 0;
540 currentMipMapLevelIndex--) {
541 SkISize mipSize = SkMipMap::ComputeLevelSize(scaledSize.width(), scaledSize.height(),
542 currentMipMapLevelIndex);
brianosman32b5e702016-10-13 06:44:23 -0700543 SkImageInfo mipInfo = info.makeWH(mipSize.fWidth, mipSize.fHeight);
cblume33e0cb52016-08-30 12:09:23 -0700544 pixelSize += SkAlign8(SkAutoPixmapStorage::AllocSize(mipInfo, nullptr));
545 }
546 }
bsalomon41b952c2016-03-11 06:46:33 -0800547 size_t size = 0;
548 size_t dtiSize = SkAlign8(sizeof(DeferredTextureImage));
549 size += dtiSize;
cblume33e0cb52016-08-30 12:09:23 -0700550 size += (mipMapLevelCount - 1) * sizeof(MipMapLevelData);
551 // We subtract 1 because DeferredTextureImage already includes the base
552 // level in its size
bsalomon41b952c2016-03-11 06:46:33 -0800553 size_t pixelOffset = size;
554 size += pixelSize;
bsalomon4d516a62016-07-28 13:37:31 -0700555 size_t colorSpaceOffset = 0;
556 size_t colorSpaceSize = 0;
557 if (info.colorSpace()) {
558 colorSpaceOffset = size;
559 colorSpaceSize = info.colorSpace()->writeToMemory(nullptr);
560 size += colorSpaceSize;
561 }
bsalomon41b952c2016-03-11 06:46:33 -0800562 if (!fillMode) {
563 return size;
564 }
cblume921bc672016-09-22 05:25:26 -0700565 char* bufferAsCharPtr = reinterpret_cast<char*>(buffer);
566 char* pixelsAsCharPtr = bufferAsCharPtr + pixelOffset;
567 void* pixels = pixelsAsCharPtr;
bsalomon41b952c2016-03-11 06:46:33 -0800568
cblume921bc672016-09-22 05:25:26 -0700569 memcpy(reinterpret_cast<void*>(SkAlign8(reinterpret_cast<uintptr_t>(pixelsAsCharPtr))),
570 pixmap.addr(), pixmap.getSafeSize());
bsalomon41b952c2016-03-11 06:46:33 -0800571
Brian Osman6c15cc72016-10-17 09:51:37 -0400572 // If the context has sRGB support, and we're intending to render to a surface with an attached
573 // color space, and the image has an sRGB-like color space attached, then use our gamma (sRGB)
574 // aware mip-mapping.
Brian Osman7b8400d2016-11-08 17:08:54 -0500575 SkDestinationSurfaceColorMode colorMode = SkDestinationSurfaceColorMode::kLegacy;
Brian Osman6c15cc72016-10-17 09:51:37 -0400576 if (proxy.fCaps->srgbSupport() && SkToBool(dstColorSpace) &&
577 info.colorSpace() && info.colorSpace()->gammaCloseToSRGB()) {
Brian Osman7b8400d2016-11-08 17:08:54 -0500578 colorMode = SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware;
Brian Osman6c15cc72016-10-17 09:51:37 -0400579 }
580
bsalomon41b952c2016-03-11 06:46:33 -0800581 SkASSERT(info == pixmap.info());
582 size_t rowBytes = pixmap.rowBytes();
cblume33e0cb52016-08-30 12:09:23 -0700583 static_assert(std::is_standard_layout<DeferredTextureImage>::value,
584 "offsetof, which we use below, requires the type have standard layout");
cblume921bc672016-09-22 05:25:26 -0700585 auto dtiBufferFiller = DTIBufferFiller{bufferAsCharPtr};
Brian Osman7b8400d2016-11-08 17:08:54 -0500586 FILL_MEMBER(dtiBufferFiller, fColorMode, &colorMode);
cblume33e0cb52016-08-30 12:09:23 -0700587 FILL_MEMBER(dtiBufferFiller, fContextUniqueID, &proxy.fContextUniqueID);
588 int width = info.width();
589 FILL_MEMBER(dtiBufferFiller, fWidth, &width);
590 int height = info.height();
591 FILL_MEMBER(dtiBufferFiller, fHeight, &height);
592 SkColorType colorType = info.colorType();
593 FILL_MEMBER(dtiBufferFiller, fColorType, &colorType);
594 SkAlphaType alphaType = info.alphaType();
595 FILL_MEMBER(dtiBufferFiller, fAlphaType, &alphaType);
cblume33e0cb52016-08-30 12:09:23 -0700596 FILL_MEMBER(dtiBufferFiller, fMipMapLevelCount, &mipMapLevelCount);
cblume921bc672016-09-22 05:25:26 -0700597 memcpy(bufferAsCharPtr + offsetof(DeferredTextureImage, fMipMapLevelData[0].fPixelData),
cblume33e0cb52016-08-30 12:09:23 -0700598 &pixels, sizeof(pixels));
cblume921bc672016-09-22 05:25:26 -0700599 memcpy(bufferAsCharPtr + offsetof(DeferredTextureImage, fMipMapLevelData[0].fRowBytes),
cblume33e0cb52016-08-30 12:09:23 -0700600 &rowBytes, sizeof(rowBytes));
bsalomon4d516a62016-07-28 13:37:31 -0700601 if (colorSpaceSize) {
cblume921bc672016-09-22 05:25:26 -0700602 void* colorSpace = bufferAsCharPtr + colorSpaceOffset;
cblume33e0cb52016-08-30 12:09:23 -0700603 FILL_MEMBER(dtiBufferFiller, fColorSpace, &colorSpace);
604 FILL_MEMBER(dtiBufferFiller, fColorSpaceSize, &colorSpaceSize);
cblume921bc672016-09-22 05:25:26 -0700605 info.colorSpace()->writeToMemory(bufferAsCharPtr + colorSpaceOffset);
bsalomon4d516a62016-07-28 13:37:31 -0700606 } else {
cblume921bc672016-09-22 05:25:26 -0700607 memset(bufferAsCharPtr + offsetof(DeferredTextureImage, fColorSpace),
cblume33e0cb52016-08-30 12:09:23 -0700608 0, sizeof(DeferredTextureImage::fColorSpace));
cblume921bc672016-09-22 05:25:26 -0700609 memset(bufferAsCharPtr + offsetof(DeferredTextureImage, fColorSpaceSize),
cblume33e0cb52016-08-30 12:09:23 -0700610 0, sizeof(DeferredTextureImage::fColorSpaceSize));
611 }
612
613 // Fill in the mipmap levels if they exist
cblume921bc672016-09-22 05:25:26 -0700614 char* mipLevelPtr = pixelsAsCharPtr + SkAlign8(pixmap.getSafeSize());
cblume33e0cb52016-08-30 12:09:23 -0700615
616 if (useMipMaps) {
cblume94ddf542016-09-16 10:07:32 -0700617 static_assert(std::is_standard_layout<MipMapLevelData>::value,
618 "offsetof, which we use below, requires the type have a standard layout");
cblume33e0cb52016-08-30 12:09:23 -0700619
Brian Osman7b8400d2016-11-08 17:08:54 -0500620 std::unique_ptr<SkMipMap> mipmaps(SkMipMap::Build(pixmap, colorMode, nullptr));
cblume33e0cb52016-08-30 12:09:23 -0700621 // SkMipMap holds only the mipmap levels it generates.
622 // A programmer can use the data they provided to SkMipMap::Build as level 0.
623 // So the SkMipMap provides levels 1-x but it stores them in its own
624 // range 0-(x-1).
625 for (int generatedMipLevelIndex = 0; generatedMipLevelIndex < mipMapLevelCount - 1;
626 generatedMipLevelIndex++) {
cblume33e0cb52016-08-30 12:09:23 -0700627 SkMipMap::Level mipLevel;
628 mipmaps->getLevel(generatedMipLevelIndex, &mipLevel);
629
630 // Make sure the mipmap data is after the start of the buffer
cblume921bc672016-09-22 05:25:26 -0700631 SkASSERT(mipLevelPtr > bufferAsCharPtr);
cblume33e0cb52016-08-30 12:09:23 -0700632 // Make sure the mipmap data starts before the end of the buffer
cblume921bc672016-09-22 05:25:26 -0700633 SkASSERT(mipLevelPtr < bufferAsCharPtr + pixelOffset + pixelSize);
cblume33e0cb52016-08-30 12:09:23 -0700634 // Make sure the mipmap data ends before the end of the buffer
cblume12f75272016-09-19 06:18:03 -0700635 SkASSERT(mipLevelPtr + mipLevel.fPixmap.getSafeSize() <=
cblume921bc672016-09-22 05:25:26 -0700636 bufferAsCharPtr + pixelOffset + pixelSize);
cblume33e0cb52016-08-30 12:09:23 -0700637
638 // getSafeSize includes rowbyte padding except for the last row,
639 // right?
640
cblume921bc672016-09-22 05:25:26 -0700641 memcpy(mipLevelPtr, mipLevel.fPixmap.addr(), mipLevel.fPixmap.getSafeSize());
cblume33e0cb52016-08-30 12:09:23 -0700642
cblume921bc672016-09-22 05:25:26 -0700643 memcpy(bufferAsCharPtr + offsetof(DeferredTextureImage, fMipMapLevelData) +
644 sizeof(MipMapLevelData) * (generatedMipLevelIndex + 1) +
645 offsetof(MipMapLevelData, fPixelData), &mipLevelPtr, sizeof(void*));
cblume33e0cb52016-08-30 12:09:23 -0700646 size_t rowBytes = mipLevel.fPixmap.rowBytes();
cblume921bc672016-09-22 05:25:26 -0700647 memcpy(bufferAsCharPtr + offsetof(DeferredTextureImage, fMipMapLevelData) +
648 sizeof(MipMapLevelData) * (generatedMipLevelIndex + 1) +
649 offsetof(MipMapLevelData, fRowBytes), &rowBytes, sizeof(rowBytes));
cblume33e0cb52016-08-30 12:09:23 -0700650
651 mipLevelPtr += SkAlign8(mipLevel.fPixmap.getSafeSize());
652 }
bsalomon4d516a62016-07-28 13:37:31 -0700653 }
bsalomon41b952c2016-03-11 06:46:33 -0800654 return size;
655}
656
657sk_sp<SkImage> SkImage::MakeFromDeferredTextureImageData(GrContext* context, const void* data,
658 SkBudgeted budgeted) {
659 if (!data) {
660 return nullptr;
661 }
662 const DeferredTextureImage* dti = reinterpret_cast<const DeferredTextureImage*>(data);
663
664 if (!context || context->uniqueID() != dti->fContextUniqueID) {
665 return nullptr;
666 }
cblume33e0cb52016-08-30 12:09:23 -0700667 int mipLevelCount = dti->fMipMapLevelCount;
668 SkASSERT(mipLevelCount >= 1);
bsalomon4d516a62016-07-28 13:37:31 -0700669 sk_sp<SkColorSpace> colorSpace;
670 if (dti->fColorSpaceSize) {
671 colorSpace = SkColorSpace::Deserialize(dti->fColorSpace, dti->fColorSpaceSize);
672 }
673 SkImageInfo info = SkImageInfo::Make(dti->fWidth, dti->fHeight,
674 dti->fColorType, dti->fAlphaType, colorSpace);
Brian Osmanb92234a2017-01-25 14:13:00 +0000675 if (mipLevelCount == 1) {
676 SkPixmap pixmap;
677 pixmap.reset(info, dti->fMipMapLevelData[0].fPixelData, dti->fMipMapLevelData[0].fRowBytes);
678 return SkImage::MakeTextureFromPixmap(context, pixmap, budgeted);
679 } else {
680 std::unique_ptr<GrMipLevel[]> texels(new GrMipLevel[mipLevelCount]);
681 for (int i = 0; i < mipLevelCount; i++) {
682 texels[i].fPixels = dti->fMipMapLevelData[i].fPixelData;
683 texels[i].fRowBytes = dti->fMipMapLevelData[i].fRowBytes;
684 }
Brian Osman8ccbbb42017-01-20 14:08:04 -0500685
Brian Osmanb92234a2017-01-25 14:13:00 +0000686 return SkImage::MakeTextureFromMipMap(context, info, texels.get(),
687 mipLevelCount, SkBudgeted::kYes,
688 dti->fColorMode);
689 }
bsalomon41b952c2016-03-11 06:46:33 -0800690}
691
692///////////////////////////////////////////////////////////////////////////////////////////////////
693
cblume186d2d42016-06-03 11:17:42 -0700694sk_sp<SkImage> SkImage::MakeTextureFromMipMap(GrContext* ctx, const SkImageInfo& info,
695 const GrMipLevel* texels, int mipLevelCount,
cblume33e0cb52016-08-30 12:09:23 -0700696 SkBudgeted budgeted,
Brian Osman7b8400d2016-11-08 17:08:54 -0500697 SkDestinationSurfaceColorMode colorMode) {
cblume186d2d42016-06-03 11:17:42 -0700698 if (!ctx) {
699 return nullptr;
700 }
bungeman6bd52842016-10-27 09:30:08 -0700701 sk_sp<GrTexture> texture(GrUploadMipMapToTexture(ctx, info, texels, mipLevelCount));
cblume186d2d42016-06-03 11:17:42 -0700702 if (!texture) {
703 return nullptr;
704 }
Brian Osman7b8400d2016-11-08 17:08:54 -0500705 texture->texturePriv().setMipColorMode(colorMode);
cblume186d2d42016-06-03 11:17:42 -0700706 return sk_make_sp<SkImage_Gpu>(texture->width(), texture->height(), kNeedNewImageUniqueID,
bungeman6bd52842016-10-27 09:30:08 -0700707 info.alphaType(), std::move(texture),
708 sk_ref_sp(info.colorSpace()), budgeted);
cblume186d2d42016-06-03 11:17:42 -0700709}