blob: 2d434aee194f675efdb7373e0ad4461e8ba930a1 [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"
reed5965c8a2015-01-07 18:04:45 -080014#include "SkImageGenerator.h"
scroggo@google.com7def5e12013-05-31 14:00:10 +000015#include "SkImagePriv.h"
reed856e9d92015-09-30 12:21:45 -070016#include "SkImageShader.h"
scroggo@google.com7def5e12013-05-31 14:00:10 +000017#include "SkImage_Base.h"
reed80c772b2015-07-30 18:58:23 -070018#include "SkNextID.h"
reed7fb4f8b2016-03-11 04:33:52 -080019#include "SkPicture.h"
reed56179002015-07-07 06:11:19 -070020#include "SkPixelRef.h"
fmalita2be71252015-09-03 07:17:25 -070021#include "SkPixelSerializer.h"
reed96472de2014-12-10 09:53:42 -080022#include "SkReadPixelsRec.h"
senorblanco5878dbd2016-05-19 14:50:29 -070023#include "SkSpecialImage.h"
reedf8d18742015-01-02 20:45:37 -080024#include "SkString.h"
reed4af267b2014-11-21 08:46:37 -080025#include "SkSurface.h"
reed56179002015-07-07 06:11:19 -070026
bsalomon55812362015-06-10 08:49:28 -070027#if SK_SUPPORT_GPU
28#include "GrTexture.h"
29#include "GrContext.h"
reed56179002015-07-07 06:11:19 -070030#include "SkImage_Gpu.h"
bsalomon55812362015-06-10 08:49:28 -070031#endif
scroggo@google.com7def5e12013-05-31 14:00:10 +000032
reed80c772b2015-07-30 18:58:23 -070033SkImage::SkImage(int width, int height, uint32_t uniqueID)
34 : fWidth(width)
35 , fHeight(height)
36 , fUniqueID(kNeedNewImageUniqueID == uniqueID ? SkNextID::ImageID() : uniqueID)
37{
38 SkASSERT(width > 0);
39 SkASSERT(height > 0);
reed@google.comf6627b72012-07-27 18:02:50 +000040}
41
reed6ceeebd2016-03-09 14:26:26 -080042bool SkImage::peekPixels(SkPixmap* pm) const {
43 SkPixmap tmp;
44 if (!pm) {
45 pm = &tmp;
reed@google.com4f7c6152014-02-06 14:11:56 +000046 }
reed6ceeebd2016-03-09 14:26:26 -080047 return as_IB(this)->onPeekPixels(pm);
reed@google.com4f7c6152014-02-06 14:11:56 +000048}
49
reed6ceeebd2016-03-09 14:26:26 -080050#ifdef SK_SUPPORT_LEGACY_PEEKPIXELS_PARMS
51const void* SkImage::peekPixels(SkImageInfo* info, size_t* rowBytes) const {
52 SkPixmap pm;
53 if (this->peekPixels(&pm)) {
54 if (info) {
55 *info = pm.info();
56 }
57 if (rowBytes) {
58 *rowBytes = pm.rowBytes();
59 }
60 return pm.addr();
61 }
62 return nullptr;
63}
64#endif
65
reed96472de2014-12-10 09:53:42 -080066bool SkImage::readPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes,
reed09553032015-11-23 12:32:16 -080067 int srcX, int srcY, CachingHint chint) const {
reed96472de2014-12-10 09:53:42 -080068 SkReadPixelsRec rec(dstInfo, dstPixels, dstRowBytes, srcX, srcY);
69 if (!rec.trim(this->width(), this->height())) {
reed@google.com4f7c6152014-02-06 14:11:56 +000070 return false;
71 }
reed09553032015-11-23 12:32:16 -080072 return as_IB(this)->onReadPixels(rec.fInfo, rec.fPixels, rec.fRowBytes, rec.fX, rec.fY, chint);
73}
74
75bool SkImage::scalePixels(const SkPixmap& dst, SkFilterQuality quality, CachingHint chint) const {
reed6868c3f2015-11-24 11:44:47 -080076 if (this->width() == dst.width() && this->height() == dst.height()) {
77 return this->readPixels(dst, 0, 0, chint);
78 }
79
reed09553032015-11-23 12:32:16 -080080 // Idea: If/when SkImageGenerator supports a native-scaling API (where the generator itself
81 // can scale more efficiently) we should take advantage of it here.
82 //
83 SkBitmap bm;
84 if (as_IB(this)->getROPixels(&bm, chint)) {
85 bm.lockPixels();
86 SkPixmap pmap;
87 // Note: By calling the pixmap scaler, we never cache the final result, so the chint
88 // is (currently) only being applied to the getROPixels. If we get a request to
89 // also attempt to cache the final (scaled) result, we would add that logic here.
90 //
91 return bm.peekPixels(&pmap) && pmap.scalePixels(dst, quality);
92 }
93 return false;
reed@google.com4f7c6152014-02-06 14:11:56 +000094}
95
reedd6b30312015-09-02 07:06:23 -070096void SkImage::preroll(GrContext* ctx) const {
reedefd50da2015-09-14 11:17:23 -070097 // For now, and to maintain parity w/ previous pixelref behavior, we just force the image
98 // to produce a cached raster-bitmap form, so that drawing to a raster canvas should be fast.
99 //
100 SkBitmap bm;
101 if (as_IB(this)->getROPixels(&bm)) {
102 bm.lockPixels();
103 bm.unlockPixels();
104 }
reedd6b30312015-09-02 07:06:23 -0700105}
106
reed88d064d2015-10-12 11:30:02 -0700107///////////////////////////////////////////////////////////////////////////////////////////////////
108
reed5671c5b2016-03-09 14:47:34 -0800109sk_sp<SkShader> SkImage::makeShader(SkShader::TileMode tileX, SkShader::TileMode tileY,
110 const SkMatrix* localMatrix) const {
111 return SkImageShader::Make(this, tileX, tileY, localMatrix);
piotaixrcef04f82014-07-14 07:48:04 -0700112}
113
reed5671c5b2016-03-09 14:47:34 -0800114#ifdef SK_SUPPORT_LEGACY_CREATESHADER_PTR
115SkShader* SkImage::newShader(SkShader::TileMode tileX, SkShader::TileMode tileY,
116 const SkMatrix* localMatrix) const {
117 return this->makeShader(tileX, tileY, localMatrix).release();
118}
119#endif
120
scroggo@google.com7def5e12013-05-31 14:00:10 +0000121SkData* SkImage::encode(SkImageEncoder::Type type, int quality) const {
122 SkBitmap bm;
123 if (as_IB(this)->getROPixels(&bm)) {
124 return SkImageEncoder::EncodeData(bm, type, quality);
125 }
halcanary96fcdcc2015-08-27 07:41:13 -0700126 return nullptr;
junov@chromium.orgda904742013-05-01 22:38:16 +0000127}
reed@google.com4f7c6152014-02-06 14:11:56 +0000128
halcanarya2e05672015-12-09 03:56:02 -0800129SkData* SkImage::encode(SkPixelSerializer* serializer) const {
halcanaryf2848b62015-12-10 12:40:23 -0800130 SkAutoTUnref<SkPixelSerializer> defaultSerializer;
131 SkPixelSerializer* effectiveSerializer = serializer;
132 if (!effectiveSerializer) {
133 defaultSerializer.reset(SkImageEncoder::CreatePixelSerializer());
134 SkASSERT(defaultSerializer.get());
135 effectiveSerializer = defaultSerializer.get();
136 }
bungemanffae30d2016-08-03 13:32:32 -0700137 sk_sp<SkData> encoded(this->refEncoded());
reedc9e190d2015-09-28 09:58:41 -0700138 if (encoded && effectiveSerializer->useEncodedData(encoded->data(), encoded->size())) {
mtklein18300a32016-03-16 13:53:35 -0700139 return encoded.release();
fmalita2be71252015-09-03 07:17:25 -0700140 }
141
142 SkBitmap bm;
143 SkAutoPixmapUnlock apu;
144 if (as_IB(this)->getROPixels(&bm) && bm.requestLock(&apu)) {
halcanary6b280172015-12-07 12:42:24 -0800145 return effectiveSerializer->encode(apu.pixmap());
fmalita2be71252015-09-03 07:17:25 -0700146 }
147
148 return nullptr;
149}
150
reed871872f2015-06-22 12:48:26 -0700151SkData* SkImage::refEncoded() const {
reed05dd2512016-01-05 09:16:19 -0800152 GrContext* ctx = nullptr; // should we allow the caller to pass in a ctx?
153 return as_IB(this)->onRefEncoded(ctx);
reed871872f2015-06-22 12:48:26 -0700154}
155
reed7fb4f8b2016-03-11 04:33:52 -0800156sk_sp<SkImage> SkImage::MakeFromEncoded(sk_sp<SkData> encoded, const SkIRect* subset) {
halcanary96fcdcc2015-08-27 07:41:13 -0700157 if (nullptr == encoded || 0 == encoded->size()) {
158 return nullptr;
reed5965c8a2015-01-07 18:04:45 -0800159 }
reed7fb4f8b2016-03-11 04:33:52 -0800160 SkImageGenerator* generator = SkImageGenerator::NewFromEncoded(encoded.get());
161 return SkImage::MakeFromGenerator(generator, subset);
reed5965c8a2015-01-07 18:04:45 -0800162}
163
reedf8d18742015-01-02 20:45:37 -0800164const char* SkImage::toString(SkString* str) const {
165 str->appendf("image: (id:%d (%d, %d) %s)", this->uniqueID(), this->width(), this->height(),
166 this->isOpaque() ? "opaque" : "");
167 return str->c_str();
168}
169
reed7fb4f8b2016-03-11 04:33:52 -0800170sk_sp<SkImage> SkImage::makeSubset(const SkIRect& subset) const {
reed7b6945b2015-09-24 00:50:58 -0700171 if (subset.isEmpty()) {
172 return nullptr;
173 }
174
175 const SkIRect bounds = SkIRect::MakeWH(this->width(), this->height());
176 if (!bounds.contains(subset)) {
177 return nullptr;
178 }
179
180 // optimization : return self if the subset == our bounds
181 if (bounds == subset) {
reed7fb4f8b2016-03-11 04:33:52 -0800182 return sk_ref_sp(const_cast<SkImage*>(this));
reed7b6945b2015-09-24 00:50:58 -0700183 }
reed7fb4f8b2016-03-11 04:33:52 -0800184 return as_IB(this)->onMakeSubset(subset);
reedf803da12015-01-23 05:58:07 -0800185}
186
bsalomon55812362015-06-10 08:49:28 -0700187#if SK_SUPPORT_GPU
188
189GrTexture* SkImage::getTexture() const {
reed85d91782015-09-10 14:33:38 -0700190 return as_IB(this)->peekTexture();
bsalomon55812362015-06-10 08:49:28 -0700191}
192
bsalomon84a4e5a2016-02-29 11:41:52 -0800193bool SkImage::isTextureBacked() const { return SkToBool(as_IB(this)->peekTexture()); }
bsalomon55812362015-06-10 08:49:28 -0700194
bsalomonc49e8682015-06-30 11:37:35 -0700195GrBackendObject SkImage::getTextureHandle(bool flushPendingGrContextIO) const {
bsalomon84a4e5a2016-02-29 11:41:52 -0800196 GrTexture* texture = as_IB(this)->peekTexture();
bsalomon55812362015-06-10 08:49:28 -0700197 if (texture) {
198 GrContext* context = texture->getContext();
199 if (context) {
bsalomonc49e8682015-06-30 11:37:35 -0700200 if (flushPendingGrContextIO) {
201 context->prepareSurfaceForExternalIO(texture);
bsalomon55812362015-06-10 08:49:28 -0700202 }
203 }
204 return texture->getTextureHandle();
205 }
206 return 0;
207}
208
209#else
210
halcanary96fcdcc2015-08-27 07:41:13 -0700211GrTexture* SkImage::getTexture() const { return nullptr; }
bsalomon55812362015-06-10 08:49:28 -0700212
213bool SkImage::isTextureBacked() const { return false; }
214
bsalomonc49e8682015-06-30 11:37:35 -0700215GrBackendObject SkImage::getTextureHandle(bool) const { return 0; }
bsalomon55812362015-06-10 08:49:28 -0700216
217#endif
218
reed@google.com4f7c6152014-02-06 14:11:56 +0000219///////////////////////////////////////////////////////////////////////////////
220
221static bool raster_canvas_supports(const SkImageInfo& info) {
reede5ea5002014-09-03 11:54:58 -0700222 switch (info.colorType()) {
commit-bot@chromium.org28fcae22014-04-11 17:15:40 +0000223 case kN32_SkColorType:
reede5ea5002014-09-03 11:54:58 -0700224 return kUnpremul_SkAlphaType != info.alphaType();
reed@google.com4f7c6152014-02-06 14:11:56 +0000225 case kRGB_565_SkColorType:
226 return true;
227 case kAlpha_8_SkColorType:
228 return true;
229 default:
230 break;
231 }
232 return false;
233}
234
reedaf3fbfc2015-10-04 11:28:36 -0700235SkImage_Base::SkImage_Base(int width, int height, uint32_t uniqueID)
fmalita3b0d5322015-09-18 08:07:31 -0700236 : INHERITED(width, height, uniqueID)
fmalita3b0d5322015-09-18 08:07:31 -0700237 , fAddedToCache(false)
reedaf3fbfc2015-10-04 11:28:36 -0700238{}
fmalita3b0d5322015-09-18 08:07:31 -0700239
240SkImage_Base::~SkImage_Base() {
241 if (fAddedToCache.load()) {
242 SkNotifyBitmapGenIDIsStale(this->uniqueID());
243 }
244}
245
reed96472de2014-12-10 09:53:42 -0800246bool SkImage_Base::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes,
reed09553032015-11-23 12:32:16 -0800247 int srcX, int srcY, CachingHint) const {
reed96472de2014-12-10 09:53:42 -0800248 if (!raster_canvas_supports(dstInfo)) {
249 return false;
reed@google.com4f7c6152014-02-06 14:11:56 +0000250 }
251
reed96472de2014-12-10 09:53:42 -0800252 SkBitmap bm;
253 bm.installPixels(dstInfo, dstPixels, dstRowBytes);
254 SkCanvas canvas(bm);
reed@google.com4f7c6152014-02-06 14:11:56 +0000255
256 SkPaint paint;
reed96472de2014-12-10 09:53:42 -0800257 paint.setXfermodeMode(SkXfermode::kSrc_Mode);
258 canvas.drawImage(this, -SkIntToScalar(srcX), -SkIntToScalar(srcY), &paint);
reed@google.com4f7c6152014-02-06 14:11:56 +0000259
reed@google.com4f7c6152014-02-06 14:11:56 +0000260 return true;
261}
reedf803da12015-01-23 05:58:07 -0800262
reed871872f2015-06-22 12:48:26 -0700263///////////////////////////////////////////////////////////////////////////////////////////////////
264
reed09553032015-11-23 12:32:16 -0800265bool SkImage::readPixels(const SkPixmap& pmap, int srcX, int srcY, CachingHint chint) const {
266 return this->readPixels(pmap.info(), pmap.writable_addr(), pmap.rowBytes(), srcX, srcY, chint);
reed871872f2015-06-22 12:48:26 -0700267}
268
bsalomonf267c1e2016-02-01 13:16:14 -0800269#if SK_SUPPORT_GPU
270#include "GrTextureToYUVPlanes.h"
271#endif
272
273#include "SkRGBAToYUV.h"
274
275bool SkImage::readYUV8Planes(const SkISize sizes[3], void* const planes[3],
Brian Salomonde3a7262016-02-03 17:09:00 -0500276 const size_t rowBytes[3], SkYUVColorSpace colorSpace) const {
bsalomonf267c1e2016-02-01 13:16:14 -0800277#if SK_SUPPORT_GPU
278 if (GrTexture* texture = as_IB(this)->peekTexture()) {
279 if (GrTextureToYUVPlanes(texture, sizes, planes, rowBytes, colorSpace)) {
280 return true;
281 }
282 }
283#endif
284 return SkRGBAToYUV(this, sizes, planes, rowBytes, colorSpace);
285}
286
reed871872f2015-06-22 12:48:26 -0700287///////////////////////////////////////////////////////////////////////////////////////////////////
reedf803da12015-01-23 05:58:07 -0800288
reed7fb4f8b2016-03-11 04:33:52 -0800289sk_sp<SkImage> SkImage::MakeFromBitmap(const SkBitmap& bm) {
reed56179002015-07-07 06:11:19 -0700290 SkPixelRef* pr = bm.pixelRef();
halcanary96fcdcc2015-08-27 07:41:13 -0700291 if (nullptr == pr) {
292 return nullptr;
reed56179002015-07-07 06:11:19 -0700293 }
294
295#if SK_SUPPORT_GPU
296 if (GrTexture* tex = pr->getTexture()) {
297 SkAutoTUnref<GrTexture> unrefCopy;
298 if (!bm.isImmutable()) {
bsalomon5ec26ae2016-02-25 08:33:02 -0800299 tex = GrDeepCopyTexture(tex, SkBudgeted::kNo);
halcanary96fcdcc2015-08-27 07:41:13 -0700300 if (nullptr == tex) {
301 return nullptr;
reed56179002015-07-07 06:11:19 -0700302 }
303 unrefCopy.reset(tex);
304 }
305 const SkImageInfo info = bm.info();
reed7fb4f8b2016-03-11 04:33:52 -0800306 return sk_make_sp<SkImage_Gpu>(info.width(), info.height(), bm.getGenerationID(),
brianosmandddbe382016-07-20 13:55:39 -0700307 info.alphaType(), tex, sk_ref_sp(info.colorSpace()),
308 SkBudgeted::kNo);
reed56179002015-07-07 06:11:19 -0700309 }
310#endif
311
reed1ec04d92016-08-05 12:07:41 -0700312 return SkMakeImageFromRasterBitmap(bm, kIfMutable_SkCopyPixelsMode);
reed56179002015-07-07 06:11:19 -0700313}
314
reed3c065112015-07-08 12:46:22 -0700315bool SkImage::asLegacyBitmap(SkBitmap* bitmap, LegacyBitmapMode mode) const {
316 return as_IB(this)->onAsLegacyBitmap(bitmap, mode);
317}
318
319bool SkImage_Base::onAsLegacyBitmap(SkBitmap* bitmap, LegacyBitmapMode mode) const {
320 // As the base-class, all we can do is make a copy (regardless of mode).
321 // Subclasses that want to be more optimal should override.
msarettbe36d592016-06-13 11:25:03 -0700322 SkImageInfo info = this->onImageInfo().makeColorType(kN32_SkColorType)
323 .makeAlphaType(this->isOpaque() ? kOpaque_SkAlphaType : kPremul_SkAlphaType);
reed3c065112015-07-08 12:46:22 -0700324 if (!bitmap->tryAllocPixels(info)) {
325 return false;
326 }
327 if (!this->readPixels(bitmap->info(), bitmap->getPixels(), bitmap->rowBytes(), 0, 0)) {
328 bitmap->reset();
329 return false;
330 }
331
332 if (kRO_LegacyBitmapMode == mode) {
333 bitmap->setImmutable();
334 }
335 return true;
336}
337
reed7fb4f8b2016-03-11 04:33:52 -0800338sk_sp<SkImage> SkImage::MakeFromPicture(sk_sp<SkPicture> picture, const SkISize& dimensions,
339 const SkMatrix* matrix, const SkPaint* paint) {
reedd5b75632015-08-13 09:37:45 -0700340 if (!picture) {
341 return nullptr;
342 }
reed7fb4f8b2016-03-11 04:33:52 -0800343 return MakeFromGenerator(SkImageGenerator::NewFromPicture(dimensions, picture.get(),
344 matrix, paint));
reedd5b75632015-08-13 09:37:45 -0700345}
346
senorblanco5878dbd2016-05-19 14:50:29 -0700347sk_sp<SkImage> SkImage::makeWithFilter(const SkImageFilter* filter, const SkIRect& subset,
348 const SkIRect& clipBounds, SkIRect* outSubset,
349 SkIPoint* offset) const {
350 if (!filter || !outSubset || !offset || !this->bounds().contains(subset)) {
351 return nullptr;
352 }
353 sk_sp<SkSpecialImage> srcSpecialImage = SkSpecialImage::MakeFromImage(
354 subset, sk_ref_sp(const_cast<SkImage*>(this)));
355 if (!srcSpecialImage) {
356 return nullptr;
357 }
358
359 // FIXME: build a cache here.
360 SkImageFilter::Context context(SkMatrix::I(), clipBounds, nullptr);
361 sk_sp<SkSpecialImage> result =
362 filter->filterImage(srcSpecialImage.get(), context, offset);
363
364 if (!result) {
365 return nullptr;
366 }
367
368 SkIRect fullSize = SkIRect::MakeWH(result->width(), result->height());
369#if SK_SUPPORT_GPU
370 if (result->isTextureBacked()) {
371 GrContext* context = result->getContext();
372 sk_sp<GrTexture> texture = result->asTextureRef(context);
373 fullSize = SkIRect::MakeWH(texture->width(), texture->height());
374 }
375#endif
376 *outSubset = SkIRect::MakeWH(result->width(), result->height());
377 if (!outSubset->intersect(clipBounds.makeOffset(-offset->x(), -offset->y()))) {
378 return nullptr;
379 }
380 offset->fX += outSubset->x();
381 offset->fY += outSubset->y();
382 // This isn't really a "tight" subset, but includes any texture padding.
383 return result->makeTightSubset(fullSize);
384}
385
fmalitaddbbdda2015-08-20 08:47:26 -0700386bool SkImage::isLazyGenerated() const {
387 return as_IB(this)->onIsLazyGenerated();
388}
389
reed56179002015-07-07 06:11:19 -0700390//////////////////////////////////////////////////////////////////////////////////////
391
reed8b26b992015-05-07 15:36:17 -0700392#if !SK_SUPPORT_GPU
393
reed7fb4f8b2016-03-11 04:33:52 -0800394sk_sp<SkImage> SkImage::MakeTextureFromPixmap(GrContext*, const SkPixmap&, SkBudgeted budgeted) {
bsalomon0d996862016-03-09 18:44:43 -0800395 return nullptr;
396}
397
reed7fb4f8b2016-03-11 04:33:52 -0800398sk_sp<SkImage> SkImage::MakeFromTexture(GrContext*, const GrBackendTextureDesc&, SkAlphaType,
brianosmandddbe382016-07-20 13:55:39 -0700399 sk_sp<SkColorSpace>, TextureReleaseProc, ReleaseContext) {
halcanary96fcdcc2015-08-27 07:41:13 -0700400 return nullptr;
reed8b26b992015-05-07 15:36:17 -0700401}
402
bsalomon41b952c2016-03-11 06:46:33 -0800403size_t SkImage::getDeferredTextureImageData(const GrContextThreadSafeProxy&,
404 const DeferredTextureImageUsageParams[],
halcanarye9d55c52016-08-09 17:46:25 -0700405 int paramCnt, void* buffer) const {
bsalomon41b952c2016-03-11 06:46:33 -0800406 return 0;
407}
408
409sk_sp<SkImage> SkImage::MakeFromDeferredTextureImageData(GrContext* context, const void*,
410 SkBudgeted) {
411 return nullptr;
412}
413
reed7fb4f8b2016-03-11 04:33:52 -0800414sk_sp<SkImage> SkImage::MakeFromAdoptedTexture(GrContext*, const GrBackendTextureDesc&,
brianosmandddbe382016-07-20 13:55:39 -0700415 SkAlphaType, sk_sp<SkColorSpace>) {
halcanary96fcdcc2015-08-27 07:41:13 -0700416 return nullptr;
bsalomon6dc6f5f2015-06-18 09:12:16 -0700417}
418
reed7fb4f8b2016-03-11 04:33:52 -0800419sk_sp<SkImage> SkImage::MakeFromYUVTexturesCopy(GrContext* ctx, SkYUVColorSpace space,
420 const GrBackendObject yuvTextureHandles[3],
421 const SkISize yuvSizes[3],
brianosmandddbe382016-07-20 13:55:39 -0700422 GrSurfaceOrigin origin,
423 sk_sp<SkColorSpace> imageColorSpace) {
bsalomon8e74f802016-01-30 10:01:40 -0800424 return nullptr;
425}
426
reed7fb4f8b2016-03-11 04:33:52 -0800427sk_sp<SkImage> SkImage::makeTextureImage(GrContext*) const {
428 return nullptr;
429}
430
bsalomon634b4302016-07-12 18:11:17 -0700431sk_sp<SkImage> SkImage::makeNonTextureImage() const {
432 return sk_ref_sp(const_cast<SkImage*>(this));
433}
434
reed7fb4f8b2016-03-11 04:33:52 -0800435#endif
436
437///////////////////////////////////////////////////////////////////////////////////////////////////
438
439#ifdef SK_SUPPORT_LEGACY_IMAGEFACTORY
440SkImage* SkImage::NewRasterCopy(const Info& info, const void* pixels, size_t rowBytes,
441 SkColorTable* ctable) {
442 return MakeRasterCopy(SkPixmap(info, pixels, rowBytes, ctable)).release();
443}
444
445SkImage* SkImage::NewRasterData(const Info& info, SkData* pixels, size_t rowBytes) {
446 return MakeRasterData(info, sk_ref_sp(pixels), rowBytes).release();
447}
448
449SkImage* SkImage::NewFromRaster(const Info& info, const void* pixels, size_t rowBytes,
450 RasterReleaseProc proc, ReleaseContext releasectx) {
451 return MakeFromRaster(SkPixmap(info, pixels, rowBytes), proc, releasectx).release();
452}
453
454SkImage* SkImage::NewFromBitmap(const SkBitmap& bm) {
455 return MakeFromBitmap(bm).release();
456}
457
458SkImage* SkImage::NewFromGenerator(SkImageGenerator* gen, const SkIRect* subset) {
459 return MakeFromGenerator(gen, subset).release();
460}
461
462SkImage* SkImage::NewFromEncoded(SkData* encoded, const SkIRect* subset) {
463 return MakeFromEncoded(sk_ref_sp(encoded), subset).release();
464}
465
466SkImage* SkImage::NewFromTexture(GrContext* ctx, const GrBackendTextureDesc& desc, SkAlphaType at,
467 TextureReleaseProc proc, ReleaseContext releasectx) {
468 return MakeFromTexture(ctx, desc, at, proc, releasectx).release();
469}
470
471SkImage* SkImage::NewFromAdoptedTexture(GrContext* ctx, const GrBackendTextureDesc& desc,
472 SkAlphaType at) {
473 return MakeFromAdoptedTexture(ctx, desc, at).release();
474}
475
reed7fb4f8b2016-03-11 04:33:52 -0800476SkImage* SkImage::NewFromYUVTexturesCopy(GrContext* ctx, SkYUVColorSpace space,
477 const GrBackendObject yuvTextureHandles[3],
478 const SkISize yuvSizes[3],
479 GrSurfaceOrigin origin) {
480 return MakeFromYUVTexturesCopy(ctx, space, yuvTextureHandles, yuvSizes, origin).release();
481}
482
483SkImage* SkImage::NewFromPicture(const SkPicture* picture, const SkISize& dimensions,
484 const SkMatrix* matrix, const SkPaint* paint) {
485 return MakeFromPicture(sk_ref_sp(const_cast<SkPicture*>(picture)), dimensions,
486 matrix, paint).release();
487}
488
489SkImage* SkImage::NewTextureFromPixmap(GrContext* ctx, const SkPixmap& pmap, SkBudgeted budgeted) {
490 return MakeTextureFromPixmap(ctx, pmap, budgeted).release();
491}
bsalomon41b952c2016-03-11 06:46:33 -0800492
493SkImage* SkImage::NewFromDeferredTextureImageData(GrContext* ctx, const void* data,
494 SkBudgeted budgeted) {
495 return MakeFromDeferredTextureImageData(ctx, data, budgeted).release();
496}
reed8b26b992015-05-07 15:36:17 -0700497#endif
cblume186d2d42016-06-03 11:17:42 -0700498
499sk_sp<SkImage> MakeTextureFromMipMap(GrContext*, const SkImageInfo&, const GrMipLevel* texels,
500 int mipLevelCount, SkBudgeted) {
501 return nullptr;
502}