blob: c75e36b9d991e20ffcd0987768999f7f02e7897b [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"
reed856e9d92015-09-30 12:21:45 -070013#include "GrCaps.h"
robertphillips@google.com97b6b072012-10-31 14:48:39 +000014#include "GrContext.h"
Brian Osman11052242016-10-27 14:47:55 -040015#include "GrRenderTargetContext.h"
bsalomonf1ecd212015-12-09 17:06:02 -080016#include "GrImageIDTextureAdjuster.h"
cblume33e0cb52016-08-30 12:09:23 -070017#include "GrTexturePriv.h"
bsalomonf267c1e2016-02-01 13:16:14 -080018#include "effects/GrYUVEffect.h"
bsalomon993a4212015-05-29 11:37:25 -070019#include "SkCanvas.h"
reed262a71b2015-12-05 13:07:27 -080020#include "SkBitmapCache.h"
bsalomon89fe56b2015-10-29 10:49:28 -070021#include "SkGrPriv.h"
reed262a71b2015-12-05 13:07:27 -080022#include "SkImage_Gpu.h"
ericrkb4da01d2016-06-13 11:18:14 -070023#include "SkMipMap.h"
reed6f1216a2015-08-04 08:10:13 -070024#include "SkPixelRef.h"
bsalomon993a4212015-05-29 11:37:25 -070025
bungeman6bd52842016-10-27 09:30:08 -070026SkImage_Gpu::SkImage_Gpu(int w, int h, uint32_t uniqueID, SkAlphaType at, sk_sp<GrTexture> tex,
brianosmandddbe382016-07-20 13:55:39 -070027 sk_sp<SkColorSpace> colorSpace, SkBudgeted budgeted)
reedaf3fbfc2015-10-04 11:28:36 -070028 : INHERITED(w, h, uniqueID)
bungeman6bd52842016-10-27 09:30:08 -070029 , fTexture(std::move(tex))
reed8b26b992015-05-07 15:36:17 -070030 , fAlphaType(at)
bsalomoneaaaf0b2015-01-23 08:08:04 -080031 , fBudgeted(budgeted)
brianosmandddbe382016-07-20 13:55:39 -070032 , fColorSpace(std::move(colorSpace))
bsalomon1cd63112015-08-05 06:58:39 -070033 , fAddedRasterVersionToCache(false)
reedc9b5f8b2015-10-22 13:20:20 -070034{
bungeman6bd52842016-10-27 09:30:08 -070035 SkASSERT(fTexture->width() == w);
36 SkASSERT(fTexture->height() == h);
reedc9b5f8b2015-10-22 13:20:20 -070037}
piotaixrcef04f82014-07-14 07:48:04 -070038
reed6f1216a2015-08-04 08:10:13 -070039SkImage_Gpu::~SkImage_Gpu() {
40 if (fAddedRasterVersionToCache.load()) {
41 SkNotifyBitmapGenIDIsStale(this->uniqueID());
42 }
43}
44
bsalomoneaaaf0b2015-01-23 08:08:04 -080045extern void SkTextureImageApplyBudgetedDecision(SkImage* image) {
robertphillipsea70c4b2016-07-20 08:54:31 -070046 if (image->isTextureBacked()) {
reed8b26b992015-05-07 15:36:17 -070047 ((SkImage_Gpu*)image)->applyBudgetDecision();
48 }
49}
50
brianosman396fcdb2016-07-22 06:26:11 -070051SkImageInfo SkImage_Gpu::onImageInfo() const {
52 SkColorType ct;
53 if (!GrPixelConfigToColorType(fTexture->config(), &ct)) {
54 ct = kUnknown_SkColorType;
55 }
56 return SkImageInfo::Make(fTexture->width(), fTexture->height(), ct, fAlphaType, fColorSpace);
57}
58
brianosman69c166d2016-08-17 14:01:05 -070059static SkImageInfo make_info(int w, int h, SkAlphaType at, sk_sp<SkColorSpace> colorSpace) {
60 return SkImageInfo::MakeN32(w, h, at, std::move(colorSpace));
reed88d064d2015-10-12 11:30:02 -070061}
62
Brian Osman57ae6cf2016-11-15 18:07:26 +000063bool SkImage_Gpu::getROPixels(SkBitmap* dst, CachingHint chint) const {
reed6f1216a2015-08-04 08:10:13 -070064 if (SkBitmapCache::Find(this->uniqueID(), dst)) {
65 SkASSERT(dst->getGenerationID() == this->uniqueID());
66 SkASSERT(dst->isImmutable());
67 SkASSERT(dst->getPixels());
68 return true;
69 }
70
brianosman69c166d2016-08-17 14:01:05 -070071 if (!dst->tryAllocPixels(make_info(this->width(), this->height(), this->alphaType(),
brianosmandddbe382016-07-20 13:55:39 -070072 this->fColorSpace))) {
reed8b26b992015-05-07 15:36:17 -070073 return false;
74 }
75 if (!fTexture->readPixels(0, 0, dst->width(), dst->height(), kSkia8888_GrPixelConfig,
76 dst->getPixels(), dst->rowBytes())) {
77 return false;
78 }
reed6f1216a2015-08-04 08:10:13 -070079
80 dst->pixelRef()->setImmutableWithID(this->uniqueID());
reed09553032015-11-23 12:32:16 -080081 if (kAllow_CachingHint == chint) {
82 SkBitmapCache::Add(this->uniqueID(), *dst);
83 fAddedRasterVersionToCache.store(true);
84 }
reed8b26b992015-05-07 15:36:17 -070085 return true;
86}
87
brianosman982eb7f2016-06-06 13:10:58 -070088GrTexture* SkImage_Gpu::asTextureRef(GrContext* ctx, const GrTextureParams& params,
Brian Osman7b8400d2016-11-08 17:08:54 -050089 SkDestinationSurfaceColorMode colorMode) const {
brianosman5814b8a2016-08-18 06:43:03 -070090 GrTextureAdjuster adjuster(this->peekTexture(), this->alphaType(), this->bounds(), this->uniqueID(),
reed2d5b7142016-08-17 11:12:33 -070091 this->onImageInfo().colorSpace());
Brian Osman7b8400d2016-11-08 17:08:54 -050092 return adjuster.refTextureSafeForParams(params, colorMode, nullptr);
reed85d91782015-09-10 14:33:38 -070093}
94
reed8b26b992015-05-07 15:36:17 -070095static void apply_premul(const SkImageInfo& info, void* pixels, size_t rowBytes) {
96 switch (info.colorType()) {
97 case kRGBA_8888_SkColorType:
98 case kBGRA_8888_SkColorType:
99 break;
100 default:
101 return; // nothing to do
102 }
103
104 // SkColor is not necesarily RGBA or BGRA, but it is one of them on little-endian,
105 // and in either case, the alpha-byte is always in the same place, so we can safely call
106 // SkPreMultiplyColor()
107 //
108 SkColor* row = (SkColor*)pixels;
109 for (int y = 0; y < info.height(); ++y) {
110 for (int x = 0; x < info.width(); ++x) {
111 row[x] = SkPreMultiplyColor(row[x]);
112 }
113 }
114}
115
116bool SkImage_Gpu::onReadPixels(const SkImageInfo& info, void* pixels, size_t rowBytes,
reed09553032015-11-23 12:32:16 -0800117 int srcX, int srcY, CachingHint) const {
brianosmanb109b8c2016-06-16 13:03:24 -0700118 GrPixelConfig config = SkImageInfo2GrPixelConfig(info, *fTexture->getContext()->caps());
reed8b26b992015-05-07 15:36:17 -0700119 uint32_t flags = 0;
120 if (kUnpremul_SkAlphaType == info.alphaType() && kPremul_SkAlphaType == fAlphaType) {
121 // let the GPU perform this transformation for us
122 flags = GrContext::kUnpremul_PixelOpsFlag;
123 }
124 if (!fTexture->readPixels(srcX, srcY, info.width(), info.height(), config,
125 pixels, rowBytes, flags)) {
126 return false;
127 }
128 // do we have to manually fix-up the alpha channel?
129 // src dst
130 // unpremul premul fix manually
131 // premul unpremul done by kUnpremul_PixelOpsFlag
132 // all other combos need to change.
133 //
134 // Should this be handled by Ganesh? todo:?
135 //
136 if (kPremul_SkAlphaType == info.alphaType() && kUnpremul_SkAlphaType == fAlphaType) {
137 apply_premul(info, pixels, rowBytes);
138 }
139 return true;
140}
141
reed7fb4f8b2016-03-11 04:33:52 -0800142sk_sp<SkImage> SkImage_Gpu::onMakeSubset(const SkIRect& subset) const {
reed7b6945b2015-09-24 00:50:58 -0700143 GrContext* ctx = fTexture->getContext();
144 GrSurfaceDesc desc = fTexture->desc();
145 desc.fWidth = subset.width();
146 desc.fHeight = subset.height();
147
senorblanco87751122016-05-20 07:27:38 -0700148 sk_sp<GrTexture> subTx(ctx->textureProvider()->createTexture(desc, fBudgeted));
reed7b6945b2015-09-24 00:50:58 -0700149 if (!subTx) {
150 return nullptr;
151 }
bungeman6bd52842016-10-27 09:30:08 -0700152 ctx->copySurface(subTx.get(), fTexture.get(), subset, SkIPoint::Make(0, 0));
reed7fb4f8b2016-03-11 04:33:52 -0800153 return sk_make_sp<SkImage_Gpu>(desc.fWidth, desc.fHeight, kNeedNewImageUniqueID,
bungeman6bd52842016-10-27 09:30:08 -0700154 fAlphaType, std::move(subTx), fColorSpace, fBudgeted);
reed7b6945b2015-09-24 00:50:58 -0700155}
156
reed8b26b992015-05-07 15:36:17 -0700157///////////////////////////////////////////////////////////////////////////////////////////////////
158
reed7fb4f8b2016-03-11 04:33:52 -0800159static sk_sp<SkImage> new_wrapped_texture_common(GrContext* ctx, const GrBackendTextureDesc& desc,
brianosmandddbe382016-07-20 13:55:39 -0700160 SkAlphaType at, sk_sp<SkColorSpace> colorSpace,
161 GrWrapOwnership ownership,
reed7fb4f8b2016-03-11 04:33:52 -0800162 SkImage::TextureReleaseProc releaseProc,
163 SkImage::ReleaseContext releaseCtx) {
reed8b26b992015-05-07 15:36:17 -0700164 if (desc.fWidth <= 0 || desc.fHeight <= 0) {
halcanary96fcdcc2015-08-27 07:41:13 -0700165 return nullptr;
reed8b26b992015-05-07 15:36:17 -0700166 }
bungeman6bd52842016-10-27 09:30:08 -0700167 sk_sp<GrTexture> tex = ctx->textureProvider()->wrapBackendTexture(desc, ownership);
reed8b26b992015-05-07 15:36:17 -0700168 if (!tex) {
halcanary96fcdcc2015-08-27 07:41:13 -0700169 return nullptr;
reed8b26b992015-05-07 15:36:17 -0700170 }
reedde499882015-06-18 13:41:40 -0700171 if (releaseProc) {
172 tex->setRelease(releaseProc, releaseCtx);
173 }
174
bsalomon5ec26ae2016-02-25 08:33:02 -0800175 const SkBudgeted budgeted = SkBudgeted::kNo;
reed7fb4f8b2016-03-11 04:33:52 -0800176 return sk_make_sp<SkImage_Gpu>(desc.fWidth, desc.fHeight, kNeedNewImageUniqueID,
bungeman6bd52842016-10-27 09:30:08 -0700177 at, std::move(tex), std::move(colorSpace), budgeted);
bsalomon6dc6f5f2015-06-18 09:12:16 -0700178}
179
reed7fb4f8b2016-03-11 04:33:52 -0800180sk_sp<SkImage> SkImage::MakeFromTexture(GrContext* ctx, const GrBackendTextureDesc& desc,
brianosmandddbe382016-07-20 13:55:39 -0700181 SkAlphaType at, sk_sp<SkColorSpace> cs,
182 TextureReleaseProc releaseP, ReleaseContext releaseC) {
183 return new_wrapped_texture_common(ctx, desc, at, std::move(cs), kBorrow_GrWrapOwnership,
184 releaseP, releaseC);
bsalomon6dc6f5f2015-06-18 09:12:16 -0700185}
186
reed7fb4f8b2016-03-11 04:33:52 -0800187sk_sp<SkImage> SkImage::MakeFromAdoptedTexture(GrContext* ctx, const GrBackendTextureDesc& desc,
brianosmandddbe382016-07-20 13:55:39 -0700188 SkAlphaType at, sk_sp<SkColorSpace> cs) {
189 return new_wrapped_texture_common(ctx, desc, at, std::move(cs), kAdopt_GrWrapOwnership,
190 nullptr, nullptr);
reed8b26b992015-05-07 15:36:17 -0700191}
192
jbaumanb445a572016-06-09 13:24:48 -0700193static sk_sp<SkImage> make_from_yuv_textures_copy(GrContext* ctx, SkYUVColorSpace colorSpace,
194 bool nv12,
195 const GrBackendObject yuvTextureHandles[],
196 const SkISize yuvSizes[],
brianosmandddbe382016-07-20 13:55:39 -0700197 GrSurfaceOrigin origin,
198 sk_sp<SkColorSpace> imageColorSpace) {
bsalomon5ec26ae2016-02-25 08:33:02 -0800199 const SkBudgeted budgeted = SkBudgeted::kYes;
bsalomon993a4212015-05-29 11:37:25 -0700200
jbaumanb445a572016-06-09 13:24:48 -0700201 if (yuvSizes[0].fWidth <= 0 || yuvSizes[0].fHeight <= 0 || yuvSizes[1].fWidth <= 0 ||
202 yuvSizes[1].fHeight <= 0) {
halcanary96fcdcc2015-08-27 07:41:13 -0700203 return nullptr;
bsalomon993a4212015-05-29 11:37:25 -0700204 }
jbaumanb445a572016-06-09 13:24:48 -0700205 if (!nv12 && (yuvSizes[2].fWidth <= 0 || yuvSizes[2].fHeight <= 0)) {
206 return nullptr;
207 }
208
209 const GrPixelConfig kConfig = nv12 ? kRGBA_8888_GrPixelConfig : kAlpha_8_GrPixelConfig;
210
bsalomon993a4212015-05-29 11:37:25 -0700211 GrBackendTextureDesc yDesc;
212 yDesc.fConfig = kConfig;
213 yDesc.fOrigin = origin;
214 yDesc.fSampleCnt = 0;
215 yDesc.fTextureHandle = yuvTextureHandles[0];
216 yDesc.fWidth = yuvSizes[0].fWidth;
217 yDesc.fHeight = yuvSizes[0].fHeight;
218
219 GrBackendTextureDesc uDesc;
220 uDesc.fConfig = kConfig;
221 uDesc.fOrigin = origin;
222 uDesc.fSampleCnt = 0;
223 uDesc.fTextureHandle = yuvTextureHandles[1];
224 uDesc.fWidth = yuvSizes[1].fWidth;
225 uDesc.fHeight = yuvSizes[1].fHeight;
226
jbaumanb445a572016-06-09 13:24:48 -0700227 sk_sp<GrTexture> yTex(
228 ctx->textureProvider()->wrapBackendTexture(yDesc, kBorrow_GrWrapOwnership));
229 sk_sp<GrTexture> uTex(
230 ctx->textureProvider()->wrapBackendTexture(uDesc, kBorrow_GrWrapOwnership));
231 sk_sp<GrTexture> vTex;
232 if (nv12) {
233 vTex = uTex;
234 } else {
235 GrBackendTextureDesc vDesc;
236 vDesc.fConfig = kConfig;
237 vDesc.fOrigin = origin;
238 vDesc.fSampleCnt = 0;
239 vDesc.fTextureHandle = yuvTextureHandles[2];
240 vDesc.fWidth = yuvSizes[2].fWidth;
241 vDesc.fHeight = yuvSizes[2].fHeight;
bsalomon993a4212015-05-29 11:37:25 -0700242
jbaumanb445a572016-06-09 13:24:48 -0700243 vTex = sk_sp<GrTexture>(
244 ctx->textureProvider()->wrapBackendTexture(vDesc, kBorrow_GrWrapOwnership));
245 }
bsalomon993a4212015-05-29 11:37:25 -0700246 if (!yTex || !uTex || !vTex) {
halcanary96fcdcc2015-08-27 07:41:13 -0700247 return nullptr;
bsalomon993a4212015-05-29 11:37:25 -0700248 }
249
robertphillipsd4c741e2016-04-28 09:55:15 -0700250 const int width = yuvSizes[0].fWidth;
251 const int height = yuvSizes[0].fHeight;
robertphillipsaa19a5f2016-04-28 06:21:55 -0700252
robertphillipsd4c741e2016-04-28 09:55:15 -0700253 // Needs to be a render target in order to draw to it for the yuv->rgb conversion.
Brian Osman11052242016-10-27 14:47:55 -0400254 sk_sp<GrRenderTargetContext> renderTargetContext(ctx->makeRenderTargetContext(
255 SkBackingFit::kExact,
256 width, height,
257 kRGBA_8888_GrPixelConfig,
258 std::move(imageColorSpace),
259 0,
260 origin));
261 if (!renderTargetContext) {
halcanary96fcdcc2015-08-27 07:41:13 -0700262 return nullptr;
bsalomon993a4212015-05-29 11:37:25 -0700263 }
264
265 GrPaint paint;
Mike Reed7d954ad2016-10-28 15:42:34 -0400266 paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
jbaumanb445a572016-06-09 13:24:48 -0700267 paint.addColorFragmentProcessor(
268 GrYUVEffect::MakeYUVToRGB(yTex.get(), uTex.get(), vTex.get(), yuvSizes, colorSpace, nv12));
bsalomon993a4212015-05-29 11:37:25 -0700269
robertphillipsd4c741e2016-04-28 09:55:15 -0700270 const SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height));
robertphillipsc9a37062015-09-01 08:34:28 -0700271
Brian Osman11052242016-10-27 14:47:55 -0400272 renderTargetContext->drawRect(GrNoClip(), paint, SkMatrix::I(), rect);
Robert Phillipse60ad622016-11-17 10:22:48 -0500273
274 if (!renderTargetContext->accessRenderTarget()) {
275 return nullptr;
276 }
Brian Osman11052242016-10-27 14:47:55 -0400277 ctx->flushSurfaceWrites(renderTargetContext->accessRenderTarget());
robertphillipsd4c741e2016-04-28 09:55:15 -0700278 return sk_make_sp<SkImage_Gpu>(width, height, kNeedNewImageUniqueID,
Brian Osman11052242016-10-27 14:47:55 -0400279 kOpaque_SkAlphaType, renderTargetContext->asTexture(),
280 sk_ref_sp(renderTargetContext->getColorSpace()), budgeted);
bsalomon993a4212015-05-29 11:37:25 -0700281}
reed56179002015-07-07 06:11:19 -0700282
jbaumanb445a572016-06-09 13:24:48 -0700283sk_sp<SkImage> SkImage::MakeFromYUVTexturesCopy(GrContext* ctx, SkYUVColorSpace colorSpace,
284 const GrBackendObject yuvTextureHandles[3],
brianosmandddbe382016-07-20 13:55:39 -0700285 const SkISize yuvSizes[3], GrSurfaceOrigin origin,
286 sk_sp<SkColorSpace> imageColorSpace) {
287 return make_from_yuv_textures_copy(ctx, colorSpace, false, yuvTextureHandles, yuvSizes, origin,
288 std::move(imageColorSpace));
jbaumanb445a572016-06-09 13:24:48 -0700289}
290
291sk_sp<SkImage> SkImage::MakeFromNV12TexturesCopy(GrContext* ctx, SkYUVColorSpace colorSpace,
292 const GrBackendObject yuvTextureHandles[2],
293 const SkISize yuvSizes[2],
brianosmandddbe382016-07-20 13:55:39 -0700294 GrSurfaceOrigin origin,
295 sk_sp<SkColorSpace> imageColorSpace) {
296 return make_from_yuv_textures_copy(ctx, colorSpace, true, yuvTextureHandles, yuvSizes, origin,
297 std::move(imageColorSpace));
jbaumanb445a572016-06-09 13:24:48 -0700298}
299
reed7fb4f8b2016-03-11 04:33:52 -0800300static sk_sp<SkImage> create_image_from_maker(GrTextureMaker* maker, SkAlphaType at, uint32_t id) {
Brian Osman7b8400d2016-11-08 17:08:54 -0500301 sk_sp<GrTexture> texture(
302 maker->refTextureForParams(GrTextureParams::ClampNoFilter(),
303 SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware));
bsalomon8e74f802016-01-30 10:01:40 -0800304 if (!texture) {
305 return nullptr;
306 }
bungeman6bd52842016-10-27 09:30:08 -0700307 return sk_make_sp<SkImage_Gpu>(texture->width(), texture->height(), id, at, std::move(texture),
brianosmandddbe382016-07-20 13:55:39 -0700308 sk_ref_sp(maker->getColorSpace()), SkBudgeted::kNo);
bsalomon8e74f802016-01-30 10:01:40 -0800309}
310
reed7fb4f8b2016-03-11 04:33:52 -0800311sk_sp<SkImage> SkImage::makeTextureImage(GrContext *context) const {
bsalomon8e74f802016-01-30 10:01:40 -0800312 if (!context) {
313 return nullptr;
314 }
315 if (GrTexture* peek = as_IB(this)->peekTexture()) {
reed7fb4f8b2016-03-11 04:33:52 -0800316 return peek->getContext() == context ? sk_ref_sp(const_cast<SkImage*>(this)) : nullptr;
bsalomon8e74f802016-01-30 10:01:40 -0800317 }
bsalomon8e74f802016-01-30 10:01:40 -0800318
319 if (SkImageCacherator* cacher = as_IB(this)->peekCacherator()) {
320 GrImageTextureMaker maker(context, cacher, this, kDisallow_CachingHint);
brianosman69c166d2016-08-17 14:01:05 -0700321 return create_image_from_maker(&maker, this->alphaType(), this->uniqueID());
bsalomon8e74f802016-01-30 10:01:40 -0800322 }
reed9a5a2012016-08-08 09:00:29 -0700323
324 if (const SkBitmap* bmp = as_IB(this)->onPeekBitmap()) {
325 GrBitmapTextureMaker maker(context, *bmp);
brianosman69c166d2016-08-17 14:01:05 -0700326 return create_image_from_maker(&maker, this->alphaType(), this->uniqueID());
bsalomon8e74f802016-01-30 10:01:40 -0800327 }
reed9a5a2012016-08-08 09:00:29 -0700328 return nullptr;
bsalomon8e74f802016-01-30 10:01:40 -0800329}
330
bsalomon634b4302016-07-12 18:11:17 -0700331sk_sp<SkImage> SkImage::makeNonTextureImage() const {
brianosman396fcdb2016-07-22 06:26:11 -0700332 if (!this->isTextureBacked()) {
bsalomon634b4302016-07-12 18:11:17 -0700333 return sk_ref_sp(const_cast<SkImage*>(this));
334 }
brianosman396fcdb2016-07-22 06:26:11 -0700335 SkImageInfo info = as_IB(this)->onImageInfo();
bsalomon634b4302016-07-12 18:11:17 -0700336 size_t rowBytes = info.minRowBytes();
337 size_t size = info.getSafeSize(rowBytes);
338 auto data = SkData::MakeUninitialized(size);
339 if (!data) {
340 return nullptr;
341 }
342 SkPixmap pm(info, data->writable_data(), rowBytes);
343 if (!this->readPixels(pm, 0, 0, kDisallow_CachingHint)) {
344 return nullptr;
345 }
346 return MakeRasterData(info, data, rowBytes);
347}
348
reed7fb4f8b2016-03-11 04:33:52 -0800349sk_sp<SkImage> SkImage::MakeTextureFromPixmap(GrContext* ctx, const SkPixmap& pixmap,
350 SkBudgeted budgeted) {
bsalomon0d996862016-03-09 18:44:43 -0800351 if (!ctx) {
352 return nullptr;
353 }
bungeman6bd52842016-10-27 09:30:08 -0700354 sk_sp<GrTexture> texture(GrUploadPixmapToTexture(ctx, pixmap, budgeted));
bsalomon0d996862016-03-09 18:44:43 -0800355 if (!texture) {
356 return nullptr;
357 }
reed7fb4f8b2016-03-11 04:33:52 -0800358 return sk_make_sp<SkImage_Gpu>(texture->width(), texture->height(), kNeedNewImageUniqueID,
bungeman6bd52842016-10-27 09:30:08 -0700359 pixmap.alphaType(), std::move(texture),
brianosmandddbe382016-07-20 13:55:39 -0700360 sk_ref_sp(pixmap.info().colorSpace()), budgeted);
bsalomon0d996862016-03-09 18:44:43 -0800361}
362
reed56179002015-07-07 06:11:19 -0700363///////////////////////////////////////////////////////////////////////////////////////////////////
364
bsalomon4d516a62016-07-28 13:37:31 -0700365namespace {
366struct MipMapLevelData {
367 void* fPixelData;
368 size_t fRowBytes;
bsalomon41b952c2016-03-11 06:46:33 -0800369};
370
bsalomon4d516a62016-07-28 13:37:31 -0700371struct DeferredTextureImage {
Brian Osman7b8400d2016-11-08 17:08:54 -0500372 uint32_t fContextUniqueID;
373 // Right now, the destination color mode is only considered when generating mipmaps
374 SkDestinationSurfaceColorMode fColorMode;
bsalomon4d516a62016-07-28 13:37:31 -0700375 // We don't store a SkImageInfo because it contains a ref-counted SkColorSpace.
Brian Osman7b8400d2016-11-08 17:08:54 -0500376 int fWidth;
377 int fHeight;
378 SkColorType fColorType;
379 SkAlphaType fAlphaType;
380 void* fColorSpace;
381 size_t fColorSpaceSize;
382 int fColorTableCnt;
383 uint32_t* fColorTableData;
384 int fMipMapLevelCount;
bsalomon4d516a62016-07-28 13:37:31 -0700385 // The fMipMapLevelData array may contain more than 1 element.
386 // It contains fMipMapLevelCount elements.
387 // That means this struct's size is not known at compile-time.
Brian Osman7b8400d2016-11-08 17:08:54 -0500388 MipMapLevelData fMipMapLevelData[1];
bsalomon4d516a62016-07-28 13:37:31 -0700389};
390} // anonymous namespace
391
cblume33e0cb52016-08-30 12:09:23 -0700392static bool should_use_mip_maps(const SkImage::DeferredTextureImageUsageParams & param) {
393 bool shouldUseMipMaps = false;
394
395 // Use mipmaps if either
396 // 1.) it is a perspective matrix, or
397 // 2.) the quality is med/high and the scale is < 1
398 if (param.fMatrix.hasPerspective()) {
399 shouldUseMipMaps = true;
400 }
401 if (param.fQuality == kMedium_SkFilterQuality ||
402 param.fQuality == kHigh_SkFilterQuality) {
403 SkScalar minAxisScale = param.fMatrix.getMinScale();
404 if (minAxisScale != -1.f && minAxisScale < 1.f) {
405 shouldUseMipMaps = true;
406 }
407 }
408
409
410 return shouldUseMipMaps;
411}
412
413namespace {
414
415class DTIBufferFiller
416{
417public:
cblume921bc672016-09-22 05:25:26 -0700418 explicit DTIBufferFiller(char* bufferAsCharPtr)
419 : bufferAsCharPtr_(bufferAsCharPtr) {}
cblume33e0cb52016-08-30 12:09:23 -0700420
421 void fillMember(const void* source, size_t memberOffset, size_t size) {
cblume921bc672016-09-22 05:25:26 -0700422 memcpy(bufferAsCharPtr_ + memberOffset, source, size);
cblume33e0cb52016-08-30 12:09:23 -0700423 }
424
425private:
426
cblume921bc672016-09-22 05:25:26 -0700427 char* bufferAsCharPtr_;
cblume33e0cb52016-08-30 12:09:23 -0700428};
429}
430
431#define FILL_MEMBER(bufferFiller, member, source) \
432 bufferFiller.fillMember(source, \
433 offsetof(DeferredTextureImage, member), \
434 sizeof(DeferredTextureImage::member));
435
bsalomon41b952c2016-03-11 06:46:33 -0800436size_t SkImage::getDeferredTextureImageData(const GrContextThreadSafeProxy& proxy,
ericrkb4da01d2016-06-13 11:18:14 -0700437 const DeferredTextureImageUsageParams params[],
cblume33e0cb52016-08-30 12:09:23 -0700438 int paramCnt, void* buffer,
Brian Osman6c15cc72016-10-17 09:51:37 -0400439 SkColorSpace* dstColorSpace) const {
ericrkb4da01d2016-06-13 11:18:14 -0700440 // Extract relevant min/max values from the params array.
441 int lowestPreScaleMipLevel = params[0].fPreScaleMipLevel;
442 SkFilterQuality highestFilterQuality = params[0].fQuality;
cblume33e0cb52016-08-30 12:09:23 -0700443 bool useMipMaps = should_use_mip_maps(params[0]);
ericrkb4da01d2016-06-13 11:18:14 -0700444 for (int i = 1; i < paramCnt; ++i) {
445 if (lowestPreScaleMipLevel > params[i].fPreScaleMipLevel)
446 lowestPreScaleMipLevel = params[i].fPreScaleMipLevel;
447 if (highestFilterQuality < params[i].fQuality)
448 highestFilterQuality = params[i].fQuality;
cblume33e0cb52016-08-30 12:09:23 -0700449 useMipMaps |= should_use_mip_maps(params[i]);
ericrkb4da01d2016-06-13 11:18:14 -0700450 }
451
bsalomon41b952c2016-03-11 06:46:33 -0800452 const bool fillMode = SkToBool(buffer);
453 if (fillMode && !SkIsAlign8(reinterpret_cast<intptr_t>(buffer))) {
454 return 0;
455 }
456
ericrkb4da01d2016-06-13 11:18:14 -0700457 // Calculate scaling parameters.
458 bool isScaled = lowestPreScaleMipLevel != 0;
459
460 SkISize scaledSize;
461 if (isScaled) {
462 // SkMipMap::ComputeLevelSize takes an index into an SkMipMap. SkMipMaps don't contain the
463 // base level, so to get an SkMipMap index we must subtract one from the GL MipMap level.
464 scaledSize = SkMipMap::ComputeLevelSize(this->width(), this->height(),
465 lowestPreScaleMipLevel - 1);
466 } else {
467 scaledSize = SkISize::Make(this->width(), this->height());
468 }
469
470 // We never want to scale at higher than SW medium quality, as SW medium matches GPU high.
471 SkFilterQuality scaleFilterQuality = highestFilterQuality;
472 if (scaleFilterQuality > kMedium_SkFilterQuality) {
473 scaleFilterQuality = kMedium_SkFilterQuality;
474 }
475
ericrkc429baf2016-03-24 15:35:45 -0700476 const int maxTextureSize = proxy.fCaps->maxTextureSize();
ericrkb4da01d2016-06-13 11:18:14 -0700477 if (scaledSize.width() > maxTextureSize || scaledSize.height() > maxTextureSize) {
ericrkc429baf2016-03-24 15:35:45 -0700478 return 0;
479 }
480
bsalomon41b952c2016-03-11 06:46:33 -0800481 SkAutoPixmapStorage pixmap;
482 SkImageInfo info;
483 size_t pixelSize = 0;
484 size_t ctSize = 0;
485 int ctCount = 0;
ericrkb4da01d2016-06-13 11:18:14 -0700486 if (!isScaled && this->peekPixels(&pixmap)) {
bsalomon41b952c2016-03-11 06:46:33 -0800487 info = pixmap.info();
488 pixelSize = SkAlign8(pixmap.getSafeSize());
489 if (pixmap.ctable()) {
490 ctCount = pixmap.ctable()->count();
491 ctSize = SkAlign8(pixmap.ctable()->count() * 4);
492 }
493 } else {
494 // Here we're just using presence of data to know whether there is a codec behind the image.
495 // In the future we will access the cacherator and get the exact data that we want to (e.g.
496 // yuv planes) upload.
bungemanffae30d2016-08-03 13:32:32 -0700497 sk_sp<SkData> data(this->refEncoded());
ericrkb4da01d2016-06-13 11:18:14 -0700498 if (!data && !this->peekPixels(nullptr)) {
bsalomon41b952c2016-03-11 06:46:33 -0800499 return 0;
500 }
Brian Osman57ae6cf2016-11-15 18:07:26 +0000501 info = as_IB(this)->onImageInfo().makeWH(scaledSize.width(), scaledSize.height());
bsalomon41b952c2016-03-11 06:46:33 -0800502 pixelSize = SkAlign8(SkAutoPixmapStorage::AllocSize(info, nullptr));
503 if (fillMode) {
504 pixmap.alloc(info);
ericrkb4da01d2016-06-13 11:18:14 -0700505 if (isScaled) {
506 if (!this->scalePixels(pixmap, scaleFilterQuality,
507 SkImage::kDisallow_CachingHint)) {
508 return 0;
509 }
510 } else {
511 if (!this->readPixels(pixmap, 0, 0, SkImage::kDisallow_CachingHint)) {
512 return 0;
513 }
bsalomon41b952c2016-03-11 06:46:33 -0800514 }
515 SkASSERT(!pixmap.ctable());
516 }
517 }
cblume2c052802016-05-31 09:55:08 -0700518 int mipMapLevelCount = 1;
cblume33e0cb52016-08-30 12:09:23 -0700519 if (useMipMaps) {
520 // SkMipMap only deals with the mipmap levels it generates, which does
521 // not include the base level.
522 // That means it generates and holds levels 1-x instead of 0-x.
523 // So the total mipmap level count is 1 more than what
524 // SkMipMap::ComputeLevelCount returns.
525 mipMapLevelCount = SkMipMap::ComputeLevelCount(scaledSize.width(), scaledSize.height()) + 1;
526
527 // We already initialized pixelSize to the size of the base level.
528 // SkMipMap will generate the extra mipmap levels. Their sizes need to
529 // be added to the total.
530 // Index 0 here does not refer to the base mipmap level -- it is
531 // SkMipMap's first generated mipmap level (level 1).
532 for (int currentMipMapLevelIndex = mipMapLevelCount - 2; currentMipMapLevelIndex >= 0;
533 currentMipMapLevelIndex--) {
534 SkISize mipSize = SkMipMap::ComputeLevelSize(scaledSize.width(), scaledSize.height(),
535 currentMipMapLevelIndex);
brianosman32b5e702016-10-13 06:44:23 -0700536 SkImageInfo mipInfo = info.makeWH(mipSize.fWidth, mipSize.fHeight);
cblume33e0cb52016-08-30 12:09:23 -0700537 pixelSize += SkAlign8(SkAutoPixmapStorage::AllocSize(mipInfo, nullptr));
538 }
539 }
bsalomon41b952c2016-03-11 06:46:33 -0800540 size_t size = 0;
541 size_t dtiSize = SkAlign8(sizeof(DeferredTextureImage));
542 size += dtiSize;
cblume33e0cb52016-08-30 12:09:23 -0700543 size += (mipMapLevelCount - 1) * sizeof(MipMapLevelData);
544 // We subtract 1 because DeferredTextureImage already includes the base
545 // level in its size
bsalomon41b952c2016-03-11 06:46:33 -0800546 size_t pixelOffset = size;
547 size += pixelSize;
548 size_t ctOffset = size;
549 size += ctSize;
bsalomon4d516a62016-07-28 13:37:31 -0700550 size_t colorSpaceOffset = 0;
551 size_t colorSpaceSize = 0;
552 if (info.colorSpace()) {
553 colorSpaceOffset = size;
554 colorSpaceSize = info.colorSpace()->writeToMemory(nullptr);
555 size += colorSpaceSize;
556 }
bsalomon41b952c2016-03-11 06:46:33 -0800557 if (!fillMode) {
558 return size;
559 }
cblume921bc672016-09-22 05:25:26 -0700560 char* bufferAsCharPtr = reinterpret_cast<char*>(buffer);
561 char* pixelsAsCharPtr = bufferAsCharPtr + pixelOffset;
562 void* pixels = pixelsAsCharPtr;
cblume33e0cb52016-08-30 12:09:23 -0700563 void* ct = nullptr;
bsalomon41b952c2016-03-11 06:46:33 -0800564 if (ctSize) {
cblume921bc672016-09-22 05:25:26 -0700565 ct = bufferAsCharPtr + ctOffset;
bsalomon41b952c2016-03-11 06:46:33 -0800566 }
567
cblume921bc672016-09-22 05:25:26 -0700568 memcpy(reinterpret_cast<void*>(SkAlign8(reinterpret_cast<uintptr_t>(pixelsAsCharPtr))),
569 pixmap.addr(), pixmap.getSafeSize());
bsalomon41b952c2016-03-11 06:46:33 -0800570 if (ctSize) {
571 memcpy(ct, pixmap.ctable()->readColors(), ctSize);
572 }
573
Brian Osman6c15cc72016-10-17 09:51:37 -0400574 // If the context has sRGB support, and we're intending to render to a surface with an attached
575 // color space, and the image has an sRGB-like color space attached, then use our gamma (sRGB)
576 // aware mip-mapping.
Brian Osman7b8400d2016-11-08 17:08:54 -0500577 SkDestinationSurfaceColorMode colorMode = SkDestinationSurfaceColorMode::kLegacy;
Brian Osman6c15cc72016-10-17 09:51:37 -0400578 if (proxy.fCaps->srgbSupport() && SkToBool(dstColorSpace) &&
579 info.colorSpace() && info.colorSpace()->gammaCloseToSRGB()) {
Brian Osman7b8400d2016-11-08 17:08:54 -0500580 colorMode = SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware;
Brian Osman6c15cc72016-10-17 09:51:37 -0400581 }
582
bsalomon41b952c2016-03-11 06:46:33 -0800583 SkASSERT(info == pixmap.info());
584 size_t rowBytes = pixmap.rowBytes();
cblume33e0cb52016-08-30 12:09:23 -0700585 static_assert(std::is_standard_layout<DeferredTextureImage>::value,
586 "offsetof, which we use below, requires the type have standard layout");
cblume921bc672016-09-22 05:25:26 -0700587 auto dtiBufferFiller = DTIBufferFiller{bufferAsCharPtr};
Brian Osman7b8400d2016-11-08 17:08:54 -0500588 FILL_MEMBER(dtiBufferFiller, fColorMode, &colorMode);
cblume33e0cb52016-08-30 12:09:23 -0700589 FILL_MEMBER(dtiBufferFiller, fContextUniqueID, &proxy.fContextUniqueID);
590 int width = info.width();
591 FILL_MEMBER(dtiBufferFiller, fWidth, &width);
592 int height = info.height();
593 FILL_MEMBER(dtiBufferFiller, fHeight, &height);
594 SkColorType colorType = info.colorType();
595 FILL_MEMBER(dtiBufferFiller, fColorType, &colorType);
596 SkAlphaType alphaType = info.alphaType();
597 FILL_MEMBER(dtiBufferFiller, fAlphaType, &alphaType);
598 FILL_MEMBER(dtiBufferFiller, fColorTableCnt, &ctCount);
599 FILL_MEMBER(dtiBufferFiller, fColorTableData, &ct);
600 FILL_MEMBER(dtiBufferFiller, fMipMapLevelCount, &mipMapLevelCount);
cblume921bc672016-09-22 05:25:26 -0700601 memcpy(bufferAsCharPtr + offsetof(DeferredTextureImage, fMipMapLevelData[0].fPixelData),
cblume33e0cb52016-08-30 12:09:23 -0700602 &pixels, sizeof(pixels));
cblume921bc672016-09-22 05:25:26 -0700603 memcpy(bufferAsCharPtr + offsetof(DeferredTextureImage, fMipMapLevelData[0].fRowBytes),
cblume33e0cb52016-08-30 12:09:23 -0700604 &rowBytes, sizeof(rowBytes));
bsalomon4d516a62016-07-28 13:37:31 -0700605 if (colorSpaceSize) {
cblume921bc672016-09-22 05:25:26 -0700606 void* colorSpace = bufferAsCharPtr + colorSpaceOffset;
cblume33e0cb52016-08-30 12:09:23 -0700607 FILL_MEMBER(dtiBufferFiller, fColorSpace, &colorSpace);
608 FILL_MEMBER(dtiBufferFiller, fColorSpaceSize, &colorSpaceSize);
cblume921bc672016-09-22 05:25:26 -0700609 info.colorSpace()->writeToMemory(bufferAsCharPtr + colorSpaceOffset);
bsalomon4d516a62016-07-28 13:37:31 -0700610 } else {
cblume921bc672016-09-22 05:25:26 -0700611 memset(bufferAsCharPtr + offsetof(DeferredTextureImage, fColorSpace),
cblume33e0cb52016-08-30 12:09:23 -0700612 0, sizeof(DeferredTextureImage::fColorSpace));
cblume921bc672016-09-22 05:25:26 -0700613 memset(bufferAsCharPtr + offsetof(DeferredTextureImage, fColorSpaceSize),
cblume33e0cb52016-08-30 12:09:23 -0700614 0, sizeof(DeferredTextureImage::fColorSpaceSize));
615 }
616
617 // Fill in the mipmap levels if they exist
cblume921bc672016-09-22 05:25:26 -0700618 char* mipLevelPtr = pixelsAsCharPtr + SkAlign8(pixmap.getSafeSize());
cblume33e0cb52016-08-30 12:09:23 -0700619
620 if (useMipMaps) {
cblume94ddf542016-09-16 10:07:32 -0700621 static_assert(std::is_standard_layout<MipMapLevelData>::value,
622 "offsetof, which we use below, requires the type have a standard layout");
cblume33e0cb52016-08-30 12:09:23 -0700623
Brian Osman7b8400d2016-11-08 17:08:54 -0500624 std::unique_ptr<SkMipMap> mipmaps(SkMipMap::Build(pixmap, colorMode, nullptr));
cblume33e0cb52016-08-30 12:09:23 -0700625 // SkMipMap holds only the mipmap levels it generates.
626 // A programmer can use the data they provided to SkMipMap::Build as level 0.
627 // So the SkMipMap provides levels 1-x but it stores them in its own
628 // range 0-(x-1).
629 for (int generatedMipLevelIndex = 0; generatedMipLevelIndex < mipMapLevelCount - 1;
630 generatedMipLevelIndex++) {
cblume33e0cb52016-08-30 12:09:23 -0700631 SkMipMap::Level mipLevel;
632 mipmaps->getLevel(generatedMipLevelIndex, &mipLevel);
633
634 // Make sure the mipmap data is after the start of the buffer
cblume921bc672016-09-22 05:25:26 -0700635 SkASSERT(mipLevelPtr > bufferAsCharPtr);
cblume33e0cb52016-08-30 12:09:23 -0700636 // Make sure the mipmap data starts before the end of the buffer
cblume921bc672016-09-22 05:25:26 -0700637 SkASSERT(mipLevelPtr < bufferAsCharPtr + pixelOffset + pixelSize);
cblume33e0cb52016-08-30 12:09:23 -0700638 // Make sure the mipmap data ends before the end of the buffer
cblume12f75272016-09-19 06:18:03 -0700639 SkASSERT(mipLevelPtr + mipLevel.fPixmap.getSafeSize() <=
cblume921bc672016-09-22 05:25:26 -0700640 bufferAsCharPtr + pixelOffset + pixelSize);
cblume33e0cb52016-08-30 12:09:23 -0700641
642 // getSafeSize includes rowbyte padding except for the last row,
643 // right?
644
cblume921bc672016-09-22 05:25:26 -0700645 memcpy(mipLevelPtr, mipLevel.fPixmap.addr(), mipLevel.fPixmap.getSafeSize());
cblume33e0cb52016-08-30 12:09:23 -0700646
cblume921bc672016-09-22 05:25:26 -0700647 memcpy(bufferAsCharPtr + offsetof(DeferredTextureImage, fMipMapLevelData) +
648 sizeof(MipMapLevelData) * (generatedMipLevelIndex + 1) +
649 offsetof(MipMapLevelData, fPixelData), &mipLevelPtr, sizeof(void*));
cblume33e0cb52016-08-30 12:09:23 -0700650 size_t rowBytes = mipLevel.fPixmap.rowBytes();
cblume921bc672016-09-22 05:25:26 -0700651 memcpy(bufferAsCharPtr + offsetof(DeferredTextureImage, fMipMapLevelData) +
652 sizeof(MipMapLevelData) * (generatedMipLevelIndex + 1) +
653 offsetof(MipMapLevelData, fRowBytes), &rowBytes, sizeof(rowBytes));
cblume33e0cb52016-08-30 12:09:23 -0700654
655 mipLevelPtr += SkAlign8(mipLevel.fPixmap.getSafeSize());
656 }
bsalomon4d516a62016-07-28 13:37:31 -0700657 }
bsalomon41b952c2016-03-11 06:46:33 -0800658 return size;
659}
660
661sk_sp<SkImage> SkImage::MakeFromDeferredTextureImageData(GrContext* context, const void* data,
662 SkBudgeted budgeted) {
663 if (!data) {
664 return nullptr;
665 }
666 const DeferredTextureImage* dti = reinterpret_cast<const DeferredTextureImage*>(data);
667
668 if (!context || context->uniqueID() != dti->fContextUniqueID) {
669 return nullptr;
670 }
Hal Canary67b39de2016-11-07 11:47:44 -0500671 sk_sp<SkColorTable> colorTable;
bsalomon4d516a62016-07-28 13:37:31 -0700672 if (dti->fColorTableCnt) {
673 SkASSERT(dti->fColorTableData);
674 colorTable.reset(new SkColorTable(dti->fColorTableData, dti->fColorTableCnt));
bsalomon41b952c2016-03-11 06:46:33 -0800675 }
cblume33e0cb52016-08-30 12:09:23 -0700676 int mipLevelCount = dti->fMipMapLevelCount;
677 SkASSERT(mipLevelCount >= 1);
bsalomon4d516a62016-07-28 13:37:31 -0700678 sk_sp<SkColorSpace> colorSpace;
679 if (dti->fColorSpaceSize) {
680 colorSpace = SkColorSpace::Deserialize(dti->fColorSpace, dti->fColorSpaceSize);
681 }
682 SkImageInfo info = SkImageInfo::Make(dti->fWidth, dti->fHeight,
683 dti->fColorType, dti->fAlphaType, colorSpace);
cblume33e0cb52016-08-30 12:09:23 -0700684 if (mipLevelCount == 1) {
685 SkPixmap pixmap;
686 pixmap.reset(info, dti->fMipMapLevelData[0].fPixelData,
687 dti->fMipMapLevelData[0].fRowBytes, colorTable.get());
688 return SkImage::MakeTextureFromPixmap(context, pixmap, budgeted);
689 } else {
Ben Wagner7ecc5962016-11-02 17:07:33 -0400690 std::unique_ptr<GrMipLevel[]> texels(new GrMipLevel[mipLevelCount]);
cblume33e0cb52016-08-30 12:09:23 -0700691 for (int i = 0; i < mipLevelCount; i++) {
692 texels[i].fPixels = dti->fMipMapLevelData[i].fPixelData;
693 texels[i].fRowBytes = dti->fMipMapLevelData[i].fRowBytes;
694 }
695
696 return SkImage::MakeTextureFromMipMap(context, info, texels.get(),
697 mipLevelCount, SkBudgeted::kYes,
Brian Osman7b8400d2016-11-08 17:08:54 -0500698 dti->fColorMode);
cblume33e0cb52016-08-30 12:09:23 -0700699 }
bsalomon41b952c2016-03-11 06:46:33 -0800700}
701
702///////////////////////////////////////////////////////////////////////////////////////////////////
703
cblume186d2d42016-06-03 11:17:42 -0700704sk_sp<SkImage> SkImage::MakeTextureFromMipMap(GrContext* ctx, const SkImageInfo& info,
705 const GrMipLevel* texels, int mipLevelCount,
cblume33e0cb52016-08-30 12:09:23 -0700706 SkBudgeted budgeted,
Brian Osman7b8400d2016-11-08 17:08:54 -0500707 SkDestinationSurfaceColorMode colorMode) {
cblume186d2d42016-06-03 11:17:42 -0700708 if (!ctx) {
709 return nullptr;
710 }
bungeman6bd52842016-10-27 09:30:08 -0700711 sk_sp<GrTexture> texture(GrUploadMipMapToTexture(ctx, info, texels, mipLevelCount));
cblume186d2d42016-06-03 11:17:42 -0700712 if (!texture) {
713 return nullptr;
714 }
Brian Osman7b8400d2016-11-08 17:08:54 -0500715 texture->texturePriv().setMipColorMode(colorMode);
cblume186d2d42016-06-03 11:17:42 -0700716 return sk_make_sp<SkImage_Gpu>(texture->width(), texture->height(), kNeedNewImageUniqueID,
bungeman6bd52842016-10-27 09:30:08 -0700717 info.alphaType(), std::move(texture),
718 sk_ref_sp(info.colorSpace()), budgeted);
cblume186d2d42016-06-03 11:17:42 -0700719}