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 | |
reed | 6f1216a | 2015-08-04 08:10:13 -0700 | [diff] [blame] | 8 | #include "SkBitmapCache.h" |
bsalomon | eaaaf0b | 2015-01-23 08:08:04 -0800 | [diff] [blame] | 9 | #include "SkImage_Gpu.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" |
| 12 | #include "effects/GrYUVtoRGBEffect.h" |
| 13 | #include "SkCanvas.h" |
reed | 8b26b99 | 2015-05-07 15:36:17 -0700 | [diff] [blame] | 14 | #include "SkGpuDevice.h" |
reed | 6f1216a | 2015-08-04 08:10:13 -0700 | [diff] [blame] | 15 | #include "SkPixelRef.h" |
bsalomon | 993a421 | 2015-05-29 11:37:25 -0700 | [diff] [blame] | 16 | |
reed | 80c772b | 2015-07-30 18:58:23 -0700 | [diff] [blame] | 17 | SkImage_Gpu::SkImage_Gpu(int w, int h, uint32_t uniqueID, SkAlphaType at, GrTexture* tex, |
reed | 8b26b99 | 2015-05-07 15:36:17 -0700 | [diff] [blame] | 18 | int sampleCountForNewSurfaces, SkSurface::Budgeted budgeted) |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 19 | : INHERITED(w, h, uniqueID, nullptr) |
reed | 8b26b99 | 2015-05-07 15:36:17 -0700 | [diff] [blame] | 20 | , fTexture(SkRef(tex)) |
reed | 3f10b9d | 2014-11-21 10:27:53 -0800 | [diff] [blame] | 21 | , fSampleCountForNewSurfaces(sampleCountForNewSurfaces) |
reed | 8b26b99 | 2015-05-07 15:36:17 -0700 | [diff] [blame] | 22 | , fAlphaType(at) |
bsalomon | eaaaf0b | 2015-01-23 08:08:04 -0800 | [diff] [blame] | 23 | , fBudgeted(budgeted) |
bsalomon | 1cd6311 | 2015-08-05 06:58:39 -0700 | [diff] [blame] | 24 | , fAddedRasterVersionToCache(false) |
reed | 8b26b99 | 2015-05-07 15:36:17 -0700 | [diff] [blame] | 25 | {} |
piotaixr | cef04f8 | 2014-07-14 07:48:04 -0700 | [diff] [blame] | 26 | |
reed | 6f1216a | 2015-08-04 08:10:13 -0700 | [diff] [blame] | 27 | SkImage_Gpu::~SkImage_Gpu() { |
| 28 | if (fAddedRasterVersionToCache.load()) { |
| 29 | SkNotifyBitmapGenIDIsStale(this->uniqueID()); |
| 30 | } |
| 31 | } |
| 32 | |
reed | 4af267b | 2014-11-21 08:46:37 -0800 | [diff] [blame] | 33 | SkSurface* SkImage_Gpu::onNewSurface(const SkImageInfo& info, const SkSurfaceProps& props) const { |
reed | 8b26b99 | 2015-05-07 15:36:17 -0700 | [diff] [blame] | 34 | GrTexture* tex = this->getTexture(); |
| 35 | SkASSERT(tex); |
| 36 | GrContext* ctx = tex->getContext(); |
| 37 | if (!ctx) { |
| 38 | // the texture may have been abandoned, so we have to check |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 39 | return nullptr; |
robertphillips@google.com | 97b6b07 | 2012-10-31 14:48:39 +0000 | [diff] [blame] | 40 | } |
reed | 8b26b99 | 2015-05-07 15:36:17 -0700 | [diff] [blame] | 41 | // TODO: Change signature of onNewSurface to take a budgeted param. |
| 42 | const SkSurface::Budgeted budgeted = SkSurface::kNo_Budgeted; |
| 43 | return SkSurface::NewRenderTarget(ctx, budgeted, info, fSampleCountForNewSurfaces, &props); |
robertphillips@google.com | 97b6b07 | 2012-10-31 14:48:39 +0000 | [diff] [blame] | 44 | } |
reed | 4af267b | 2014-11-21 08:46:37 -0800 | [diff] [blame] | 45 | |
bsalomon | eaaaf0b | 2015-01-23 08:08:04 -0800 | [diff] [blame] | 46 | extern void SkTextureImageApplyBudgetedDecision(SkImage* image) { |
bsalomon | 5581236 | 2015-06-10 08:49:28 -0700 | [diff] [blame] | 47 | if (as_IB(image)->getTexture()) { |
reed | 8b26b99 | 2015-05-07 15:36:17 -0700 | [diff] [blame] | 48 | ((SkImage_Gpu*)image)->applyBudgetDecision(); |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | SkShader* SkImage_Gpu::onNewShader(SkShader::TileMode tileX, SkShader::TileMode tileY, |
| 53 | const SkMatrix* localMatrix) const { |
| 54 | SkBitmap bm; |
| 55 | GrWrapTextureInBitmap(fTexture, this->width(), this->height(), this->isOpaque(), &bm); |
| 56 | return SkShader::CreateBitmapShader(bm, tileX, tileY, localMatrix); |
| 57 | } |
| 58 | |
| 59 | bool SkImage_Gpu::getROPixels(SkBitmap* dst) 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 | |
reed | 8b26b99 | 2015-05-07 15:36:17 -0700 | [diff] [blame] | 67 | SkAlphaType at = this->isOpaque() ? kOpaque_SkAlphaType : kPremul_SkAlphaType; |
| 68 | if (!dst->tryAllocPixels(SkImageInfo::MakeN32(this->width(), this->height(), at))) { |
| 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()); |
| 77 | SkBitmapCache::Add(this->uniqueID(), *dst); |
| 78 | fAddedRasterVersionToCache.store(true); |
reed | 8b26b99 | 2015-05-07 15:36:17 -0700 | [diff] [blame] | 79 | return true; |
| 80 | } |
| 81 | |
reed | 85d9178 | 2015-09-10 14:33:38 -0700 | [diff] [blame^] | 82 | GrTexture* SkImage_Gpu::asTextureRef(GrContext* ctx, SkImageUsageType usage) const { |
| 83 | fTexture->ref(); |
| 84 | return fTexture; |
| 85 | } |
| 86 | |
reed | 8b26b99 | 2015-05-07 15:36:17 -0700 | [diff] [blame] | 87 | bool SkImage_Gpu::isOpaque() const { |
bsalomon | 74f681d | 2015-06-23 14:38:48 -0700 | [diff] [blame] | 88 | return GrPixelConfigIsOpaque(fTexture->config()) || fAlphaType == kOpaque_SkAlphaType; |
reed | 8b26b99 | 2015-05-07 15:36:17 -0700 | [diff] [blame] | 89 | } |
| 90 | |
| 91 | static void apply_premul(const SkImageInfo& info, void* pixels, size_t rowBytes) { |
| 92 | switch (info.colorType()) { |
| 93 | case kRGBA_8888_SkColorType: |
| 94 | case kBGRA_8888_SkColorType: |
| 95 | break; |
| 96 | default: |
| 97 | return; // nothing to do |
| 98 | } |
| 99 | |
| 100 | // SkColor is not necesarily RGBA or BGRA, but it is one of them on little-endian, |
| 101 | // and in either case, the alpha-byte is always in the same place, so we can safely call |
| 102 | // SkPreMultiplyColor() |
| 103 | // |
| 104 | SkColor* row = (SkColor*)pixels; |
| 105 | for (int y = 0; y < info.height(); ++y) { |
| 106 | for (int x = 0; x < info.width(); ++x) { |
| 107 | row[x] = SkPreMultiplyColor(row[x]); |
| 108 | } |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | bool SkImage_Gpu::onReadPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, |
| 113 | int srcX, int srcY) const { |
| 114 | GrPixelConfig config = SkImageInfo2GrPixelConfig(info.colorType(), info.alphaType(), |
| 115 | info.profileType()); |
| 116 | uint32_t flags = 0; |
| 117 | if (kUnpremul_SkAlphaType == info.alphaType() && kPremul_SkAlphaType == fAlphaType) { |
| 118 | // let the GPU perform this transformation for us |
| 119 | flags = GrContext::kUnpremul_PixelOpsFlag; |
| 120 | } |
| 121 | if (!fTexture->readPixels(srcX, srcY, info.width(), info.height(), config, |
| 122 | pixels, rowBytes, flags)) { |
| 123 | return false; |
| 124 | } |
| 125 | // do we have to manually fix-up the alpha channel? |
| 126 | // src dst |
| 127 | // unpremul premul fix manually |
| 128 | // premul unpremul done by kUnpremul_PixelOpsFlag |
| 129 | // all other combos need to change. |
| 130 | // |
| 131 | // Should this be handled by Ganesh? todo:? |
| 132 | // |
| 133 | if (kPremul_SkAlphaType == info.alphaType() && kUnpremul_SkAlphaType == fAlphaType) { |
| 134 | apply_premul(info, pixels, rowBytes); |
| 135 | } |
| 136 | return true; |
| 137 | } |
| 138 | |
| 139 | /////////////////////////////////////////////////////////////////////////////////////////////////// |
| 140 | |
bsalomon | 6dc6f5f | 2015-06-18 09:12:16 -0700 | [diff] [blame] | 141 | static SkImage* new_wrapped_texture_common(GrContext* ctx, const GrBackendTextureDesc& desc, |
reed | de49988 | 2015-06-18 13:41:40 -0700 | [diff] [blame] | 142 | SkAlphaType at, GrWrapOwnership ownership, |
| 143 | SkImage::TextureReleaseProc releaseProc, |
| 144 | SkImage::ReleaseContext releaseCtx) { |
reed | 8b26b99 | 2015-05-07 15:36:17 -0700 | [diff] [blame] | 145 | if (desc.fWidth <= 0 || desc.fHeight <= 0) { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 146 | return nullptr; |
reed | 8b26b99 | 2015-05-07 15:36:17 -0700 | [diff] [blame] | 147 | } |
bsalomon | 6dc6f5f | 2015-06-18 09:12:16 -0700 | [diff] [blame] | 148 | SkAutoTUnref<GrTexture> tex(ctx->textureProvider()->wrapBackendTexture(desc, ownership)); |
reed | 8b26b99 | 2015-05-07 15:36:17 -0700 | [diff] [blame] | 149 | if (!tex) { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 150 | return nullptr; |
reed | 8b26b99 | 2015-05-07 15:36:17 -0700 | [diff] [blame] | 151 | } |
reed | de49988 | 2015-06-18 13:41:40 -0700 | [diff] [blame] | 152 | if (releaseProc) { |
| 153 | tex->setRelease(releaseProc, releaseCtx); |
| 154 | } |
| 155 | |
reed | 8b26b99 | 2015-05-07 15:36:17 -0700 | [diff] [blame] | 156 | const SkSurface::Budgeted budgeted = SkSurface::kNo_Budgeted; |
halcanary | 385fe4d | 2015-08-26 13:07:48 -0700 | [diff] [blame] | 157 | return new SkImage_Gpu(desc.fWidth, desc.fHeight, kNeedNewImageUniqueID, at, tex, 0, budgeted); |
bsalomon | 6dc6f5f | 2015-06-18 09:12:16 -0700 | [diff] [blame] | 158 | } |
| 159 | |
reed | de49988 | 2015-06-18 13:41:40 -0700 | [diff] [blame] | 160 | SkImage* SkImage::NewFromTexture(GrContext* ctx, const GrBackendTextureDesc& desc, SkAlphaType at, |
| 161 | TextureReleaseProc releaseP, ReleaseContext releaseC) { |
| 162 | return new_wrapped_texture_common(ctx, desc, at, kBorrow_GrWrapOwnership, releaseP, releaseC); |
bsalomon | 6dc6f5f | 2015-06-18 09:12:16 -0700 | [diff] [blame] | 163 | } |
| 164 | |
| 165 | SkImage* SkImage::NewFromAdoptedTexture(GrContext* ctx, const GrBackendTextureDesc& desc, |
| 166 | SkAlphaType at) { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 167 | return new_wrapped_texture_common(ctx, desc, at, kAdopt_GrWrapOwnership, nullptr, nullptr); |
reed | 8b26b99 | 2015-05-07 15:36:17 -0700 | [diff] [blame] | 168 | } |
| 169 | |
reed | 5617900 | 2015-07-07 06:11:19 -0700 | [diff] [blame] | 170 | SkImage* SkImage::NewFromTextureCopy(GrContext* ctx, const GrBackendTextureDesc& desc, |
reed | 8b26b99 | 2015-05-07 15:36:17 -0700 | [diff] [blame] | 171 | SkAlphaType at) { |
reed | 5617900 | 2015-07-07 06:11:19 -0700 | [diff] [blame] | 172 | if (desc.fWidth <= 0 || desc.fHeight <= 0) { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 173 | return nullptr; |
reed | 8b26b99 | 2015-05-07 15:36:17 -0700 | [diff] [blame] | 174 | } |
reed | 5617900 | 2015-07-07 06:11:19 -0700 | [diff] [blame] | 175 | |
bsalomon | 6dc6f5f | 2015-06-18 09:12:16 -0700 | [diff] [blame] | 176 | SkAutoTUnref<GrTexture> src(ctx->textureProvider()->wrapBackendTexture( |
reed | 5617900 | 2015-07-07 06:11:19 -0700 | [diff] [blame] | 177 | desc, kBorrow_GrWrapOwnership)); |
reed | 8b26b99 | 2015-05-07 15:36:17 -0700 | [diff] [blame] | 178 | if (!src) { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 179 | return nullptr; |
reed | 8b26b99 | 2015-05-07 15:36:17 -0700 | [diff] [blame] | 180 | } |
| 181 | |
reed | 5617900 | 2015-07-07 06:11:19 -0700 | [diff] [blame] | 182 | const bool isBudgeted = true; |
| 183 | SkAutoTUnref<GrTexture> dst(GrDeepCopyTexture(src, isBudgeted)); |
reed | 8b26b99 | 2015-05-07 15:36:17 -0700 | [diff] [blame] | 184 | if (!dst) { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 185 | return nullptr; |
reed | 8b26b99 | 2015-05-07 15:36:17 -0700 | [diff] [blame] | 186 | } |
| 187 | |
reed | 5617900 | 2015-07-07 06:11:19 -0700 | [diff] [blame] | 188 | const SkSurface::Budgeted budgeted = SkSurface::kYes_Budgeted; |
reed | 8b26b99 | 2015-05-07 15:36:17 -0700 | [diff] [blame] | 189 | const int sampleCount = 0; // todo: make this an explicit parameter to newSurface()? |
halcanary | 385fe4d | 2015-08-26 13:07:48 -0700 | [diff] [blame] | 190 | return new SkImage_Gpu(desc.fWidth, desc.fHeight, kNeedNewImageUniqueID, at, dst, sampleCount, |
| 191 | budgeted); |
bsalomon | eaaaf0b | 2015-01-23 08:08:04 -0800 | [diff] [blame] | 192 | } |
bsalomon | 993a421 | 2015-05-29 11:37:25 -0700 | [diff] [blame] | 193 | |
| 194 | SkImage* SkImage::NewFromYUVTexturesCopy(GrContext* ctx , SkYUVColorSpace colorSpace, |
| 195 | const GrBackendObject yuvTextureHandles[3], |
| 196 | const SkISize yuvSizes[3], |
| 197 | GrSurfaceOrigin origin) { |
| 198 | const SkSurface::Budgeted budgeted = SkSurface::kYes_Budgeted; |
| 199 | |
| 200 | if (yuvSizes[0].fWidth <= 0 || yuvSizes[0].fHeight <= 0 || |
| 201 | yuvSizes[1].fWidth <= 0 || yuvSizes[1].fHeight <= 0 || |
| 202 | yuvSizes[2].fWidth <= 0 || yuvSizes[2].fHeight <= 0) { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 203 | return nullptr; |
bsalomon | 993a421 | 2015-05-29 11:37:25 -0700 | [diff] [blame] | 204 | } |
| 205 | static const GrPixelConfig kConfig = kAlpha_8_GrPixelConfig; |
| 206 | GrBackendTextureDesc yDesc; |
| 207 | yDesc.fConfig = kConfig; |
| 208 | yDesc.fOrigin = origin; |
| 209 | yDesc.fSampleCnt = 0; |
| 210 | yDesc.fTextureHandle = yuvTextureHandles[0]; |
| 211 | yDesc.fWidth = yuvSizes[0].fWidth; |
| 212 | yDesc.fHeight = yuvSizes[0].fHeight; |
| 213 | |
| 214 | GrBackendTextureDesc uDesc; |
| 215 | uDesc.fConfig = kConfig; |
| 216 | uDesc.fOrigin = origin; |
| 217 | uDesc.fSampleCnt = 0; |
| 218 | uDesc.fTextureHandle = yuvTextureHandles[1]; |
| 219 | uDesc.fWidth = yuvSizes[1].fWidth; |
| 220 | uDesc.fHeight = yuvSizes[1].fHeight; |
| 221 | |
| 222 | GrBackendTextureDesc vDesc; |
| 223 | vDesc.fConfig = kConfig; |
| 224 | vDesc.fOrigin = origin; |
| 225 | vDesc.fSampleCnt = 0; |
| 226 | vDesc.fTextureHandle = yuvTextureHandles[2]; |
| 227 | vDesc.fWidth = yuvSizes[2].fWidth; |
| 228 | vDesc.fHeight = yuvSizes[2].fHeight; |
| 229 | |
bsalomon | 6dc6f5f | 2015-06-18 09:12:16 -0700 | [diff] [blame] | 230 | SkAutoTUnref<GrTexture> yTex(ctx->textureProvider()->wrapBackendTexture( |
| 231 | yDesc, kBorrow_GrWrapOwnership)); |
| 232 | SkAutoTUnref<GrTexture> uTex(ctx->textureProvider()->wrapBackendTexture( |
| 233 | uDesc, kBorrow_GrWrapOwnership)); |
| 234 | SkAutoTUnref<GrTexture> vTex(ctx->textureProvider()->wrapBackendTexture( |
| 235 | vDesc, kBorrow_GrWrapOwnership)); |
bsalomon | 993a421 | 2015-05-29 11:37:25 -0700 | [diff] [blame] | 236 | if (!yTex || !uTex || !vTex) { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 237 | return nullptr; |
bsalomon | 993a421 | 2015-05-29 11:37:25 -0700 | [diff] [blame] | 238 | } |
| 239 | |
| 240 | GrSurfaceDesc dstDesc; |
| 241 | // Needs to be a render target in order to draw to it for the yuv->rgb conversion. |
| 242 | dstDesc.fFlags = kRenderTarget_GrSurfaceFlag; |
| 243 | dstDesc.fOrigin = origin; |
| 244 | dstDesc.fWidth = yuvSizes[0].fWidth; |
| 245 | dstDesc.fHeight = yuvSizes[0].fHeight; |
| 246 | dstDesc.fConfig = kRGBA_8888_GrPixelConfig; |
| 247 | dstDesc.fSampleCnt = 0; |
| 248 | |
bsalomon | eae6200 | 2015-07-31 13:59:30 -0700 | [diff] [blame] | 249 | SkAutoTUnref<GrTexture> dst(ctx->textureProvider()->createTexture(dstDesc, true)); |
bsalomon | 993a421 | 2015-05-29 11:37:25 -0700 | [diff] [blame] | 250 | if (!dst) { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 251 | return nullptr; |
bsalomon | 993a421 | 2015-05-29 11:37:25 -0700 | [diff] [blame] | 252 | } |
| 253 | |
| 254 | GrPaint paint; |
| 255 | paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); |
bsalomon | ac856c9 | 2015-08-27 06:30:17 -0700 | [diff] [blame] | 256 | paint.addColorFragmentProcessor(GrYUVtoRGBEffect::Create(paint.getProcessorDataManager(), |
| 257 | yTex, uTex, vTex, yuvSizes, |
| 258 | colorSpace))->unref(); |
bsalomon | 993a421 | 2015-05-29 11:37:25 -0700 | [diff] [blame] | 259 | |
| 260 | const SkRect rect = SkRect::MakeWH(SkIntToScalar(dstDesc.fWidth), |
| 261 | SkIntToScalar(dstDesc.fHeight)); |
robertphillips | c9a3706 | 2015-09-01 08:34:28 -0700 | [diff] [blame] | 262 | SkAutoTUnref<GrDrawContext> drawContext(ctx->drawContext()); |
| 263 | if (!drawContext) { |
| 264 | return nullptr; |
| 265 | } |
| 266 | |
robertphillips | 2334fb6 | 2015-06-17 05:43:33 -0700 | [diff] [blame] | 267 | drawContext->drawRect(dst->asRenderTarget(), GrClip::WideOpen(), paint, SkMatrix::I(), rect); |
bsalomon | 993a421 | 2015-05-29 11:37:25 -0700 | [diff] [blame] | 268 | ctx->flushSurfaceWrites(dst); |
halcanary | 385fe4d | 2015-08-26 13:07:48 -0700 | [diff] [blame] | 269 | return new SkImage_Gpu(dstDesc.fWidth, dstDesc.fHeight, kNeedNewImageUniqueID, |
| 270 | kOpaque_SkAlphaType, dst, 0, budgeted); |
bsalomon | 993a421 | 2015-05-29 11:37:25 -0700 | [diff] [blame] | 271 | } |
reed | 5617900 | 2015-07-07 06:11:19 -0700 | [diff] [blame] | 272 | |
| 273 | /////////////////////////////////////////////////////////////////////////////////////////////////// |
| 274 | |
| 275 | GrTexture* GrDeepCopyTexture(GrTexture* src, bool budgeted) { |
| 276 | GrContext* ctx = src->getContext(); |
| 277 | |
| 278 | GrSurfaceDesc desc = src->desc(); |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 279 | GrTexture* dst = ctx->textureProvider()->createTexture(desc, budgeted, nullptr, 0); |
reed | 5617900 | 2015-07-07 06:11:19 -0700 | [diff] [blame] | 280 | if (!dst) { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 281 | return nullptr; |
reed | 5617900 | 2015-07-07 06:11:19 -0700 | [diff] [blame] | 282 | } |
| 283 | |
| 284 | const SkIRect srcR = SkIRect::MakeWH(desc.fWidth, desc.fHeight); |
| 285 | const SkIPoint dstP = SkIPoint::Make(0, 0); |
| 286 | ctx->copySurface(dst, src, srcR, dstP, GrContext::kFlushWrites_PixelOp); |
| 287 | return dst; |
| 288 | } |
| 289 | |