reed@google.com | 5d4ba88 | 2012-07-31 15:45:27 +0000 | [diff] [blame] | 1 | /* |
| 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 | |
robertphillips | c5035e7 | 2016-03-17 06:58:39 -0700 | [diff] [blame] | 8 | #include "SkAutoPixmapStorage.h" |
reed | 856e9d9 | 2015-09-30 12:21:45 -0700 | [diff] [blame] | 9 | #include "GrCaps.h" |
robertphillips@google.com | 97b6b07 | 2012-10-31 14:48:39 +0000 | [diff] [blame] | 10 | #include "GrContext.h" |
bsalomon | 993a421 | 2015-05-29 11:37:25 -0700 | [diff] [blame] | 11 | #include "GrDrawContext.h" |
bsalomon | f1ecd21 | 2015-12-09 17:06:02 -0800 | [diff] [blame] | 12 | #include "GrImageIDTextureAdjuster.h" |
bsalomon | f267c1e | 2016-02-01 13:16:14 -0800 | [diff] [blame] | 13 | #include "effects/GrYUVEffect.h" |
bsalomon | 993a421 | 2015-05-29 11:37:25 -0700 | [diff] [blame] | 14 | #include "SkCanvas.h" |
reed | 262a71b | 2015-12-05 13:07:27 -0800 | [diff] [blame] | 15 | #include "SkBitmapCache.h" |
bsalomon | 89fe56b | 2015-10-29 10:49:28 -0700 | [diff] [blame] | 16 | #include "SkGrPriv.h" |
reed | 262a71b | 2015-12-05 13:07:27 -0800 | [diff] [blame] | 17 | #include "SkImage_Gpu.h" |
ericrk | b4da01d | 2016-06-13 11:18:14 -0700 | [diff] [blame] | 18 | #include "SkMipMap.h" |
reed | 6f1216a | 2015-08-04 08:10:13 -0700 | [diff] [blame] | 19 | #include "SkPixelRef.h" |
bsalomon | 993a421 | 2015-05-29 11:37:25 -0700 | [diff] [blame] | 20 | |
reed | 80c772b | 2015-07-30 18:58:23 -0700 | [diff] [blame] | 21 | SkImage_Gpu::SkImage_Gpu(int w, int h, uint32_t uniqueID, SkAlphaType at, GrTexture* tex, |
brianosman | dddbe38 | 2016-07-20 13:55:39 -0700 | [diff] [blame] | 22 | sk_sp<SkColorSpace> colorSpace, SkBudgeted budgeted) |
reed | af3fbfc | 2015-10-04 11:28:36 -0700 | [diff] [blame] | 23 | : INHERITED(w, h, uniqueID) |
reed | 8b26b99 | 2015-05-07 15:36:17 -0700 | [diff] [blame] | 24 | , fTexture(SkRef(tex)) |
reed | 8b26b99 | 2015-05-07 15:36:17 -0700 | [diff] [blame] | 25 | , fAlphaType(at) |
bsalomon | eaaaf0b | 2015-01-23 08:08:04 -0800 | [diff] [blame] | 26 | , fBudgeted(budgeted) |
brianosman | dddbe38 | 2016-07-20 13:55:39 -0700 | [diff] [blame] | 27 | , fColorSpace(std::move(colorSpace)) |
bsalomon | 1cd6311 | 2015-08-05 06:58:39 -0700 | [diff] [blame] | 28 | , fAddedRasterVersionToCache(false) |
reed | c9b5f8b | 2015-10-22 13:20:20 -0700 | [diff] [blame] | 29 | { |
| 30 | SkASSERT(tex->width() == w); |
| 31 | SkASSERT(tex->height() == h); |
| 32 | } |
piotaixr | cef04f8 | 2014-07-14 07:48:04 -0700 | [diff] [blame] | 33 | |
reed | 6f1216a | 2015-08-04 08:10:13 -0700 | [diff] [blame] | 34 | SkImage_Gpu::~SkImage_Gpu() { |
| 35 | if (fAddedRasterVersionToCache.load()) { |
| 36 | SkNotifyBitmapGenIDIsStale(this->uniqueID()); |
| 37 | } |
| 38 | } |
| 39 | |
bsalomon | eaaaf0b | 2015-01-23 08:08:04 -0800 | [diff] [blame] | 40 | extern void SkTextureImageApplyBudgetedDecision(SkImage* image) { |
robertphillips | ea70c4b | 2016-07-20 08:54:31 -0700 | [diff] [blame] | 41 | if (image->isTextureBacked()) { |
reed | 8b26b99 | 2015-05-07 15:36:17 -0700 | [diff] [blame] | 42 | ((SkImage_Gpu*)image)->applyBudgetDecision(); |
| 43 | } |
| 44 | } |
| 45 | |
brianosman | 396fcdb | 2016-07-22 06:26:11 -0700 | [diff] [blame] | 46 | SkImageInfo SkImage_Gpu::onImageInfo() const { |
| 47 | SkColorType ct; |
| 48 | if (!GrPixelConfigToColorType(fTexture->config(), &ct)) { |
| 49 | ct = kUnknown_SkColorType; |
| 50 | } |
| 51 | return SkImageInfo::Make(fTexture->width(), fTexture->height(), ct, fAlphaType, fColorSpace); |
| 52 | } |
| 53 | |
brianosman | dddbe38 | 2016-07-20 13:55:39 -0700 | [diff] [blame] | 54 | static SkImageInfo make_info(int w, int h, bool isOpaque, sk_sp<SkColorSpace> colorSpace) { |
| 55 | return SkImageInfo::MakeN32(w, h, isOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType, |
| 56 | std::move(colorSpace)); |
reed | 88d064d | 2015-10-12 11:30:02 -0700 | [diff] [blame] | 57 | } |
| 58 | |
reed | 0955303 | 2015-11-23 12:32:16 -0800 | [diff] [blame] | 59 | bool SkImage_Gpu::getROPixels(SkBitmap* dst, CachingHint chint) const { |
reed | 6f1216a | 2015-08-04 08:10:13 -0700 | [diff] [blame] | 60 | if (SkBitmapCache::Find(this->uniqueID(), dst)) { |
| 61 | SkASSERT(dst->getGenerationID() == this->uniqueID()); |
| 62 | SkASSERT(dst->isImmutable()); |
| 63 | SkASSERT(dst->getPixels()); |
| 64 | return true; |
| 65 | } |
| 66 | |
brianosman | dddbe38 | 2016-07-20 13:55:39 -0700 | [diff] [blame] | 67 | if (!dst->tryAllocPixels(make_info(this->width(), this->height(), this->isOpaque(), |
| 68 | this->fColorSpace))) { |
reed | 8b26b99 | 2015-05-07 15:36:17 -0700 | [diff] [blame] | 69 | return false; |
| 70 | } |
| 71 | if (!fTexture->readPixels(0, 0, dst->width(), dst->height(), kSkia8888_GrPixelConfig, |
| 72 | dst->getPixels(), dst->rowBytes())) { |
| 73 | return false; |
| 74 | } |
reed | 6f1216a | 2015-08-04 08:10:13 -0700 | [diff] [blame] | 75 | |
| 76 | dst->pixelRef()->setImmutableWithID(this->uniqueID()); |
reed | 0955303 | 2015-11-23 12:32:16 -0800 | [diff] [blame] | 77 | if (kAllow_CachingHint == chint) { |
| 78 | SkBitmapCache::Add(this->uniqueID(), *dst); |
| 79 | fAddedRasterVersionToCache.store(true); |
| 80 | } |
reed | 8b26b99 | 2015-05-07 15:36:17 -0700 | [diff] [blame] | 81 | return true; |
| 82 | } |
| 83 | |
brianosman | 982eb7f | 2016-06-06 13:10:58 -0700 | [diff] [blame] | 84 | GrTexture* SkImage_Gpu::asTextureRef(GrContext* ctx, const GrTextureParams& params, |
| 85 | SkSourceGammaTreatment gammaTreatment) const { |
| 86 | return GrImageTextureAdjuster(as_IB(this)).refTextureSafeForParams(params, gammaTreatment, |
| 87 | nullptr); |
reed | 85d9178 | 2015-09-10 14:33:38 -0700 | [diff] [blame] | 88 | } |
| 89 | |
reed | 8b26b99 | 2015-05-07 15:36:17 -0700 | [diff] [blame] | 90 | bool SkImage_Gpu::isOpaque() const { |
bsalomon | 74f681d | 2015-06-23 14:38:48 -0700 | [diff] [blame] | 91 | return GrPixelConfigIsOpaque(fTexture->config()) || fAlphaType == kOpaque_SkAlphaType; |
reed | 8b26b99 | 2015-05-07 15:36:17 -0700 | [diff] [blame] | 92 | } |
| 93 | |
| 94 | static void apply_premul(const SkImageInfo& info, void* pixels, size_t rowBytes) { |
| 95 | switch (info.colorType()) { |
| 96 | case kRGBA_8888_SkColorType: |
| 97 | case kBGRA_8888_SkColorType: |
| 98 | break; |
| 99 | default: |
| 100 | return; // nothing to do |
| 101 | } |
| 102 | |
| 103 | // SkColor is not necesarily RGBA or BGRA, but it is one of them on little-endian, |
| 104 | // and in either case, the alpha-byte is always in the same place, so we can safely call |
| 105 | // SkPreMultiplyColor() |
| 106 | // |
| 107 | SkColor* row = (SkColor*)pixels; |
| 108 | for (int y = 0; y < info.height(); ++y) { |
| 109 | for (int x = 0; x < info.width(); ++x) { |
| 110 | row[x] = SkPreMultiplyColor(row[x]); |
| 111 | } |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | bool SkImage_Gpu::onReadPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, |
reed | 0955303 | 2015-11-23 12:32:16 -0800 | [diff] [blame] | 116 | int srcX, int srcY, CachingHint) const { |
brianosman | b109b8c | 2016-06-16 13:03:24 -0700 | [diff] [blame] | 117 | GrPixelConfig config = SkImageInfo2GrPixelConfig(info, *fTexture->getContext()->caps()); |
reed | 8b26b99 | 2015-05-07 15:36:17 -0700 | [diff] [blame] | 118 | uint32_t flags = 0; |
| 119 | if (kUnpremul_SkAlphaType == info.alphaType() && kPremul_SkAlphaType == fAlphaType) { |
| 120 | // let the GPU perform this transformation for us |
| 121 | flags = GrContext::kUnpremul_PixelOpsFlag; |
| 122 | } |
| 123 | if (!fTexture->readPixels(srcX, srcY, info.width(), info.height(), config, |
| 124 | pixels, rowBytes, flags)) { |
| 125 | return false; |
| 126 | } |
| 127 | // do we have to manually fix-up the alpha channel? |
| 128 | // src dst |
| 129 | // unpremul premul fix manually |
| 130 | // premul unpremul done by kUnpremul_PixelOpsFlag |
| 131 | // all other combos need to change. |
| 132 | // |
| 133 | // Should this be handled by Ganesh? todo:? |
| 134 | // |
| 135 | if (kPremul_SkAlphaType == info.alphaType() && kUnpremul_SkAlphaType == fAlphaType) { |
| 136 | apply_premul(info, pixels, rowBytes); |
| 137 | } |
| 138 | return true; |
| 139 | } |
| 140 | |
reed | 7fb4f8b | 2016-03-11 04:33:52 -0800 | [diff] [blame] | 141 | sk_sp<SkImage> SkImage_Gpu::onMakeSubset(const SkIRect& subset) const { |
reed | 7b6945b | 2015-09-24 00:50:58 -0700 | [diff] [blame] | 142 | GrContext* ctx = fTexture->getContext(); |
| 143 | GrSurfaceDesc desc = fTexture->desc(); |
| 144 | desc.fWidth = subset.width(); |
| 145 | desc.fHeight = subset.height(); |
| 146 | |
senorblanco | 8775112 | 2016-05-20 07:27:38 -0700 | [diff] [blame] | 147 | sk_sp<GrTexture> subTx(ctx->textureProvider()->createTexture(desc, fBudgeted)); |
reed | 7b6945b | 2015-09-24 00:50:58 -0700 | [diff] [blame] | 148 | if (!subTx) { |
| 149 | return nullptr; |
| 150 | } |
senorblanco | 8775112 | 2016-05-20 07:27:38 -0700 | [diff] [blame] | 151 | ctx->copySurface(subTx.get(), fTexture, subset, SkIPoint::Make(0, 0)); |
reed | 7fb4f8b | 2016-03-11 04:33:52 -0800 | [diff] [blame] | 152 | return sk_make_sp<SkImage_Gpu>(desc.fWidth, desc.fHeight, kNeedNewImageUniqueID, |
brianosman | dddbe38 | 2016-07-20 13:55:39 -0700 | [diff] [blame] | 153 | fAlphaType, subTx.get(), fColorSpace, fBudgeted); |
reed | 7b6945b | 2015-09-24 00:50:58 -0700 | [diff] [blame] | 154 | } |
| 155 | |
reed | 8b26b99 | 2015-05-07 15:36:17 -0700 | [diff] [blame] | 156 | /////////////////////////////////////////////////////////////////////////////////////////////////// |
| 157 | |
reed | 7fb4f8b | 2016-03-11 04:33:52 -0800 | [diff] [blame] | 158 | static sk_sp<SkImage> new_wrapped_texture_common(GrContext* ctx, const GrBackendTextureDesc& desc, |
brianosman | dddbe38 | 2016-07-20 13:55:39 -0700 | [diff] [blame] | 159 | SkAlphaType at, sk_sp<SkColorSpace> colorSpace, |
| 160 | GrWrapOwnership ownership, |
reed | 7fb4f8b | 2016-03-11 04:33:52 -0800 | [diff] [blame] | 161 | SkImage::TextureReleaseProc releaseProc, |
| 162 | SkImage::ReleaseContext releaseCtx) { |
reed | 8b26b99 | 2015-05-07 15:36:17 -0700 | [diff] [blame] | 163 | if (desc.fWidth <= 0 || desc.fHeight <= 0) { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 164 | return nullptr; |
reed | 8b26b99 | 2015-05-07 15:36:17 -0700 | [diff] [blame] | 165 | } |
bsalomon | 6dc6f5f | 2015-06-18 09:12:16 -0700 | [diff] [blame] | 166 | SkAutoTUnref<GrTexture> tex(ctx->textureProvider()->wrapBackendTexture(desc, ownership)); |
reed | 8b26b99 | 2015-05-07 15:36:17 -0700 | [diff] [blame] | 167 | if (!tex) { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 168 | return nullptr; |
reed | 8b26b99 | 2015-05-07 15:36:17 -0700 | [diff] [blame] | 169 | } |
reed | de49988 | 2015-06-18 13:41:40 -0700 | [diff] [blame] | 170 | if (releaseProc) { |
| 171 | tex->setRelease(releaseProc, releaseCtx); |
| 172 | } |
| 173 | |
bsalomon | 5ec26ae | 2016-02-25 08:33:02 -0800 | [diff] [blame] | 174 | const SkBudgeted budgeted = SkBudgeted::kNo; |
reed | 7fb4f8b | 2016-03-11 04:33:52 -0800 | [diff] [blame] | 175 | return sk_make_sp<SkImage_Gpu>(desc.fWidth, desc.fHeight, kNeedNewImageUniqueID, |
brianosman | dddbe38 | 2016-07-20 13:55:39 -0700 | [diff] [blame] | 176 | at, tex, colorSpace, budgeted); |
bsalomon | 6dc6f5f | 2015-06-18 09:12:16 -0700 | [diff] [blame] | 177 | } |
| 178 | |
reed | 7fb4f8b | 2016-03-11 04:33:52 -0800 | [diff] [blame] | 179 | sk_sp<SkImage> SkImage::MakeFromTexture(GrContext* ctx, const GrBackendTextureDesc& desc, |
brianosman | dddbe38 | 2016-07-20 13:55:39 -0700 | [diff] [blame] | 180 | SkAlphaType at, sk_sp<SkColorSpace> cs, |
| 181 | TextureReleaseProc releaseP, ReleaseContext releaseC) { |
| 182 | return new_wrapped_texture_common(ctx, desc, at, std::move(cs), kBorrow_GrWrapOwnership, |
| 183 | releaseP, releaseC); |
bsalomon | 6dc6f5f | 2015-06-18 09:12:16 -0700 | [diff] [blame] | 184 | } |
| 185 | |
reed | 7fb4f8b | 2016-03-11 04:33:52 -0800 | [diff] [blame] | 186 | sk_sp<SkImage> SkImage::MakeFromAdoptedTexture(GrContext* ctx, const GrBackendTextureDesc& desc, |
brianosman | dddbe38 | 2016-07-20 13:55:39 -0700 | [diff] [blame] | 187 | SkAlphaType at, sk_sp<SkColorSpace> cs) { |
| 188 | return new_wrapped_texture_common(ctx, desc, at, std::move(cs), kAdopt_GrWrapOwnership, |
| 189 | nullptr, nullptr); |
reed | 8b26b99 | 2015-05-07 15:36:17 -0700 | [diff] [blame] | 190 | } |
| 191 | |
jbauman | b445a57 | 2016-06-09 13:24:48 -0700 | [diff] [blame] | 192 | static sk_sp<SkImage> make_from_yuv_textures_copy(GrContext* ctx, SkYUVColorSpace colorSpace, |
| 193 | bool nv12, |
| 194 | const GrBackendObject yuvTextureHandles[], |
| 195 | const SkISize yuvSizes[], |
brianosman | dddbe38 | 2016-07-20 13:55:39 -0700 | [diff] [blame] | 196 | GrSurfaceOrigin origin, |
| 197 | sk_sp<SkColorSpace> imageColorSpace) { |
bsalomon | 5ec26ae | 2016-02-25 08:33:02 -0800 | [diff] [blame] | 198 | const SkBudgeted budgeted = SkBudgeted::kYes; |
bsalomon | 993a421 | 2015-05-29 11:37:25 -0700 | [diff] [blame] | 199 | |
jbauman | b445a57 | 2016-06-09 13:24:48 -0700 | [diff] [blame] | 200 | if (yuvSizes[0].fWidth <= 0 || yuvSizes[0].fHeight <= 0 || yuvSizes[1].fWidth <= 0 || |
| 201 | yuvSizes[1].fHeight <= 0) { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 202 | return nullptr; |
bsalomon | 993a421 | 2015-05-29 11:37:25 -0700 | [diff] [blame] | 203 | } |
jbauman | b445a57 | 2016-06-09 13:24:48 -0700 | [diff] [blame] | 204 | if (!nv12 && (yuvSizes[2].fWidth <= 0 || yuvSizes[2].fHeight <= 0)) { |
| 205 | return nullptr; |
| 206 | } |
| 207 | |
| 208 | const GrPixelConfig kConfig = nv12 ? kRGBA_8888_GrPixelConfig : kAlpha_8_GrPixelConfig; |
| 209 | |
bsalomon | 993a421 | 2015-05-29 11:37:25 -0700 | [diff] [blame] | 210 | GrBackendTextureDesc yDesc; |
| 211 | yDesc.fConfig = kConfig; |
| 212 | yDesc.fOrigin = origin; |
| 213 | yDesc.fSampleCnt = 0; |
| 214 | yDesc.fTextureHandle = yuvTextureHandles[0]; |
| 215 | yDesc.fWidth = yuvSizes[0].fWidth; |
| 216 | yDesc.fHeight = yuvSizes[0].fHeight; |
| 217 | |
| 218 | GrBackendTextureDesc uDesc; |
| 219 | uDesc.fConfig = kConfig; |
| 220 | uDesc.fOrigin = origin; |
| 221 | uDesc.fSampleCnt = 0; |
| 222 | uDesc.fTextureHandle = yuvTextureHandles[1]; |
| 223 | uDesc.fWidth = yuvSizes[1].fWidth; |
| 224 | uDesc.fHeight = yuvSizes[1].fHeight; |
| 225 | |
jbauman | b445a57 | 2016-06-09 13:24:48 -0700 | [diff] [blame] | 226 | sk_sp<GrTexture> yTex( |
| 227 | ctx->textureProvider()->wrapBackendTexture(yDesc, kBorrow_GrWrapOwnership)); |
| 228 | sk_sp<GrTexture> uTex( |
| 229 | ctx->textureProvider()->wrapBackendTexture(uDesc, kBorrow_GrWrapOwnership)); |
| 230 | sk_sp<GrTexture> vTex; |
| 231 | if (nv12) { |
| 232 | vTex = uTex; |
| 233 | } else { |
| 234 | GrBackendTextureDesc vDesc; |
| 235 | vDesc.fConfig = kConfig; |
| 236 | vDesc.fOrigin = origin; |
| 237 | vDesc.fSampleCnt = 0; |
| 238 | vDesc.fTextureHandle = yuvTextureHandles[2]; |
| 239 | vDesc.fWidth = yuvSizes[2].fWidth; |
| 240 | vDesc.fHeight = yuvSizes[2].fHeight; |
bsalomon | 993a421 | 2015-05-29 11:37:25 -0700 | [diff] [blame] | 241 | |
jbauman | b445a57 | 2016-06-09 13:24:48 -0700 | [diff] [blame] | 242 | vTex = sk_sp<GrTexture>( |
| 243 | ctx->textureProvider()->wrapBackendTexture(vDesc, kBorrow_GrWrapOwnership)); |
| 244 | } |
bsalomon | 993a421 | 2015-05-29 11:37:25 -0700 | [diff] [blame] | 245 | if (!yTex || !uTex || !vTex) { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 246 | return nullptr; |
bsalomon | 993a421 | 2015-05-29 11:37:25 -0700 | [diff] [blame] | 247 | } |
| 248 | |
robertphillips | d4c741e | 2016-04-28 09:55:15 -0700 | [diff] [blame] | 249 | const int width = yuvSizes[0].fWidth; |
| 250 | const int height = yuvSizes[0].fHeight; |
robertphillips | aa19a5f | 2016-04-28 06:21:55 -0700 | [diff] [blame] | 251 | |
robertphillips | d4c741e | 2016-04-28 09:55:15 -0700 | [diff] [blame] | 252 | // Needs to be a render target in order to draw to it for the yuv->rgb conversion. |
robertphillips | 6738c70 | 2016-07-27 12:13:51 -0700 | [diff] [blame] | 253 | sk_sp<GrDrawContext> drawContext(ctx->makeDrawContext(SkBackingFit::kExact, |
| 254 | width, height, |
| 255 | kRGBA_8888_GrPixelConfig, |
| 256 | std::move(imageColorSpace), |
| 257 | 0, |
| 258 | origin)); |
robertphillips | d4c741e | 2016-04-28 09:55:15 -0700 | [diff] [blame] | 259 | if (!drawContext) { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 260 | return nullptr; |
bsalomon | 993a421 | 2015-05-29 11:37:25 -0700 | [diff] [blame] | 261 | } |
| 262 | |
| 263 | GrPaint paint; |
| 264 | paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); |
jbauman | b445a57 | 2016-06-09 13:24:48 -0700 | [diff] [blame] | 265 | paint.addColorFragmentProcessor( |
| 266 | GrYUVEffect::MakeYUVToRGB(yTex.get(), uTex.get(), vTex.get(), yuvSizes, colorSpace, nv12)); |
bsalomon | 993a421 | 2015-05-29 11:37:25 -0700 | [diff] [blame] | 267 | |
robertphillips | d4c741e | 2016-04-28 09:55:15 -0700 | [diff] [blame] | 268 | const SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height)); |
robertphillips | c9a3706 | 2015-09-01 08:34:28 -0700 | [diff] [blame] | 269 | |
cdalton | 846c051 | 2016-05-13 10:25:00 -0700 | [diff] [blame] | 270 | drawContext->drawRect(GrNoClip(), paint, SkMatrix::I(), rect); |
robertphillips | d4c741e | 2016-04-28 09:55:15 -0700 | [diff] [blame] | 271 | ctx->flushSurfaceWrites(drawContext->accessRenderTarget()); |
| 272 | return sk_make_sp<SkImage_Gpu>(width, height, kNeedNewImageUniqueID, |
brianosman | dddbe38 | 2016-07-20 13:55:39 -0700 | [diff] [blame] | 273 | kOpaque_SkAlphaType, drawContext->asTexture().get(), |
brianosman | dfe4f2e | 2016-07-21 13:28:36 -0700 | [diff] [blame] | 274 | sk_ref_sp(drawContext->getColorSpace()), budgeted); |
bsalomon | 993a421 | 2015-05-29 11:37:25 -0700 | [diff] [blame] | 275 | } |
reed | 5617900 | 2015-07-07 06:11:19 -0700 | [diff] [blame] | 276 | |
jbauman | b445a57 | 2016-06-09 13:24:48 -0700 | [diff] [blame] | 277 | sk_sp<SkImage> SkImage::MakeFromYUVTexturesCopy(GrContext* ctx, SkYUVColorSpace colorSpace, |
| 278 | const GrBackendObject yuvTextureHandles[3], |
brianosman | dddbe38 | 2016-07-20 13:55:39 -0700 | [diff] [blame] | 279 | const SkISize yuvSizes[3], GrSurfaceOrigin origin, |
| 280 | sk_sp<SkColorSpace> imageColorSpace) { |
| 281 | return make_from_yuv_textures_copy(ctx, colorSpace, false, yuvTextureHandles, yuvSizes, origin, |
| 282 | std::move(imageColorSpace)); |
jbauman | b445a57 | 2016-06-09 13:24:48 -0700 | [diff] [blame] | 283 | } |
| 284 | |
| 285 | sk_sp<SkImage> SkImage::MakeFromNV12TexturesCopy(GrContext* ctx, SkYUVColorSpace colorSpace, |
| 286 | const GrBackendObject yuvTextureHandles[2], |
| 287 | const SkISize yuvSizes[2], |
brianosman | dddbe38 | 2016-07-20 13:55:39 -0700 | [diff] [blame] | 288 | GrSurfaceOrigin origin, |
| 289 | sk_sp<SkColorSpace> imageColorSpace) { |
| 290 | return make_from_yuv_textures_copy(ctx, colorSpace, true, yuvTextureHandles, yuvSizes, origin, |
| 291 | std::move(imageColorSpace)); |
jbauman | b445a57 | 2016-06-09 13:24:48 -0700 | [diff] [blame] | 292 | } |
| 293 | |
reed | 7fb4f8b | 2016-03-11 04:33:52 -0800 | [diff] [blame] | 294 | static sk_sp<SkImage> create_image_from_maker(GrTextureMaker* maker, SkAlphaType at, uint32_t id) { |
brianosman | 982eb7f | 2016-06-06 13:10:58 -0700 | [diff] [blame] | 295 | SkAutoTUnref<GrTexture> texture(maker->refTextureForParams(GrTextureParams::ClampNoFilter(), |
| 296 | SkSourceGammaTreatment::kRespect)); |
bsalomon | 8e74f80 | 2016-01-30 10:01:40 -0800 | [diff] [blame] | 297 | if (!texture) { |
| 298 | return nullptr; |
| 299 | } |
reed | 7fb4f8b | 2016-03-11 04:33:52 -0800 | [diff] [blame] | 300 | return sk_make_sp<SkImage_Gpu>(texture->width(), texture->height(), id, at, texture, |
brianosman | dddbe38 | 2016-07-20 13:55:39 -0700 | [diff] [blame] | 301 | sk_ref_sp(maker->getColorSpace()), SkBudgeted::kNo); |
bsalomon | 8e74f80 | 2016-01-30 10:01:40 -0800 | [diff] [blame] | 302 | } |
| 303 | |
reed | 7fb4f8b | 2016-03-11 04:33:52 -0800 | [diff] [blame] | 304 | sk_sp<SkImage> SkImage::makeTextureImage(GrContext *context) const { |
bsalomon | 8e74f80 | 2016-01-30 10:01:40 -0800 | [diff] [blame] | 305 | if (!context) { |
| 306 | return nullptr; |
| 307 | } |
| 308 | if (GrTexture* peek = as_IB(this)->peekTexture()) { |
reed | 7fb4f8b | 2016-03-11 04:33:52 -0800 | [diff] [blame] | 309 | return peek->getContext() == context ? sk_ref_sp(const_cast<SkImage*>(this)) : nullptr; |
bsalomon | 8e74f80 | 2016-01-30 10:01:40 -0800 | [diff] [blame] | 310 | } |
| 311 | // No way to check whether a image is premul or not? |
| 312 | SkAlphaType at = this->isOpaque() ? kOpaque_SkAlphaType : kPremul_SkAlphaType; |
| 313 | |
| 314 | if (SkImageCacherator* cacher = as_IB(this)->peekCacherator()) { |
| 315 | GrImageTextureMaker maker(context, cacher, this, kDisallow_CachingHint); |
| 316 | return create_image_from_maker(&maker, at, this->uniqueID()); |
| 317 | } |
| 318 | SkBitmap bmp; |
| 319 | if (!this->asLegacyBitmap(&bmp, kRO_LegacyBitmapMode)) { |
| 320 | return nullptr; |
| 321 | } |
| 322 | GrBitmapTextureMaker maker(context, bmp); |
| 323 | return create_image_from_maker(&maker, at, this->uniqueID()); |
| 324 | } |
| 325 | |
bsalomon | 634b430 | 2016-07-12 18:11:17 -0700 | [diff] [blame] | 326 | sk_sp<SkImage> SkImage::makeNonTextureImage() const { |
brianosman | 396fcdb | 2016-07-22 06:26:11 -0700 | [diff] [blame] | 327 | if (!this->isTextureBacked()) { |
bsalomon | 634b430 | 2016-07-12 18:11:17 -0700 | [diff] [blame] | 328 | return sk_ref_sp(const_cast<SkImage*>(this)); |
| 329 | } |
brianosman | 396fcdb | 2016-07-22 06:26:11 -0700 | [diff] [blame] | 330 | SkImageInfo info = as_IB(this)->onImageInfo(); |
bsalomon | 634b430 | 2016-07-12 18:11:17 -0700 | [diff] [blame] | 331 | size_t rowBytes = info.minRowBytes(); |
| 332 | size_t size = info.getSafeSize(rowBytes); |
| 333 | auto data = SkData::MakeUninitialized(size); |
| 334 | if (!data) { |
| 335 | return nullptr; |
| 336 | } |
| 337 | SkPixmap pm(info, data->writable_data(), rowBytes); |
| 338 | if (!this->readPixels(pm, 0, 0, kDisallow_CachingHint)) { |
| 339 | return nullptr; |
| 340 | } |
| 341 | return MakeRasterData(info, data, rowBytes); |
| 342 | } |
| 343 | |
reed | 7fb4f8b | 2016-03-11 04:33:52 -0800 | [diff] [blame] | 344 | sk_sp<SkImage> SkImage::MakeTextureFromPixmap(GrContext* ctx, const SkPixmap& pixmap, |
| 345 | SkBudgeted budgeted) { |
bsalomon | 0d99686 | 2016-03-09 18:44:43 -0800 | [diff] [blame] | 346 | if (!ctx) { |
| 347 | return nullptr; |
| 348 | } |
ericrk | 8bea890 | 2016-03-18 11:52:20 -0700 | [diff] [blame] | 349 | SkAutoTUnref<GrTexture> texture(GrUploadPixmapToTexture(ctx, pixmap, budgeted)); |
bsalomon | 0d99686 | 2016-03-09 18:44:43 -0800 | [diff] [blame] | 350 | if (!texture) { |
| 351 | return nullptr; |
| 352 | } |
reed | 7fb4f8b | 2016-03-11 04:33:52 -0800 | [diff] [blame] | 353 | return sk_make_sp<SkImage_Gpu>(texture->width(), texture->height(), kNeedNewImageUniqueID, |
brianosman | dddbe38 | 2016-07-20 13:55:39 -0700 | [diff] [blame] | 354 | pixmap.alphaType(), texture, |
| 355 | sk_ref_sp(pixmap.info().colorSpace()), budgeted); |
bsalomon | 0d99686 | 2016-03-09 18:44:43 -0800 | [diff] [blame] | 356 | } |
| 357 | |
reed | 5617900 | 2015-07-07 06:11:19 -0700 | [diff] [blame] | 358 | /////////////////////////////////////////////////////////////////////////////////////////////////// |
| 359 | |
bsalomon | 4d516a6 | 2016-07-28 13:37:31 -0700 | [diff] [blame] | 360 | namespace { |
| 361 | struct MipMapLevelData { |
| 362 | void* fPixelData; |
| 363 | size_t fRowBytes; |
bsalomon | 41b952c | 2016-03-11 06:46:33 -0800 | [diff] [blame] | 364 | }; |
| 365 | |
bsalomon | 4d516a6 | 2016-07-28 13:37:31 -0700 | [diff] [blame] | 366 | struct DeferredTextureImage { |
| 367 | uint32_t fContextUniqueID; |
| 368 | // We don't store a SkImageInfo because it contains a ref-counted SkColorSpace. |
| 369 | int fWidth; |
| 370 | int fHeight; |
| 371 | SkColorType fColorType; |
| 372 | SkAlphaType fAlphaType; |
| 373 | void* fColorSpace; |
| 374 | size_t fColorSpaceSize; |
| 375 | int fColorTableCnt; |
| 376 | uint32_t* fColorTableData; |
| 377 | int fMipMapLevelCount; |
| 378 | // The fMipMapLevelData array may contain more than 1 element. |
| 379 | // It contains fMipMapLevelCount elements. |
| 380 | // That means this struct's size is not known at compile-time. |
| 381 | MipMapLevelData fMipMapLevelData[1]; |
| 382 | }; |
| 383 | } // anonymous namespace |
| 384 | |
bsalomon | 41b952c | 2016-03-11 06:46:33 -0800 | [diff] [blame] | 385 | size_t SkImage::getDeferredTextureImageData(const GrContextThreadSafeProxy& proxy, |
ericrk | b4da01d | 2016-06-13 11:18:14 -0700 | [diff] [blame] | 386 | const DeferredTextureImageUsageParams params[], |
brianosman | 6efeda4 | 2016-06-22 07:10:06 -0700 | [diff] [blame] | 387 | int paramCnt, void* buffer) const { |
ericrk | b4da01d | 2016-06-13 11:18:14 -0700 | [diff] [blame] | 388 | // Extract relevant min/max values from the params array. |
| 389 | int lowestPreScaleMipLevel = params[0].fPreScaleMipLevel; |
| 390 | SkFilterQuality highestFilterQuality = params[0].fQuality; |
| 391 | for (int i = 1; i < paramCnt; ++i) { |
| 392 | if (lowestPreScaleMipLevel > params[i].fPreScaleMipLevel) |
| 393 | lowestPreScaleMipLevel = params[i].fPreScaleMipLevel; |
| 394 | if (highestFilterQuality < params[i].fQuality) |
| 395 | highestFilterQuality = params[i].fQuality; |
| 396 | } |
| 397 | |
bsalomon | 41b952c | 2016-03-11 06:46:33 -0800 | [diff] [blame] | 398 | const bool fillMode = SkToBool(buffer); |
| 399 | if (fillMode && !SkIsAlign8(reinterpret_cast<intptr_t>(buffer))) { |
| 400 | return 0; |
| 401 | } |
| 402 | |
ericrk | b4da01d | 2016-06-13 11:18:14 -0700 | [diff] [blame] | 403 | // Calculate scaling parameters. |
| 404 | bool isScaled = lowestPreScaleMipLevel != 0; |
| 405 | |
| 406 | SkISize scaledSize; |
| 407 | if (isScaled) { |
| 408 | // SkMipMap::ComputeLevelSize takes an index into an SkMipMap. SkMipMaps don't contain the |
| 409 | // base level, so to get an SkMipMap index we must subtract one from the GL MipMap level. |
| 410 | scaledSize = SkMipMap::ComputeLevelSize(this->width(), this->height(), |
| 411 | lowestPreScaleMipLevel - 1); |
| 412 | } else { |
| 413 | scaledSize = SkISize::Make(this->width(), this->height()); |
| 414 | } |
| 415 | |
| 416 | // We never want to scale at higher than SW medium quality, as SW medium matches GPU high. |
| 417 | SkFilterQuality scaleFilterQuality = highestFilterQuality; |
| 418 | if (scaleFilterQuality > kMedium_SkFilterQuality) { |
| 419 | scaleFilterQuality = kMedium_SkFilterQuality; |
| 420 | } |
| 421 | |
ericrk | c429baf | 2016-03-24 15:35:45 -0700 | [diff] [blame] | 422 | const int maxTextureSize = proxy.fCaps->maxTextureSize(); |
ericrk | b4da01d | 2016-06-13 11:18:14 -0700 | [diff] [blame] | 423 | if (scaledSize.width() > maxTextureSize || scaledSize.height() > maxTextureSize) { |
ericrk | c429baf | 2016-03-24 15:35:45 -0700 | [diff] [blame] | 424 | return 0; |
| 425 | } |
| 426 | |
bsalomon | 41b952c | 2016-03-11 06:46:33 -0800 | [diff] [blame] | 427 | SkAutoPixmapStorage pixmap; |
| 428 | SkImageInfo info; |
| 429 | size_t pixelSize = 0; |
| 430 | size_t ctSize = 0; |
| 431 | int ctCount = 0; |
ericrk | b4da01d | 2016-06-13 11:18:14 -0700 | [diff] [blame] | 432 | if (!isScaled && this->peekPixels(&pixmap)) { |
bsalomon | 41b952c | 2016-03-11 06:46:33 -0800 | [diff] [blame] | 433 | info = pixmap.info(); |
| 434 | pixelSize = SkAlign8(pixmap.getSafeSize()); |
| 435 | if (pixmap.ctable()) { |
| 436 | ctCount = pixmap.ctable()->count(); |
| 437 | ctSize = SkAlign8(pixmap.ctable()->count() * 4); |
| 438 | } |
| 439 | } else { |
| 440 | // Here we're just using presence of data to know whether there is a codec behind the image. |
| 441 | // In the future we will access the cacherator and get the exact data that we want to (e.g. |
| 442 | // yuv planes) upload. |
bungeman | ffae30d | 2016-08-03 13:32:32 -0700 | [diff] [blame^] | 443 | sk_sp<SkData> data(this->refEncoded()); |
ericrk | b4da01d | 2016-06-13 11:18:14 -0700 | [diff] [blame] | 444 | if (!data && !this->peekPixels(nullptr)) { |
bsalomon | 41b952c | 2016-03-11 06:46:33 -0800 | [diff] [blame] | 445 | return 0; |
| 446 | } |
| 447 | SkAlphaType at = this->isOpaque() ? kOpaque_SkAlphaType : kPremul_SkAlphaType; |
ericrk | b4da01d | 2016-06-13 11:18:14 -0700 | [diff] [blame] | 448 | info = SkImageInfo::MakeN32(scaledSize.width(), scaledSize.height(), at); |
bsalomon | 41b952c | 2016-03-11 06:46:33 -0800 | [diff] [blame] | 449 | pixelSize = SkAlign8(SkAutoPixmapStorage::AllocSize(info, nullptr)); |
| 450 | if (fillMode) { |
| 451 | pixmap.alloc(info); |
ericrk | b4da01d | 2016-06-13 11:18:14 -0700 | [diff] [blame] | 452 | if (isScaled) { |
| 453 | if (!this->scalePixels(pixmap, scaleFilterQuality, |
| 454 | SkImage::kDisallow_CachingHint)) { |
| 455 | return 0; |
| 456 | } |
| 457 | } else { |
| 458 | if (!this->readPixels(pixmap, 0, 0, SkImage::kDisallow_CachingHint)) { |
| 459 | return 0; |
| 460 | } |
bsalomon | 41b952c | 2016-03-11 06:46:33 -0800 | [diff] [blame] | 461 | } |
| 462 | SkASSERT(!pixmap.ctable()); |
| 463 | } |
| 464 | } |
cblume | 2c05280 | 2016-05-31 09:55:08 -0700 | [diff] [blame] | 465 | int mipMapLevelCount = 1; |
bsalomon | 41b952c | 2016-03-11 06:46:33 -0800 | [diff] [blame] | 466 | size_t size = 0; |
| 467 | size_t dtiSize = SkAlign8(sizeof(DeferredTextureImage)); |
| 468 | size += dtiSize; |
bsalomon | 4d516a6 | 2016-07-28 13:37:31 -0700 | [diff] [blame] | 469 | size += mipMapLevelCount * sizeof(MipMapLevelData); |
bsalomon | 41b952c | 2016-03-11 06:46:33 -0800 | [diff] [blame] | 470 | size_t pixelOffset = size; |
| 471 | size += pixelSize; |
| 472 | size_t ctOffset = size; |
| 473 | size += ctSize; |
bsalomon | 4d516a6 | 2016-07-28 13:37:31 -0700 | [diff] [blame] | 474 | size_t colorSpaceOffset = 0; |
| 475 | size_t colorSpaceSize = 0; |
| 476 | if (info.colorSpace()) { |
| 477 | colorSpaceOffset = size; |
| 478 | colorSpaceSize = info.colorSpace()->writeToMemory(nullptr); |
| 479 | size += colorSpaceSize; |
| 480 | } |
bsalomon | 41b952c | 2016-03-11 06:46:33 -0800 | [diff] [blame] | 481 | if (!fillMode) { |
| 482 | return size; |
| 483 | } |
| 484 | intptr_t bufferAsInt = reinterpret_cast<intptr_t>(buffer); |
| 485 | void* pixels = reinterpret_cast<void*>(bufferAsInt + pixelOffset); |
| 486 | SkPMColor* ct = nullptr; |
| 487 | if (ctSize) { |
| 488 | ct = reinterpret_cast<SkPMColor*>(bufferAsInt + ctOffset); |
| 489 | } |
| 490 | |
| 491 | memcpy(pixels, pixmap.addr(), pixmap.getSafeSize()); |
| 492 | if (ctSize) { |
| 493 | memcpy(ct, pixmap.ctable()->readColors(), ctSize); |
| 494 | } |
| 495 | |
| 496 | SkASSERT(info == pixmap.info()); |
| 497 | size_t rowBytes = pixmap.rowBytes(); |
| 498 | DeferredTextureImage* dti = new (buffer) DeferredTextureImage(); |
| 499 | dti->fContextUniqueID = proxy.fContextUniqueID; |
bsalomon | 4d516a6 | 2016-07-28 13:37:31 -0700 | [diff] [blame] | 500 | dti->fWidth = info.width(); |
| 501 | dti->fHeight = info.height(); |
| 502 | dti->fColorType = info.colorType(); |
| 503 | dti->fAlphaType = info.alphaType(); |
| 504 | dti->fColorTableCnt = ctCount; |
| 505 | dti->fColorTableData = ct; |
| 506 | dti->fMipMapLevelCount = mipMapLevelCount; |
| 507 | dti->fMipMapLevelData[0].fPixelData = pixels; |
| 508 | dti->fMipMapLevelData[0].fRowBytes = rowBytes; |
| 509 | if (colorSpaceSize) { |
| 510 | dti->fColorSpace = reinterpret_cast<void*>(bufferAsInt + colorSpaceOffset); |
| 511 | dti->fColorSpaceSize = colorSpaceSize; |
| 512 | info.colorSpace()->writeToMemory(dti->fColorSpace); |
| 513 | } else { |
| 514 | dti->fColorSpace = nullptr; |
| 515 | dti->fColorSpaceSize = 0; |
| 516 | } |
bsalomon | 41b952c | 2016-03-11 06:46:33 -0800 | [diff] [blame] | 517 | return size; |
| 518 | } |
| 519 | |
| 520 | sk_sp<SkImage> SkImage::MakeFromDeferredTextureImageData(GrContext* context, const void* data, |
| 521 | SkBudgeted budgeted) { |
| 522 | if (!data) { |
| 523 | return nullptr; |
| 524 | } |
| 525 | const DeferredTextureImage* dti = reinterpret_cast<const DeferredTextureImage*>(data); |
| 526 | |
| 527 | if (!context || context->uniqueID() != dti->fContextUniqueID) { |
| 528 | return nullptr; |
| 529 | } |
| 530 | SkAutoTUnref<SkColorTable> colorTable; |
bsalomon | 4d516a6 | 2016-07-28 13:37:31 -0700 | [diff] [blame] | 531 | if (dti->fColorTableCnt) { |
| 532 | SkASSERT(dti->fColorTableData); |
| 533 | colorTable.reset(new SkColorTable(dti->fColorTableData, dti->fColorTableCnt)); |
bsalomon | 41b952c | 2016-03-11 06:46:33 -0800 | [diff] [blame] | 534 | } |
bsalomon | 4d516a6 | 2016-07-28 13:37:31 -0700 | [diff] [blame] | 535 | SkASSERT(dti->fMipMapLevelCount == 1); |
| 536 | sk_sp<SkColorSpace> colorSpace; |
| 537 | if (dti->fColorSpaceSize) { |
| 538 | colorSpace = SkColorSpace::Deserialize(dti->fColorSpace, dti->fColorSpaceSize); |
| 539 | } |
| 540 | SkImageInfo info = SkImageInfo::Make(dti->fWidth, dti->fHeight, |
| 541 | dti->fColorType, dti->fAlphaType, colorSpace); |
brianosman | 6efeda4 | 2016-06-22 07:10:06 -0700 | [diff] [blame] | 542 | SkPixmap pixmap; |
bsalomon | 4d516a6 | 2016-07-28 13:37:31 -0700 | [diff] [blame] | 543 | pixmap.reset(info, dti->fMipMapLevelData[0].fPixelData, |
| 544 | dti->fMipMapLevelData[0].fRowBytes, colorTable.get()); |
brianosman | 6efeda4 | 2016-06-22 07:10:06 -0700 | [diff] [blame] | 545 | return SkImage::MakeTextureFromPixmap(context, pixmap, budgeted); |
bsalomon | 41b952c | 2016-03-11 06:46:33 -0800 | [diff] [blame] | 546 | } |
| 547 | |
| 548 | /////////////////////////////////////////////////////////////////////////////////////////////////// |
| 549 | |
bsalomon | 5ec26ae | 2016-02-25 08:33:02 -0800 | [diff] [blame] | 550 | GrTexture* GrDeepCopyTexture(GrTexture* src, SkBudgeted budgeted) { |
reed | 5617900 | 2015-07-07 06:11:19 -0700 | [diff] [blame] | 551 | GrContext* ctx = src->getContext(); |
| 552 | |
| 553 | GrSurfaceDesc desc = src->desc(); |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 554 | GrTexture* dst = ctx->textureProvider()->createTexture(desc, budgeted, nullptr, 0); |
reed | 5617900 | 2015-07-07 06:11:19 -0700 | [diff] [blame] | 555 | if (!dst) { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 556 | return nullptr; |
reed | 5617900 | 2015-07-07 06:11:19 -0700 | [diff] [blame] | 557 | } |
cblume | 6121405 | 2016-01-26 09:10:48 -0800 | [diff] [blame] | 558 | |
reed | 5617900 | 2015-07-07 06:11:19 -0700 | [diff] [blame] | 559 | const SkIRect srcR = SkIRect::MakeWH(desc.fWidth, desc.fHeight); |
| 560 | const SkIPoint dstP = SkIPoint::Make(0, 0); |
bsalomon | b8fea97 | 2016-02-16 07:34:17 -0800 | [diff] [blame] | 561 | ctx->copySurface(dst, src, srcR, dstP); |
| 562 | ctx->flushSurfaceWrites(dst); |
reed | 5617900 | 2015-07-07 06:11:19 -0700 | [diff] [blame] | 563 | return dst; |
| 564 | } |
| 565 | |
cblume | 186d2d4 | 2016-06-03 11:17:42 -0700 | [diff] [blame] | 566 | sk_sp<SkImage> SkImage::MakeTextureFromMipMap(GrContext* ctx, const SkImageInfo& info, |
| 567 | const GrMipLevel* texels, int mipLevelCount, |
brianosman | 6efeda4 | 2016-06-22 07:10:06 -0700 | [diff] [blame] | 568 | SkBudgeted budgeted) { |
cblume | 186d2d4 | 2016-06-03 11:17:42 -0700 | [diff] [blame] | 569 | if (!ctx) { |
| 570 | return nullptr; |
| 571 | } |
| 572 | SkAutoTUnref<GrTexture> texture(GrUploadMipMapToTexture(ctx, info, texels, mipLevelCount)); |
| 573 | if (!texture) { |
| 574 | return nullptr; |
| 575 | } |
| 576 | return sk_make_sp<SkImage_Gpu>(texture->width(), texture->height(), kNeedNewImageUniqueID, |
brianosman | dddbe38 | 2016-07-20 13:55:39 -0700 | [diff] [blame] | 577 | info.alphaType(), texture, sk_ref_sp(info.colorSpace()), |
| 578 | budgeted); |
cblume | 186d2d4 | 2016-06-03 11:17:42 -0700 | [diff] [blame] | 579 | } |