blob: 334984dfcb20d9f07b7edaedfccb49d47e7e79dc [file] [log] [blame]
reed@google.com6997ebb2012-07-30 19:50:31 +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
reed@google.comf6627b72012-07-27 18:02:50 +00008#include "SkBitmap.h"
fmalita3b0d5322015-09-18 08:07:31 -07009#include "SkBitmapCache.h"
mike@reedtribe.org70e35902012-07-29 20:38:16 +000010#include "SkCanvas.h"
reed871872f2015-06-22 12:48:26 -070011#include "SkData.h"
halcanaryf2848b62015-12-10 12:40:23 -080012#include "SkImageEncoder.h"
senorblanco5878dbd2016-05-19 14:50:29 -070013#include "SkImageFilter.h"
brianosman04a44d02016-09-21 09:46:57 -070014#include "SkImageFilterCache.h"
reed5965c8a2015-01-07 18:04:45 -080015#include "SkImageGenerator.h"
scroggo@google.com7def5e12013-05-31 14:00:10 +000016#include "SkImagePriv.h"
reed856e9d92015-09-30 12:21:45 -070017#include "SkImageShader.h"
scroggo@google.com7def5e12013-05-31 14:00:10 +000018#include "SkImage_Base.h"
reed80c772b2015-07-30 18:58:23 -070019#include "SkNextID.h"
reed7fb4f8b2016-03-11 04:33:52 -080020#include "SkPicture.h"
reed56179002015-07-07 06:11:19 -070021#include "SkPixelRef.h"
fmalita2be71252015-09-03 07:17:25 -070022#include "SkPixelSerializer.h"
reed96472de2014-12-10 09:53:42 -080023#include "SkReadPixelsRec.h"
senorblanco5878dbd2016-05-19 14:50:29 -070024#include "SkSpecialImage.h"
reedf8d18742015-01-02 20:45:37 -080025#include "SkString.h"
reed4af267b2014-11-21 08:46:37 -080026#include "SkSurface.h"
reed56179002015-07-07 06:11:19 -070027
bsalomon55812362015-06-10 08:49:28 -070028#if SK_SUPPORT_GPU
29#include "GrTexture.h"
30#include "GrContext.h"
reed56179002015-07-07 06:11:19 -070031#include "SkImage_Gpu.h"
bsalomon55812362015-06-10 08:49:28 -070032#endif
scroggo@google.com7def5e12013-05-31 14:00:10 +000033
reed80c772b2015-07-30 18:58:23 -070034SkImage::SkImage(int width, int height, uint32_t uniqueID)
35 : fWidth(width)
36 , fHeight(height)
37 , fUniqueID(kNeedNewImageUniqueID == uniqueID ? SkNextID::ImageID() : uniqueID)
38{
39 SkASSERT(width > 0);
40 SkASSERT(height > 0);
reed@google.comf6627b72012-07-27 18:02:50 +000041}
42
reed6ceeebd2016-03-09 14:26:26 -080043bool SkImage::peekPixels(SkPixmap* pm) const {
44 SkPixmap tmp;
45 if (!pm) {
46 pm = &tmp;
reed@google.com4f7c6152014-02-06 14:11:56 +000047 }
reed6ceeebd2016-03-09 14:26:26 -080048 return as_IB(this)->onPeekPixels(pm);
reed@google.com4f7c6152014-02-06 14:11:56 +000049}
50
reed96472de2014-12-10 09:53:42 -080051bool SkImage::readPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes,
reed09553032015-11-23 12:32:16 -080052 int srcX, int srcY, CachingHint chint) const {
reed96472de2014-12-10 09:53:42 -080053 SkReadPixelsRec rec(dstInfo, dstPixels, dstRowBytes, srcX, srcY);
54 if (!rec.trim(this->width(), this->height())) {
reed@google.com4f7c6152014-02-06 14:11:56 +000055 return false;
56 }
reed09553032015-11-23 12:32:16 -080057 return as_IB(this)->onReadPixels(rec.fInfo, rec.fPixels, rec.fRowBytes, rec.fX, rec.fY, chint);
58}
59
60bool SkImage::scalePixels(const SkPixmap& dst, SkFilterQuality quality, CachingHint chint) const {
reed6868c3f2015-11-24 11:44:47 -080061 if (this->width() == dst.width() && this->height() == dst.height()) {
62 return this->readPixels(dst, 0, 0, chint);
63 }
64
reed09553032015-11-23 12:32:16 -080065 // Idea: If/when SkImageGenerator supports a native-scaling API (where the generator itself
66 // can scale more efficiently) we should take advantage of it here.
67 //
68 SkBitmap bm;
69 if (as_IB(this)->getROPixels(&bm, chint)) {
70 bm.lockPixels();
71 SkPixmap pmap;
72 // Note: By calling the pixmap scaler, we never cache the final result, so the chint
73 // is (currently) only being applied to the getROPixels. If we get a request to
74 // also attempt to cache the final (scaled) result, we would add that logic here.
75 //
76 return bm.peekPixels(&pmap) && pmap.scalePixels(dst, quality);
77 }
78 return false;
reed@google.com4f7c6152014-02-06 14:11:56 +000079}
80
reedd6b30312015-09-02 07:06:23 -070081void SkImage::preroll(GrContext* ctx) const {
reedefd50da2015-09-14 11:17:23 -070082 // For now, and to maintain parity w/ previous pixelref behavior, we just force the image
83 // to produce a cached raster-bitmap form, so that drawing to a raster canvas should be fast.
84 //
85 SkBitmap bm;
86 if (as_IB(this)->getROPixels(&bm)) {
87 bm.lockPixels();
88 bm.unlockPixels();
89 }
reedd6b30312015-09-02 07:06:23 -070090}
91
reed88d064d2015-10-12 11:30:02 -070092///////////////////////////////////////////////////////////////////////////////////////////////////
93
brianosman69c166d2016-08-17 14:01:05 -070094SkAlphaType SkImage::alphaType() const {
95 return as_IB(this)->onAlphaType();
96}
97
reed5671c5b2016-03-09 14:47:34 -080098sk_sp<SkShader> SkImage::makeShader(SkShader::TileMode tileX, SkShader::TileMode tileY,
99 const SkMatrix* localMatrix) const {
reed6b2d7ac2016-08-11 06:42:26 -0700100 return SkImageShader::Make(sk_ref_sp(const_cast<SkImage*>(this)), tileX, tileY, localMatrix);
piotaixrcef04f82014-07-14 07:48:04 -0700101}
102
scroggo@google.com7def5e12013-05-31 14:00:10 +0000103SkData* SkImage::encode(SkImageEncoder::Type type, int quality) const {
104 SkBitmap bm;
105 if (as_IB(this)->getROPixels(&bm)) {
106 return SkImageEncoder::EncodeData(bm, type, quality);
107 }
halcanary96fcdcc2015-08-27 07:41:13 -0700108 return nullptr;
junov@chromium.orgda904742013-05-01 22:38:16 +0000109}
reed@google.com4f7c6152014-02-06 14:11:56 +0000110
halcanarya2e05672015-12-09 03:56:02 -0800111SkData* SkImage::encode(SkPixelSerializer* serializer) const {
halcanaryf2848b62015-12-10 12:40:23 -0800112 SkAutoTUnref<SkPixelSerializer> defaultSerializer;
113 SkPixelSerializer* effectiveSerializer = serializer;
114 if (!effectiveSerializer) {
115 defaultSerializer.reset(SkImageEncoder::CreatePixelSerializer());
116 SkASSERT(defaultSerializer.get());
117 effectiveSerializer = defaultSerializer.get();
118 }
bungemanffae30d2016-08-03 13:32:32 -0700119 sk_sp<SkData> encoded(this->refEncoded());
reedc9e190d2015-09-28 09:58:41 -0700120 if (encoded && effectiveSerializer->useEncodedData(encoded->data(), encoded->size())) {
mtklein18300a32016-03-16 13:53:35 -0700121 return encoded.release();
fmalita2be71252015-09-03 07:17:25 -0700122 }
123
124 SkBitmap bm;
125 SkAutoPixmapUnlock apu;
126 if (as_IB(this)->getROPixels(&bm) && bm.requestLock(&apu)) {
halcanary6b280172015-12-07 12:42:24 -0800127 return effectiveSerializer->encode(apu.pixmap());
fmalita2be71252015-09-03 07:17:25 -0700128 }
129
130 return nullptr;
131}
132
reed871872f2015-06-22 12:48:26 -0700133SkData* SkImage::refEncoded() const {
reed05dd2512016-01-05 09:16:19 -0800134 GrContext* ctx = nullptr; // should we allow the caller to pass in a ctx?
135 return as_IB(this)->onRefEncoded(ctx);
reed871872f2015-06-22 12:48:26 -0700136}
137
reed7fb4f8b2016-03-11 04:33:52 -0800138sk_sp<SkImage> SkImage::MakeFromEncoded(sk_sp<SkData> encoded, const SkIRect* subset) {
halcanary96fcdcc2015-08-27 07:41:13 -0700139 if (nullptr == encoded || 0 == encoded->size()) {
140 return nullptr;
reed5965c8a2015-01-07 18:04:45 -0800141 }
reed7fb4f8b2016-03-11 04:33:52 -0800142 SkImageGenerator* generator = SkImageGenerator::NewFromEncoded(encoded.get());
143 return SkImage::MakeFromGenerator(generator, subset);
reed5965c8a2015-01-07 18:04:45 -0800144}
145
reedf8d18742015-01-02 20:45:37 -0800146const char* SkImage::toString(SkString* str) const {
147 str->appendf("image: (id:%d (%d, %d) %s)", this->uniqueID(), this->width(), this->height(),
148 this->isOpaque() ? "opaque" : "");
149 return str->c_str();
150}
151
reed7fb4f8b2016-03-11 04:33:52 -0800152sk_sp<SkImage> SkImage::makeSubset(const SkIRect& subset) const {
reed7b6945b2015-09-24 00:50:58 -0700153 if (subset.isEmpty()) {
154 return nullptr;
155 }
156
157 const SkIRect bounds = SkIRect::MakeWH(this->width(), this->height());
158 if (!bounds.contains(subset)) {
159 return nullptr;
160 }
161
162 // optimization : return self if the subset == our bounds
163 if (bounds == subset) {
reed7fb4f8b2016-03-11 04:33:52 -0800164 return sk_ref_sp(const_cast<SkImage*>(this));
reed7b6945b2015-09-24 00:50:58 -0700165 }
reed7fb4f8b2016-03-11 04:33:52 -0800166 return as_IB(this)->onMakeSubset(subset);
reedf803da12015-01-23 05:58:07 -0800167}
168
bsalomon55812362015-06-10 08:49:28 -0700169#if SK_SUPPORT_GPU
170
171GrTexture* SkImage::getTexture() const {
reed85d91782015-09-10 14:33:38 -0700172 return as_IB(this)->peekTexture();
bsalomon55812362015-06-10 08:49:28 -0700173}
174
bsalomon84a4e5a2016-02-29 11:41:52 -0800175bool SkImage::isTextureBacked() const { return SkToBool(as_IB(this)->peekTexture()); }
bsalomon55812362015-06-10 08:49:28 -0700176
bsalomonc49e8682015-06-30 11:37:35 -0700177GrBackendObject SkImage::getTextureHandle(bool flushPendingGrContextIO) const {
bsalomon84a4e5a2016-02-29 11:41:52 -0800178 GrTexture* texture = as_IB(this)->peekTexture();
bsalomon55812362015-06-10 08:49:28 -0700179 if (texture) {
180 GrContext* context = texture->getContext();
181 if (context) {
bsalomonc49e8682015-06-30 11:37:35 -0700182 if (flushPendingGrContextIO) {
183 context->prepareSurfaceForExternalIO(texture);
bsalomon55812362015-06-10 08:49:28 -0700184 }
185 }
186 return texture->getTextureHandle();
187 }
188 return 0;
189}
190
191#else
192
halcanary96fcdcc2015-08-27 07:41:13 -0700193GrTexture* SkImage::getTexture() const { return nullptr; }
bsalomon55812362015-06-10 08:49:28 -0700194
195bool SkImage::isTextureBacked() const { return false; }
196
bsalomonc49e8682015-06-30 11:37:35 -0700197GrBackendObject SkImage::getTextureHandle(bool) const { return 0; }
bsalomon55812362015-06-10 08:49:28 -0700198
199#endif
200
reed@google.com4f7c6152014-02-06 14:11:56 +0000201///////////////////////////////////////////////////////////////////////////////
202
203static bool raster_canvas_supports(const SkImageInfo& info) {
reede5ea5002014-09-03 11:54:58 -0700204 switch (info.colorType()) {
commit-bot@chromium.org28fcae22014-04-11 17:15:40 +0000205 case kN32_SkColorType:
reede5ea5002014-09-03 11:54:58 -0700206 return kUnpremul_SkAlphaType != info.alphaType();
reed@google.com4f7c6152014-02-06 14:11:56 +0000207 case kRGB_565_SkColorType:
208 return true;
209 case kAlpha_8_SkColorType:
210 return true;
211 default:
212 break;
213 }
214 return false;
215}
216
reedaf3fbfc2015-10-04 11:28:36 -0700217SkImage_Base::SkImage_Base(int width, int height, uint32_t uniqueID)
fmalita3b0d5322015-09-18 08:07:31 -0700218 : INHERITED(width, height, uniqueID)
fmalita3b0d5322015-09-18 08:07:31 -0700219 , fAddedToCache(false)
reedaf3fbfc2015-10-04 11:28:36 -0700220{}
fmalita3b0d5322015-09-18 08:07:31 -0700221
222SkImage_Base::~SkImage_Base() {
223 if (fAddedToCache.load()) {
224 SkNotifyBitmapGenIDIsStale(this->uniqueID());
225 }
226}
227
reed96472de2014-12-10 09:53:42 -0800228bool SkImage_Base::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes,
reed09553032015-11-23 12:32:16 -0800229 int srcX, int srcY, CachingHint) const {
reed96472de2014-12-10 09:53:42 -0800230 if (!raster_canvas_supports(dstInfo)) {
231 return false;
reed@google.com4f7c6152014-02-06 14:11:56 +0000232 }
233
reed96472de2014-12-10 09:53:42 -0800234 SkBitmap bm;
235 bm.installPixels(dstInfo, dstPixels, dstRowBytes);
236 SkCanvas canvas(bm);
reed@google.com4f7c6152014-02-06 14:11:56 +0000237
238 SkPaint paint;
reed374772b2016-10-05 17:33:02 -0700239 paint.setBlendMode(SkBlendMode::kSrc);
reed96472de2014-12-10 09:53:42 -0800240 canvas.drawImage(this, -SkIntToScalar(srcX), -SkIntToScalar(srcY), &paint);
reed@google.com4f7c6152014-02-06 14:11:56 +0000241
reed@google.com4f7c6152014-02-06 14:11:56 +0000242 return true;
243}
reedf803da12015-01-23 05:58:07 -0800244
reed871872f2015-06-22 12:48:26 -0700245///////////////////////////////////////////////////////////////////////////////////////////////////
246
reed09553032015-11-23 12:32:16 -0800247bool SkImage::readPixels(const SkPixmap& pmap, int srcX, int srcY, CachingHint chint) const {
248 return this->readPixels(pmap.info(), pmap.writable_addr(), pmap.rowBytes(), srcX, srcY, chint);
reed871872f2015-06-22 12:48:26 -0700249}
250
bsalomonf267c1e2016-02-01 13:16:14 -0800251#if SK_SUPPORT_GPU
252#include "GrTextureToYUVPlanes.h"
253#endif
254
255#include "SkRGBAToYUV.h"
256
257bool SkImage::readYUV8Planes(const SkISize sizes[3], void* const planes[3],
Brian Salomonde3a7262016-02-03 17:09:00 -0500258 const size_t rowBytes[3], SkYUVColorSpace colorSpace) const {
bsalomonf267c1e2016-02-01 13:16:14 -0800259#if SK_SUPPORT_GPU
260 if (GrTexture* texture = as_IB(this)->peekTexture()) {
261 if (GrTextureToYUVPlanes(texture, sizes, planes, rowBytes, colorSpace)) {
262 return true;
263 }
264 }
265#endif
266 return SkRGBAToYUV(this, sizes, planes, rowBytes, colorSpace);
267}
268
reed871872f2015-06-22 12:48:26 -0700269///////////////////////////////////////////////////////////////////////////////////////////////////
reedf803da12015-01-23 05:58:07 -0800270
reed7fb4f8b2016-03-11 04:33:52 -0800271sk_sp<SkImage> SkImage::MakeFromBitmap(const SkBitmap& bm) {
reed56179002015-07-07 06:11:19 -0700272 SkPixelRef* pr = bm.pixelRef();
halcanary96fcdcc2015-08-27 07:41:13 -0700273 if (nullptr == pr) {
274 return nullptr;
reed56179002015-07-07 06:11:19 -0700275 }
276
reed1ec04d92016-08-05 12:07:41 -0700277 return SkMakeImageFromRasterBitmap(bm, kIfMutable_SkCopyPixelsMode);
reed56179002015-07-07 06:11:19 -0700278}
279
reed3c065112015-07-08 12:46:22 -0700280bool SkImage::asLegacyBitmap(SkBitmap* bitmap, LegacyBitmapMode mode) const {
281 return as_IB(this)->onAsLegacyBitmap(bitmap, mode);
282}
283
284bool SkImage_Base::onAsLegacyBitmap(SkBitmap* bitmap, LegacyBitmapMode mode) const {
285 // As the base-class, all we can do is make a copy (regardless of mode).
286 // Subclasses that want to be more optimal should override.
msarettbe36d592016-06-13 11:25:03 -0700287 SkImageInfo info = this->onImageInfo().makeColorType(kN32_SkColorType)
brianosman69c166d2016-08-17 14:01:05 -0700288 .makeAlphaType(this->alphaType());
reed3c065112015-07-08 12:46:22 -0700289 if (!bitmap->tryAllocPixels(info)) {
290 return false;
291 }
292 if (!this->readPixels(bitmap->info(), bitmap->getPixels(), bitmap->rowBytes(), 0, 0)) {
293 bitmap->reset();
294 return false;
295 }
296
297 if (kRO_LegacyBitmapMode == mode) {
298 bitmap->setImmutable();
299 }
300 return true;
301}
302
reed7fb4f8b2016-03-11 04:33:52 -0800303sk_sp<SkImage> SkImage::MakeFromPicture(sk_sp<SkPicture> picture, const SkISize& dimensions,
304 const SkMatrix* matrix, const SkPaint* paint) {
reedd5b75632015-08-13 09:37:45 -0700305 if (!picture) {
306 return nullptr;
307 }
reed7fb4f8b2016-03-11 04:33:52 -0800308 return MakeFromGenerator(SkImageGenerator::NewFromPicture(dimensions, picture.get(),
309 matrix, paint));
reedd5b75632015-08-13 09:37:45 -0700310}
311
senorblanco5878dbd2016-05-19 14:50:29 -0700312sk_sp<SkImage> SkImage::makeWithFilter(const SkImageFilter* filter, const SkIRect& subset,
313 const SkIRect& clipBounds, SkIRect* outSubset,
314 SkIPoint* offset) const {
brianosman04a44d02016-09-21 09:46:57 -0700315 if (!filter || !outSubset || !offset || !this->bounds().contains(subset)) {
316 return nullptr;
317 }
318 sk_sp<SkSpecialImage> srcSpecialImage = SkSpecialImage::MakeFromImage(
319 subset, sk_ref_sp(const_cast<SkImage*>(this)));
320 if (!srcSpecialImage) {
321 return nullptr;
322 }
senorblanco5878dbd2016-05-19 14:50:29 -0700323
brianosman04a44d02016-09-21 09:46:57 -0700324 SkAutoTUnref<SkImageFilterCache> cache(
325 SkImageFilterCache::Create(SkImageFilterCache::kDefaultTransientSize));
brianosman2a75e5d2016-09-22 07:15:37 -0700326 SkImageFilter::OutputProperties outputProperties(as_IB(this)->onImageInfo().colorSpace());
327 SkImageFilter::Context context(SkMatrix::I(), clipBounds, cache.get(), outputProperties);
328
brianosman04a44d02016-09-21 09:46:57 -0700329 sk_sp<SkSpecialImage> result =
330 filter->filterImage(srcSpecialImage.get(), context, offset);
senorblanco5878dbd2016-05-19 14:50:29 -0700331
brianosman04a44d02016-09-21 09:46:57 -0700332 if (!result) {
333 return nullptr;
334 }
senorblanco5878dbd2016-05-19 14:50:29 -0700335
brianosman04a44d02016-09-21 09:46:57 -0700336 SkIRect fullSize = SkIRect::MakeWH(result->width(), result->height());
senorblanco5878dbd2016-05-19 14:50:29 -0700337#if SK_SUPPORT_GPU
brianosman04a44d02016-09-21 09:46:57 -0700338 if (result->isTextureBacked()) {
339 GrContext* context = result->getContext();
340 sk_sp<GrTexture> texture = result->asTextureRef(context);
341 fullSize = SkIRect::MakeWH(texture->width(), texture->height());
342 }
senorblanco5878dbd2016-05-19 14:50:29 -0700343#endif
brianosman04a44d02016-09-21 09:46:57 -0700344 *outSubset = SkIRect::MakeWH(result->width(), result->height());
345 if (!outSubset->intersect(clipBounds.makeOffset(-offset->x(), -offset->y()))) {
346 return nullptr;
347 }
348 offset->fX += outSubset->x();
349 offset->fY += outSubset->y();
350 // This isn't really a "tight" subset, but includes any texture padding.
351 return result->makeTightSubset(fullSize);
senorblanco5878dbd2016-05-19 14:50:29 -0700352}
353
fmalitaddbbdda2015-08-20 08:47:26 -0700354bool SkImage::isLazyGenerated() const {
355 return as_IB(this)->onIsLazyGenerated();
356}
357
reed9e2ed832016-10-31 05:27:28 -0700358bool SkImage::isAlphaOnly() const {
359 return as_IB(this)->onImageInfo().colorType() == kAlpha_8_SkColorType;
360}
361
reed56179002015-07-07 06:11:19 -0700362//////////////////////////////////////////////////////////////////////////////////////
363
reed8b26b992015-05-07 15:36:17 -0700364#if !SK_SUPPORT_GPU
365
reed7fb4f8b2016-03-11 04:33:52 -0800366sk_sp<SkImage> SkImage::MakeTextureFromPixmap(GrContext*, const SkPixmap&, SkBudgeted budgeted) {
bsalomon0d996862016-03-09 18:44:43 -0800367 return nullptr;
368}
369
cblume33e0cb52016-08-30 12:09:23 -0700370sk_sp<SkImage> MakeTextureFromMipMap(GrContext*, const SkImageInfo&, const GrMipLevel* texels,
371 int mipLevelCount, SkBudgeted, SkSourceGammaTreatment) {
372 return nullptr;
373}
374
reed7fb4f8b2016-03-11 04:33:52 -0800375sk_sp<SkImage> SkImage::MakeFromTexture(GrContext*, const GrBackendTextureDesc&, SkAlphaType,
brianosmandddbe382016-07-20 13:55:39 -0700376 sk_sp<SkColorSpace>, TextureReleaseProc, ReleaseContext) {
halcanary96fcdcc2015-08-27 07:41:13 -0700377 return nullptr;
reed8b26b992015-05-07 15:36:17 -0700378}
379
bsalomon41b952c2016-03-11 06:46:33 -0800380size_t SkImage::getDeferredTextureImageData(const GrContextThreadSafeProxy&,
381 const DeferredTextureImageUsageParams[],
cblume33e0cb52016-08-30 12:09:23 -0700382 int paramCnt, void* buffer,
Brian Osman6c15cc72016-10-17 09:51:37 -0400383 SkColorSpace* dstColorSpace) const {
bsalomon41b952c2016-03-11 06:46:33 -0800384 return 0;
385}
386
387sk_sp<SkImage> SkImage::MakeFromDeferredTextureImageData(GrContext* context, const void*,
388 SkBudgeted) {
389 return nullptr;
390}
391
reed7fb4f8b2016-03-11 04:33:52 -0800392sk_sp<SkImage> SkImage::MakeFromAdoptedTexture(GrContext*, const GrBackendTextureDesc&,
brianosmandddbe382016-07-20 13:55:39 -0700393 SkAlphaType, sk_sp<SkColorSpace>) {
halcanary96fcdcc2015-08-27 07:41:13 -0700394 return nullptr;
bsalomon6dc6f5f2015-06-18 09:12:16 -0700395}
396
reed7fb4f8b2016-03-11 04:33:52 -0800397sk_sp<SkImage> SkImage::MakeFromYUVTexturesCopy(GrContext* ctx, SkYUVColorSpace space,
398 const GrBackendObject yuvTextureHandles[3],
399 const SkISize yuvSizes[3],
brianosmandddbe382016-07-20 13:55:39 -0700400 GrSurfaceOrigin origin,
401 sk_sp<SkColorSpace> imageColorSpace) {
bsalomon8e74f802016-01-30 10:01:40 -0800402 return nullptr;
403}
404
reed7fb4f8b2016-03-11 04:33:52 -0800405sk_sp<SkImage> SkImage::makeTextureImage(GrContext*) const {
406 return nullptr;
407}
408
bsalomon634b4302016-07-12 18:11:17 -0700409sk_sp<SkImage> SkImage::makeNonTextureImage() const {
410 return sk_ref_sp(const_cast<SkImage*>(this));
411}
412
reed7fb4f8b2016-03-11 04:33:52 -0800413#endif
414
415///////////////////////////////////////////////////////////////////////////////////////////////////
416
cblume186d2d42016-06-03 11:17:42 -0700417sk_sp<SkImage> MakeTextureFromMipMap(GrContext*, const SkImageInfo&, const GrMipLevel* texels,
418 int mipLevelCount, SkBudgeted) {
419 return nullptr;
420}
reeda9ca05c2016-08-11 03:55:15 -0700421
422///////////////////////////////////////////////////////////////////////////////////////////////////
423#include "SkImageDeserializer.h"
424
425sk_sp<SkImage> SkImageDeserializer::makeFromData(SkData* data, const SkIRect* subset) {
426 return SkImage::MakeFromEncoded(sk_ref_sp(data), subset);
427}
428sk_sp<SkImage> SkImageDeserializer::makeFromMemory(const void* data, size_t length,
429 const SkIRect* subset) {
430 return SkImage::MakeFromEncoded(SkData::MakeWithCopy(data, length), subset);
431}
reed2d5b7142016-08-17 11:12:33 -0700432
433///////////////////////////////////////////////////////////////////////////////////////////////////
434
435void SkImage_pinAsTexture(const SkImage* image, GrContext* ctx) {
436 SkASSERT(image);
437 SkASSERT(ctx);
438 as_IB(image)->onPinAsTexture(ctx);
439}
440
441void SkImage_unpinAsTexture(const SkImage* image, GrContext* ctx) {
442 SkASSERT(image);
443 SkASSERT(ctx);
444 as_IB(image)->onUnpinAsTexture(ctx);
445}