blob: 92a300fbdecf77f5321ca4d22527869fdc181dd3 [file] [log] [blame]
reed@google.comc9062042012-07-30 18:06:00 +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
Brian Salomonab32f652019-05-10 14:24:50 -04008#include <atomic>
Brian Salomon201700f2019-05-17 12:05:44 -04009#include <cmath>
Mike Kleinc0bd9f92019-04-23 12:05:21 -050010#include "include/core/SkCanvas.h"
11#include "include/core/SkFontLCDConfig.h"
12#include "include/gpu/GrBackendSurface.h"
Brian Salomonab32f652019-05-10 14:24:50 -040013#include "src/core/SkAutoPixmapStorage.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050014#include "src/core/SkImagePriv.h"
15#include "src/image/SkSurface_Base.h"
Robert Phillips8caf85f2018-04-05 09:30:38 -040016
reed4a8126e2014-09-22 07:29:03 -070017static SkPixelGeometry compute_default_geometry() {
18 SkFontLCDConfig::LCDOrder order = SkFontLCDConfig::GetSubpixelOrder();
19 if (SkFontLCDConfig::kNONE_LCDOrder == order) {
20 return kUnknown_SkPixelGeometry;
21 } else {
22 // Bit0 is RGB(0), BGR(1)
23 // Bit1 is H(0), V(1)
24 const SkPixelGeometry gGeo[] = {
25 kRGB_H_SkPixelGeometry,
26 kBGR_H_SkPixelGeometry,
27 kRGB_V_SkPixelGeometry,
28 kBGR_V_SkPixelGeometry,
29 };
30 int index = 0;
31 if (SkFontLCDConfig::kBGR_LCDOrder == order) {
32 index |= 1;
33 }
34 if (SkFontLCDConfig::kVertical_LCDOrientation == SkFontLCDConfig::GetSubpixelOrientation()){
35 index |= 2;
36 }
37 return gGeo[index];
38 }
39}
40
41SkSurfaceProps::SkSurfaceProps() : fFlags(0), fPixelGeometry(kUnknown_SkPixelGeometry) {}
42
43SkSurfaceProps::SkSurfaceProps(InitType) : fFlags(0), fPixelGeometry(compute_default_geometry()) {}
44
45SkSurfaceProps::SkSurfaceProps(uint32_t flags, InitType)
46 : fFlags(flags)
47 , fPixelGeometry(compute_default_geometry())
48{}
49
50SkSurfaceProps::SkSurfaceProps(uint32_t flags, SkPixelGeometry pg)
51 : fFlags(flags), fPixelGeometry(pg)
52{}
53
reed4af267b2014-11-21 08:46:37 -080054SkSurfaceProps::SkSurfaceProps(const SkSurfaceProps& other)
55 : fFlags(other.fFlags)
56 , fPixelGeometry(other.fPixelGeometry)
57{}
58
reed@google.com889b09e2012-07-27 21:10:42 +000059///////////////////////////////////////////////////////////////////////////////
60
reed4a8126e2014-09-22 07:29:03 -070061SkSurface_Base::SkSurface_Base(int width, int height, const SkSurfaceProps* props)
Robert Phillipsa54ccb22017-01-31 07:40:33 -050062 : INHERITED(width, height, props) {
reed@google.com9ea5a3b2012-07-30 21:03:46 +000063}
reed@google.com889b09e2012-07-27 21:10:42 +000064
reed4a8126e2014-09-22 07:29:03 -070065SkSurface_Base::SkSurface_Base(const SkImageInfo& info, const SkSurfaceProps* props)
Robert Phillipsa54ccb22017-01-31 07:40:33 -050066 : INHERITED(info, props) {
reed@google.com1360c522014-01-08 21:25:26 +000067}
68
reed@google.com9ea5a3b2012-07-30 21:03:46 +000069SkSurface_Base::~SkSurface_Base() {
reed@google.com97af1a62012-08-28 12:19:02 +000070 // in case the canvas outsurvives us, we null the callback
71 if (fCachedCanvas) {
halcanary96fcdcc2015-08-27 07:41:13 -070072 fCachedCanvas->setSurfaceBase(nullptr);
reed@google.com97af1a62012-08-28 12:19:02 +000073 }
reed@google.com9ea5a3b2012-07-30 21:03:46 +000074}
reed@google.com889b09e2012-07-27 21:10:42 +000075
Robert Phillips8caf85f2018-04-05 09:30:38 -040076GrBackendTexture SkSurface_Base::onGetBackendTexture(BackendHandleAccess) {
77 return GrBackendTexture(); // invalid
78}
79
80GrBackendRenderTarget SkSurface_Base::onGetBackendRenderTarget(BackendHandleAccess) {
81 return GrBackendRenderTarget(); // invalid
82}
83
reed4a8126e2014-09-22 07:29:03 -070084void SkSurface_Base::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkPaint* paint) {
Robert Phillipsac6b1fa2017-03-20 08:38:50 -040085 auto image = this->makeImageSnapshot();
reed@google.com889b09e2012-07-27 21:10:42 +000086 if (image) {
piotaixrb5fae932014-09-24 13:03:30 -070087 canvas->drawImage(image, x, y, paint);
reed@google.com889b09e2012-07-27 21:10:42 +000088 }
89}
90
Brian Salomon201700f2019-05-17 12:05:44 -040091void SkSurface_Base::onAsyncReadPixels(const SkImageInfo& info, int srcX, int srcY,
92 ReadPixelsCallback callback, ReadPixelsContext context) {
93 SkASSERT(SkIRect::MakeWH(this->width(), this->height())
94 .contains(SkIRect::MakeXYWH(srcX, srcY, info.width(), info.height())));
Brian Salomonab32f652019-05-10 14:24:50 -040095 SkAutoPixmapStorage pm;
96 pm.alloc(info);
Brian Salomon201700f2019-05-17 12:05:44 -040097 if (this->readPixels(pm, srcX, srcY)) {
Brian Salomonab32f652019-05-10 14:24:50 -040098 callback(context, pm.addr(), pm.rowBytes());
99 } else {
100 callback(context, nullptr, 0);
101 }
102}
103
reedc83a2972015-07-16 07:40:45 -0700104bool SkSurface_Base::outstandingImageSnapshot() const {
105 return fCachedImage && !fCachedImage->unique();
106}
107
commit-bot@chromium.orgc4c98702013-04-22 14:28:01 +0000108void SkSurface_Base::aboutToDraw(ContentChangeMode mode) {
reed@google.com97af1a62012-08-28 12:19:02 +0000109 this->dirtyGenerationID();
110
commit-bot@chromium.org28361fa2014-03-28 16:08:05 +0000111 SkASSERT(!fCachedCanvas || fCachedCanvas->getSurfaceBase() == this);
reed@google.com97af1a62012-08-28 12:19:02 +0000112
bsalomon49f085d2014-09-05 13:34:00 -0700113 if (fCachedImage) {
reed@google.com97af1a62012-08-28 12:19:02 +0000114 // the surface may need to fork its backend, if its sharing it with
115 // the cached image. Note: we only call if there is an outstanding owner
116 // on the image (besides us).
reed26e0e582015-07-29 11:44:52 -0700117 bool unique = fCachedImage->unique();
118 if (!unique) {
commit-bot@chromium.orgc4c98702013-04-22 14:28:01 +0000119 this->onCopyOnWrite(mode);
reed@google.com97af1a62012-08-28 12:19:02 +0000120 }
121
122 // regardless of copy-on-write, we must drop our cached image now, so
123 // that the next request will get our new contents.
Robert Phillipsa54ccb22017-01-31 07:40:33 -0500124 fCachedImage.reset();
reed26e0e582015-07-29 11:44:52 -0700125
126 if (unique) {
127 // Our content isn't held by any image now, so we can consider that content mutable.
128 // Raster surfaces need to be told it's safe to consider its pixels mutable again.
129 // We make this call after the ->unref() so the subclass can assert there are no images.
130 this->onRestoreBackingMutability();
131 }
commit-bot@chromium.org28361fa2014-03-28 16:08:05 +0000132 } else if (kDiscard_ContentChangeMode == mode) {
133 this->onDiscard();
reed@google.com97af1a62012-08-28 12:19:02 +0000134 }
135}
136
137uint32_t SkSurface_Base::newGenerationID() {
commit-bot@chromium.org28361fa2014-03-28 16:08:05 +0000138 SkASSERT(!fCachedCanvas || fCachedCanvas->getSurfaceBase() == this);
Mike Klein0ec1c572018-12-04 11:52:51 -0500139 static std::atomic<uint32_t> nextID{1};
140 return nextID++;
reed@google.com97af1a62012-08-28 12:19:02 +0000141}
142
reed@google.com889b09e2012-07-27 21:10:42 +0000143static SkSurface_Base* asSB(SkSurface* surface) {
144 return static_cast<SkSurface_Base*>(surface);
145}
146
147///////////////////////////////////////////////////////////////////////////////
148
reed4a8126e2014-09-22 07:29:03 -0700149SkSurface::SkSurface(int width, int height, const SkSurfaceProps* props)
150 : fProps(SkSurfacePropsCopyOrDefault(props)), fWidth(width), fHeight(height)
151{
reedb2497c22014-12-31 12:31:43 -0800152 SkASSERT(fWidth > 0);
153 SkASSERT(fHeight > 0);
reed@google.com1360c522014-01-08 21:25:26 +0000154 fGenerationID = 0;
155}
156
reed4a8126e2014-09-22 07:29:03 -0700157SkSurface::SkSurface(const SkImageInfo& info, const SkSurfaceProps* props)
158 : fProps(SkSurfacePropsCopyOrDefault(props)), fWidth(info.width()), fHeight(info.height())
159{
reedb2497c22014-12-31 12:31:43 -0800160 SkASSERT(fWidth > 0);
161 SkASSERT(fHeight > 0);
reed@google.com889b09e2012-07-27 21:10:42 +0000162 fGenerationID = 0;
163}
164
reed@google.com97af1a62012-08-28 12:19:02 +0000165uint32_t SkSurface::generationID() {
166 if (0 == fGenerationID) {
167 fGenerationID = asSB(this)->newGenerationID();
168 }
169 return fGenerationID;
170}
171
commit-bot@chromium.orgc4c98702013-04-22 14:28:01 +0000172void SkSurface::notifyContentWillChange(ContentChangeMode mode) {
173 asSB(this)->aboutToDraw(mode);
reed@google.com97af1a62012-08-28 12:19:02 +0000174}
175
reed@google.com9ea5a3b2012-07-30 21:03:46 +0000176SkCanvas* SkSurface::getCanvas() {
177 return asSB(this)->getCachedCanvas();
reed@google.com889b09e2012-07-27 21:10:42 +0000178}
179
Robert Phillipsac6b1fa2017-03-20 08:38:50 -0400180sk_sp<SkImage> SkSurface::makeImageSnapshot() {
181 return asSB(this)->refCachedImage();
reed@google.com889b09e2012-07-27 21:10:42 +0000182}
183
Mike Reed114bde82018-11-21 09:12:09 -0500184sk_sp<SkImage> SkSurface::makeImageSnapshot(const SkIRect& srcBounds) {
185 const SkIRect surfBounds = { 0, 0, fWidth, fHeight };
186 SkIRect bounds = srcBounds;
187 if (!bounds.intersect(surfBounds)) {
188 return nullptr;
189 }
190 SkASSERT(!bounds.isEmpty());
191 if (bounds == surfBounds) {
192 return this->makeImageSnapshot();
193 } else {
194 return asSB(this)->onNewImageSnapshot(&bounds);
195 }
196}
197
reede8f30622016-03-23 18:59:25 -0700198sk_sp<SkSurface> SkSurface::makeSurface(const SkImageInfo& info) {
mike@reedtribe.orgb9476252012-11-15 02:37:45 +0000199 return asSB(this)->onNewSurface(info);
reed@google.com889b09e2012-07-27 21:10:42 +0000200}
201
202void SkSurface::draw(SkCanvas* canvas, SkScalar x, SkScalar y,
203 const SkPaint* paint) {
204 return asSB(this)->onDraw(canvas, x, y, paint);
205}
commit-bot@chromium.orgc3bd8af2014-02-13 17:14:46 +0000206
reed6ceeebd2016-03-09 14:26:26 -0800207bool SkSurface::peekPixels(SkPixmap* pmap) {
208 return this->getCanvas()->peekPixels(pmap);
commit-bot@chromium.orgc3bd8af2014-02-13 17:14:46 +0000209}
reed4a8126e2014-09-22 07:29:03 -0700210
Mike Reed353196f2017-07-21 11:01:18 -0400211bool SkSurface::readPixels(const SkPixmap& pm, int srcX, int srcY) {
212 return this->getCanvas()->readPixels(pm, srcX, srcY);
213}
214
reed7543aa22014-12-09 14:39:44 -0800215bool SkSurface::readPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes,
216 int srcX, int srcY) {
Mike Reed353196f2017-07-21 11:01:18 -0400217 return this->readPixels({dstInfo, dstPixels, dstRowBytes}, srcX, srcY);
218}
219
220bool SkSurface::readPixels(const SkBitmap& bitmap, int srcX, int srcY) {
221 SkPixmap pm;
222 return bitmap.peekPixels(&pm) && this->readPixels(pm, srcX, srcY);
reed7543aa22014-12-09 14:39:44 -0800223}
224
Brian Salomon201700f2019-05-17 12:05:44 -0400225void SkSurface::asyncRescaleAndReadPixels(const SkImageInfo& info, const SkIRect& srcRect,
226 RescaleGamma rescaleGamma, SkFilterQuality rescaleQuality,
227 ReadPixelsCallback callback, ReadPixelsContext context) {
Brian Salomonab32f652019-05-10 14:24:50 -0400228 if (!SkIRect::MakeWH(this->width(), this->height()).contains(srcRect) ||
Brian Salomon201700f2019-05-17 12:05:44 -0400229 !SkImageInfoIsValid(info)) {
Brian Salomonab32f652019-05-10 14:24:50 -0400230 callback(context, nullptr, 0);
231 return;
232 }
Brian Salomon201700f2019-05-17 12:05:44 -0400233 int srcW = srcRect.width();
234 int srcH = srcRect.height();
235 float sx = (float)info.width() / srcW;
236 float sy = (float)info.height() / srcH;
237 // How many bilerp/bicubic steps to do in X and Y. + means upscaling, - means downscaling.
238 int stepsX;
239 int stepsY;
240 if (rescaleQuality > kNone_SkFilterQuality) {
241 stepsX = static_cast<int>((sx > 1.f) ? std::ceil(std::log2f(sx))
242 : std::floor(std::log2f(sx)));
243 stepsY = static_cast<int>((sy > 1.f) ? std::ceil(std::log2f(sy))
244 : std::floor(std::log2f(sy)));
245 } else {
246 stepsX = sx != 1.f;
247 stepsY = sy != 1.f;
248 }
249
250 SkPaint paint;
251 paint.setBlendMode(SkBlendMode::kSrc);
252 if (stepsX < 0 || stepsY < 0) {
253 // Don't trigger MIP generation. We don't currently have a way to trigger bicubic for
254 // downscaling draws.
255 rescaleQuality = std::min(rescaleQuality, kLow_SkFilterQuality);
256 }
257 paint.setFilterQuality(rescaleQuality);
258 sk_sp<SkSurface> src(SkRef(this));
259 int srcX = srcRect.fLeft;
260 int srcY = srcRect.fTop;
261 if (rescaleGamma == SkSurface::RescaleGamma::kLinear &&
262 !this->getCanvas()->imageInfo().colorSpace()->gammaIsLinear()) {
263 auto cs = this->getCanvas()->imageInfo().colorSpace()->makeLinearGamma();
264 // Promote to F16 color type to preserve precision.
265 auto ii = SkImageInfo::Make(srcW, srcH, kRGBA_F16_SkColorType,
266 this->getCanvas()->imageInfo().alphaType(), std::move(cs));
267 auto linearSurf = this->makeSurface(ii);
268 if (!linearSurf) {
269 // Maybe F16 isn't supported? Try again with original color type.
270 ii = ii.makeColorType(this->getCanvas()->imageInfo().colorType());
271 linearSurf = this->makeSurface(ii);
272 if (!linearSurf) {
273 callback(context, nullptr, 0);
274 return;
275 }
276 }
277 this->draw(linearSurf->getCanvas(), -srcX, -srcY, &paint);
278 src = std::move(linearSurf);
279 srcX = 0;
280 srcY = 0;
281 }
282 while (stepsX || stepsY) {
283 int nextW = info.width();
284 int nextH = info.height();
285 if (stepsX < 0) {
286 nextW = info.width() << (-stepsX - 1);
287 stepsX++;
288 } else if (stepsX != 0) {
289 if (stepsX > 1) {
290 nextW = srcW * 2;
291 }
292 --stepsX;
293 }
294 if (stepsY < 0) {
295 nextH = info.height() << (-stepsY - 1);
296 stepsY++;
297 } else if (stepsY != 0) {
298 if (stepsY > 1) {
299 nextH = srcH * 2;
300 }
301 --stepsY;
302 }
303 auto ii = src->getCanvas()->imageInfo().makeWH(nextW, nextH);
304 if (!stepsX && !stepsY) {
305 // Might as well fold conversion to final info in the last step.
306 ii = info;
307 }
308 auto next = this->makeSurface(ii);
309 if (!next) {
310 callback(context, nullptr, 0);
311 return;
312 }
Brian Salomona34e0fc2019-05-17 19:56:59 +0000313 next->getCanvas()->drawImageRect(src->makeImageSnapshot(),
314 SkIRect::MakeXYWH(srcX, srcY, srcW, srcH),
315 SkRect::MakeWH((float)nextW, (float)nextH), &paint,
316 SkCanvas::kFast_SrcRectConstraint);
Brian Salomon201700f2019-05-17 12:05:44 -0400317 src = std::move(next);
318 srcX = srcY = 0;
319 srcW = nextW;
320 srcH = nextH;
321 }
322 static_cast<SkSurface_Base*>(src.get())->onAsyncReadPixels(info, srcX, srcY, callback, context);
Brian Salomonab32f652019-05-10 14:24:50 -0400323}
324
Mike Reed4c790bd2018-02-08 14:10:40 -0500325void SkSurface::writePixels(const SkPixmap& pmap, int x, int y) {
326 if (pmap.addr() == nullptr || pmap.width() <= 0 || pmap.height() <= 0) {
327 return;
328 }
329
330 const SkIRect srcR = SkIRect::MakeXYWH(x, y, pmap.width(), pmap.height());
331 const SkIRect dstR = SkIRect::MakeWH(this->width(), this->height());
332 if (SkIRect::Intersects(srcR, dstR)) {
333 ContentChangeMode mode = kRetain_ContentChangeMode;
334 if (srcR.contains(dstR)) {
335 mode = kDiscard_ContentChangeMode;
336 }
337 asSB(this)->aboutToDraw(mode);
338 asSB(this)->onWritePixels(pmap, x, y);
339 }
340}
341
342void SkSurface::writePixels(const SkBitmap& src, int x, int y) {
343 SkPixmap pm;
344 if (src.peekPixels(&pm)) {
345 this->writePixels(pm, x, y);
346 }
347}
348
Robert Phillips8caf85f2018-04-05 09:30:38 -0400349GrBackendTexture SkSurface::getBackendTexture(BackendHandleAccess access) {
350 return asSB(this)->onGetBackendTexture(access);
351}
352
353GrBackendRenderTarget SkSurface::getBackendRenderTarget(BackendHandleAccess access) {
354 return asSB(this)->onGetBackendRenderTarget(access);
355}
Robert Phillips8caf85f2018-04-05 09:30:38 -0400356
Greg Daniela5cb7812017-06-16 09:45:32 -0400357void SkSurface::flush() {
Greg Daniele6bfb7d2019-04-17 15:26:11 -0400358 this->flush(BackendSurfaceAccess::kNoAccess, GrFlushInfo());
Greg Danielbae71212019-03-01 15:24:35 -0500359}
360
Greg Daniele6bfb7d2019-04-17 15:26:11 -0400361GrSemaphoresSubmitted SkSurface::flush(BackendSurfaceAccess access, const GrFlushInfo& flushInfo) {
362 return asSB(this)->onFlush(access, flushInfo);
Greg Daniela5cb7812017-06-16 09:45:32 -0400363}
364
Greg Daniel5816b3d2019-04-22 11:46:41 -0400365GrSemaphoresSubmitted SkSurface::flush(BackendSurfaceAccess access, GrFlushFlags flags,
366 int numSemaphores, GrBackendSemaphore signalSemaphores[],
367 GrGpuFinishedProc finishedProc,
368 GrGpuFinishedContext finishedContext) {
369 GrFlushInfo info;
370 info.fFlags = flags;
371 info.fNumSemaphores = numSemaphores;
372 info.fSignalSemaphores = signalSemaphores;
373 info.fFinishedProc = finishedProc;
374 info.fFinishedContext = finishedContext;
375 return this->flush(access, info);
376}
377
Greg Danielb9990e42019-04-10 16:28:52 -0400378GrSemaphoresSubmitted SkSurface::flush(BackendSurfaceAccess access, FlushFlags flags,
379 int numSemaphores, GrBackendSemaphore signalSemaphores[]) {
380 GrFlushFlags grFlags = flags == kSyncCpu_FlushFlag ? kSyncCpu_GrFlushFlag : kNone_GrFlushFlags;
Greg Daniele6bfb7d2019-04-17 15:26:11 -0400381 GrFlushInfo info;
382 info.fFlags = grFlags;
383 info.fNumSemaphores = numSemaphores;
384 info.fSignalSemaphores = signalSemaphores;
385 return this->flush(access, info);
Greg Danielb9990e42019-04-10 16:28:52 -0400386}
387
Greg Daniel51316782017-08-02 15:10:09 +0000388GrSemaphoresSubmitted SkSurface::flushAndSignalSemaphores(int numSemaphores,
389 GrBackendSemaphore signalSemaphores[]) {
Greg Daniele6bfb7d2019-04-17 15:26:11 -0400390 GrFlushInfo info;
391 info.fNumSemaphores = numSemaphores;
392 info.fSignalSemaphores = signalSemaphores;
393 return this->flush(BackendSurfaceAccess::kNoAccess, info);
Greg Daniela5cb7812017-06-16 09:45:32 -0400394}
395
Greg Danielc64ee462017-06-15 16:59:49 -0400396bool SkSurface::wait(int numSemaphores, const GrBackendSemaphore* waitSemaphores) {
397 return asSB(this)->onWait(numSemaphores, waitSemaphores);
ericrkf7b8b8a2016-02-24 14:49:51 -0800398}
399
Robert Phillipsad8a43f2017-08-30 12:06:35 -0400400bool SkSurface::characterize(SkSurfaceCharacterization* characterization) const {
401 return asSB(const_cast<SkSurface*>(this))->onCharacterize(characterization);
402}
403
Robert Phillips7ffbcf92017-12-04 12:52:46 -0500404bool SkSurface::draw(SkDeferredDisplayList* ddl) {
Robert Phillipsad8a43f2017-08-30 12:06:35 -0400405 return asSB(this)->onDraw(ddl);
406}
407
reed4a8126e2014-09-22 07:29:03 -0700408//////////////////////////////////////////////////////////////////////////////////////
Mike Kleinc0bd9f92019-04-23 12:05:21 -0500409#include "include/utils/SkNoDrawCanvas.h"
Mike Reed44d04bd2017-06-28 19:57:21 -0400410
411class SkNullSurface : public SkSurface_Base {
412public:
413 SkNullSurface(int width, int height) : SkSurface_Base(width, height, nullptr) {}
414
415protected:
416 SkCanvas* onNewCanvas() override {
417 return new SkNoDrawCanvas(this->width(), this->height());
418 }
419 sk_sp<SkSurface> onNewSurface(const SkImageInfo& info) override {
420 return MakeNull(info.width(), info.height());
421 }
Mike Reed114bde82018-11-21 09:12:09 -0500422 sk_sp<SkImage> onNewImageSnapshot(const SkIRect* subsetOrNull) override { return nullptr; }
Mike Reed4c790bd2018-02-08 14:10:40 -0500423 void onWritePixels(const SkPixmap&, int x, int y) override {}
Mike Reed44d04bd2017-06-28 19:57:21 -0400424 void onDraw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*) override {}
425 void onCopyOnWrite(ContentChangeMode) override {}
426};
427
428sk_sp<SkSurface> SkSurface::MakeNull(int width, int height) {
429 if (width < 1 || height < 1) {
430 return nullptr;
431 }
432 return sk_sp<SkSurface>(new SkNullSurface(width, height));
433}
434
435//////////////////////////////////////////////////////////////////////////////////////
reed4a8126e2014-09-22 07:29:03 -0700436
437#if !SK_SUPPORT_GPU
438
Brian Salomonbdecacf2018-02-02 20:32:49 -0500439sk_sp<SkSurface> SkSurface::MakeRenderTarget(GrContext*, SkBudgeted, const SkImageInfo&, int,
440 GrSurfaceOrigin, const SkSurfaceProps*, bool) {
halcanary96fcdcc2015-08-27 07:41:13 -0700441 return nullptr;
reed4a8126e2014-09-22 07:29:03 -0700442}
443
Robert Phillips9338c602019-02-19 12:52:29 -0500444sk_sp<SkSurface> SkSurface::MakeRenderTarget(GrRecordingContext*, const SkSurfaceCharacterization&,
Robert Phillips6b6fcc72018-03-30 13:57:00 -0400445 SkBudgeted) {
446 return nullptr;
447}
448
Greg Daniel94403452017-04-18 15:52:36 -0400449sk_sp<SkSurface> SkSurface::MakeFromBackendTexture(GrContext*, const GrBackendTexture&,
450 GrSurfaceOrigin origin, int sampleCnt,
Greg Danielfaa095e2017-12-19 13:15:02 -0500451 SkColorType, sk_sp<SkColorSpace>,
Greg Daniel8ce79912019-02-05 10:08:43 -0500452 const SkSurfaceProps*,
453 TextureReleaseProc, ReleaseContext) {
Greg Danielfaa095e2017-12-19 13:15:02 -0500454 return nullptr;
455}
456
reede8f30622016-03-23 18:59:25 -0700457sk_sp<SkSurface> SkSurface::MakeFromBackendRenderTarget(GrContext*,
Greg Daniel94403452017-04-18 15:52:36 -0400458 const GrBackendRenderTarget&,
459 GrSurfaceOrigin origin,
Greg Danielfaa095e2017-12-19 13:15:02 -0500460 SkColorType,
461 sk_sp<SkColorSpace>,
Greg Daniel8ce79912019-02-05 10:08:43 -0500462 const SkSurfaceProps*,
463 RenderTargetReleaseProc, ReleaseContext) {
Greg Danielfaa095e2017-12-19 13:15:02 -0500464 return nullptr;
465}
466
Greg Daniel94403452017-04-18 15:52:36 -0400467sk_sp<SkSurface> SkSurface::MakeFromBackendTextureAsRenderTarget(GrContext*,
Greg Daniel94403452017-04-18 15:52:36 -0400468 const GrBackendTexture&,
469 GrSurfaceOrigin origin,
470 int sampleCnt,
Greg Danielfaa095e2017-12-19 13:15:02 -0500471 SkColorType,
472 sk_sp<SkColorSpace>,
473 const SkSurfaceProps*) {
474 return nullptr;
475}
476
reed4a8126e2014-09-22 07:29:03 -0700477#endif