OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkAutoPixmapStorage.h" | 8 #include "SkAutoPixmapStorage.h" |
9 #include "GrCaps.h" | 9 #include "GrCaps.h" |
10 #include "GrContext.h" | 10 #include "GrContext.h" |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 } | 133 } |
134 return true; | 134 return true; |
135 } | 135 } |
136 | 136 |
137 sk_sp<SkImage> SkImage_Gpu::onMakeSubset(const SkIRect& subset) const { | 137 sk_sp<SkImage> SkImage_Gpu::onMakeSubset(const SkIRect& subset) const { |
138 GrContext* ctx = fTexture->getContext(); | 138 GrContext* ctx = fTexture->getContext(); |
139 GrSurfaceDesc desc = fTexture->desc(); | 139 GrSurfaceDesc desc = fTexture->desc(); |
140 desc.fWidth = subset.width(); | 140 desc.fWidth = subset.width(); |
141 desc.fHeight = subset.height(); | 141 desc.fHeight = subset.height(); |
142 | 142 |
143 GrTexture* subTx = ctx->textureProvider()->createTexture(desc, fBudgeted); | 143 sk_sp<GrTexture> subTx(ctx->textureProvider()->createTexture(desc, fBudgeted
)); |
144 if (!subTx) { | 144 if (!subTx) { |
145 return nullptr; | 145 return nullptr; |
146 } | 146 } |
147 ctx->copySurface(subTx, fTexture, subset, SkIPoint::Make(0, 0)); | 147 ctx->copySurface(subTx.get(), fTexture, subset, SkIPoint::Make(0, 0)); |
148 return sk_make_sp<SkImage_Gpu>(desc.fWidth, desc.fHeight, kNeedNewImageUniqu
eID, | 148 return sk_make_sp<SkImage_Gpu>(desc.fWidth, desc.fHeight, kNeedNewImageUniqu
eID, |
149 fAlphaType, subTx, fBudgeted); | 149 fAlphaType, subTx.get(), fBudgeted); |
150 } | 150 } |
151 | 151 |
152 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 152 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
153 | 153 |
154 static sk_sp<SkImage> new_wrapped_texture_common(GrContext* ctx, const GrBackend
TextureDesc& desc, | 154 static sk_sp<SkImage> new_wrapped_texture_common(GrContext* ctx, const GrBackend
TextureDesc& desc, |
155 SkAlphaType at, GrWrapOwnership
ownership, | 155 SkAlphaType at, GrWrapOwnership
ownership, |
156 SkImage::TextureReleaseProc rel
easeProc, | 156 SkImage::TextureReleaseProc rel
easeProc, |
157 SkImage::ReleaseContext release
Ctx) { | 157 SkImage::ReleaseContext release
Ctx) { |
158 if (desc.fWidth <= 0 || desc.fHeight <= 0) { | 158 if (desc.fWidth <= 0 || desc.fHeight <= 0) { |
159 return nullptr; | 159 return nullptr; |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 return nullptr; | 449 return nullptr; |
450 } | 450 } |
451 | 451 |
452 const SkIRect srcR = SkIRect::MakeWH(desc.fWidth, desc.fHeight); | 452 const SkIRect srcR = SkIRect::MakeWH(desc.fWidth, desc.fHeight); |
453 const SkIPoint dstP = SkIPoint::Make(0, 0); | 453 const SkIPoint dstP = SkIPoint::Make(0, 0); |
454 ctx->copySurface(dst, src, srcR, dstP); | 454 ctx->copySurface(dst, src, srcR, dstP); |
455 ctx->flushSurfaceWrites(dst); | 455 ctx->flushSurfaceWrites(dst); |
456 return dst; | 456 return dst; |
457 } | 457 } |
458 | 458 |
OLD | NEW |