Move SkSurface factories to SkSurfaces namespace
* SkSurface::MakeFromAHardwareBuffer -> SkSurfaces::WrapAndroidHardwareBuffer
* SkSurface::MakeFromBackendRenderTarget -> SkSurfaces::WrapBackendRenderTarget
* SkSurface::MakeFromBackendTexture -> SkSurfaces::WrapBackendTexture
* SkSurface::MakeFromCAMetalLayer -> SkSurfaces::WrapCAMetalLayer
* SkSurface::MakeFromMTKView -> SkSurfaces::WrapMTKView
* SkSurface::MakeGraphite -> SkSurfaces::RenderTarget
* SkSurface::MakeGraphiteFromBackendTexture -> SkSurfaces::WrapBackendTexture
* SkSurface::MakeRaster -> SkSurfaces::Raster
* SkSurface::MakeRasterDirect -> SkSurfaces::WrapPixels
* SkSurface::MakeRasterDirectReleaseProc -> SkSurfaces::WrapPixels
* SkSurface::MakeRasterN32Premul -> SkSurfaces::Raster
* SkSurface::MakeRenderTarget -> SkSurfaces::RenderTarget
Suggested review order:
- include/*
- src/gpu/ganesh/surface/SkSurface_Ganesh.cpp
- src/image/SkSurface_Raster.cpp
- src/image/SkSurface.cpp
- All other changes which were mostly find-replace followed
by `git clang-format origin/main`
Change-Id: Idb18ab5c2beb12d8b4ec6712e9abee286646424f
Bug: skia:13983
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/687639
Commit-Queue: Kevin Lubick <[email protected]>
Reviewed-by: Brian Osman <[email protected]>
diff --git a/bazel/exporter_tool/main.go b/bazel/exporter_tool/main.go
index 3d4587d..48a26cc 100644
--- a/bazel/exporter_tool/main.go
+++ b/bazel/exporter_tool/main.go
@@ -279,6 +279,7 @@
"//src/gpu/ganesh/ops:ops_srcs",
"//src/gpu/ganesh/surface:surface_srcs",
"//src/gpu/ganesh/surface:surface_srcs",
+ "//src/gpu/ganesh/surface:android_srcs",
"//src/gpu/ganesh/tessellate:tessellate_hdrs",
"//src/gpu/ganesh/tessellate:tessellate_srcs",
"//src/gpu/ganesh/text:private_hdrs",
diff --git a/bench/ClipMaskBench.cpp b/bench/ClipMaskBench.cpp
index d9c1927..763c275 100644
--- a/bench/ClipMaskBench.cpp
+++ b/bench/ClipMaskBench.cpp
@@ -25,7 +25,7 @@
RasterTileBench() : fName("rastertile") {
int W = 2014 * 20;
int H = 20;
- fSurf = SkSurface::MakeRasterN32Premul(W, H);
+ fSurf = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(W, H));
fPath.moveTo(0, 0);
fPath.cubicTo(20, 10, 10, 15, 30, 5);
diff --git a/bench/ColorFilterBench.cpp b/bench/ColorFilterBench.cpp
index ffaac02..6b0bb72 100644
--- a/bench/ColorFilterBench.cpp
+++ b/bench/ColorFilterBench.cpp
@@ -149,7 +149,7 @@
void onDelayedSetup() override {
// Pass the image though a premul canvas so that we "forget" it is opaque.
- auto surface = SkSurface::MakeRasterN32Premul(256, 256);
+ auto surface = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(256, 256));
surface->getCanvas()->drawImage(GetResourceAsImage("images/mandrill_256.png"), 0, 0);
fImage = surface->makeImageSnapshot();
diff --git a/bench/DisplacementBench.cpp b/bench/DisplacementBench.cpp
index b86577c..09c98b9 100644
--- a/bench/DisplacementBench.cpp
+++ b/bench/DisplacementBench.cpp
@@ -33,7 +33,7 @@
void makeBitmap() {
const int w = this->isSmall() ? FILTER_WIDTH_SMALL : FILTER_WIDTH_LARGE;
const int h = this->isSmall() ? FILTER_HEIGHT_SMALL : FILTER_HEIGHT_LARGE;
- auto surf = SkSurface::MakeRasterN32Premul(w, h);
+ auto surf = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(w, h));
SkPaint paint;
paint.setColor(0xFF884422);
@@ -46,7 +46,7 @@
void makeCheckerboard() {
const int w = this->isSmall() ? FILTER_WIDTH_SMALL : FILTER_WIDTH_LARGE;
const int h = this->isSmall() ? FILTER_HEIGHT_SMALL : FILTER_HEIGHT_LARGE;
- auto surface(SkSurface::MakeRasterN32Premul(w, h));
+ auto surface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(w, h)));
SkCanvas* canvas = surface->getCanvas();
canvas->clear(0x00000000);
SkPaint darkPaint;
diff --git a/bench/DrawBitmapAABench.cpp b/bench/DrawBitmapAABench.cpp
index 7c68143..5f08e68 100644
--- a/bench/DrawBitmapAABench.cpp
+++ b/bench/DrawBitmapAABench.cpp
@@ -33,7 +33,7 @@
}
void onDelayedSetup() override {
- auto surf = SkSurface::MakeRasterN32Premul(200, 200);
+ auto surf = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(200, 200));
surf->getCanvas()->clear(0xFF00FF00);
fImage = surf->makeImageSnapshot();
}
diff --git a/bench/GrMipmapBench.cpp b/bench/GrMipmapBench.cpp
index f70dcff..419a2f3 100644
--- a/bench/GrMipmapBench.cpp
+++ b/bench/GrMipmapBench.cpp
@@ -12,6 +12,7 @@
#include "include/core/SkPaint.h"
#include "include/core/SkSurface.h"
#include "include/gpu/GpuTypes.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
class GrMipMapBench: public Benchmark {
sk_sp<SkSurface> fSurface;
@@ -41,13 +42,13 @@
SkImageInfo::Make(fW, fH, kRGBA_8888_SkColorType, kPremul_SkAlphaType, srgb);
// We're benching the regeneration of the mip levels not the need to allocate them every
// frame. Thus we create the surface with mips to begin with.
- fSurface = SkSurface::MakeRenderTarget(context,
- skgpu::Budgeted::kNo,
- info,
- 0,
- kBottomLeft_GrSurfaceOrigin,
- nullptr,
- true);
+ fSurface = SkSurfaces::RenderTarget(context,
+ skgpu::Budgeted::kNo,
+ info,
+ 0,
+ kBottomLeft_GrSurfaceOrigin,
+ nullptr,
+ true);
}
// Clear surface once:
diff --git a/bench/ImageBench.cpp b/bench/ImageBench.cpp
index cd1c756..c0895d2 100644
--- a/bench/ImageBench.cpp
+++ b/bench/ImageBench.cpp
@@ -37,7 +37,7 @@
// create a cpu-backed Surface
SkImageInfo n32Info = SkImageInfo::MakeN32Premul(100, 100);
- fRasterSurface = SkSurface::MakeRaster(n32Info);
+ fRasterSurface = SkSurfaces::Raster(n32Info);
}
void onPerCanvasPostDraw(SkCanvas*) override {
diff --git a/bench/ImageFilterCollapse.cpp b/bench/ImageFilterCollapse.cpp
index 37ddaa2..ff0d863 100644
--- a/bench/ImageFilterCollapse.cpp
+++ b/bench/ImageFilterCollapse.cpp
@@ -50,7 +50,7 @@
void makeBitmap() {
int W = 400;
int H = 400;
- auto surf = SkSurface::MakeRasterN32Premul(W, H);
+ auto surf = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(W, H));
SkPaint paint;
SkPoint pts[] = { {0, 0}, {SkIntToScalar(W), SkIntToScalar(H)} };
diff --git a/bench/MergeBench.cpp b/bench/MergeBench.cpp
index 19f81f3..b045530 100644
--- a/bench/MergeBench.cpp
+++ b/bench/MergeBench.cpp
@@ -17,7 +17,7 @@
#define FILTER_HEIGHT_LARGE SkIntToScalar(256)
static sk_sp<SkImage> make_bitmap() {
- sk_sp<SkSurface> surface(SkSurface::MakeRasterN32Premul(80, 80));
+ sk_sp<SkSurface> surface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(80, 80)));
surface->getCanvas()->clear(0x00000000);
SkPaint paint;
paint.setColor(0xFF884422);
@@ -28,7 +28,7 @@
}
static sk_sp<SkImage> make_checkerboard() {
- sk_sp<SkSurface> surface(SkSurface::MakeRasterN32Premul(80, 80));
+ sk_sp<SkSurface> surface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(80, 80)));
SkCanvas* canvas = surface->getCanvas();
canvas->clear(0x00000000);
SkPaint darkPaint;
diff --git a/bench/ShaderMaskFilterBench.cpp b/bench/ShaderMaskFilterBench.cpp
index 38a2e9d..208c241 100644
--- a/bench/ShaderMaskFilterBench.cpp
+++ b/bench/ShaderMaskFilterBench.cpp
@@ -19,7 +19,7 @@
p.setColor(SK_ColorBLACK);
p.setAntiAlias(true);
- auto surface = SkSurface::MakeRasterN32Premul(100, 100);
+ auto surface = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(100, 100));
surface->getCanvas()->drawCircle(50, 50, 50, p);
return surface->makeImageSnapshot()->makeShader(SkTileMode::kRepeat, SkTileMode::kRepeat,
diff --git a/bench/nanobench.cpp b/bench/nanobench.cpp
index 9c967d8..90686ef 100644
--- a/bench/nanobench.cpp
+++ b/bench/nanobench.cpp
@@ -67,6 +67,7 @@
#include "include/gpu/graphite/Context.h"
#include "include/gpu/graphite/Recorder.h"
#include "include/gpu/graphite/Recording.h"
+#include "include/gpu/graphite/Surface.h"
#include "tools/graphite/ContextFactory.h"
#include "tools/graphite/GraphiteTestContext.h"
#endif
@@ -86,6 +87,7 @@
#endif
#include "include/gpu/GrDirectContext.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "src/gpu/ganesh/GrCaps.h"
#include "src/gpu/ganesh/GrDirectContextPriv.h"
#include "src/gpu/ganesh/SkGr.h"
@@ -212,7 +214,7 @@
bool Target::init(SkImageInfo info, Benchmark* bench) {
if (Benchmark::kRaster_Backend == config.backend) {
- this->surface = SkSurface::MakeRaster(info);
+ this->surface = SkSurfaces::Raster(info);
if (!this->surface) {
return false;
}
@@ -268,7 +270,7 @@
bench->modifyGrContextOptions(&options);
this->factory = std::make_unique<GrContextFactory>(options);
SkSurfaceProps props(this->config.surfaceFlags, kRGB_H_SkPixelGeometry);
- this->surface = SkSurface::MakeRenderTarget(
+ this->surface = SkSurfaces::RenderTarget(
this->factory->get(this->config.ctxType, this->config.ctxOverrides),
skgpu::Budgeted::kNo,
info,
@@ -357,7 +359,7 @@
return false;
}
- this->surface = SkSurface::MakeGraphite(this->recorder.get(), info);
+ this->surface = SkSurfaces::RenderTarget(this->recorder.get(), info);
if (!this->surface) {
return false;
}
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
index 837221f..1c63bb7 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -25,6 +25,7 @@
#include "include/gpu/GrBackendSurface.h"
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/ganesh/SkImageGanesh.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "include/ports/SkImageGeneratorCG.h"
#include "include/ports/SkImageGeneratorNDK.h"
#include "include/ports/SkImageGeneratorWIC.h"
@@ -87,6 +88,7 @@
#include "include/gpu/graphite/Context.h"
#include "include/gpu/graphite/Recorder.h"
#include "include/gpu/graphite/Recording.h"
+#include "include/gpu/graphite/Surface.h"
// TODO: Remove this src include once we figure out public readPixels call for Graphite.
#include "src/gpu/graphite/Surface_Graphite.h"
#include "tools/graphite/ContextFactory.h"
@@ -1490,7 +1492,7 @@
switch (fSurfType) {
case SkCommandLineConfigGpu::SurfType::kDefault:
- surface = SkSurface::MakeRenderTarget(
+ surface = SkSurfaces::RenderTarget(
context, skgpu::Budgeted::kNo, info, fSampleCount, &props);
break;
case SkCommandLineConfigGpu::SurfType::kBackendTexture:
@@ -2126,7 +2128,7 @@
dst->allocPixels(ii);
{
- sk_sp<SkSurface> surface = SkSurface::MakeGraphite(recorder.get(), ii);
+ sk_sp<SkSurface> surface = SkSurfaces::RenderTarget(recorder.get(), ii);
if (!surface) {
return Result::Fatal("Could not create a surface.");
}
diff --git a/docs/examples/50_percent_gray.cpp b/docs/examples/50_percent_gray.cpp
index cfaeef2..11a849d 100644
--- a/docs/examples/50_percent_gray.cpp
+++ b/docs/examples/50_percent_gray.cpp
@@ -3,7 +3,7 @@
#include "tools/fiddle/examples.h"
REG_FIDDLE_SRGB(50_percent_gray, 530, 150, false, 0, 0, false) {
static sk_sp<SkShader> make_bw_dither() {
- auto surf = SkSurface::MakeRasterN32Premul(2, 2);
+ auto surf = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(2, 2));
surf->getCanvas()->drawColor(SK_ColorWHITE);
surf->getCanvas()->drawRect({0, 0, 1, 1}, SkPaint());
surf->getCanvas()->drawRect({1, 1, 2, 2}, SkPaint());
diff --git a/docs/examples/50_percent_srgb.cpp b/docs/examples/50_percent_srgb.cpp
index d26491d..ab3813d 100644
--- a/docs/examples/50_percent_srgb.cpp
+++ b/docs/examples/50_percent_srgb.cpp
@@ -3,7 +3,7 @@
#include "tools/fiddle/examples.h"
REG_FIDDLE_SRGB(50_percent_srgb, 256, 256, false, 0, 0, false) {
static sk_sp<SkShader> make() {
- auto surf = SkSurface::MakeRasterN32Premul(2, 2);
+ auto surf = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(2, 2));
surf->getCanvas()->drawColor(SK_ColorWHITE);
surf->getCanvas()->drawRect({0, 0, 1, 1}, SkPaint());
surf->getCanvas()->drawRect({1, 1, 2, 2}, SkPaint());
diff --git a/docs/examples/Canvas_makeSurface.cpp b/docs/examples/Canvas_makeSurface.cpp
index 9de07d0..5cba7af 100644
--- a/docs/examples/Canvas_makeSurface.cpp
+++ b/docs/examples/Canvas_makeSurface.cpp
@@ -4,7 +4,7 @@
// HASH=1ce28351444b41ab2b8e3128a4b9b9c2
REG_FIDDLE(Canvas_makeSurface, 256, 256, true, 0) {
void draw(SkCanvas* canvas) {
- sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul(5, 6);
+ sk_sp<SkSurface> surface = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(5, 6));
SkCanvas* smallCanvas = surface->getCanvas();
SkImageInfo imageInfo = SkImageInfo::MakeN32Premul(3, 4);
sk_sp<SkSurface> compatible = smallCanvas->makeSurface(imageInfo);
diff --git a/docs/examples/Image_MakeBackendTextureFromImage.cpp b/docs/examples/Image_MakeBackendTextureFromImage.cpp
index 53dae0a..3d27301 100644
--- a/docs/examples/Image_MakeBackendTextureFromImage.cpp
+++ b/docs/examples/Image_MakeBackendTextureFromImage.cpp
@@ -5,7 +5,7 @@
REG_FIDDLE(Image_MakeBackendTextureFromImage, 256, 64, false, 0) {
static sk_sp<SkImage> create_gpu_image(GrRecordingContext * rContext) {
const SkImageInfo info = SkImageInfo::MakeN32(20, 20, kOpaque_SkAlphaType);
- auto surface(SkSurface::MakeRenderTarget(rContext, skgpu::Budgeted::kNo, info));
+ auto surface(SkSurfaces::RenderTarget(rContext, skgpu::Budgeted::kNo, info));
SkCanvas* canvas = surface->getCanvas();
canvas->clear(SK_ColorWHITE);
SkPaint paint;
diff --git a/docs/examples/Image_isOpaque.cpp b/docs/examples/Image_isOpaque.cpp
index bd2fd4e..3e9099e 100644
--- a/docs/examples/Image_isOpaque.cpp
+++ b/docs/examples/Image_isOpaque.cpp
@@ -5,7 +5,7 @@
REG_FIDDLE(Image_isOpaque, 256, 256, true, 0) {
void draw(SkCanvas* canvas) {
auto check_isopaque = [](const SkImageInfo& imageInfo) -> void {
- auto surface(SkSurface::MakeRaster(imageInfo));
+ auto surface(SkSurfaces::Raster(imageInfo));
auto image(surface->makeImageSnapshot());
SkDebugf("isOpaque = %s\n", image->isOpaque() ? "true" : "false");
};
diff --git a/docs/examples/Surface_MakeFromBackendTexture.cpp b/docs/examples/Surface_MakeFromBackendTexture.cpp
index f0b95e6..e6f41a8 100644
--- a/docs/examples/Surface_MakeFromBackendTexture.cpp
+++ b/docs/examples/Surface_MakeFromBackendTexture.cpp
@@ -2,33 +2,33 @@
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
#include "tools/fiddle/examples.h"
// HASH=d3aec071998f871809f515e58abb1b0e
-REG_FIDDLE(Surface_MakeFromBackendTexture, 256, 256, false, 3) {
-void draw(SkCanvas* canvas) {
- SkFont font(nullptr, 32);
- SkPaint paint;
+REG_FIDDLE(Surface_WrapBackendTexture, 256, 256, false, 3) {
+ void draw(SkCanvas * canvas) {
+ SkFont font(nullptr, 32);
+ SkPaint paint;
- GrRecordingContext* context = canvas->recordingContext();
- if (!context) {
- canvas->drawString("GPU only!", 20, 40, font, paint);
- return;
- }
- GrDirectContext* direct = context->asDirectContext();
- if (!direct) {
- canvas->drawString("Direct Context only!", 20, 40, font, paint);
- return;
- }
+ GrRecordingContext* context = canvas->recordingContext();
+ if (!context) {
+ canvas->drawString("GPU only!", 20, 40, font, paint);
+ return;
+ }
+ GrDirectContext* direct = context->asDirectContext();
+ if (!direct) {
+ canvas->drawString("Direct Context only!", 20, 40, font, paint);
+ return;
+ }
- sk_sp<SkSurface> gpuSurface = SkSurface::MakeFromBackendTexture(direct,
- backEndTexture,
- kTopLeft_GrSurfaceOrigin,
- 0,
- kRGBA_8888_SkColorType,
- nullptr,
- nullptr,
- nullptr);
- auto surfaceCanvas = gpuSurface->getCanvas();
- surfaceCanvas->drawString("GPU rocks!", 20, 40, font, paint);
- sk_sp<SkImage> image(gpuSurface->makeImageSnapshot());
- canvas->drawImage(image, 0, 0);
-}
+ sk_sp<SkSurface> gpuSurface = SkSurfaces::WrapBackendTexture(direct,
+ backEndTexture,
+ kTopLeft_GrSurfaceOrigin,
+ 0,
+ kRGBA_8888_SkColorType,
+ nullptr,
+ nullptr,
+ nullptr);
+ auto surfaceCanvas = gpuSurface->getCanvas();
+ surfaceCanvas->drawString("GPU rocks!", 20, 40, font, paint);
+ sk_sp<SkImage> image(gpuSurface->makeImageSnapshot());
+ canvas->drawImage(image, 0, 0);
+ }
} // END FIDDLE
diff --git a/docs/examples/Surface_MakeRaster.cpp b/docs/examples/Surface_MakeRaster.cpp
index b580c93..490ae21 100644
--- a/docs/examples/Surface_MakeRaster.cpp
+++ b/docs/examples/Surface_MakeRaster.cpp
@@ -6,7 +6,7 @@
void draw(SkCanvas* ) {
SkImageInfo info = SkImageInfo::MakeN32Premul(3, 3);
const size_t rowBytes = 64;
- sk_sp<SkSurface> surface(SkSurface::MakeRaster(info, rowBytes, nullptr));
+ sk_sp<SkSurface> surface(SkSurfaces::Raster(info, rowBytes, nullptr));
SkCanvas* canvas = surface->getCanvas();
canvas->clear(SK_ColorWHITE);
SkPixmap pixmap;
diff --git a/docs/examples/Surface_MakeRasterDirect.cpp b/docs/examples/Surface_MakeRasterDirect.cpp
index c6cbc52..92d176c 100644
--- a/docs/examples/Surface_MakeRasterDirect.cpp
+++ b/docs/examples/Surface_MakeRasterDirect.cpp
@@ -8,7 +8,7 @@
const size_t size = info.computeMinByteSize();
AutoTMalloc<SkPMColor> storage(size);
SkPMColor* pixels = storage.get();
- sk_sp<SkSurface> surface(SkSurface::MakeRasterDirect(info, pixels, info.minRowBytes()));
+ sk_sp<SkSurface> surface(SkSurfaces::WrapPixels(info, pixels, info.minRowBytes()));
SkCanvas* canvas = surface->getCanvas();
canvas->clear(SK_ColorWHITE);
SkPMColor pmWhite = pixels[0];
diff --git a/docs/examples/Surface_MakeRasterDirectReleaseProc.cpp b/docs/examples/Surface_MakeRasterDirectReleaseProc.cpp
index 6d4c2bc..902da02 100644
--- a/docs/examples/Surface_MakeRasterDirectReleaseProc.cpp
+++ b/docs/examples/Surface_MakeRasterDirectReleaseProc.cpp
@@ -2,32 +2,32 @@
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
#include "tools/fiddle/examples.h"
// HASH=8e6530b26ab4096a9a91cfaadda1c568
-REG_FIDDLE(Surface_MakeRasterDirectReleaseProc, 256, 256, true, 0) {
-static void release_direct_surface_storage(void* pixels, void* context) {
- if (pixels == context) {
- SkDebugf("expected release context\n");
- }
- sk_free(pixels);
-}
-
-void draw(SkCanvas* ) {
- SkImageInfo info = SkImageInfo::MakeN32Premul(3, 3);
- const size_t rowBytes = info.minRowBytes();
- void* pixels = sk_malloc_throw(info.computeByteSize(rowBytes));
- sk_sp<SkSurface> surface(SkSurface::MakeRasterDirectReleaseProc(info, pixels, rowBytes,
- release_direct_surface_storage, pixels));
- SkCanvas* canvas = surface->getCanvas();
- canvas->clear(SK_ColorWHITE);
- SkPMColor* colorPtr = (SkPMColor*) pixels;
- SkPMColor pmWhite = colorPtr[0];
- SkPaint paint;
- canvas->drawPoint(1, 1, paint);
- canvas->flush(); // ensure that point was drawn
- for (int y = 0; y < info.height(); ++y) {
- for (int x = 0; x < info.width(); ++x) {
- SkDebugf("%c", *colorPtr++ == pmWhite ? '-' : 'x');
+REG_FIDDLE(Surface_WrapPixels_WithReleaseProc, 256, 256, true, 0) {
+ static void release_direct_surface_storage(void* pixels, void* context) {
+ if (pixels == context) {
+ SkDebugf("expected release context\n");
}
- SkDebugf("\n");
+ sk_free(pixels);
}
-}
+
+ void draw(SkCanvas*) {
+ SkImageInfo info = SkImageInfo::MakeN32Premul(3, 3);
+ const size_t rowBytes = info.minRowBytes();
+ void* pixels = sk_malloc_throw(info.computeByteSize(rowBytes));
+ sk_sp<SkSurface> surface(SkSurfaces::WrapPixels(
+ info, pixels, rowBytes, release_direct_surface_storage, pixels));
+ SkCanvas* canvas = surface->getCanvas();
+ canvas->clear(SK_ColorWHITE);
+ SkPMColor* colorPtr = (SkPMColor*)pixels;
+ SkPMColor pmWhite = colorPtr[0];
+ SkPaint paint;
+ canvas->drawPoint(1, 1, paint);
+ canvas->flush(); // ensure that point was drawn
+ for (int y = 0; y < info.height(); ++y) {
+ for (int x = 0; x < info.width(); ++x) {
+ SkDebugf("%c", *colorPtr++ == pmWhite ? '-' : 'x');
+ }
+ SkDebugf("\n");
+ }
+ }
} // END FIDDLE
diff --git a/docs/examples/Surface_MakeRasterN32Premul.cpp b/docs/examples/Surface_MakeRasterN32Premul.cpp
index 3de585b..92f950c 100644
--- a/docs/examples/Surface_MakeRasterN32Premul.cpp
+++ b/docs/examples/Surface_MakeRasterN32Premul.cpp
@@ -4,7 +4,7 @@
// HASH=b932a2bd68455fb0af2e7a1ed19e36b3
REG_FIDDLE(Surface_MakeRasterN32Premul, 256, 256, true, 0) {
void draw(SkCanvas* ) {
- sk_sp<SkSurface> surface(SkSurface::MakeRasterN32Premul(3, 3));
+ sk_sp<SkSurface> surface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(3, 3)));
SkCanvas* canvas = surface->getCanvas();
canvas->clear(SK_ColorWHITE);
SkPixmap pixmap;
diff --git a/docs/examples/Surface_MakeRaster_2.cpp b/docs/examples/Surface_MakeRaster_2.cpp
index b9d32cb..50080b3 100644
--- a/docs/examples/Surface_MakeRaster_2.cpp
+++ b/docs/examples/Surface_MakeRaster_2.cpp
@@ -5,7 +5,7 @@
REG_FIDDLE(Surface_MakeRaster_2, 256, 256, true, 0) {
void draw(SkCanvas* ) {
SkImageInfo info = SkImageInfo::MakeN32Premul(3, 3);
- sk_sp<SkSurface> surface(SkSurface::MakeRaster(info));
+ sk_sp<SkSurface> surface(SkSurfaces::Raster(info));
SkCanvas* canvas = surface->getCanvas();
canvas->clear(SK_ColorWHITE);
SkPixmap pixmap;
diff --git a/docs/examples/Surface_MakeRenderTarget.cpp b/docs/examples/Surface_MakeRenderTarget.cpp
index ab3a519..87ab740 100644
--- a/docs/examples/Surface_MakeRenderTarget.cpp
+++ b/docs/examples/Surface_MakeRenderTarget.cpp
@@ -14,7 +14,7 @@
SkImageInfo info = SkImageInfo::MakeN32(256, 64, kOpaque_SkAlphaType);
for (auto surfaceOrigin : { kTopLeft_GrSurfaceOrigin, kBottomLeft_GrSurfaceOrigin } ) {
- auto gpuSurface(SkSurface::MakeRenderTarget(
+ auto gpuSurface(SkSurfaces::RenderTarget(
dContext, skgpu::Budgeted::kNo, info, 0, surfaceOrigin, nullptr));
auto surfaceCanvas = gpuSurface->getCanvas();
surfaceCanvas->clear(SK_ColorWHITE);
diff --git a/docs/examples/Surface_MakeRenderTarget_2.cpp b/docs/examples/Surface_MakeRenderTarget_2.cpp
index 8248fca..5f1a73c 100644
--- a/docs/examples/Surface_MakeRenderTarget_2.cpp
+++ b/docs/examples/Surface_MakeRenderTarget_2.cpp
@@ -23,9 +23,9 @@
for (auto geometry : { kRGB_H_SkPixelGeometry, kBGR_H_SkPixelGeometry,
kRGB_V_SkPixelGeometry, kBGR_V_SkPixelGeometry } ) {
SkSurfaceProps props(0, geometry);
- sk_sp<SkSurface> surface = context ? SkSurface::MakeRenderTarget(
- context, skgpu::Budgeted::kNo, info, 0, &props)
- : SkSurface::MakeRaster(info, &props);
+ sk_sp<SkSurface> surface =
+ context ? SkSurfaces::RenderTarget(context, skgpu::Budgeted::kNo, info, 0, &props)
+ : SkSurfaces::Raster(info, &props);
test_draw(surface->getCanvas());
surface->draw(canvas, 0, y);
sk_sp<SkImage> image(surface->makeImageSnapshot());
diff --git a/docs/examples/Surface_MakeRenderTarget_3.cpp b/docs/examples/Surface_MakeRenderTarget_3.cpp
index 9e4f3d5..a4e832a 100644
--- a/docs/examples/Surface_MakeRenderTarget_3.cpp
+++ b/docs/examples/Surface_MakeRenderTarget_3.cpp
@@ -12,7 +12,7 @@
return;
}
SkImageInfo info = SkImageInfo::MakeN32(256, 64, kOpaque_SkAlphaType);
- auto gpuSurface(SkSurface::MakeRenderTarget(context, skgpu::Budgeted::kNo, info));
+ auto gpuSurface(SkSurfaces::RenderTarget(context, skgpu::Budgeted::kNo, info));
auto surfaceCanvas = gpuSurface->getCanvas();
surfaceCanvas->clear(SK_ColorWHITE);
surfaceCanvas->drawString("GPU rocks!", 20, 40, font, paint);
diff --git a/docs/examples/Surface_characterize.cpp b/docs/examples/Surface_characterize.cpp
index 5e84bbe..c3e6f6c 100644
--- a/docs/examples/Surface_characterize.cpp
+++ b/docs/examples/Surface_characterize.cpp
@@ -11,7 +11,7 @@
canvas->drawString("GPU only!", 20, 40, font, paint);
return;
}
- sk_sp<SkSurface> gpuSurface = SkSurface::MakeRenderTarget(
+ sk_sp<SkSurface> gpuSurface = SkSurfaces::RenderTarget(
context, skgpu::Budgeted::kYes, SkImageInfo::MakeN32Premul(64, 64));
SkSurfaceCharacterization characterization;
if (!gpuSurface->characterize(&characterization)) {
diff --git a/docs/examples/Surface_draw.cpp b/docs/examples/Surface_draw.cpp
index da89e96..272126d 100644
--- a/docs/examples/Surface_draw.cpp
+++ b/docs/examples/Surface_draw.cpp
@@ -4,7 +4,7 @@
// HASH=0de693f4d8dd898a60be8cfba23952be
REG_FIDDLE(Surface_draw, 256, 64, false, 0) {
void draw(SkCanvas* canvas) {
- sk_sp<SkSurface> big(SkSurface::MakeRasterN32Premul(64, 64));
+ sk_sp<SkSurface> big(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(64, 64)));
sk_sp<SkSurface> lil(big->makeSurface(SkImageInfo::MakeN32(32, 32, kPremul_SkAlphaType)));
big->getCanvas()->clear(SK_ColorRED);
lil->getCanvas()->clear(SK_ColorBLACK);
diff --git a/docs/examples/Surface_draw_2.cpp b/docs/examples/Surface_draw_2.cpp
index 06beed8..a5c9cff 100644
--- a/docs/examples/Surface_draw_2.cpp
+++ b/docs/examples/Surface_draw_2.cpp
@@ -7,7 +7,7 @@
void draw(SkCanvas* canvas) {
SkPaint paint;
paint.setTextSize(16);
- sk_sp<SkSurface> gpuSurface = SkSurface::MakeRasterN32Premul(64, 64);
+ sk_sp<SkSurface> gpuSurface = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(64, 64));
SkSurfaceCharacterization characterization;
if (!gpuSurface->characterize(&characterization)) {
canvas->drawString("characterization unsupported", 20, 40, paint);
diff --git a/docs/examples/Surface_getCanvas.cpp b/docs/examples/Surface_getCanvas.cpp
index 781a401..6ec1015 100644
--- a/docs/examples/Surface_getCanvas.cpp
+++ b/docs/examples/Surface_getCanvas.cpp
@@ -5,7 +5,7 @@
// HASH=33d0c5ad5a4810e533ae1010e29f8b75
REG_FIDDLE(Surface_getCanvas, 256, 64, false, 0) {
void draw(SkCanvas* canvas) {
- sk_sp<SkSurface> surface(SkSurface::MakeRasterN32Premul(64, 64));
+ sk_sp<SkSurface> surface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(64, 64)));
SkCanvas* surfaceCanvas = surface->getCanvas();
surfaceCanvas->clear(SK_ColorBLUE);
SkPaint paint;
diff --git a/docs/examples/Surface_makeImageSnapshot.cpp b/docs/examples/Surface_makeImageSnapshot.cpp
index 1b60a30..029dca5 100644
--- a/docs/examples/Surface_makeImageSnapshot.cpp
+++ b/docs/examples/Surface_makeImageSnapshot.cpp
@@ -4,7 +4,7 @@
// HASH=46f1fa0d95e590a64bed0140407ce5f7
REG_FIDDLE(Surface_makeImageSnapshot, 256, 64, false, 0) {
void draw(SkCanvas* canvas) {
- sk_sp<SkSurface> big(SkSurface::MakeRasterN32Premul(64, 64));
+ sk_sp<SkSurface> big(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(64, 64)));
sk_sp<SkSurface> lil(big->makeSurface(SkImageInfo::MakeN32(32, 32, kPremul_SkAlphaType)));
big->getCanvas()->clear(SK_ColorRED);
lil->getCanvas()->clear(SK_ColorBLACK);
diff --git a/docs/examples/Surface_makeImageSnapshot_2.cpp b/docs/examples/Surface_makeImageSnapshot_2.cpp
index 80c5580..1d4bd93 100644
--- a/docs/examples/Surface_makeImageSnapshot_2.cpp
+++ b/docs/examples/Surface_makeImageSnapshot_2.cpp
@@ -4,7 +4,7 @@
// HASH=b18b8ab693b09eb70a1d22ab63790cc7
REG_FIDDLE(Surface_makeImageSnapshot_2, 256, 64, false, 0) {
void draw(SkCanvas* canvas) {
- sk_sp<SkSurface> big(SkSurface::MakeRasterN32Premul(64, 64));
+ sk_sp<SkSurface> big(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(64, 64)));
sk_sp<SkSurface> lil(big->makeSurface(SkImageInfo::MakeN32(32, 32, kPremul_SkAlphaType)));
big->getCanvas()->clear(SK_ColorRED);
lil->getCanvas()->clear(SK_ColorBLACK);
diff --git a/docs/examples/Surface_makeSurface.cpp b/docs/examples/Surface_makeSurface.cpp
index 293f691..e877b2e 100644
--- a/docs/examples/Surface_makeSurface.cpp
+++ b/docs/examples/Surface_makeSurface.cpp
@@ -4,7 +4,7 @@
// HASH=a9889b519a26896b900da0444e423c61
REG_FIDDLE(Surface_makeSurface, 256, 96, false, 0) {
void draw(SkCanvas* canvas) {
- sk_sp<SkSurface> big(SkSurface::MakeRasterN32Premul(64, 64));
+ sk_sp<SkSurface> big(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(64, 64)));
sk_sp<SkSurface> lil(big->makeSurface(SkImageInfo::MakeN32(32, 32, kPremul_SkAlphaType)));
big->getCanvas()->clear(SK_ColorRED);
lil->getCanvas()->clear(SK_ColorBLACK);
diff --git a/docs/examples/Surface_notifyContentWillChange.cpp b/docs/examples/Surface_notifyContentWillChange.cpp
index b2fde72..57ff064 100644
--- a/docs/examples/Surface_notifyContentWillChange.cpp
+++ b/docs/examples/Surface_notifyContentWillChange.cpp
@@ -4,7 +4,7 @@
// HASH=be9574c4a14f891e1abb4ec2b1e51d6c
REG_FIDDLE(Surface_notifyContentWillChange, 256, 256, true, 0) {
void draw(SkCanvas* canvas) {
- auto surface = SkSurface::MakeRasterN32Premul(1, 1);
+ auto surface = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(1, 1));
for (int i = 0; i < 3; ++i) {
SkDebugf("surface generationID: %d\n", surface->generationID());
if (0 == i) {
diff --git a/docs/examples/Surface_peekPixels.cpp b/docs/examples/Surface_peekPixels.cpp
index 539c456..2a1fd8e 100644
--- a/docs/examples/Surface_peekPixels.cpp
+++ b/docs/examples/Surface_peekPixels.cpp
@@ -5,7 +5,7 @@
// HASH=8c6184f22cfe068f021704cf92a147a1
REG_FIDDLE(Surface_peekPixels, 256, 64, false, 0) {
void draw(SkCanvas* canvas) {
- sk_sp<SkSurface> surf(SkSurface::MakeRasterN32Premul(64, 64));
+ sk_sp<SkSurface> surf(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(64, 64)));
auto surfCanvas = surf->getCanvas();
surfCanvas->clear(SK_ColorRED);
SkPaint paint;
diff --git a/docs/examples/Surface_props.cpp b/docs/examples/Surface_props.cpp
index e6fc5e8..342e1eb 100644
--- a/docs/examples/Surface_props.cpp
+++ b/docs/examples/Surface_props.cpp
@@ -5,7 +5,7 @@
REG_FIDDLE(Surface_props, 256, 256, true, 0) {
void draw(SkCanvas* canvas) {
const char* names[] = { "Unknown", "RGB_H", "BGR_H", "RGB_V", "BGR_V" };
- sk_sp<SkSurface> surf(SkSurface::MakeRasterN32Premul(64, 64));
+ sk_sp<SkSurface> surf(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(64, 64)));
SkDebugf("surf.props(): k%s_SkPixelGeometry\n", names[surf->props().pixelGeometry()]);
}
} // END FIDDLE
diff --git a/docs/examples/Surface_readPixels.cpp b/docs/examples/Surface_readPixels.cpp
index 9481cdb..783d112 100644
--- a/docs/examples/Surface_readPixels.cpp
+++ b/docs/examples/Surface_readPixels.cpp
@@ -5,7 +5,7 @@
// HASH=9f454fb93bca6482598d198b4121f0a6
REG_FIDDLE(Surface_readPixels, 256, 32, false, 0) {
void draw(SkCanvas* canvas) {
- sk_sp<SkSurface> surf(SkSurface::MakeRasterN32Premul(64, 64));
+ sk_sp<SkSurface> surf(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(64, 64)));
auto surfCanvas = surf->getCanvas();
surfCanvas->clear(SK_ColorRED);
SkPaint paint;
diff --git a/docs/examples/Surface_readPixels_2.cpp b/docs/examples/Surface_readPixels_2.cpp
index 7d869fc..e4f4c81 100644
--- a/docs/examples/Surface_readPixels_2.cpp
+++ b/docs/examples/Surface_readPixels_2.cpp
@@ -4,7 +4,7 @@
// HASH=484d60dab5d846bf28c7a4d48892324a
REG_FIDDLE(Surface_readPixels_2, 256, 64, false, 0) {
void draw(SkCanvas* canvas) {
- sk_sp<SkSurface> surf(SkSurface::MakeRasterN32Premul(64, 64));
+ sk_sp<SkSurface> surf(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(64, 64)));
auto surfCanvas = surf->getCanvas();
surfCanvas->clear(SK_ColorRED);
SkPaint paint;
diff --git a/docs/examples/Surface_readPixels_3.cpp b/docs/examples/Surface_readPixels_3.cpp
index ce43994..eb2f2e8 100644
--- a/docs/examples/Surface_readPixels_3.cpp
+++ b/docs/examples/Surface_readPixels_3.cpp
@@ -4,7 +4,7 @@
// HASH=2d991a231e49d1de13eeb2ba9b440e01
REG_FIDDLE(Surface_readPixels_3, 256, 256, false, 0) {
void draw(SkCanvas* canvas) {
- sk_sp<SkSurface> surf(SkSurface::MakeRasterN32Premul(64, 64));
+ sk_sp<SkSurface> surf(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(64, 64)));
auto surfCanvas = surf->getCanvas();
surfCanvas->clear(SK_ColorGREEN);
SkPaint paint;
diff --git a/docs/examples/Surface_writePixels.cpp b/docs/examples/Surface_writePixels.cpp
index 2705371..f8a723c 100644
--- a/docs/examples/Surface_writePixels.cpp
+++ b/docs/examples/Surface_writePixels.cpp
@@ -5,7 +5,7 @@
// HASH=760793bcf0ef193fa61ea03e6e8fc825
REG_FIDDLE(Surface_writePixels, 256, 96, false, 4) {
void draw(SkCanvas* canvas) {
- sk_sp<SkSurface> surf(SkSurface::MakeRasterN32Premul(64, 64));
+ sk_sp<SkSurface> surf(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(64, 64)));
auto surfCanvas = surf->getCanvas();
surfCanvas->clear(SK_ColorRED);
SkPaint paint;
diff --git a/docs/examples/Surface_writePixels_2.cpp b/docs/examples/Surface_writePixels_2.cpp
index 1736b39..eee44d0 100644
--- a/docs/examples/Surface_writePixels_2.cpp
+++ b/docs/examples/Surface_writePixels_2.cpp
@@ -4,7 +4,7 @@
// HASH=d77790dd3bc9f678fa4f582347fb8fba
REG_FIDDLE(Surface_writePixels_2, 256, 96, false, 4) {
void draw(SkCanvas* canvas) {
- sk_sp<SkSurface> surf(SkSurface::MakeRasterN32Premul(64, 64));
+ sk_sp<SkSurface> surf(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(64, 64)));
auto surfCanvas = surf->getCanvas();
surfCanvas->clear(SK_ColorGREEN);
surf->writePixels(source, 25, 25);
diff --git a/docs/examples/alphaimage_shader_colorfilter.cpp b/docs/examples/alphaimage_shader_colorfilter.cpp
index 16a899a..be70e11 100644
--- a/docs/examples/alphaimage_shader_colorfilter.cpp
+++ b/docs/examples/alphaimage_shader_colorfilter.cpp
@@ -3,7 +3,7 @@
#include "tools/fiddle/examples.h"
REG_FIDDLE(alphaimage_shader_colorfilter, 256, 256, false, 0) {
sk_sp<SkImage> alpha_image() {
- auto s = SkSurface::MakeRaster(SkImageInfo::MakeA8(64, 64));
+ auto s = SkSurfaces::Raster(SkImageInfo::MakeA8(64, 64));
s->getCanvas()->clear(SkColorSetARGB(0x80, 0x00, 0x00, 0x00));
return s->makeImageSnapshot();
}
diff --git a/docs/examples/blur4444.cpp b/docs/examples/blur4444.cpp
index 4f072ed..e30ac0a 100644
--- a/docs/examples/blur4444.cpp
+++ b/docs/examples/blur4444.cpp
@@ -22,9 +22,9 @@
sk_sp<SkSurface> surf;
auto ii = SkImageInfo::Make(650, 480, kARGB_4444_SkColorType, kPremul_SkAlphaType);
if (canvas->recordingContext() && !forceRaster) {
- surf = SkSurface::MakeRenderTarget(canvas->recordingContext(), skgpu::Budgeted::kNo, ii);
+ surf = SkSurfaces::RenderTarget(canvas->recordingContext(), skgpu::Budgeted::kNo, ii);
} else {
- surf = SkSurface::MakeRaster(ii);
+ surf = SkSurfaces::Raster(ii);
}
if (!surf) {
return;
diff --git a/docs/examples/f16to8888busted.cpp b/docs/examples/f16to8888busted.cpp
index 506d3b0..01b5849 100644
--- a/docs/examples/f16to8888busted.cpp
+++ b/docs/examples/f16to8888busted.cpp
@@ -8,7 +8,7 @@
SkImageInfo info = SkImageInfo::Make(100, 100, SkColorType::kRGBA_F16_SkColorType,
SkAlphaType::kPremul_SkAlphaType, colorSpace);
- sk_sp<SkSurface> offscreen = SkSurface::MakeRaster(info);
+ sk_sp<SkSurface> offscreen = SkSurfaces::Raster(info);
SkPaint paint;
offscreen->getCanvas()->drawRect(SkRect::MakeXYWH(25, 25, 50, 50), paint);
diff --git a/docs/examples/f16to8888drawImageBug.cpp b/docs/examples/f16to8888drawImageBug.cpp
index c232f42..6ba0d88 100644
--- a/docs/examples/f16to8888drawImageBug.cpp
+++ b/docs/examples/f16to8888drawImageBug.cpp
@@ -8,7 +8,7 @@
SkImageInfo imageInfo =
SkImageInfo::Make(100, 100, kRGBA_F16_SkColorType, kPremul_SkAlphaType, colorSpace);
- sk_sp<SkSurface> surface = SkSurface::MakeRaster(imageInfo);
+ sk_sp<SkSurface> surface = SkSurfaces::Raster(imageInfo);
SkPaint p;
surface->getCanvas()->drawRect(SkRect::MakeXYWH(20, 20, 40, 40), p);
@@ -16,7 +16,7 @@
SkImageInfo imageInfo2 =
SkImageInfo::Make(100, 100, kN32_SkColorType, kPremul_SkAlphaType, colorSpace2);
- sk_sp<SkSurface> surface2 = SkSurface::MakeRaster(imageInfo2);
+ sk_sp<SkSurface> surface2 = SkSurfaces::Raster(imageInfo2);
surface2->getCanvas()->drawImage(surface->makeImageSnapshot(), 0, 0);
canvas->drawImage(surface->makeImageSnapshot(), 0, 0);
diff --git a/docs/examples/purplestamp.cpp b/docs/examples/purplestamp.cpp
index d922508..87e20e5 100644
--- a/docs/examples/purplestamp.cpp
+++ b/docs/examples/purplestamp.cpp
@@ -31,8 +31,8 @@
}
sk_sp<SkImage> stampImage(int size) {
- sk_sp<SkSurface> surface = SkSurface::MakeRaster(
- SkImageInfo::Make(size, size, colorType, kPremul_SkAlphaType));
+ sk_sp<SkSurface> surface =
+ SkSurfaces::Raster(SkImageInfo::Make(size, size, colorType, kPremul_SkAlphaType));
drawStamp(surface->getCanvas(), size);
return surface->makeImageSnapshot();
}
diff --git a/docs/examples/shader_alphaimage.cpp b/docs/examples/shader_alphaimage.cpp
index 7f21c97..88a951b 100644
--- a/docs/examples/shader_alphaimage.cpp
+++ b/docs/examples/shader_alphaimage.cpp
@@ -3,7 +3,7 @@
#include "tools/fiddle/examples.h"
REG_FIDDLE(shader_alphaimage, 256, 256, false, 0) {
sk_sp<SkImage> alpha_image() {
- auto s = SkSurface::MakeRaster(SkImageInfo::MakeA8(128, 128));
+ auto s = SkSurfaces::Raster(SkImageInfo::MakeA8(128, 128));
s->getCanvas()->clear(SkColorSetARGB(0xF0, 0x00, 0x00, 0x00));
return s->makeImageSnapshot();
}
diff --git a/example/VulkanBasic.cpp b/example/VulkanBasic.cpp
index 6456050..391e276 100644
--- a/example/VulkanBasic.cpp
+++ b/example/VulkanBasic.cpp
@@ -14,6 +14,7 @@
#include "include/core/SkSurface.h"
#include "include/core/SkTypes.h"
#include "include/gpu/GrDirectContext.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "include/gpu/vk/GrVkBackendContext.h"
#include "include/gpu/vk/VulkanExtensions.h"
#include "tools/gpu/vk/VkTestUtils.h"
@@ -91,11 +92,11 @@
SkImageInfo imageInfo = SkImageInfo::Make(16, 16, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
// Create an SkSurface backed by a Vulkan VkImage. Often clients will be getting VkImages from
- // swapchains. In those cases they should use SkSurface::MakeFromBackendTexture or
- // SkSurface::MakeFromBackendRenderTarget to wrap those premade VkImages in Skia. See the
+ // swapchains. In those cases they should use SkSurfaces::WrapBackendTexture or
+ // SkSurfaces::WrapBackendRenderTarget to wrap those premade VkImages in Skia. See the
// HelloWorld example app to see how this is done.
sk_sp<SkSurface> surface =
- SkSurface::MakeRenderTarget(context.get(), skgpu::Budgeted::kYes, imageInfo);
+ SkSurfaces::RenderTarget(context.get(), skgpu::Budgeted::kYes, imageInfo);
if (!surface) {
context.reset();
fVkDestroyDevice(backendContext.fDevice, nullptr);
diff --git a/experimental/ffmpeg/SkVideoEncoder.cpp b/experimental/ffmpeg/SkVideoEncoder.cpp
index b09609e..bab34e5 100644
--- a/experimental/ffmpeg/SkVideoEncoder.cpp
+++ b/experimental/ffmpeg/SkVideoEncoder.cpp
@@ -303,7 +303,7 @@
SkCanvas* SkVideoEncoder::beginFrame() {
if (!fSurface) {
- fSurface = SkSurface::MakeRaster(fInfo);
+ fSurface = SkSurfaces::Raster(fInfo);
if (!fSurface) {
return nullptr;
}
diff --git a/experimental/webgpu-bazel/src/bindings.cpp b/experimental/webgpu-bazel/src/bindings.cpp
index 4a298ab..b26ef95 100644
--- a/experimental/webgpu-bazel/src/bindings.cpp
+++ b/experimental/webgpu-bazel/src/bindings.cpp
@@ -17,6 +17,7 @@
#include "include/effects/SkRuntimeEffect.h"
#include "include/gpu/GrBackendSurface.h"
#include "include/gpu/GrDirectContext.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include <emscripten/bind.h>
#include <emscripten/emscripten.h>
@@ -127,12 +128,12 @@
GrBackendRenderTarget backendRenderTarget(fWidth, fHeight, 1, 8, rtInfo);
SkSurfaceProps surfaceProps(0, kRGB_H_SkPixelGeometry);
- sk_sp<SkSurface> surface = SkSurface::MakeFromBackendRenderTarget(fContext.get(),
- backendRenderTarget,
- kTopLeft_GrSurfaceOrigin,
- kN32_SkColorType,
- nullptr,
- &surfaceProps);
+ sk_sp<SkSurface> surface = SkSurfaces::WrapBackendRenderTarget(fContext.get(),
+ backendRenderTarget,
+ kTopLeft_GrSurfaceOrigin,
+ kN32_SkColorType,
+ nullptr,
+ &surfaceProps);
SkPaint paint;
if (fDemoKind == DemoKind::SOLID_COLOR) {
diff --git a/fuzz/FuzzCanvas.cpp b/fuzz/FuzzCanvas.cpp
index fbda02e..eb7c370 100644
--- a/fuzz/FuzzCanvas.cpp
+++ b/fuzz/FuzzCanvas.cpp
@@ -34,6 +34,7 @@
#include "include/effects/SkImageFilters.h"
#include "include/effects/SkLumaColorFilter.h"
#include "include/effects/SkPerlinNoiseShader.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "include/private/base/SkTo.h"
#include "include/svg/SkSVGCanvas.h"
#include "include/utils/SkNullCanvas.h"
@@ -1514,7 +1515,8 @@
constexpr SkISize kCanvasSize = {128, 160};
DEF_FUZZ(RasterN32Canvas, fuzz) {
- auto surface = SkSurface::MakeRasterN32Premul(kCanvasSize.width(), kCanvasSize.height());
+ auto surface = SkSurfaces::Raster(
+ SkImageInfo::MakeN32Premul(kCanvasSize.width(), kCanvasSize.height()));
if (!surface || !surface->getCanvas()) { fuzz->signalBug(); }
fuzz_canvas(fuzz, surface->getCanvas());
}
@@ -1530,7 +1532,8 @@
SkReadBuffer rb(data->data(), data->size());
auto deserialized = SkPicturePriv::MakeFromBuffer(rb);
if (!deserialized) { fuzz->signalBug(); }
- auto surface = SkSurface::MakeRasterN32Premul(kCanvasSize.width(), kCanvasSize.height());
+ auto surface = SkSurfaces::Raster(
+ SkImageInfo::MakeN32Premul(kCanvasSize.width(), kCanvasSize.height()));
SkASSERT(surface && surface->getCanvas());
surface->getCanvas()->drawPicture(deserialized);
}
@@ -1614,7 +1617,7 @@
#if defined(SK_GANESH)
static void fuzz_ganesh(Fuzz* fuzz, GrDirectContext* context) {
SkASSERT(context);
- auto surface = SkSurface::MakeRenderTarget(
+ auto surface = SkSurfaces::RenderTarget(
context,
skgpu::Budgeted::kNo,
SkImageInfo::Make(kCanvasSize, kRGBA_8888_SkColorType, kPremul_SkAlphaType));
diff --git a/fuzz/FuzzCreateDDL.cpp b/fuzz/FuzzCreateDDL.cpp
index 6c2d831..0e7aab9 100644
--- a/fuzz/FuzzCreateDDL.cpp
+++ b/fuzz/FuzzCreateDDL.cpp
@@ -12,6 +12,7 @@
#include "include/core/SkSurface.h"
#include "include/core/SkSurfaceCharacterization.h"
#include "include/gpu/GrDirectContext.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "include/private/gpu/ganesh/GrTypesPriv.h"
#include "src/gpu/ganesh/GrShaderCaps.h"
#include "tools/gpu/GrContextFactory.h"
@@ -175,8 +176,8 @@
skgpu::Budgeted budgeted;
fuzz->nextEnum(&budgeted, skgpu::Budgeted::kYes);
SkSurfaceProps surfaceProps = gen_fuzzed_surface_props(fuzz);
- auto surface = SkSurface::MakeRenderTarget(dContext, budgeted, ii, kSampleCount, origin,
- &surfaceProps);
+ auto surface =
+ SkSurfaces::RenderTarget(dContext, budgeted, ii, kSampleCount, origin, &surfaceProps);
return surface;
}
diff --git a/fuzz/FuzzDDLThreading.cpp b/fuzz/FuzzDDLThreading.cpp
index 07809e5..b487f88 100644
--- a/fuzz/FuzzDDLThreading.cpp
+++ b/fuzz/FuzzDDLThreading.cpp
@@ -17,6 +17,7 @@
#include "include/core/SkSurface.h"
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/ganesh/SkImageGanesh.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "include/private/base/SkDeque.h"
#include "include/private/base/SkMutex.h"
#include "include/private/base/SkTemplates.h"
@@ -133,7 +134,7 @@
SkISize canvasSize = kPromiseImageSize;
canvasSize.fWidth *= kPromiseImagesPerDDL;
SkImageInfo ii = SkImageInfo::Make(canvasSize, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
- fSurface = SkSurface::MakeRenderTarget(fContext, skgpu::Budgeted::kNo, ii);
+ fSurface = SkSurfaces::RenderTarget(fContext, skgpu::Budgeted::kNo, ii);
if (!fSurface || !fSurface->characterize(&fSurfaceCharacterization)) {
return;
}
diff --git a/fuzz/FuzzDrawFunctions.cpp b/fuzz/FuzzDrawFunctions.cpp
index c96020a..6ddf1bf 100644
--- a/fuzz/FuzzDrawFunctions.cpp
+++ b/fuzz/FuzzDrawFunctions.cpp
@@ -98,7 +98,7 @@
uint8_t x, y;
fuzz->nextRange(&x, 1, kMaxX);
fuzz->nextRange(&y, 1, kMaxY);
- *s = SkSurface::MakeRasterN32Premul(x, y);
+ *s = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(x, y));
if (!*s) {
// Was possibly too big for the memory constrained fuzzing environments
diff --git a/fuzz/FuzzGradients.cpp b/fuzz/FuzzGradients.cpp
index 4732954..93bc1e0 100644
--- a/fuzz/FuzzGradients.cpp
+++ b/fuzz/FuzzGradients.cpp
@@ -124,7 +124,7 @@
p.setShader(SkGradientShader::MakeLinear(pts, colors.data(), pos.data(),
colors.size(), mode, flags, localMatrix.getMaybeNull()));
- sk_sp<SkSurface> surface(SkSurface::MakeRasterN32Premul(50, 50));
+ sk_sp<SkSurface> surface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(50, 50)));
if (useGlobalMatrix) {
SkMatrix gm;
makeMatrix(fuzz, &gm);
@@ -162,8 +162,7 @@
p.setShader(SkGradientShader::MakeRadial(center, radius, colors.data(),
pos.data(), colors.size(), mode, flags, localMatrix.getMaybeNull()));
-
- sk_sp<SkSurface> surface(SkSurface::MakeRasterN32Premul(50, 50));
+ sk_sp<SkSurface> surface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(50, 50)));
if (useGlobalMatrix) {
SkMatrix gm;
makeMatrix(fuzz, &gm);
@@ -201,7 +200,7 @@
end, endRadius, colors.data(), pos.data(), colors.size(), mode,
flags, localMatrix.getMaybeNull()));
- sk_sp<SkSurface> surface(SkSurface::MakeRasterN32Premul(50, 50));
+ sk_sp<SkSurface> surface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(50, 50)));
if (useGlobalMatrix) {
SkMatrix gm;
makeMatrix(fuzz, &gm);
@@ -237,7 +236,7 @@
pos.data(), colors.size()));
}
- sk_sp<SkSurface> surface(SkSurface::MakeRasterN32Premul(50, 50));
+ sk_sp<SkSurface> surface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(50, 50)));
if (useGlobalMatrix) {
SkMatrix gm;
makeMatrix(fuzz, &gm);
diff --git a/fuzz/oss_fuzz/FuzzAndroidCodec.cpp b/fuzz/oss_fuzz/FuzzAndroidCodec.cpp
index c2ef3ca..822af31 100644
--- a/fuzz/oss_fuzz/FuzzAndroidCodec.cpp
+++ b/fuzz/oss_fuzz/FuzzAndroidCodec.cpp
@@ -55,7 +55,7 @@
}
}
- auto surface = SkSurface::MakeRasterN32Premul(size.width(), size.height());
+ auto surface = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(size.width(), size.height()));
if (!surface) {
// May return nullptr in memory-constrained fuzzing environments
return false;
diff --git a/fuzz/oss_fuzz/FuzzAnimatedImage.cpp b/fuzz/oss_fuzz/FuzzAnimatedImage.cpp
index ddbdba2..0eb4c68 100644
--- a/fuzz/oss_fuzz/FuzzAnimatedImage.cpp
+++ b/fuzz/oss_fuzz/FuzzAnimatedImage.cpp
@@ -21,7 +21,7 @@
return false;
}
- auto s = SkSurface::MakeRasterN32Premul(128, 128);
+ auto s = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(128, 128));
if (!s) {
// May return nullptr in memory-constrained fuzzing environments
return false;
diff --git a/fuzz/oss_fuzz/FuzzCOLRv1.cpp b/fuzz/oss_fuzz/FuzzCOLRv1.cpp
index b236a15..a53d3c2 100644
--- a/fuzz/oss_fuzz/FuzzCOLRv1.cpp
+++ b/fuzz/oss_fuzz/FuzzCOLRv1.cpp
@@ -25,7 +25,7 @@
return;
}
- auto s = SkSurface::MakeRasterN32Premul(128, 128);
+ auto s = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(128, 128));
if (!s) {
return;
}
diff --git a/fuzz/oss_fuzz/FuzzImage.cpp b/fuzz/oss_fuzz/FuzzImage.cpp
index b2720cb..e920d11 100644
--- a/fuzz/oss_fuzz/FuzzImage.cpp
+++ b/fuzz/oss_fuzz/FuzzImage.cpp
@@ -17,7 +17,7 @@
return false;
}
- auto s = SkSurface::MakeRasterN32Premul(128, 128);
+ auto s = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(128, 128));
if (!s) {
// May return nullptr in memory-constrained fuzzing environments
return false;
diff --git a/fuzz/oss_fuzz/FuzzPathDeserialize.cpp b/fuzz/oss_fuzz/FuzzPathDeserialize.cpp
index cd3493b..b39cb97 100644
--- a/fuzz/oss_fuzz/FuzzPathDeserialize.cpp
+++ b/fuzz/oss_fuzz/FuzzPathDeserialize.cpp
@@ -18,7 +18,7 @@
return;
}
- auto s = SkSurface::MakeRasterN32Premul(128, 128);
+ auto s = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(128, 128));
if (!s) {
// May return nullptr in memory-constrained fuzzing environments
return;
diff --git a/fuzz/oss_fuzz/FuzzRegionDeserialize.cpp b/fuzz/oss_fuzz/FuzzRegionDeserialize.cpp
index 4b3610e..6792e9a 100644
--- a/fuzz/oss_fuzz/FuzzRegionDeserialize.cpp
+++ b/fuzz/oss_fuzz/FuzzRegionDeserialize.cpp
@@ -25,7 +25,7 @@
} else {
region.contains(1,1);
}
- auto s = SkSurface::MakeRasterN32Premul(128, 128);
+ auto s = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(128, 128));
if (!s) {
// May return nullptr in memory-constrained fuzzing environments
return false;
diff --git a/fuzz/oss_fuzz/FuzzSKP.cpp b/fuzz/oss_fuzz/FuzzSKP.cpp
index 20724a4..94c4060 100644
--- a/fuzz/oss_fuzz/FuzzSKP.cpp
+++ b/fuzz/oss_fuzz/FuzzSKP.cpp
@@ -18,8 +18,8 @@
if (!pic) {
return;
}
- sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul(kCanvasSize.width(),
- kCanvasSize.height());
+ sk_sp<SkSurface> surface = SkSurfaces::Raster(
+ SkImageInfo::MakeN32Premul(kCanvasSize.width(), kCanvasSize.height()));
surface->getCanvas()->drawPicture(pic);
pic->approximateBytesUsed();
pic->approximateOpCount();
diff --git a/fuzz/oss_fuzz/FuzzSVG.cpp b/fuzz/oss_fuzz/FuzzSVG.cpp
index 30d27a4..07f3d4f 100644
--- a/fuzz/oss_fuzz/FuzzSVG.cpp
+++ b/fuzz/oss_fuzz/FuzzSVG.cpp
@@ -23,7 +23,7 @@
return;
}
- auto s = SkSurface::MakeRasterN32Premul(128, 128);
+ auto s = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(128, 128));
if (!s) {
return;
}
diff --git a/fuzz/oss_fuzz/FuzzSkRuntimeEffect.cpp b/fuzz/oss_fuzz/FuzzSkRuntimeEffect.cpp
index 46ed1b6..d7102ec 100644
--- a/fuzz/oss_fuzz/FuzzSkRuntimeEffect.cpp
+++ b/fuzz/oss_fuzz/FuzzSkRuntimeEffect.cpp
@@ -89,7 +89,7 @@
SkPaint paint;
paint.setShader(std::move(shader));
- sk_sp<SkSurface> s = SkSurface::MakeRasterN32Premul(4, 4);
+ sk_sp<SkSurface> s = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(4, 4));
if (!s) {
return false;
}
diff --git a/fuzz/oss_fuzz/FuzzTextBlobDeserialize.cpp b/fuzz/oss_fuzz/FuzzTextBlobDeserialize.cpp
index 3ace654..0510c7b 100644
--- a/fuzz/oss_fuzz/FuzzTextBlobDeserialize.cpp
+++ b/fuzz/oss_fuzz/FuzzTextBlobDeserialize.cpp
@@ -19,7 +19,7 @@
return;
}
- auto s = SkSurface::MakeRasterN32Premul(128, 128);
+ auto s = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(128, 128));
if (!s) {
// May return nullptr in memory-constrained fuzzing environments
return;
diff --git a/gm/anisotropic.cpp b/gm/anisotropic.cpp
index ebb7334..e0f60cc 100644
--- a/gm/anisotropic.cpp
+++ b/gm/anisotropic.cpp
@@ -18,6 +18,7 @@
#include "include/core/SkString.h"
#include "include/core/SkSurface.h"
#include "include/gpu/GpuTypes.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
namespace skiagm {
@@ -70,7 +71,7 @@
constexpr int kInnerOffset = 10;
auto info = SkImageInfo::MakeN32(kImageSize, kImageSize, kOpaque_SkAlphaType);
- auto surf = SkSurface::MakeRaster(info);
+ auto surf = SkSurfaces::Raster(info);
auto canvas = surf->getCanvas();
canvas->clear(SK_ColorWHITE);
@@ -190,13 +191,13 @@
// texture.
sk_sp<SkSurface> surface;
if (auto rc = canvas->recordingContext()) {
- surface = SkSurface::MakeRenderTarget(rc,
- skgpu::Budgeted::kYes,
- ii,
- 1,
- kTopLeft_GrSurfaceOrigin,
- /*surfaceProps=*/nullptr,
- /*shouldCreateWithMips=*/true);
+ surface = SkSurfaces::RenderTarget(rc,
+ skgpu::Budgeted::kYes,
+ ii,
+ 1,
+ kTopLeft_GrSurfaceOrigin,
+ /*surfaceProps=*/nullptr,
+ /*shouldCreateWithMips=*/true);
if (!surface) {
// We could be in an abandoned context situation.
return;
@@ -204,7 +205,7 @@
} else {
surface = canvas->makeSurface(ii);
if (!surface) { // could be a recording canvas.
- surface = SkSurface::MakeRaster(ii);
+ surface = SkSurfaces::Raster(ii);
}
}
diff --git a/gm/arithmode.cpp b/gm/arithmode.cpp
index b76c9c0..79cc7bb6 100644
--- a/gm/arithmode.cpp
+++ b/gm/arithmode.cpp
@@ -31,7 +31,7 @@
#include <utility>
static sk_sp<SkImage> make_src(int w, int h) {
- sk_sp<SkSurface> surface(SkSurface::MakeRasterN32Premul(w, h));
+ sk_sp<SkSurface> surface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(w, h)));
SkCanvas* canvas = surface->getCanvas();
SkPaint paint;
@@ -47,7 +47,7 @@
}
static sk_sp<SkImage> make_dst(int w, int h) {
- sk_sp<SkSurface> surface(SkSurface::MakeRasterN32Premul(w, h));
+ sk_sp<SkSurface> surface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(w, h)));
SkCanvas* canvas = surface->getCanvas();
SkPaint paint;
diff --git a/gm/asyncrescaleandread.cpp b/gm/asyncrescaleandread.cpp
index 47e40a5..7a2d141 100644
--- a/gm/asyncrescaleandread.cpp
+++ b/gm/asyncrescaleandread.cpp
@@ -375,8 +375,8 @@
auto pmII = upmII.makeAlphaType(kPremul_SkAlphaType);
- auto upmSurf = SkSurface::MakeRaster(upmII);
- auto pmSurf = SkSurface::MakeRaster( pmII);
+ auto upmSurf = SkSurfaces::Raster(upmII);
+ auto pmSurf = SkSurfaces::Raster(pmII);
SkColor4f colors[] = {
{.3f, .3f, .3f, .3f},
diff --git a/gm/bicubic.cpp b/gm/bicubic.cpp
index 3bb2b54..e40a2d9 100644
--- a/gm/bicubic.cpp
+++ b/gm/bicubic.cpp
@@ -22,7 +22,7 @@
};
auto make_img = []() {
- auto surf = SkSurface::MakeRasterN32Premul(7, 7);
+ auto surf = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(7, 7));
surf->getCanvas()->drawColor(SK_ColorBLACK);
SkPaint paint;
diff --git a/gm/bigtileimagefilter.cpp b/gm/bigtileimagefilter.cpp
index 3688e7e..4e87c48 100644
--- a/gm/bigtileimagefilter.cpp
+++ b/gm/bigtileimagefilter.cpp
@@ -23,7 +23,7 @@
#include <utility>
static sk_sp<SkImage> create_circle_texture(int size, SkColor color) {
- auto surface(SkSurface::MakeRasterN32Premul(size, size));
+ auto surface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(size, size)));
SkCanvas* canvas = surface->getCanvas();
canvas->clear(0xFF000000);
diff --git a/gm/bitmaprect.cpp b/gm/bitmaprect.cpp
index 0db8234..e38499d 100644
--- a/gm/bitmaprect.cpp
+++ b/gm/bitmaprect.cpp
@@ -28,7 +28,7 @@
#include <iterator>
static sk_sp<SkImage> make_image(SkCanvas* destCanvas) {
- auto surf = SkSurface::MakeRasterN32Premul(64, 64);
+ auto surf = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(64, 64));
auto tmpCanvas = surf->getCanvas();
tmpCanvas->drawColor(SK_ColorRED);
diff --git a/gm/bug6783.cpp b/gm/bug6783.cpp
index ead77b3..bd47fd4 100644
--- a/gm/bug6783.cpp
+++ b/gm/bug6783.cpp
@@ -33,7 +33,7 @@
// the bug were still present. All stripes should now look roughly the same.
DEF_SIMPLE_GM(bug6783, canvas, 500, 500) {
- sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul(100, 100);
+ sk_sp<SkSurface> surface = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(100, 100));
SkPaint p;
p.setColor(SK_ColorYELLOW);
diff --git a/gm/clipshader.cpp b/gm/clipshader.cpp
index 9aa7277..42e593c 100644
--- a/gm/clipshader.cpp
+++ b/gm/clipshader.cpp
@@ -20,7 +20,7 @@
// This tests using clip shader and then changing the canvas matrix before drawing. It also verifies
// that we don't incorrectly disable linear filtering of a clip image shader.
DEF_SIMPLE_GM(clipshadermatrix, canvas, 145, 128) {
- auto clipSurface = SkSurface::MakeRaster(SkImageInfo::MakeA8({70, 60}));
+ auto clipSurface = SkSurfaces::Raster(SkImageInfo::MakeA8({70, 60}));
// Hard edged oval clip
clipSurface->getCanvas()->drawOval(SkRect::MakeXYWH(0, 10, 64, 44), SkPaint{});
auto clipShader = clipSurface->makeImageSnapshot()->makeShader(
diff --git a/gm/color4f.cpp b/gm/color4f.cpp
index d12415e..d13ec06 100644
--- a/gm/color4f.cpp
+++ b/gm/color4f.cpp
@@ -84,7 +84,7 @@
for (const sk_sp<SkColorSpace>& colorSpace : colorSpaces) {
const SkImageInfo info = SkImageInfo::Make(1024, 100, kN32_SkColorType, kPremul_SkAlphaType,
colorSpace);
- auto surface(SkSurface::MakeRaster(info));
+ auto surface(SkSurfaces::Raster(info));
surface->getCanvas()->drawPaint(bg);
draw_into_canvas(surface->getCanvas());
surface->draw(canvas, 0, 0);
diff --git a/gm/convexpolyclip.cpp b/gm/convexpolyclip.cpp
index 473e2d0..6bb3a52 100644
--- a/gm/convexpolyclip.cpp
+++ b/gm/convexpolyclip.cpp
@@ -28,7 +28,7 @@
#include "tools/ToolUtils.h"
static sk_sp<SkImage> make_img(int w, int h) {
- auto surf = SkSurface::MakeRaster(SkImageInfo::MakeN32(w, h, kOpaque_SkAlphaType));
+ auto surf = SkSurfaces::Raster(SkImageInfo::MakeN32(w, h, kOpaque_SkAlphaType));
auto canvas = surf->getCanvas();
SkScalar wScalar = SkIntToScalar(w);
diff --git a/gm/crbug_224618.cpp b/gm/crbug_224618.cpp
index 9cdd32e..0824c0e 100644
--- a/gm/crbug_224618.cpp
+++ b/gm/crbug_224618.cpp
@@ -41,7 +41,7 @@
{200.f, 200.f}, 25.f, kColors, nullptr, 2, SkTileMode::kMirror,
SkGradientShader::kInterpolateColorsInPremul_Flag, nullptr);
- sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul(400, 400);
+ sk_sp<SkSurface> surface = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(400, 400));
SkPaint bgPaint;
bgPaint.setShader(gradient);
diff --git a/gm/crbug_905548.cpp b/gm/crbug_905548.cpp
index bbf2eac..0a0a6d3 100644
--- a/gm/crbug_905548.cpp
+++ b/gm/crbug_905548.cpp
@@ -20,7 +20,7 @@
DEF_SIMPLE_GM(crbug_905548, canvas, 100, 200) {
auto surface = canvas->makeSurface(SkImageInfo::MakeN32Premul(100, 100));
if (!surface) {
- surface = SkSurface::MakeRaster(SkImageInfo::MakeN32Premul(100, 100));
+ surface = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(100, 100));
}
surface->getCanvas()->clear(0);
surface->getCanvas()->drawCircle(50, 50, 45, SkPaint());
diff --git a/gm/crop_imagefilter.cpp b/gm/crop_imagefilter.cpp
index 0c71866..eb8c126 100644
--- a/gm/crop_imagefilter.cpp
+++ b/gm/crop_imagefilter.cpp
@@ -122,7 +122,7 @@
const auto srcII = SkImageInfo::Make(SkISize::Make(SkScalarCeilToInt(w), SkScalarCeilToInt(h)),
kRGBA_8888_SkColorType, kPremul_SkAlphaType);
- auto surf = SkSurface::MakeRaster(srcII);
+ auto surf = SkSurfaces::Raster(srcII);
surf->getCanvas()->drawColor(SK_ColorDKGRAY);
SkPaint paint;
diff --git a/gm/croppedrects.cpp b/gm/croppedrects.cpp
index 55c2ee4..f8cf184 100644
--- a/gm/croppedrects.cpp
+++ b/gm/croppedrects.cpp
@@ -25,7 +25,7 @@
constexpr SkRect kSrcImageClip{75, 75, 275, 275};
static sk_sp<SkImage> create_image(SkCanvas* destCanvas) {
- sk_sp<SkSurface> srcSurface = SkSurface::MakeRasterN32Premul(500, 500);
+ sk_sp<SkSurface> srcSurface = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(500, 500));
SkCanvas* srcCanvas = srcSurface->getCanvas();
srcCanvas->clear(SK_ColorRED);
diff --git a/gm/dftext.cpp b/gm/dftext.cpp
index 14af19f..9dc4f8a 100644
--- a/gm/dftext.cpp
+++ b/gm/dftext.cpp
@@ -27,6 +27,7 @@
#include "include/core/SkTypeface.h"
#include "include/core/SkTypes.h"
#include "include/gpu/GpuTypes.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "include/private/base/SkTemplates.h"
#include "include/private/base/SkTo.h"
#include "tools/ToolUtils.h"
@@ -68,7 +69,7 @@
inputCanvas->getProps(&inputProps);
SkSurfaceProps props(SkSurfaceProps::kUseDeviceIndependentFonts_Flag | inputProps.flags(),
inputProps.pixelGeometry());
- auto surface(SkSurface::MakeRenderTarget(ctx, skgpu::Budgeted::kNo, info, 0, &props));
+ auto surface(SkSurfaces::RenderTarget(ctx, skgpu::Budgeted::kNo, info, 0, &props));
SkCanvas* canvas = surface ? surface->getCanvas() : inputCanvas;
// init our new canvas with the old canvas's matrix
canvas->setMatrix(inputCanvas->getLocalToDeviceAs3x3());
diff --git a/gm/dftext_blob_persp.cpp b/gm/dftext_blob_persp.cpp
index df3b066..ea4aba0 100644
--- a/gm/dftext_blob_persp.cpp
+++ b/gm/dftext_blob_persp.cpp
@@ -23,6 +23,7 @@
#include "include/core/SkTextBlob.h"
#include "include/core/SkTypes.h"
#include "include/gpu/GpuTypes.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "include/private/base/SkTArray.h"
#include "tools/ToolUtils.h"
@@ -73,7 +74,7 @@
inputCanvas->getProps(&inputProps);
SkSurfaceProps props(SkSurfaceProps::kUseDeviceIndependentFonts_Flag | inputProps.flags(),
inputProps.pixelGeometry());
- auto surface = SkSurface::MakeRenderTarget(ctx, skgpu::Budgeted::kNo, info, 0, &props);
+ auto surface = SkSurfaces::RenderTarget(ctx, skgpu::Budgeted::kNo, info, 0, &props);
SkCanvas* canvas = surface ? surface->getCanvas() : inputCanvas;
// init our new canvas with the old canvas's matrix
canvas->setMatrix(inputCanvas->getLocalToDeviceAs3x3());
diff --git a/gm/discard.cpp b/gm/discard.cpp
index 87ea4a9..3224cc8 100644
--- a/gm/discard.cpp
+++ b/gm/discard.cpp
@@ -18,9 +18,14 @@
#include "include/core/SkTypes.h"
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/GrRecordingContext.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "src/base/SkRandom.h"
#include "tools/ToolUtils.h"
+#if defined(SK_GRAPHITE)
+#include "include/gpu/graphite/Surface.h"
+#endif
+
namespace skiagm {
/*
@@ -51,18 +56,18 @@
auto dContext = GrAsDirectContext(canvas->recordingContext());
if (dContext && !dContext->abandoned()) {
- surface = SkSurface::MakeRenderTarget(dContext, skgpu::Budgeted::kNo, info);
+ surface = SkSurfaces::RenderTarget(dContext, skgpu::Budgeted::kNo, info);
}
#if defined(SK_GRAPHITE)
auto recorder = canvas->recorder();
if (recorder) {
- surface = SkSurface::MakeGraphite(recorder, info);
+ surface = SkSurfaces::RenderTarget(recorder, info);
}
#endif
if (!surface) {
- surface = SkSurface::MakeRaster(info);
+ surface = SkSurfaces::Raster(info);
}
if (!surface) {
*errorMsg = "Could not create surface.";
diff --git a/gm/drawimageset.cpp b/gm/drawimageset.cpp
index 1d9e27a..553f963 100644
--- a/gm/drawimageset.cpp
+++ b/gm/drawimageset.cpp
@@ -38,7 +38,7 @@
SkCanvas::ImageSetEntry set[], const SkColor bgColor=SK_ColorLTGRAY) {
const int w = tileW * m;
const int h = tileH * n;
- auto surf = SkSurface::MakeRaster(
+ auto surf = SkSurfaces::Raster(
SkImageInfo::Make(w, h, kRGBA_8888_SkColorType, kPremul_SkAlphaType));
surf->getCanvas()->clear(bgColor);
diff --git a/gm/drawminibitmaprect.cpp b/gm/drawminibitmaprect.cpp
index afef74f..9f9c084 100644
--- a/gm/drawminibitmaprect.cpp
+++ b/gm/drawminibitmaprect.cpp
@@ -29,7 +29,7 @@
static sk_sp<SkImage> makebm(int w, int h) {
SkImageInfo info = SkImageInfo::MakeN32Premul(w, h);
- auto surface(SkSurface::MakeRaster(info));
+ auto surface(SkSurfaces::Raster(info));
SkCanvas* canvas = surface->getCanvas();
const SkScalar wScalar = SkIntToScalar(w);
diff --git a/gm/dropshadowimagefilter.cpp b/gm/dropshadowimagefilter.cpp
index 5d90645..f59c656 100644
--- a/gm/dropshadowimagefilter.cpp
+++ b/gm/dropshadowimagefilter.cpp
@@ -67,7 +67,7 @@
SkIRect bounds;
r.roundOut(&bounds);
- auto surf = SkSurface::MakeRasterN32Premul(bounds.width(), bounds.height());
+ auto surf = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(bounds.width(), bounds.height()));
draw_path(surf->getCanvas(), r, nullptr);
paint.setImageFilter(std::move(imf));
diff --git a/gm/dstreadshuffle.cpp b/gm/dstreadshuffle.cpp
index 767c0f0..a27afca 100644
--- a/gm/dstreadshuffle.cpp
+++ b/gm/dstreadshuffle.cpp
@@ -183,7 +183,7 @@
canvas->imageInfo().alphaType(),
canvas->imageInfo().refColorSpace());
}
- surf = SkSurface::MakeRaster(info);
+ surf = SkSurfaces::Raster(info);
SkASSERT(surf);
}
canvas->scale(5.f, 5.f);
diff --git a/gm/emboss.cpp b/gm/emboss.cpp
index af414db..d5fa01b 100644
--- a/gm/emboss.cpp
+++ b/gm/emboss.cpp
@@ -24,7 +24,7 @@
#include "src/effects/SkEmbossMaskFilter.h"
static sk_sp<SkImage> make_bm() {
- auto surf = SkSurface::MakeRasterN32Premul(100, 100);
+ auto surf = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(100, 100));
SkPaint paint;
paint.setAntiAlias(true);
diff --git a/gm/encode_color_types.cpp b/gm/encode_color_types.cpp
index 7c9608f..4a1d5ae 100644
--- a/gm/encode_color_types.cpp
+++ b/gm/encode_color_types.cpp
@@ -52,8 +52,8 @@
return nullptr;
}
- auto surface = SkSurface::MakeRaster(SkImageInfo::Make(image->width(), image->height(),
- colorType, alphaType, image->refColorSpace()));
+ auto surface = SkSurfaces::Raster(SkImageInfo::Make(
+ image->width(), image->height(), colorType, alphaType, image->refColorSpace()));
surface->getCanvas()->drawImage(image, 0, 0);
return surface->makeImageSnapshot();
}
diff --git a/gm/fatpathfill.cpp b/gm/fatpathfill.cpp
index 181cb92..2228b4a 100644
--- a/gm/fatpathfill.cpp
+++ b/gm/fatpathfill.cpp
@@ -22,7 +22,7 @@
#define REPEAT_LOOP 5
static sk_sp<SkSurface> new_surface(int width, int height) {
- return SkSurface::MakeRasterN32Premul(width, height);
+ return SkSurfaces::Raster(SkImageInfo::MakeN32Premul(width, height));
}
static void draw_pixel_centers(SkCanvas* canvas) {
diff --git a/gm/filterfastbounds.cpp b/gm/filterfastbounds.cpp
index 1a2cb7d..13caf49 100644
--- a/gm/filterfastbounds.cpp
+++ b/gm/filterfastbounds.cpp
@@ -256,7 +256,7 @@
//-----------
// Paints with a SkImageSource as a source
- auto surface(SkSurface::MakeRasterN32Premul(10, 10));
+ auto surface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(10, 10)));
{
SkPaint p;
SkCanvas* temp = surface->getCanvas();
diff --git a/gm/flippity.cpp b/gm/flippity.cpp
index 06728ea..dd5cadf 100644
--- a/gm/flippity.cpp
+++ b/gm/flippity.cpp
@@ -97,7 +97,7 @@
const SkMatrix mat = SkMatrix::RectToRect(bounds, SkRect::MakeWH(kLabelSize, kLabelSize));
const SkImageInfo ii = SkImageInfo::MakeN32Premul(kLabelSize, kLabelSize);
- sk_sp<SkSurface> surf = SkSurface::MakeRaster(ii);
+ sk_sp<SkSurface> surf = SkSurfaces::Raster(ii);
SkCanvas* canvas = surf->getCanvas();
diff --git a/gm/gpu_blur_utils.cpp b/gm/gpu_blur_utils.cpp
index c764406..97811cd 100644
--- a/gm/gpu_blur_utils.cpp
+++ b/gm/gpu_blur_utils.cpp
@@ -10,6 +10,7 @@
#include "include/core/SkColorSpace.h"
#include "include/effects/SkGradientShader.h"
#include "include/gpu/GrRecordingContext.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "src/core/SkCanvasPriv.h"
#include "src/core/SkGpuBlurUtils.h"
#include "src/gpu/ganesh/GrRecordingContextPriv.h"
@@ -130,7 +131,7 @@
SkISize dimensions,
const SkIRect* contentArea = nullptr) {
auto srcII = SkImageInfo::Make(dimensions, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
- auto surf = SkSurface::MakeRenderTarget(rContext, skgpu::Budgeted::kYes, srcII);
+ auto surf = SkSurfaces::RenderTarget(rContext, skgpu::Budgeted::kYes, srcII);
if (!surf) {
return {};
}
diff --git a/gm/hugepath.cpp b/gm/hugepath.cpp
index f76ade3..611001d 100644
--- a/gm/hugepath.cpp
+++ b/gm/hugepath.cpp
@@ -44,7 +44,7 @@
auto proc = [](SkCanvas* canvas, int w, int h) {
SkAutoCanvasRestore acr(canvas, true);
- auto surf = SkSurface::MakeRasterN32Premul(w, h);
+ auto surf = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(w, h));
auto can = surf->getCanvas();
SkPaint paint;
diff --git a/gm/image.cpp b/gm/image.cpp
index 4c3775f..530b73f 100644
--- a/gm/image.cpp
+++ b/gm/image.cpp
@@ -32,12 +32,17 @@
#include "include/encode/SkPngEncoder.h"
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/ganesh/SkImageGanesh.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "include/private/base/SkMalloc.h"
#include "src/core/SkAutoPixmapStorage.h"
#include "src/core/SkReadBuffer.h"
#include "src/core/SkWriteBuffer.h"
#include "tools/ToolUtils.h"
+#if defined(SK_GRAPHITE)
+#include "include/gpu/graphite/Surface.h"
+#endif
+
#include <functional>
#include <utility>
@@ -167,10 +172,10 @@
sk_bzero(fBuffer, fBufferSize);
SkImageInfo info = SkImageInfo::MakeN32Premul(W, H);
- sk_sp<SkSurface> surf0(SkSurface::MakeRasterDirect(info, fBuffer, RB));
- sk_sp<SkSurface> surf1(SkSurface::MakeRaster(info));
- sk_sp<SkSurface> surf2(SkSurface::MakeRenderTarget(
- canvas->recordingContext(), skgpu::Budgeted::kNo, info));
+ sk_sp<SkSurface> surf0(SkSurfaces::WrapPixels(info, fBuffer, RB));
+ sk_sp<SkSurface> surf1(SkSurfaces::Raster(info));
+ sk_sp<SkSurface> surf2(
+ SkSurfaces::RenderTarget(canvas->recordingContext(), skgpu::Budgeted::kNo, info));
test_surface(canvas, surf0.get(), true);
canvas->translate(80, 0);
@@ -231,7 +236,7 @@
static sk_sp<SkImage> make_raster(const SkImageInfo& info,
GrRecordingContext*,
void (*draw)(SkCanvas*)) {
- auto surface(SkSurface::MakeRaster(info));
+ auto surface(SkSurfaces::Raster(info));
draw(surface->getCanvas());
return surface->makeImageSnapshot();
}
@@ -263,7 +268,7 @@
return nullptr;
}
- auto surface(SkSurface::MakeRenderTarget(ctx, skgpu::Budgeted::kNo, info));
+ auto surface(SkSurfaces::RenderTarget(ctx, skgpu::Budgeted::kNo, info));
if (!surface) {
return nullptr;
}
@@ -381,10 +386,10 @@
[&]() -> sk_sp<SkImage> {
sk_sp<SkSurface> surface;
if (dContext) {
- surface = SkSurface::MakeRenderTarget(dContext, skgpu::Budgeted::kYes, ii);
+ surface = SkSurfaces::RenderTarget(dContext, skgpu::Budgeted::kYes, ii);
} else {
#if defined(SK_GRAPHITE)
- surface = SkSurface::MakeGraphite(recorder, ii);
+ surface = SkSurfaces::RenderTarget(recorder, ii);
#endif
}
diff --git a/gm/image_pict.cpp b/gm/image_pict.cpp
index 12cb212..3713c5e 100644
--- a/gm/image_pict.cpp
+++ b/gm/image_pict.cpp
@@ -29,6 +29,7 @@
#include "include/gpu/GrRecordingContext.h"
#include "include/gpu/GrTypes.h"
#include "include/gpu/ganesh/GrTextureGenerator.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "include/private/gpu/ganesh/GrTypesPriv.h"
#include "src/gpu/ganesh/GrRecordingContextPriv.h"
#include "src/gpu/ganesh/GrSamplerState.h"
@@ -42,6 +43,10 @@
#include <memory>
#include <utility>
+#if defined(SK_GRAPHITE)
+#include "include/gpu/graphite/Surface.h"
+#endif
+
class GrRecordingContext;
static void draw_something(SkCanvas* canvas, const SkRect& bounds) {
@@ -177,12 +182,16 @@
sk_sp<SkSurface> surface;
if (fRContext) {
- surface = SkSurface::MakeRenderTarget(fRContext.get(), skgpu::Budgeted::kYes, info,
- 0, kTopLeft_GrSurfaceOrigin, nullptr);
+ surface = SkSurfaces::RenderTarget(fRContext.get(),
+ skgpu::Budgeted::kYes,
+ info,
+ 0,
+ kTopLeft_GrSurfaceOrigin,
+ nullptr);
}
#if defined(SK_GRAPHITE)
if (skgpu::graphite::Recorder* recorder = canvas->recorder()) {
- surface = SkSurface::MakeGraphite(recorder, info);
+ surface = SkSurfaces::RenderTarget(recorder, info);
}
#endif
diff --git a/gm/image_shader.cpp b/gm/image_shader.cpp
index 65c390a..0307a0a 100644
--- a/gm/image_shader.cpp
+++ b/gm/image_shader.cpp
@@ -28,6 +28,7 @@
#include "include/core/SkTypes.h"
#include "include/encode/SkPngEncoder.h"
#include "include/gpu/GpuTypes.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include <utility>
@@ -48,7 +49,7 @@
static sk_sp<SkImage> make_raster(GrRecordingContext*,
SkPicture* pic,
const SkImageInfo& info) {
- auto surface(SkSurface::MakeRaster(info));
+ auto surface(SkSurfaces::Raster(info));
surface->getCanvas()->clear(0);
surface->getCanvas()->drawPicture(pic);
return surface->makeImageSnapshot();
@@ -60,7 +61,7 @@
if (!ctx) {
return nullptr;
}
- auto surface(SkSurface::MakeRenderTarget(ctx, skgpu::Budgeted::kNo, info));
+ auto surface(SkSurfaces::RenderTarget(ctx, skgpu::Budgeted::kNo, info));
if (!surface) {
return nullptr;
}
@@ -219,7 +220,7 @@
image = canvas->getSurface()->makeImageSnapshot();
canvas->clear(SK_ColorRED);
} else {
- auto greenSurface = SkSurface::MakeRasterN32Premul(50, 50);
+ auto greenSurface = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(50, 50));
greenSurface->getCanvas()->clear(SK_ColorGREEN);
image = greenSurface->makeImageSnapshot();
}
@@ -229,7 +230,7 @@
// surface, to ensure that we get automatic read-back. If all goes well, we will get a pure
// green result. If either draw fails, we'll get red (most likely).
- auto surface = SkSurface::MakeRasterN32Premul(50, 50);
+ auto surface = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(50, 50));
// First, use drawImage:
surface->getCanvas()->clear(SK_ColorRED);
diff --git a/gm/imagefiltersclipped.cpp b/gm/imagefiltersclipped.cpp
index 08ed696..76c8d72 100644
--- a/gm/imagefiltersclipped.cpp
+++ b/gm/imagefiltersclipped.cpp
@@ -38,7 +38,7 @@
SkScalar x = SkIntToScalar(width / 2);
SkScalar y = SkIntToScalar(height / 2);
SkScalar radius = std::min(x, y) * 0.8f;
- auto surface(SkSurface::MakeRasterN32Premul(width, height));
+ auto surface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(width, height)));
SkCanvas* canvas = surface->getCanvas();
canvas->clear(0x00000000);
SkColor colors[2];
diff --git a/gm/imagefilterscropexpand.cpp b/gm/imagefilterscropexpand.cpp
index c2575bc..e29351c 100644
--- a/gm/imagefilterscropexpand.cpp
+++ b/gm/imagefilterscropexpand.cpp
@@ -105,7 +105,7 @@
namespace {
sk_sp<SkImage> make_checkerboard() {
- auto surf = SkSurface::MakeRasterN32Premul(64, 64);
+ auto surf = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(64, 64));
auto canvas = surf->getCanvas();
canvas->clear(0xFFFF0000);
SkPaint darkPaint;
@@ -130,7 +130,7 @@
SkScalar x = SkIntToScalar(width / 2);
SkScalar y = SkIntToScalar(height / 2);
SkScalar radius = std::min(x, y) * 0.8f;
- auto surface(SkSurface::MakeRasterN32Premul(width, height));
+ auto surface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(width, height)));
SkCanvas* canvas = surface->getCanvas();
canvas->clear(0x00000000);
SkColor colors[2];
diff --git a/gm/imagefilterscropped.cpp b/gm/imagefilterscropped.cpp
index b9eb7ff..ae91c54 100644
--- a/gm/imagefilterscropped.cpp
+++ b/gm/imagefilterscropped.cpp
@@ -62,7 +62,7 @@
SkIRect bounds;
r.roundOut(&bounds);
- auto surf = SkSurface::MakeRasterN32Premul(bounds.width(), bounds.height());
+ auto surf = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(bounds.width(), bounds.height()));
draw_path(surf->getCanvas(), r, nullptr);
paint.setImageFilter(std::move(imf));
@@ -83,7 +83,7 @@
SkISize onISize() override { return SkISize::Make(400, 960); }
void make_checkerboard() {
- auto surf = SkSurface::MakeRasterN32Premul(80, 80);
+ auto surf = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(80, 80));
auto canvas = surf->getCanvas();
SkPaint darkPaint;
darkPaint.setColor(0xFF404040);
diff --git a/gm/imagefiltersscaled.cpp b/gm/imagefiltersscaled.cpp
index e2df506..0118b05 100644
--- a/gm/imagefiltersscaled.cpp
+++ b/gm/imagefiltersscaled.cpp
@@ -37,7 +37,7 @@
SkScalar x = SkIntToScalar(width / 2);
SkScalar y = SkIntToScalar(height / 2);
SkScalar radius = std::min(x, y) * 4 / 5;
- sk_sp<SkSurface> surface(SkSurface::MakeRasterN32Premul(width, height));
+ sk_sp<SkSurface> surface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(width, height)));
SkCanvas* canvas = surface->getCanvas();
canvas->clear(0x00000000);
SkColor colors[2];
diff --git a/gm/imagefilterstransformed.cpp b/gm/imagefilterstransformed.cpp
index ed1f86a..0908ddc 100644
--- a/gm/imagefilterstransformed.cpp
+++ b/gm/imagefilterstransformed.cpp
@@ -42,7 +42,7 @@
SkScalar y = SkIntToScalar(height / 2);
SkScalar radius = std::min(x, y) * 0.8f;
- auto surface(SkSurface::MakeRasterN32Premul(width, height));
+ auto surface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(width, height)));
SkCanvas* canvas = surface->getCanvas();
canvas->clear(0x00000000);
diff --git a/gm/imagefromyuvtextures.cpp b/gm/imagefromyuvtextures.cpp
index 41186d5a..483e2f1 100644
--- a/gm/imagefromyuvtextures.cpp
+++ b/gm/imagefromyuvtextures.cpp
@@ -27,6 +27,7 @@
#include "include/gpu/GrBackendSurface.h"
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/GrTypes.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "include/private/base/SkTo.h"
#include "src/base/SkMathPriv.h"
#include "src/core/SkYUVMath.h"
@@ -134,7 +135,7 @@
auto resultInfo = SkImageInfo::Make(fLazyYUVImage->dimensions(),
kRGBA_8888_SkColorType,
kPremul_SkAlphaType);
- auto resultSurface = SkSurface::MakeRenderTarget(
+ auto resultSurface = SkSurfaces::RenderTarget(
dContext, skgpu::Budgeted::kYes, resultInfo, 1, kTopLeft_GrSurfaceOrigin, nullptr);
if (!resultSurface) {
return nullptr;
diff --git a/gm/imagemakewithfilter.cpp b/gm/imagemakewithfilter.cpp
index 9c8cd02..f72d43a 100644
--- a/gm/imagemakewithfilter.cpp
+++ b/gm/imagemakewithfilter.cpp
@@ -210,7 +210,7 @@
void onOnceBeforeDraw() override {
SkImageInfo info = SkImageInfo::MakeN32(100, 100, kUnpremul_SkAlphaType);
- auto surface = SkSurface::MakeRaster(info, nullptr);
+ auto surface = SkSurfaces::Raster(info, nullptr);
sk_sp<SkImage> colorImage = GetResourceAsImage("images/mandrill_128.png");
// Resize to 100x100
diff --git a/gm/imagemasksubset.cpp b/gm/imagemasksubset.cpp
index 12c6a44..736fb09 100644
--- a/gm/imagemasksubset.cpp
+++ b/gm/imagemasksubset.cpp
@@ -18,8 +18,13 @@
#include "include/core/SkSurface.h"
#include "include/core/SkTypes.h"
#include "include/gpu/GrDirectContext.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "tools/ToolUtils.h"
+#if defined(SK_GRAPHITE)
+#include "include/gpu/graphite/Surface.h"
+#endif
+
namespace {
const SkISize kSize = SkISize::Make(100, 100);
@@ -42,7 +47,7 @@
surfaceInfo = surfaceInfo.makeColorSpace(nullptr);
}
- make_mask(SkSurface::MakeRasterDirect(surfaceInfo, pixels, rowBytes));
+ make_mask(SkSurfaces::WrapPixels(surfaceInfo, pixels, rowBytes));
return true;
}
@@ -54,21 +59,21 @@
const MakerT makers[] = {
// SkImage_Raster
[](SkCanvas*, const SkImageInfo& info) -> sk_sp<SkImage> {
- return make_mask(SkSurface::MakeRaster(info));
+ return make_mask(SkSurfaces::Raster(info));
},
// SkImage_Ganesh
[](SkCanvas* c, const SkImageInfo& info) -> sk_sp<SkImage> {
sk_sp<SkSurface> surface;
if (c->recordingContext()) {
- surface = SkSurface::MakeRenderTarget(
- c->recordingContext(), skgpu::Budgeted::kNo, info);
+ surface =
+ SkSurfaces::RenderTarget(c->recordingContext(), skgpu::Budgeted::kNo, info);
} else {
#if defined(SK_GRAPHITE)
- surface = SkSurface::MakeGraphite(c->recorder(), info);
+ surface = SkSurfaces::RenderTarget(c->recorder(), info);
#endif
}
- return make_mask(surface ? surface : SkSurface::MakeRaster(info));
+ return make_mask(surface ? surface : SkSurfaces::Raster(info));
},
// SkImage_Lazy
diff --git a/gm/imagesource2.cpp b/gm/imagesource2.cpp
index 550a0fb..4045828 100644
--- a/gm/imagesource2.cpp
+++ b/gm/imagesource2.cpp
@@ -52,7 +52,7 @@
SK_ColorWHITE, SK_ColorGRAY,
};
- auto surface(SkSurface::MakeRasterN32Premul(kImageSize, kImageSize));
+ auto surface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(kImageSize, kImageSize)));
SkCanvas* canvas = surface->getCanvas();
int curColor = 0;
diff --git a/gm/kawase_blur_rt.cpp b/gm/kawase_blur_rt.cpp
index 6f5b91a..7ba9efc 100644
--- a/gm/kawase_blur_rt.cpp
+++ b/gm/kawase_blur_rt.cpp
@@ -79,7 +79,7 @@
return surface;
}
// serialize-8888 returns null from makeSurface; fallback to a raster surface.
- return SkSurface::MakeRaster(info);
+ return SkSurfaces::Raster(info);
}
void draw(SkCanvas* canvas, sk_sp<SkImage> input, int blurRadius) {
diff --git a/gm/localmatrixshader.cpp b/gm/localmatrixshader.cpp
index 1d15063..2df9f88 100644
--- a/gm/localmatrixshader.cpp
+++ b/gm/localmatrixshader.cpp
@@ -28,7 +28,7 @@
static sk_sp<SkImage> make_image(SkCanvas* rootCanvas) {
static constexpr SkScalar kSize = 50;
SkImageInfo info = SkImageInfo::MakeN32Premul(kSize, kSize);
- auto surface(SkSurface::MakeRaster(info));
+ auto surface(SkSurfaces::Raster(info));
SkPaint p;
p.setAntiAlias(true);
diff --git a/gm/mac_aa_explorer.cpp b/gm/mac_aa_explorer.cpp
index 6071ff8..45e51f0 100644
--- a/gm/mac_aa_explorer.cpp
+++ b/gm/mac_aa_explorer.cpp
@@ -79,7 +79,7 @@
for (SkColorType ct : {kRGBA_8888_SkColorType, kGray_8_SkColorType, kAlpha_8_SkColorType}) {
SkImageInfo ii = SkImageInfo::Make(w, h, ct, kPremul_SkAlphaType);
- auto surf = SkSurface::MakeRaster(ii);
+ auto surf = SkSurfaces::Raster(ii);
SkPixmap pm;
surf->peekPixels(&pm);
CGContextRef ctx = make_cg_ctx(pm);
diff --git a/gm/matrixconvolution.cpp b/gm/matrixconvolution.cpp
index f721a80..6a833e8 100644
--- a/gm/matrixconvolution.cpp
+++ b/gm/matrixconvolution.cpp
@@ -52,7 +52,7 @@
void makeBitmap() {
// Draw our bitmap in N32, so legacy devices get "premul" values they understand
- auto surf = SkSurface::MakeRasterN32Premul(80, 80);
+ auto surf = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(80, 80));
SkPaint paint;
paint.setColor(0xFFFFFFFF);
SkPoint pts[2] = { {0, 0},
diff --git a/gm/mipmap.cpp b/gm/mipmap.cpp
index 60aa818..ea028f8 100644
--- a/gm/mipmap.cpp
+++ b/gm/mipmap.cpp
@@ -20,7 +20,7 @@
static sk_sp<SkImage> make_image() {
const SkImageInfo info = SkImageInfo::MakeN32Premul(319, 52);
- auto surface(SkSurface::MakeRaster(info));
+ auto surface(SkSurfaces::Raster(info));
SkCanvas* canvas = surface->getCanvas();
canvas->drawColor(0xFFF8F8F8);
diff --git a/gm/morphology.cpp b/gm/morphology.cpp
index ee1afae..6bb56a2 100644
--- a/gm/morphology.cpp
+++ b/gm/morphology.cpp
@@ -37,7 +37,7 @@
}
void onOnceBeforeDraw() override {
- auto surf = SkSurface::MakeRasterN32Premul(135, 135);
+ auto surf = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(135, 135));
SkFont font(ToolUtils::create_portable_typeface(), 64.0f);
SkPaint paint;
diff --git a/gm/orientation.cpp b/gm/orientation.cpp
index c6ba90c..b97765c 100644
--- a/gm/orientation.cpp
+++ b/gm/orientation.cpp
@@ -50,9 +50,8 @@
swap(size.fWidth, size.fHeight);
}
using std::swap;
- auto surf = SkSurface::MakeRaster(SkImageInfo::Make(size,
- kRGBA_8888_SkColorType,
- kPremul_SkAlphaType));
+ auto surf = SkSurfaces::Raster(
+ SkImageInfo::Make(size, kRGBA_8888_SkColorType, kPremul_SkAlphaType));
auto* canvas = surf->getCanvas();
SkMatrix m = SkEncodedOriginToMatrix(origin, kImgW, kImgH);
SkAssertResult(m.invert(&m));
diff --git a/gm/overdrawcanvas.cpp b/gm/overdrawcanvas.cpp
index 4844dd9..46d1240 100644
--- a/gm/overdrawcanvas.cpp
+++ b/gm/overdrawcanvas.cpp
@@ -32,7 +32,7 @@
DEF_SIMPLE_GM_BG(overdraw_canvas, canvas, WIDTH, HEIGHT, SK_ColorWHITE) {
// Set up the overdraw canvas.
SkImageInfo offscreenInfo = SkImageInfo::MakeA8(WIDTH, HEIGHT);
- sk_sp<SkSurface> offscreen = SkSurface::MakeRaster(offscreenInfo);
+ sk_sp<SkSurface> offscreen = SkSurfaces::Raster(offscreenInfo);
auto c = offscreen->getCanvas();
SkOverdrawCanvas overdrawCanvas(c);
@@ -57,7 +57,7 @@
}
static sk_sp<SkImage> overdraw_text_grid(bool useCTM) {
- auto surface = SkSurface::MakeRaster(SkImageInfo::MakeA8(256, 512));
+ auto surface = SkSurfaces::Raster(SkImageInfo::MakeA8(256, 512));
auto canvas = SkOverdrawCanvas(surface->getCanvas());
SkPaint paint;
diff --git a/gm/path_stroke_with_zero_length.cpp b/gm/path_stroke_with_zero_length.cpp
index 146e390..93e1781 100644
--- a/gm/path_stroke_with_zero_length.cpp
+++ b/gm/path_stroke_with_zero_length.cpp
@@ -135,7 +135,7 @@
SkImageInfo info = canvas->imageInfo().makeWH(kCellWidth, kCellHeight);
auto surface = canvas->makeSurface(info);
if (!surface) {
- surface = SkSurface::MakeRasterN32Premul(kCellWidth, kCellHeight);
+ surface = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(kCellWidth, kCellHeight));
}
SkPaint paint;
@@ -201,7 +201,7 @@
SkImageInfo info = canvas->imageInfo().makeWH(kCellWidth, kCellHeight);
auto surface = canvas->makeSurface(info);
if (!surface) {
- surface = SkSurface::MakeRasterN32Premul(kCellWidth, kCellHeight);
+ surface = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(kCellWidth, kCellHeight));
}
SkPaint paint;
diff --git a/gm/pathfill.cpp b/gm/pathfill.cpp
index d9576f5..caa6641 100644
--- a/gm/pathfill.cpp
+++ b/gm/pathfill.cpp
@@ -630,7 +630,7 @@
DEF_SIMPLE_GM(path_stroke_clip_crbug1070835, canvas, 25, 50) {
SkCanvas* orig = canvas;
- auto surf = SkSurface::MakeRasterN32Premul(25, 25);
+ auto surf = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(25, 25));
canvas = surf->getCanvas();
SkPaint p;
diff --git a/gm/pictureshadercache.cpp b/gm/pictureshadercache.cpp
index 3cfd396..cf79826 100644
--- a/gm/pictureshadercache.cpp
+++ b/gm/pictureshadercache.cpp
@@ -80,7 +80,7 @@
sk_sp<SkColorSpace> gty = SkColorSpace::MakeRGB(SkNamedTransferFn::kSRGB,
greenToYellow);
SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100, std::move(gty));
- sk_sp<SkSurface> surface(SkSurface::MakeRaster(info));
+ sk_sp<SkSurface> surface(SkSurfaces::Raster(info));
surface->getCanvas()->drawRect(SkRect::MakeWH(fTileSize, fTileSize), paint);
}
diff --git a/gm/postercircle.cpp b/gm/postercircle.cpp
index d9a62b4..a271ad0 100644
--- a/gm/postercircle.cpp
+++ b/gm/postercircle.cpp
@@ -51,7 +51,8 @@
font.setEmbolden(true);
font.setSize(24.f);
- sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul(kPosterSize, kPosterSize);
+ sk_sp<SkSurface> surface =
+ SkSurfaces::Raster(SkImageInfo::MakeN32Premul(kPosterSize, kPosterSize));
for (int i = 0; i < kNumAngles; ++i) {
SkCanvas* canvas = surface->getCanvas();
diff --git a/gm/rasterhandleallocator.cpp b/gm/rasterhandleallocator.cpp
index 1096945..1805c72 100644
--- a/gm/rasterhandleallocator.cpp
+++ b/gm/rasterhandleallocator.cpp
@@ -61,7 +61,7 @@
SkiaAllocator() {}
bool allocHandle(const SkImageInfo& info, Rec* rec) override {
- sk_sp<SkSurface> surface = SkSurface::MakeRaster(info);
+ sk_sp<SkSurface> surface = SkSurfaces::Raster(info);
if (!surface) {
return false;
}
diff --git a/gm/resizeimagefilter.cpp b/gm/resizeimagefilter.cpp
index 330b5f2..866c446 100644
--- a/gm/resizeimagefilter.cpp
+++ b/gm/resizeimagefilter.cpp
@@ -88,7 +88,7 @@
}
{
- sk_sp<SkSurface> surface(SkSurface::MakeRasterN32Premul(16, 16));
+ sk_sp<SkSurface> surface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(16, 16)));
SkCanvas* surfaceCanvas = surface->getCanvas();
surfaceCanvas->clear(0x000000);
{
diff --git a/gm/rsxtext.cpp b/gm/rsxtext.cpp
index c4d184c..0617c87 100644
--- a/gm/rsxtext.cpp
+++ b/gm/rsxtext.cpp
@@ -85,7 +85,8 @@
static sk_sp<SkShader> make_shader(const SkMatrix& lm, const SkMatrix& outer_lm) {
static constexpr SkISize kTileSize = { 30, 30 };
- auto surface = SkSurface::MakeRasterN32Premul(kTileSize.width(), kTileSize.height());
+ auto surface = SkSurfaces::Raster(
+ SkImageInfo::MakeN32Premul(kTileSize.width(), kTileSize.height()));
SkPaint p;
p.setColor(0xffffff00);
diff --git a/gm/runtimecolorfilter.cpp b/gm/runtimecolorfilter.cpp
index 4ab1dce..587745f 100644
--- a/gm/runtimecolorfilter.cpp
+++ b/gm/runtimecolorfilter.cpp
@@ -142,7 +142,7 @@
kRGBA_8888_SkColorType,
kPremul_SkAlphaType,
canvas->imageInfo().refColorSpace());
- auto surf = SkSurface::MakeRaster(info);
+ auto surf = SkSurfaces::Raster(info);
surf->getCanvas()->drawVertices(verts, SkBlendMode::kDst, SkPaint());
auto atlas = surf->makeImageSnapshot();
auto xform = SkRSXform::Make(1, 0, 0, 0);
diff --git a/gm/runtimeintrinsics.cpp b/gm/runtimeintrinsics.cpp
index 230d9ee..510af08 100644
--- a/gm/runtimeintrinsics.cpp
+++ b/gm/runtimeintrinsics.cpp
@@ -67,7 +67,7 @@
SkImageInfo info = SkImageInfo::MakeN32Premul({kBoxSize, kBoxSize});
auto surface = canvas->makeSurface(info);
if (allowRasterFallback && !surface) {
- surface = SkSurface::MakeRaster(info);
+ surface = SkSurfaces::Raster(info);
}
if (surface) {
diff --git a/gm/runtimeshader.cpp b/gm/runtimeshader.cpp
index 1747bfd..d7c807e 100644
--- a/gm/runtimeshader.cpp
+++ b/gm/runtimeshader.cpp
@@ -96,7 +96,7 @@
static sk_sp<SkShader> make_threshold(SkISize size) {
auto info = SkImageInfo::Make(size.width(), size.height(), kAlpha_8_SkColorType,
kPremul_SkAlphaType);
- auto surf = SkSurface::MakeRaster(info);
+ auto surf = SkSurfaces::Raster(info);
auto canvas = surf->getCanvas();
const SkScalar rad = 50;
@@ -665,7 +665,7 @@
256, 64, kN32_SkColorType, kPremul_SkAlphaType, sk_ref_sp(cs));
auto surface = canvas->makeSurface(info);
if (!surface) {
- surface = SkSurface::MakeRaster(info);
+ surface = SkSurfaces::Raster(info);
}
surface->getCanvas()->drawRect({0, 0, 256, 64}, paint);
@@ -691,7 +691,7 @@
p.setStyle(SkPaint::kStroke_Style);
p.setStrokeWidth(1);
- auto surf = SkSurface::MakeRasterN32Premul(100,100);
+ auto surf = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(100, 100));
surf->getCanvas()->drawLine(0, 0, 100, 100, p);
auto shader = surf->makeImageSnapshot()->makeShader(SkSamplingOptions(SkFilterMode::kLinear));
@@ -719,7 +719,7 @@
static sk_sp<SkImage> normal_map_image() {
// Above, baked into an image:
auto info = SkImageInfo::Make(256, 256, kN32_SkColorType, kPremul_SkAlphaType);
- auto surface = SkSurface::MakeRaster(info);
+ auto surface = SkSurfaces::Raster(info);
SkPaint p;
p.setShader(normal_map_shader());
surface->getCanvas()->drawPaint(p);
@@ -820,7 +820,7 @@
SkColorSpace::MakeSRGB()->makeColorSpin());
auto surface = canvas->makeSurface(surfInfo);
if (!surface) {
- surface = SkSurface::MakeRaster(surfInfo);
+ surface = SkSurfaces::Raster(surfInfo);
}
auto draw_shader = [](int x, int y, sk_sp<SkShader> shader, SkCanvas* canvas) {
@@ -870,7 +870,7 @@
SkColorSpace::MakeSRGB());
auto surface = canvas->makeSurface(surfInfo);
if (!surface) {
- surface = SkSurface::MakeRaster(surfInfo);
+ surface = SkSurfaces::Raster(surfInfo);
}
auto draw_shader = [](int x, int y, sk_sp<SkShader> shader, SkCanvas* canvas) {
@@ -1069,7 +1069,7 @@
SkImageInfo::Make(50, 50, kN32_SkColorType, kPremul_SkAlphaType, spin);
auto surface = canvas->makeSurface(spinInfo);
if (!surface) {
- surface = SkSurface::MakeRaster(spinInfo);
+ surface = SkSurfaces::Raster(spinInfo);
}
SkPaint paint;
diff --git a/gm/showmiplevels.cpp b/gm/showmiplevels.cpp
index b39c966..150a0d8 100644
--- a/gm/showmiplevels.cpp
+++ b/gm/showmiplevels.cpp
@@ -42,7 +42,7 @@
SkMipmapBuilder builder(fImg->imageInfo());
for (int i = 0; i < builder.countLevels(); ++i) {
- auto surf = SkSurface::MakeRasterDirect(builder.level(i));
+ auto surf = SkSurfaces::WrapPixels(builder.level(i));
surf->getCanvas()->drawColor(colors[i % std::size(colors)]);
}
fImg = builder.attachTo(fImg);
diff --git a/gm/skbug_12212.cpp b/gm/skbug_12212.cpp
index d701b39..9eb88ac 100644
--- a/gm/skbug_12212.cpp
+++ b/gm/skbug_12212.cpp
@@ -13,16 +13,17 @@
#include "include/core/SkSurface.h"
#include "include/core/SkTextBlob.h"
#include "include/gpu/GpuTypes.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
DEF_SIMPLE_GM_BG(skbug_12212, canvas, 400, 400, SK_ColorCYAN) {
// Create an Alpha_8 surface to draw into (strangely, with RGB pixel geometry).
auto imageInfo = SkImageInfo::Make(/*width=*/400, /*height=*/400, kAlpha_8_SkColorType,
kPremul_SkAlphaType);
SkSurfaceProps props(/*flags=*/0, kRGB_H_SkPixelGeometry);
- sk_sp<SkSurface> surface = SkSurface::MakeRenderTarget(
+ sk_sp<SkSurface> surface = SkSurfaces::RenderTarget(
canvas->recordingContext(), skgpu::Budgeted::kNo, imageInfo, /*sampleCount=*/0, &props);
if (!surface) {
- surface = SkSurface::MakeRaster(imageInfo, &props);
+ surface = SkSurfaces::Raster(imageInfo, &props);
}
// Draw text into the surface using LCD antialiasing.
diff --git a/gm/srcmode.cpp b/gm/srcmode.cpp
index f2b9eee..2ad19bd 100644
--- a/gm/srcmode.cpp
+++ b/gm/srcmode.cpp
@@ -124,7 +124,7 @@
sk_sp<SkSurface> surface = canvas->makeSurface(info);
if (nullptr == surface) {
// picture canvas will return null, so fall-back to raster
- surface = SkSurface::MakeRaster(info);
+ surface = SkSurfaces::Raster(info);
}
return surface;
}
diff --git a/gm/surface.cpp b/gm/surface.cpp
index 028576e..3ffef34 100644
--- a/gm/surface.cpp
+++ b/gm/surface.cpp
@@ -29,6 +29,7 @@
#include "include/effects/SkGradientShader.h"
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/GrRecordingContext.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "include/utils/SkTextUtils.h"
#include "tools/ToolUtils.h"
#include "tools/gpu/BackendSurfaceFactory.h"
@@ -49,9 +50,9 @@
SkPixelGeometry geo) {
SkSurfaceProps props(0, geo);
if (ctx) {
- return SkSurface::MakeRenderTarget(ctx, skgpu::Budgeted::kNo, info, 0, &props);
+ return SkSurfaces::RenderTarget(ctx, skgpu::Budgeted::kNo, info, 0, &props);
} else {
- return SkSurface::MakeRaster(info, &props);
+ return SkSurfaces::Raster(info, &props);
}
}
@@ -306,7 +307,7 @@
ct,
kPremul_SkAlphaType,
canvas->imageInfo().refColorSpace());
- auto surface = SkSurface::MakeRaster(ii);
+ auto surface = SkSurfaces::Raster(ii);
auto nextImage = [&](SkColor color) {
surface->getCanvas()->clear(color);
diff --git a/gm/textblobmixedsizes.cpp b/gm/textblobmixedsizes.cpp
index d9c343f..d29d4e7 100644
--- a/gm/textblobmixedsizes.cpp
+++ b/gm/textblobmixedsizes.cpp
@@ -26,6 +26,7 @@
#include "include/core/SkTypeface.h"
#include "include/core/SkTypes.h"
#include "include/gpu/GpuTypes.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "src/base/SkRandom.h"
#include "src/core/SkBlurMask.h"
#include "tools/Resources.h"
@@ -116,7 +117,7 @@
SkSurfaceProps props(
SkSurfaceProps::kUseDeviceIndependentFonts_Flag | inputProps.flags(),
inputProps.pixelGeometry());
- surface = SkSurface::MakeRenderTarget(ctx, skgpu::Budgeted::kNo, info, 0, &props);
+ surface = SkSurfaces::RenderTarget(ctx, skgpu::Budgeted::kNo, info, 0, &props);
canvas = surface ? surface->getCanvas() : inputCanvas;
// init our new canvas with the old canvas's matrix
canvas->setMatrix(inputCanvas->getTotalMatrix());
diff --git a/gm/transparency.cpp b/gm/transparency.cpp
index e872192..d3d22ba 100644
--- a/gm/transparency.cpp
+++ b/gm/transparency.cpp
@@ -71,7 +71,7 @@
checkerboard(canvas, 0xFF999999, 0xFF666666, 8);
{
SkAutoCanvasRestore autoCanvasRestore(canvas, true);
- auto surface(SkSurface::MakeRasterN32Premul(256, 9));
+ auto surface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(256, 9)));
make_transparency(surface->getCanvas(), 256.0f, 9.0f);
canvas->scale(7.0f, 120.0f);
surface->draw(canvas, 0, 0);
diff --git a/gm/verylargebitmap.cpp b/gm/verylargebitmap.cpp
index e465a8f..e22e51c 100644
--- a/gm/verylargebitmap.cpp
+++ b/gm/verylargebitmap.cpp
@@ -37,7 +37,7 @@
}
static sk_sp<SkImage> make_raster_image(int width, int height, SkColor colors[2]) {
- auto surface(SkSurface::MakeRasterN32Premul(width, height));
+ auto surface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(width, height)));
draw(surface->getCanvas(), width, height, colors);
return surface->makeImageSnapshot();
}
diff --git a/gm/yuv420_odd_dim.cpp b/gm/yuv420_odd_dim.cpp
index c3d7b6f..290bdac 100644
--- a/gm/yuv420_odd_dim.cpp
+++ b/gm/yuv420_odd_dim.cpp
@@ -78,7 +78,7 @@
}
auto info = canvas->imageInfo().makeColorType(ct);
info = info.makeAlphaType(kPremul_SkAlphaType);
- surface = SkSurface::MakeRaster(info);
+ surface = SkSurfaces::Raster(info);
}
surface->getCanvas()->drawImage(image, 0, 0);
canvas->scale(kScale, kScale);
diff --git a/gn/gpu.gni b/gn/gpu.gni
index 1cf5724..f628064 100644
--- a/gn/gpu.gni
+++ b/gn/gpu.gni
@@ -99,6 +99,7 @@
# //src/gpu/ganesh/ops:ops_srcs
# //src/gpu/ganesh/surface:surface_srcs
# //src/gpu/ganesh/surface:surface_srcs
+# //src/gpu/ganesh/surface:android_srcs
# //src/gpu/ganesh/tessellate:tessellate_hdrs
# //src/gpu/ganesh/tessellate:tessellate_srcs
# //src/gpu/ganesh/text:private_hdrs
@@ -539,6 +540,7 @@
"$_src/gpu/ganesh/ops/TextureOp.h",
"$_src/gpu/ganesh/ops/TriangulatingPathRenderer.cpp",
"$_src/gpu/ganesh/ops/TriangulatingPathRenderer.h",
+ "$_src/gpu/ganesh/surface/SkSurface_AndroidFactories.cpp",
"$_src/gpu/ganesh/surface/SkSurface_Ganesh.cpp",
"$_src/gpu/ganesh/tessellate/GrPathTessellationShader.cpp",
"$_src/gpu/ganesh/tessellate/GrPathTessellationShader.h",
diff --git a/include/android/SkSurfaceAndroid.h b/include/android/SkSurfaceAndroid.h
new file mode 100644
index 0000000..1420665
--- /dev/null
+++ b/include/android/SkSurfaceAndroid.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2023 Google LLC
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkSurfaceAndroid_DEFINED
+#define SkSurfaceAndroid_DEFINED
+
+#include "include/core/SkRefCnt.h"
+#include "include/core/SkSurface.h"
+#include "include/gpu/GrTypes.h"
+
+class SkColorSpace;
+class GrDirectContext;
+class SkPixmap;
+struct AHardwareBuffer;
+
+namespace SkSurfaces {
+
+/** Private; only to be used by Android Framework.
+ Creates SkSurface from Android hardware buffer.
+ Returned SkSurface takes a reference on the buffer. The ref on the buffer will be released
+ when the SkSurface is destroyed and there is no pending work on the GPU involving the
+ buffer.
+
+ Currently this is only supported for buffers that can be textured as well as rendered to.
+ In other words that must have both AHARDWAREBUFFER_USAGE_GPU_COLOR_OUTPUT and
+ AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE usage bits.
+
+ @param context GPU context
+ @param hardwareBuffer AHardwareBuffer Android hardware buffer
+ @param colorSpace range of colors; may be nullptr
+ @param surfaceProps LCD striping orientation and setting for device independent
+ fonts; may be nullptr
+ @param fromWindow Whether or not the AHardwareBuffer is part of an Android Window.
+ Currently only used with Vulkan backend.
+ @return created SkSurface, or nullptr
+*/
+SK_API sk_sp<SkSurface> WrapAndroidHardwareBuffer(GrDirectContext* context,
+ AHardwareBuffer* hardwareBuffer,
+ GrSurfaceOrigin origin,
+ sk_sp<SkColorSpace> colorSpace,
+ const SkSurfaceProps* surfaceProps,
+ bool fromWindow = false);
+
+} // namespace SkSurfaces
+
+#endif
diff --git a/include/core/SkSurface.h b/include/core/SkSurface.h
index 6dade39..cad29d1 100644
--- a/include/core/SkSurface.h
+++ b/include/core/SkSurface.h
@@ -17,12 +17,6 @@
#include "include/core/SkSurfaceProps.h"
#include "include/core/SkTypes.h"
-#if defined(SK_GANESH)
-#include "include/gpu/GrTypes.h"
-#else
-enum GrSurfaceOrigin: int;
-#endif
-
#if defined(SK_GRAPHITE)
#include "include/gpu/GpuTypes.h"
namespace skgpu::graphite {
@@ -53,8 +47,12 @@
class SkColorSpace;
class SkDeferredDisplayList;
class SkPaint;
+class SkSurface;
class SkSurfaceCharacterization;
+enum GrSurfaceOrigin : int;
enum SkColorType : int;
+enum class GrSemaphoresSubmitted : bool;
+struct GrFlushInfo;
struct SkIRect;
struct SkISize;
@@ -67,6 +65,97 @@
class Recorder;
}
+namespace SkSurfaces {
+/** Allocates raster SkSurface. SkCanvas returned by SkSurface draws directly into those allocated
+ pixels, which are zeroed before use. Pixel memory size is imageInfo.height() times
+ imageInfo.minRowBytes() or rowBytes, if provided and non-zero.
+
+ Pixel memory is deleted when SkSurface is deleted.
+
+ Validity constraints include:
+ - info dimensions are greater than zero;
+ - info contains SkColorType and SkAlphaType supported by raster surface.
+
+ @param imageInfo width, height, SkColorType, SkAlphaType, SkColorSpace,
+ of raster surface; width and height must be greater than zero
+ @param rowBytes interval from one SkSurface row to the next.
+ @param props LCD striping orientation and setting for device independent fonts;
+ may be nullptr
+ @return SkSurface if parameters are valid and memory was allocated, else nullptr.
+*/
+SK_API sk_sp<SkSurface> Raster(const SkImageInfo& imageInfo,
+ size_t rowBytes,
+ const SkSurfaceProps* surfaceProps);
+inline sk_sp<SkSurface> Raster(const SkImageInfo& imageInfo,
+ const SkSurfaceProps* props = nullptr) {
+ return Raster(imageInfo, 0, props);
+}
+
+/** Allocates raster SkSurface. SkCanvas returned by SkSurface draws directly into the
+ provided pixels.
+
+ SkSurface is returned if all parameters are valid.
+ Valid parameters include:
+ info dimensions are greater than zero;
+ info contains SkColorType and SkAlphaType supported by raster surface;
+ pixels is not nullptr;
+ rowBytes is large enough to contain info width pixels of SkColorType.
+
+ Pixel buffer size should be info height times computed rowBytes.
+ Pixels are not initialized.
+ To access pixels after drawing, peekPixels() or readPixels().
+
+ @param imageInfo width, height, SkColorType, SkAlphaType, SkColorSpace,
+ of raster surface; width and height must be greater than zero
+ @param pixels pointer to destination pixels buffer
+ @param rowBytes interval from one SkSurface row to the next
+ @param surfaceProps LCD striping orientation and setting for device independent fonts;
+ may be nullptr
+ @return SkSurface if all parameters are valid; otherwise, nullptr
+*/
+
+SK_API sk_sp<SkSurface> WrapPixels(const SkImageInfo& imageInfo,
+ void* pixels,
+ size_t rowBytes,
+ const SkSurfaceProps* surfaceProps = nullptr);
+inline sk_sp<SkSurface> WrapPixels(const SkPixmap& pm, const SkSurfaceProps* props = nullptr) {
+ return WrapPixels(pm.info(), pm.writable_addr(), pm.rowBytes(), props);
+}
+
+using PixelsReleaseProc = void(void* pixels, void* context);
+
+/** Allocates raster SkSurface. SkCanvas returned by SkSurface draws directly into the provided
+ pixels. releaseProc is called with pixels and context when SkSurface is deleted.
+
+ SkSurface is returned if all parameters are valid.
+ Valid parameters include:
+ info dimensions are greater than zero;
+ info contains SkColorType and SkAlphaType supported by raster surface;
+ pixels is not nullptr;
+ rowBytes is large enough to contain info width pixels of SkColorType.
+
+ Pixel buffer size should be info height times computed rowBytes.
+ Pixels are not initialized.
+ To access pixels after drawing, call flush() or peekPixels().
+
+ @param imageInfo width, height, SkColorType, SkAlphaType, SkColorSpace,
+ of raster surface; width and height must be greater than zero
+ @param pixels pointer to destination pixels buffer
+ @param rowBytes interval from one SkSurface row to the next
+ @param releaseProc called when SkSurface is deleted; may be nullptr
+ @param context passed to releaseProc; may be nullptr
+ @param surfaceProps LCD striping orientation and setting for device independent fonts;
+ may be nullptr
+ @return SkSurface if all parameters are valid; otherwise, nullptr
+*/
+SK_API sk_sp<SkSurface> WrapPixels(const SkImageInfo& imageInfo,
+ void* pixels,
+ size_t rowBytes,
+ PixelsReleaseProc,
+ void* context,
+ const SkSurfaceProps* surfaceProps = nullptr);
+} // namespace SkSurfaces
+
/** \class SkSurface
SkSurface is responsible for managing the pixels that a canvas draws into. The pixels can be
allocated either in CPU memory (a raster surface) or on the GPU (a GrRenderTarget surface).
@@ -80,434 +169,6 @@
*/
class SK_API SkSurface : public SkRefCnt {
public:
-
- /** Allocates raster SkSurface. SkCanvas returned by SkSurface draws directly into pixels.
-
- SkSurface is returned if all parameters are valid.
- Valid parameters include:
- info dimensions are greater than zero;
- info contains SkColorType and SkAlphaType supported by raster surface;
- pixels is not nullptr;
- rowBytes is large enough to contain info width pixels of SkColorType.
-
- Pixel buffer size should be info height times computed rowBytes.
- Pixels are not initialized.
- To access pixels after drawing, peekPixels() or readPixels().
-
- @param imageInfo width, height, SkColorType, SkAlphaType, SkColorSpace,
- of raster surface; width and height must be greater than zero
- @param pixels pointer to destination pixels buffer
- @param rowBytes interval from one SkSurface row to the next
- @param surfaceProps LCD striping orientation and setting for device independent fonts;
- may be nullptr
- @return SkSurface if all parameters are valid; otherwise, nullptr
- */
- static sk_sp<SkSurface> MakeRasterDirect(const SkImageInfo& imageInfo, void* pixels,
- size_t rowBytes,
- const SkSurfaceProps* surfaceProps = nullptr);
-
- static sk_sp<SkSurface> MakeRasterDirect(const SkPixmap& pm,
- const SkSurfaceProps* props = nullptr) {
- return MakeRasterDirect(pm.info(), pm.writable_addr(), pm.rowBytes(), props);
- }
-
- /** Allocates raster SkSurface. SkCanvas returned by SkSurface draws directly into pixels.
- releaseProc is called with pixels and context when SkSurface is deleted.
-
- SkSurface is returned if all parameters are valid.
- Valid parameters include:
- info dimensions are greater than zero;
- info contains SkColorType and SkAlphaType supported by raster surface;
- pixels is not nullptr;
- rowBytes is large enough to contain info width pixels of SkColorType.
-
- Pixel buffer size should be info height times computed rowBytes.
- Pixels are not initialized.
- To access pixels after drawing, call flush() or peekPixels().
-
- @param imageInfo width, height, SkColorType, SkAlphaType, SkColorSpace,
- of raster surface; width and height must be greater than zero
- @param pixels pointer to destination pixels buffer
- @param rowBytes interval from one SkSurface row to the next
- @param releaseProc called when SkSurface is deleted; may be nullptr
- @param context passed to releaseProc; may be nullptr
- @param surfaceProps LCD striping orientation and setting for device independent fonts;
- may be nullptr
- @return SkSurface if all parameters are valid; otherwise, nullptr
- */
- static sk_sp<SkSurface> MakeRasterDirectReleaseProc(const SkImageInfo& imageInfo, void* pixels,
- size_t rowBytes,
- void (*releaseProc)(void* pixels, void* context),
- void* context, const SkSurfaceProps* surfaceProps = nullptr);
-
- /** Allocates raster SkSurface. SkCanvas returned by SkSurface draws directly into pixels.
- Allocates and zeroes pixel memory. Pixel memory size is imageInfo.height() times
- rowBytes, or times imageInfo.minRowBytes() if rowBytes is zero.
- Pixel memory is deleted when SkSurface is deleted.
-
- SkSurface is returned if all parameters are valid.
- Valid parameters include:
- info dimensions are greater than zero;
- info contains SkColorType and SkAlphaType supported by raster surface;
- rowBytes is large enough to contain info width pixels of SkColorType, or is zero.
-
- If rowBytes is zero, a suitable value will be chosen internally.
-
- @param imageInfo width, height, SkColorType, SkAlphaType, SkColorSpace,
- of raster surface; width and height must be greater than zero
- @param rowBytes interval from one SkSurface row to the next; may be zero
- @param surfaceProps LCD striping orientation and setting for device independent fonts;
- may be nullptr
- @return SkSurface if all parameters are valid; otherwise, nullptr
- */
- static sk_sp<SkSurface> MakeRaster(const SkImageInfo& imageInfo, size_t rowBytes,
- const SkSurfaceProps* surfaceProps);
-
- /** Allocates raster SkSurface. SkCanvas returned by SkSurface draws directly into pixels.
- Allocates and zeroes pixel memory. Pixel memory size is imageInfo.height() times
- imageInfo.minRowBytes().
- Pixel memory is deleted when SkSurface is deleted.
-
- SkSurface is returned if all parameters are valid.
- Valid parameters include:
- info dimensions are greater than zero;
- info contains SkColorType and SkAlphaType supported by raster surface.
-
- @param imageInfo width, height, SkColorType, SkAlphaType, SkColorSpace,
- of raster surface; width and height must be greater than zero
- @param props LCD striping orientation and setting for device independent fonts;
- may be nullptr
- @return SkSurface if all parameters are valid; otherwise, nullptr
- */
- static sk_sp<SkSurface> MakeRaster(const SkImageInfo& imageInfo,
- const SkSurfaceProps* props = nullptr) {
- return MakeRaster(imageInfo, 0, props);
- }
-
- /** Allocates raster SkSurface. SkCanvas returned by SkSurface draws directly into pixels.
- Allocates and zeroes pixel memory. Pixel memory size is height times width times
- four. Pixel memory is deleted when SkSurface is deleted.
-
- Internally, sets SkImageInfo to width, height, native color type, and
- kPremul_SkAlphaType.
-
- SkSurface is returned if width and height are greater than zero.
-
- Use to create SkSurface that matches SkPMColor, the native pixel arrangement on
- the platform. SkSurface drawn to output device skips converting its pixel format.
-
- @param width pixel column count; must be greater than zero
- @param height pixel row count; must be greater than zero
- @param surfaceProps LCD striping orientation and setting for device independent
- fonts; may be nullptr
- @return SkSurface if all parameters are valid; otherwise, nullptr
- */
- static sk_sp<SkSurface> MakeRasterN32Premul(int width, int height,
- const SkSurfaceProps* surfaceProps = nullptr);
-
- /** Caller data passed to RenderTarget/TextureReleaseProc; may be nullptr. */
- typedef void* ReleaseContext;
-
- /** User function called when supplied render target may be deleted. */
- typedef void (*RenderTargetReleaseProc)(ReleaseContext releaseContext);
-
- /** User function called when supplied texture may be deleted. */
- typedef void (*TextureReleaseProc)(ReleaseContext releaseContext);
-
- /** Wraps a GPU-backed texture into SkSurface. Caller must ensure the texture is
- valid for the lifetime of returned SkSurface. If sampleCnt greater than zero,
- creates an intermediate MSAA SkSurface which is used for drawing backendTexture.
-
- SkSurface is returned if all parameters are valid. backendTexture is valid if
- its pixel configuration agrees with colorSpace and context; for instance, if
- backendTexture has an sRGB configuration, then context must support sRGB,
- and colorSpace must be present. Further, backendTexture width and height must
- not exceed context capabilities, and the context must be able to support
- back-end textures.
-
- Upon success textureReleaseProc is called when it is safe to delete the texture in the
- backend API (accounting only for use of the texture by this surface). If SkSurface creation
- fails textureReleaseProc is called before this function returns.
-
- If defined(SK_GANESH) is defined as zero, has no effect and returns nullptr.
-
- @param context GPU context
- @param backendTexture texture residing on GPU
- @param sampleCnt samples per pixel, or 0 to disable full scene anti-aliasing
- @param colorSpace range of colors; may be nullptr
- @param surfaceProps LCD striping orientation and setting for device independent
- fonts; may be nullptr
- @param textureReleaseProc function called when texture can be released
- @param releaseContext state passed to textureReleaseProc
- @return SkSurface if all parameters are valid; otherwise, nullptr
- */
- static sk_sp<SkSurface> MakeFromBackendTexture(GrRecordingContext* context,
- const GrBackendTexture& backendTexture,
- GrSurfaceOrigin origin, int sampleCnt,
- SkColorType colorType,
- sk_sp<SkColorSpace> colorSpace,
- const SkSurfaceProps* surfaceProps,
- TextureReleaseProc textureReleaseProc = nullptr,
- ReleaseContext releaseContext = nullptr);
-
- /** Wraps a GPU-backed buffer into SkSurface. Caller must ensure backendRenderTarget
- is valid for the lifetime of returned SkSurface.
-
- SkSurface is returned if all parameters are valid. backendRenderTarget is valid if
- its pixel configuration agrees with colorSpace and context; for instance, if
- backendRenderTarget has an sRGB configuration, then context must support sRGB,
- and colorSpace must be present. Further, backendRenderTarget width and height must
- not exceed context capabilities, and the context must be able to support
- back-end render targets.
-
- Upon success releaseProc is called when it is safe to delete the render target in the
- backend API (accounting only for use of the render target by this surface). If SkSurface
- creation fails releaseProc is called before this function returns.
-
- If defined(SK_GANESH) is defined as zero, has no effect and returns nullptr.
-
- @param context GPU context
- @param backendRenderTarget GPU intermediate memory buffer
- @param colorSpace range of colors
- @param surfaceProps LCD striping orientation and setting for device independent
- fonts; may be nullptr
- @param releaseProc function called when backendRenderTarget can be released
- @param releaseContext state passed to releaseProc
- @return SkSurface if all parameters are valid; otherwise, nullptr
- */
- static sk_sp<SkSurface> MakeFromBackendRenderTarget(GrRecordingContext* context,
- const GrBackendRenderTarget& backendRenderTarget,
- GrSurfaceOrigin origin,
- SkColorType colorType,
- sk_sp<SkColorSpace> colorSpace,
- const SkSurfaceProps* surfaceProps,
- RenderTargetReleaseProc releaseProc = nullptr,
- ReleaseContext releaseContext = nullptr);
-
-#if defined(SK_GANESH)
- /** Returns SkSurface on GPU indicated by context. Allocates memory for
- pixels, based on the width, height, and SkColorType in SkImageInfo. budgeted
- selects whether allocation for pixels is tracked by context. imageInfo
- describes the pixel format in SkColorType, and transparency in
- SkAlphaType, and color matching in SkColorSpace.
-
- sampleCount requests the number of samples per pixel.
- Pass zero to disable multi-sample anti-aliasing. The request is rounded
- up to the next supported count, or rounded down if it is larger than the
- maximum supported count.
-
- surfaceOrigin pins either the top-left or the bottom-left corner to the origin.
-
- shouldCreateWithMips hints that SkImage returned by makeImageSnapshot() is mip map.
-
- If defined(SK_GANESH) is defined as zero, has no effect and returns nullptr.
-
- @param context GPU context
- @param imageInfo width, height, SkColorType, SkAlphaType, SkColorSpace;
- width, or height, or both, may be zero
- @param sampleCount samples per pixel, or 0 to disable full scene anti-aliasing
- @param surfaceProps LCD striping orientation and setting for device independent
- fonts; may be nullptr
- @param shouldCreateWithMips hint that SkSurface will host mip map images
- @return SkSurface if all parameters are valid; otherwise, nullptr
- */
- static sk_sp<SkSurface> MakeRenderTarget(GrRecordingContext* context,
- skgpu::Budgeted budgeted,
- const SkImageInfo& imageInfo,
- int sampleCount,
- GrSurfaceOrigin surfaceOrigin,
- const SkSurfaceProps* surfaceProps,
- bool shouldCreateWithMips = false);
-
- /** Returns SkSurface on GPU indicated by context. Allocates memory for
- pixels, based on the width, height, and SkColorType in SkImageInfo. budgeted
- selects whether allocation for pixels is tracked by context. imageInfo
- describes the pixel format in SkColorType, and transparency in
- SkAlphaType, and color matching in SkColorSpace.
-
- sampleCount requests the number of samples per pixel.
- Pass zero to disable multi-sample anti-aliasing. The request is rounded
- up to the next supported count, or rounded down if it is larger than the
- maximum supported count.
-
- SkSurface bottom-left corner is pinned to the origin.
-
- @param context GPU context
- @param imageInfo width, height, SkColorType, SkAlphaType, SkColorSpace,
- of raster surface; width, or height, or both, may be zero
- @param sampleCount samples per pixel, or 0 to disable multi-sample anti-aliasing
- @param surfaceProps LCD striping orientation and setting for device independent
- fonts; may be nullptr
- @return SkSurface if all parameters are valid; otherwise, nullptr
- */
- static sk_sp<SkSurface> MakeRenderTarget(GrRecordingContext* context,
- skgpu::Budgeted budgeted,
- const SkImageInfo& imageInfo,
- int sampleCount,
- const SkSurfaceProps* surfaceProps) {
- return MakeRenderTarget(context, budgeted, imageInfo, sampleCount,
- kBottomLeft_GrSurfaceOrigin, surfaceProps);
- }
-
- /** Returns SkSurface on GPU indicated by context. Allocates memory for
- pixels, based on the width, height, and SkColorType in SkImageInfo. budgeted
- selects whether allocation for pixels is tracked by context. imageInfo
- describes the pixel format in SkColorType, and transparency in
- SkAlphaType, and color matching in SkColorSpace.
-
- SkSurface bottom-left corner is pinned to the origin.
-
- @param context GPU context
- @param imageInfo width, height, SkColorType, SkAlphaType, SkColorSpace,
- of raster surface; width, or height, or both, may be zero
- @return SkSurface if all parameters are valid; otherwise, nullptr
- */
- static sk_sp<SkSurface> MakeRenderTarget(GrRecordingContext* context,
- skgpu::Budgeted budgeted,
- const SkImageInfo& imageInfo) {
- if (!imageInfo.width() || !imageInfo.height()) {
- return nullptr;
- }
- return MakeRenderTarget(context, budgeted, imageInfo, 0, kBottomLeft_GrSurfaceOrigin,
- nullptr);
- }
-
- /** Returns SkSurface on GPU indicated by context that is compatible with the provided
- characterization. budgeted selects whether allocation for pixels is tracked by context.
-
- @param context GPU context
- @param characterization description of the desired SkSurface
- @return SkSurface if all parameters are valid; otherwise, nullptr
- */
- static sk_sp<SkSurface> MakeRenderTarget(GrRecordingContext* context,
- const SkSurfaceCharacterization& characterization,
- skgpu::Budgeted budgeted);
-#endif
-
-#if defined(SK_BUILD_FOR_ANDROID) && __ANDROID_API__ >= 26
- /** Private.
- Creates SkSurface from Android hardware buffer.
- Returned SkSurface takes a reference on the buffer. The ref on the buffer will be released
- when the SkSurface is destroyed and there is no pending work on the GPU involving the
- buffer.
-
- Only available on Android, when __ANDROID_API__ is defined to be 26 or greater.
-
- Currently this is only supported for buffers that can be textured as well as rendered to.
- In other words that must have both AHARDWAREBUFFER_USAGE_GPU_COLOR_OUTPUT and
- AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE usage bits.
-
- @param context GPU context
- @param hardwareBuffer AHardwareBuffer Android hardware buffer
- @param colorSpace range of colors; may be nullptr
- @param surfaceProps LCD striping orientation and setting for device independent
- fonts; may be nullptr
- @param fromWindow Whether or not the AHardwareBuffer is part of an Android Window.
- Currently only used with Vulkan backend.
- @return created SkSurface, or nullptr
- */
- static sk_sp<SkSurface> MakeFromAHardwareBuffer(GrDirectContext* context,
- AHardwareBuffer* hardwareBuffer,
- GrSurfaceOrigin origin,
- sk_sp<SkColorSpace> colorSpace,
- const SkSurfaceProps* surfaceProps
-#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
- , bool fromWindow = false
-#endif // SK_BUILD_FOR_ANDROID_FRAMEWORK
- );
-#endif
-
-#if defined(SK_GRAPHITE)
- /**
- * In Graphite, while clients hold a ref on an SkSurface, the backing gpu object does _not_
- * count against the budget. Once an SkSurface is freed, the backing gpu object may or may
- * not become a scratch (i.e., reusable) resource but, if it does, it will be counted against
- * the budget.
- */
- static sk_sp<SkSurface> MakeGraphite(
- skgpu::graphite::Recorder*,
- const SkImageInfo& imageInfo,
- skgpu::Mipmapped = skgpu::Mipmapped::kNo,
- const SkSurfaceProps* surfaceProps = nullptr);
-
- /**
- * Wraps a GPU-backed texture in an SkSurface. Depending on the backend gpu API, the caller may
- * be required to ensure the texture is valid for the lifetime of the returned SkSurface. The
- * required lifetimes for the specific apis are:
- * Metal: Skia will call retain on the underlying MTLTexture so the caller can drop it once
- * this call returns.
- *
- * SkSurface is returned if all the parameters are valid. The backendTexture is valid if its
- * format agrees with colorSpace and recorder; for instance, if backendTexture has an sRGB
- * configuration, then the recorder must support sRGB, and colorSpace must be present. Further,
- * backendTexture's width and height must not exceed the recorder's capabilities, and the
- * recorder must be able to support the back-end texture.
- */
- static sk_sp<SkSurface> MakeGraphiteFromBackendTexture(skgpu::graphite::Recorder*,
- const skgpu::graphite::BackendTexture&,
- SkColorType colorType,
- sk_sp<SkColorSpace> colorSpace,
- const SkSurfaceProps* props);
-
-#endif // SK_GRAPHITE
-
-#if defined(SK_GANESH) && defined(SK_METAL)
- /** Creates SkSurface from CAMetalLayer.
- Returned SkSurface takes a reference on the CAMetalLayer. The ref on the layer will be
- released when the SkSurface is destroyed.
-
- Only available when Metal API is enabled.
-
- Will grab the current drawable from the layer and use its texture as a backendRT to
- create a renderable surface.
-
- @param context GPU context
- @param layer GrMTLHandle (expected to be a CAMetalLayer*)
- @param sampleCnt samples per pixel, or 0 to disable full scene anti-aliasing
- @param colorSpace range of colors; may be nullptr
- @param surfaceProps LCD striping orientation and setting for device independent
- fonts; may be nullptr
- @param drawable Pointer to drawable to be filled in when this surface is
- instantiated; may not be nullptr
- @return created SkSurface, or nullptr
- */
- static sk_sp<SkSurface> MakeFromCAMetalLayer(GrRecordingContext* context,
- GrMTLHandle layer,
- GrSurfaceOrigin origin,
- int sampleCnt,
- SkColorType colorType,
- sk_sp<SkColorSpace> colorSpace,
- const SkSurfaceProps* surfaceProps,
- GrMTLHandle* drawable)
- SK_API_AVAILABLE_CA_METAL_LAYER;
-
- /** Creates SkSurface from MTKView.
- Returned SkSurface takes a reference on the MTKView. The ref on the layer will be
- released when the SkSurface is destroyed.
-
- Only available when Metal API is enabled.
-
- Will grab the current drawable from the layer and use its texture as a backendRT to
- create a renderable surface.
-
- @param context GPU context
- @param layer GrMTLHandle (expected to be a MTKView*)
- @param sampleCnt samples per pixel, or 0 to disable full scene anti-aliasing
- @param colorSpace range of colors; may be nullptr
- @param surfaceProps LCD striping orientation and setting for device independent
- fonts; may be nullptr
- @return created SkSurface, or nullptr
- */
- static sk_sp<SkSurface> MakeFromMTKView(GrRecordingContext* context,
- GrMTLHandle mtkView,
- GrSurfaceOrigin origin,
- int sampleCnt,
- SkColorType colorType,
- sk_sp<SkColorSpace> colorSpace,
- const SkSurfaceProps* surfaceProps)
- SK_API_AVAILABLE(macos(10.11), ios(9.0));
-#endif
-
/** Is this surface compatible with the provided characterization?
This method can be used to determine if an existing SkSurface is a viable destination
@@ -604,6 +265,11 @@
static constexpr BackendHandleAccess kDiscardWrite_BackendHandleAccess =
BackendHandleAccess::kDiscardWrite;
+ /** Caller data passed to TextureReleaseProc; may be nullptr. */
+ using ReleaseContext = void*;
+ /** User function called when supplied texture may be deleted. */
+ using TextureReleaseProc = void (*)(ReleaseContext);
+
/** If the surface was made via MakeFromBackendTexture then it's backing texture may be
substituted with a different texture. The contents of the previous backing texture are
copied into the new texture. SkCanvas state is preserved. The original sample count is
@@ -616,14 +282,14 @@
@param backendTexture the new backing texture for the surface
@param mode Retain or discard current Content
- @param textureReleaseProc function called when texture can be released
- @param releaseContext state passed to textureReleaseProc
+ @param TextureReleaseProc function called when texture can be released
+ @param ReleaseContext state passed to textureReleaseProc
*/
virtual bool replaceBackendTexture(const GrBackendTexture& backendTexture,
GrSurfaceOrigin origin,
ContentChangeMode mode = kRetain_ContentChangeMode,
- TextureReleaseProc textureReleaseProc = nullptr,
- ReleaseContext releaseContext = nullptr) = 0;
+ TextureReleaseProc = nullptr,
+ ReleaseContext = nullptr) = 0;
/** Returns SkCanvas that draws into SkSurface. Subsequent calls return the same SkCanvas.
SkCanvas returned is managed and owned by SkSurface, and is deleted when SkSurface
@@ -1170,6 +836,113 @@
GrBackendTexture getBackendTexture(BackendHandleAccess backendHandleAccess);
GrBackendRenderTarget getBackendRenderTarget(BackendHandleAccess backendHandleAccess);
#endif
+
+#if !defined(SK_DISABLE_LEGACY_SKSURFACE_FACTORIES)
+ using RenderTargetReleaseProc = void (*)(ReleaseContext);
+
+ static sk_sp<SkSurface> MakeRasterDirect(const SkImageInfo& imageInfo,
+ void* pixels,
+ size_t rowBytes,
+ const SkSurfaceProps* surfaceProps = nullptr);
+ static sk_sp<SkSurface> MakeRasterDirect(const SkPixmap& pm,
+ const SkSurfaceProps* props = nullptr);
+ static sk_sp<SkSurface> MakeRasterDirectReleaseProc(
+ const SkImageInfo& imageInfo,
+ void* pixels,
+ size_t rowBytes,
+ void (*releaseProc)(void* pixels, void* context),
+ void* context,
+ const SkSurfaceProps* surfaceProps = nullptr);
+ static sk_sp<SkSurface> MakeRaster(const SkImageInfo& imageInfo,
+ size_t rowBytes,
+ const SkSurfaceProps* surfaceProps);
+ static sk_sp<SkSurface> MakeRaster(const SkImageInfo& imageInfo,
+ const SkSurfaceProps* props = nullptr);
+ static sk_sp<SkSurface> MakeRasterN32Premul(int width,
+ int height,
+ const SkSurfaceProps* surfaceProps = nullptr);
+
+#if defined(SK_GANESH)
+ static sk_sp<SkSurface> MakeFromBackendTexture(GrRecordingContext* context,
+ const GrBackendTexture& backendTexture,
+ GrSurfaceOrigin origin,
+ int sampleCnt,
+ SkColorType colorType,
+ sk_sp<SkColorSpace> colorSpace,
+ const SkSurfaceProps* surfaceProps,
+ TextureReleaseProc textureReleaseProc = nullptr,
+ ReleaseContext releaseContext = nullptr);
+ static sk_sp<SkSurface> MakeFromBackendRenderTarget(
+ GrRecordingContext* context,
+ const GrBackendRenderTarget& backendRenderTarget,
+ GrSurfaceOrigin origin,
+ SkColorType colorType,
+ sk_sp<SkColorSpace> colorSpace,
+ const SkSurfaceProps* surfaceProps,
+ RenderTargetReleaseProc releaseProc = nullptr,
+ ReleaseContext releaseContext = nullptr);
+ static sk_sp<SkSurface> MakeRenderTarget(GrRecordingContext* context,
+ skgpu::Budgeted budgeted,
+ const SkImageInfo& imageInfo,
+ int sampleCount,
+ GrSurfaceOrigin surfaceOrigin,
+ const SkSurfaceProps* surfaceProps,
+ bool shouldCreateWithMips = false);
+ static sk_sp<SkSurface> MakeRenderTarget(GrRecordingContext* context,
+ skgpu::Budgeted budgeted,
+ const SkImageInfo& imageInfo,
+ int sampleCount,
+ const SkSurfaceProps* surfaceProps);
+ static sk_sp<SkSurface> MakeRenderTarget(GrRecordingContext* context,
+ skgpu::Budgeted budgeted,
+ const SkImageInfo& imageInfo);
+ static sk_sp<SkSurface> MakeRenderTarget(GrRecordingContext* context,
+ const SkSurfaceCharacterization& characterization,
+ skgpu::Budgeted budgeted);
+#endif // defined(SK_GANESH)
+
+#if defined(SK_BUILD_FOR_ANDROID) && __ANDROID_API__ >= 26
+ static sk_sp<SkSurface> MakeFromAHardwareBuffer(GrDirectContext* context,
+ AHardwareBuffer* hardwareBuffer,
+ GrSurfaceOrigin origin,
+ sk_sp<SkColorSpace> colorSpace,
+ const SkSurfaceProps* surfaceProps,
+ bool fromWindow = false);
+#endif
+
+#if defined(SK_GRAPHITE)
+ static sk_sp<SkSurface> MakeGraphite(skgpu::graphite::Recorder*,
+ const SkImageInfo& imageInfo,
+ skgpu::Mipmapped = skgpu::Mipmapped::kNo,
+ const SkSurfaceProps* surfaceProps = nullptr);
+ static sk_sp<SkSurface> MakeGraphiteFromBackendTexture(skgpu::graphite::Recorder*,
+ const skgpu::graphite::BackendTexture&,
+ SkColorType colorType,
+ sk_sp<SkColorSpace> colorSpace,
+ const SkSurfaceProps* props);
+#endif // defined(SK_GRAPHITE)
+
+#if defined(SK_GANESH) && defined(SK_METAL)
+ static sk_sp<SkSurface> MakeFromCAMetalLayer(GrRecordingContext* context,
+ GrMTLHandle layer,
+ GrSurfaceOrigin origin,
+ int sampleCnt,
+ SkColorType colorType,
+ sk_sp<SkColorSpace> colorSpace,
+ const SkSurfaceProps* surfaceProps,
+ GrMTLHandle* drawable)
+ SK_API_AVAILABLE_CA_METAL_LAYER;
+ static sk_sp<SkSurface> MakeFromMTKView(GrRecordingContext* context,
+ GrMTLHandle mtkView,
+ GrSurfaceOrigin origin,
+ int sampleCnt,
+ SkColorType colorType,
+ sk_sp<SkColorSpace> colorSpace,
+ const SkSurfaceProps* surfaceProps)
+ SK_API_AVAILABLE(macos(10.11), ios(9.0));
+#endif // defined(SK_GANESH) && defined(SK_METAL)
+
+#endif // !defined(SK_DISABLE_LEGACY_SKSURFACE_FACTORIES)
};
#endif
diff --git a/include/gpu/ganesh/SkSurfaceGanesh.h b/include/gpu/ganesh/SkSurfaceGanesh.h
index 701a906..150d1b6 100644
--- a/include/gpu/ganesh/SkSurfaceGanesh.h
+++ b/include/gpu/ganesh/SkSurfaceGanesh.h
@@ -8,13 +8,161 @@
#ifndef SkSurfaceGanesh_DEFINED
#define SkSurfaceGanesh_DEFINED
+#include "include/core/SkImageInfo.h"
+#include "include/core/SkRefCnt.h"
#include "include/core/SkSurface.h"
+#include "include/gpu/GrTypes.h"
#include "include/private/base/SkAPI.h"
class GrBackendRenderTarget;
class GrBackendTexture;
+class GrRecordingContext;
+class SkColorSpace;
+class SkSurfaceCharacterization;
+class SkSurfaceProps;
+enum SkColorType : int;
+namespace skgpu {
+enum class Budgeted : bool;
+}
namespace SkSurfaces {
+
+/** Caller data passed to RenderTarget/TextureReleaseProc; may be nullptr. */
+using ReleaseContext = void*;
+
+/** User function called when supplied render target may be deleted. */
+using RenderTargetReleaseProc = void (*)(ReleaseContext);
+
+/** User function called when supplied texture may be deleted. */
+using TextureReleaseProc = void (*)(ReleaseContext);
+
+/** Returns SkSurface on GPU indicated by context. Allocates memory for
+ pixels, based on the width, height, and SkColorType in SkImageInfo. budgeted
+ selects whether allocation for pixels is tracked by context. imageInfo
+ describes the pixel format in SkColorType, and transparency in
+ SkAlphaType, and color matching in SkColorSpace.
+
+ sampleCount requests the number of samples per pixel.
+ Pass zero to disable multi-sample anti-aliasing. The request is rounded
+ up to the next supported count, or rounded down if it is larger than the
+ maximum supported count.
+
+ surfaceOrigin pins either the top-left or the bottom-left corner to the origin.
+
+ shouldCreateWithMips hints that SkImage returned by makeImageSnapshot() is mip map.
+
+ @param context GPU context
+ @param imageInfo width, height, SkColorType, SkAlphaType, SkColorSpace;
+ width, or height, or both, may be zero
+ @param sampleCount samples per pixel, or 0 to disable full scene anti-aliasing
+ @param surfaceOrigin How to align the pixel data.
+ @param surfaceProps LCD striping orientation and setting for device independent
+ fonts; may be nullptr
+ @param shouldCreateWithMips hint that SkSurface will host mip map images
+ @return SkSurface if all parameters are valid; otherwise, nullptr
+*/
+SK_API sk_sp<SkSurface> RenderTarget(GrRecordingContext* context,
+ skgpu::Budgeted budgeted,
+ const SkImageInfo& imageInfo,
+ int sampleCount,
+ GrSurfaceOrigin surfaceOrigin,
+ const SkSurfaceProps* surfaceProps,
+ bool shouldCreateWithMips = false);
+inline sk_sp<SkSurface> RenderTarget(GrRecordingContext* context,
+ skgpu::Budgeted budgeted,
+ const SkImageInfo& imageInfo,
+ int sampleCount,
+ const SkSurfaceProps* surfaceProps) {
+ return RenderTarget(
+ context, budgeted, imageInfo, sampleCount, kBottomLeft_GrSurfaceOrigin, surfaceProps);
+}
+inline sk_sp<SkSurface> RenderTarget(GrRecordingContext* context,
+ skgpu::Budgeted budgeted,
+ const SkImageInfo& imageInfo) {
+ if (!imageInfo.width() || !imageInfo.height()) {
+ return nullptr;
+ }
+ return RenderTarget(context, budgeted, imageInfo, 0, kBottomLeft_GrSurfaceOrigin, nullptr);
+}
+
+/** Returns SkSurface on GPU indicated by context that is compatible with the provided
+ characterization. budgeted selects whether allocation for pixels is tracked by context.
+
+ @param context GPU context
+ @param characterization description of the desired SkSurface
+ @return SkSurface if all parameters are valid; otherwise, nullptr
+*/
+SK_API sk_sp<SkSurface> RenderTarget(GrRecordingContext* context,
+ const SkSurfaceCharacterization& characterization,
+ skgpu::Budgeted budgeted);
+
+/** Wraps a GPU-backed texture into SkSurface. Caller must ensure the texture is
+ valid for the lifetime of returned SkSurface. If sampleCnt greater than zero,
+ creates an intermediate MSAA SkSurface which is used for drawing backendTexture.
+
+ SkSurface is returned if all parameters are valid. backendTexture is valid if
+ its pixel configuration agrees with colorSpace and context; for instance, if
+ backendTexture has an sRGB configuration, then context must support sRGB,
+ and colorSpace must be present. Further, backendTexture width and height must
+ not exceed context capabilities, and the context must be able to support
+ back-end textures.
+
+ Upon success textureReleaseProc is called when it is safe to delete the texture in the
+ backend API (accounting only for use of the texture by this surface). If SkSurface creation
+ fails textureReleaseProc is called before this function returns.
+
+ @param context GPU context
+ @param backendTexture texture residing on GPU
+ @param sampleCnt samples per pixel, or 0 to disable full scene anti-aliasing
+ @param colorSpace range of colors; may be nullptr
+ @param surfaceProps LCD striping orientation and setting for device independent
+ fonts; may be nullptr
+ @param textureReleaseProc function called when texture can be released
+ @param releaseContext state passed to textureReleaseProc
+ @return SkSurface if all parameters are valid; otherwise, nullptr
+*/
+SK_API sk_sp<SkSurface> WrapBackendTexture(GrRecordingContext* context,
+ const GrBackendTexture& backendTexture,
+ GrSurfaceOrigin origin,
+ int sampleCnt,
+ SkColorType colorType,
+ sk_sp<SkColorSpace> colorSpace,
+ const SkSurfaceProps* surfaceProps,
+ TextureReleaseProc textureReleaseProc = nullptr,
+ ReleaseContext releaseContext = nullptr);
+
+/** Wraps a GPU-backed buffer into SkSurface. Caller must ensure backendRenderTarget
+ is valid for the lifetime of returned SkSurface.
+
+ SkSurface is returned if all parameters are valid. backendRenderTarget is valid if
+ its pixel configuration agrees with colorSpace and context; for instance, if
+ backendRenderTarget has an sRGB configuration, then context must support sRGB,
+ and colorSpace must be present. Further, backendRenderTarget width and height must
+ not exceed context capabilities, and the context must be able to support
+ back-end render targets.
+
+ Upon success releaseProc is called when it is safe to delete the render target in the
+ backend API (accounting only for use of the render target by this surface). If SkSurface
+ creation fails releaseProc is called before this function returns.
+
+ @param context GPU context
+ @param backendRenderTarget GPU intermediate memory buffer
+ @param colorSpace range of colors
+ @param surfaceProps LCD striping orientation and setting for device independent
+ fonts; may be nullptr
+ @param releaseProc function called when backendRenderTarget can be released
+ @param releaseContext state passed to releaseProc
+ @return SkSurface if all parameters are valid; otherwise, nullptr
+*/
+SK_API sk_sp<SkSurface> WrapBackendRenderTarget(GrRecordingContext* context,
+ const GrBackendRenderTarget& backendRenderTarget,
+ GrSurfaceOrigin origin,
+ SkColorType colorType,
+ sk_sp<SkColorSpace> colorSpace,
+ const SkSurfaceProps* surfaceProps,
+ RenderTargetReleaseProc releaseProc = nullptr,
+ ReleaseContext releaseContext = nullptr);
+
using BackendHandleAccess = SkSurface::BackendHandleAccess;
/** Retrieves the back-end texture. If SkSurface has no back-end texture, an invalid
diff --git a/include/gpu/ganesh/mtl/BUILD.bazel b/include/gpu/ganesh/mtl/BUILD.bazel
new file mode 100644
index 0000000..539f6f0
--- /dev/null
+++ b/include/gpu/ganesh/mtl/BUILD.bazel
@@ -0,0 +1,14 @@
+load("//bazel:macros.bzl", "exports_files_legacy", "skia_filegroup")
+
+licenses(["notice"])
+
+exports_files_legacy()
+
+# TODO(kjlubick) include metal build in Bazel
+skia_filegroup(
+ name = "public_hdrs",
+ srcs = [
+ "SkSurfaceMetal.h",
+ ],
+ visibility = ["//include/gpu/ganesh:__pkg__"],
+)
diff --git a/include/gpu/ganesh/mtl/SkSurfaceMetal.h b/include/gpu/ganesh/mtl/SkSurfaceMetal.h
new file mode 100644
index 0000000..a14c18d
--- /dev/null
+++ b/include/gpu/ganesh/mtl/SkSurfaceMetal.h
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2023 Google LLC
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkSurfaceMetal_DEFINED
+#define SkSurfaceMetal_DEFINED
+
+#include "include/core/SkRefCnt.h"
+#include "include/core/SkSurface.h"
+#include "include/gpu/GrTypes.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
+#include "include/gpu/mtl/GrMtlTypes.h"
+
+namespace SkSurfaces {
+/** Creates SkSurface from CAMetalLayer.
+ Returned SkSurface takes a reference on the CAMetalLayer. The ref on the layer will be
+ released when the SkSurface is destroyed.
+
+ Only available when Metal API is enabled.
+
+ Will grab the current drawable from the layer and use its texture as a backendRT to
+ create a renderable surface.
+
+ @param context GPU context
+ @param layer GrMTLHandle (expected to be a CAMetalLayer*)
+ @param sampleCnt samples per pixel, or 0 to disable full scene anti-aliasing
+ @param colorSpace range of colors; may be nullptr
+ @param surfaceProps LCD striping orientation and setting for device independent
+ fonts; may be nullptr
+ @param drawable Pointer to drawable to be filled in when this surface is
+ instantiated; may not be nullptr
+ @return created SkSurface, or nullptr
+ */
+SK_API sk_sp<SkSurface> WrapCAMetalLayer(GrRecordingContext* context,
+ GrMTLHandle layer,
+ GrSurfaceOrigin origin,
+ int sampleCnt,
+ SkColorType colorType,
+ sk_sp<SkColorSpace> colorSpace,
+ const SkSurfaceProps* surfaceProps,
+ GrMTLHandle* drawable) SK_API_AVAILABLE_CA_METAL_LAYER;
+
+/** Creates SkSurface from MTKView.
+ Returned SkSurface takes a reference on the MTKView. The ref on the layer will be
+ released when the SkSurface is destroyed.
+
+ Only available when Metal API is enabled.
+
+ Will grab the current drawable from the layer and use its texture as a backendRT to
+ create a renderable surface.
+
+ @param context GPU context
+ @param layer GrMTLHandle (expected to be a MTKView*)
+ @param sampleCnt samples per pixel, or 0 to disable full scene anti-aliasing
+ @param colorSpace range of colors; may be nullptr
+ @param surfaceProps LCD striping orientation and setting for device independent
+ fonts; may be nullptr
+ @return created SkSurface, or nullptr
+ */
+SK_API sk_sp<SkSurface> WrapMTKView(GrRecordingContext* context,
+ GrMTLHandle mtkView,
+ GrSurfaceOrigin origin,
+ int sampleCnt,
+ SkColorType colorType,
+ sk_sp<SkColorSpace> colorSpace,
+ const SkSurfaceProps* surfaceProps)
+ SK_API_AVAILABLE(macos(10.11), ios(9.0));
+} // namespace SkSurfaces
+
+#endif
diff --git a/include/gpu/graphite/Surface.h b/include/gpu/graphite/Surface.h
new file mode 100644
index 0000000..1d78d6f
--- /dev/null
+++ b/include/gpu/graphite/Surface.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2023 Google LLC
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef skgpu_graphite_Surface_DEFINED
+#define skgpu_graphite_Surface_DEFINED
+
+#include "include/core/SkRefCnt.h"
+#include "include/core/SkSurface.h"
+#include "include/gpu/GpuTypes.h"
+
+struct SkImageInfo;
+
+namespace skgpu::graphite {
+class BackendTexture;
+class Recorder;
+} // namespace skgpu::graphite
+
+namespace SkSurfaces {
+/**
+ * In Graphite, while clients hold a ref on an SkSurface, the backing gpu object does _not_
+ * count against the budget. Once an SkSurface is freed, the backing gpu object may or may
+ * not become a scratch (i.e., reusable) resource but, if it does, it will be counted against
+ * the budget.
+ */
+SK_API sk_sp<SkSurface> RenderTarget(skgpu::graphite::Recorder*,
+ const SkImageInfo& imageInfo,
+ skgpu::Mipmapped = skgpu::Mipmapped::kNo,
+ const SkSurfaceProps* surfaceProps = nullptr);
+
+/**
+ * Wraps a GPU-backed texture in an SkSurface. Depending on the backend gpu API, the caller may
+ * be required to ensure the texture is valid for the lifetime of the returned SkSurface. The
+ * required lifetimes for the specific apis are:
+ * Metal: Skia will call retain on the underlying MTLTexture so the caller can drop it once
+ * this call returns.
+ *
+ * SkSurface is returned if all the parameters are valid. The backendTexture is valid if its
+ * format agrees with colorSpace and recorder; for instance, if backendTexture has an sRGB
+ * configuration, then the recorder must support sRGB, and colorSpace must be present. Further,
+ * backendTexture's width and height must not exceed the recorder's capabilities, and the
+ * recorder must be able to support the back-end texture.
+ */
+SK_API sk_sp<SkSurface> WrapBackendTexture(skgpu::graphite::Recorder*,
+ const skgpu::graphite::BackendTexture&,
+ SkColorType colorType,
+ sk_sp<SkColorSpace> colorSpace,
+ const SkSurfaceProps* props);
+} // namespace SkSurfaces
+
+#endif // skgpu_graphite_Surface_DEFINED
diff --git a/modules/canvaskit/canvaskit_bindings.cpp b/modules/canvaskit/canvaskit_bindings.cpp
index 3cab75f..1617348 100644
--- a/modules/canvaskit/canvaskit_bindings.cpp
+++ b/modules/canvaskit/canvaskit_bindings.cpp
@@ -213,8 +213,12 @@
const auto colorSettings = ColorSettings(colorSpace);
info.fFormat = colorSettings.pixFormat;
GrBackendRenderTarget target(width, height, sampleCnt, stencil, info);
- sk_sp<SkSurface> surface(SkSurface::MakeFromBackendRenderTarget(dContext.get(), target,
- kBottomLeft_GrSurfaceOrigin, colorSettings.colorType, colorSpace, nullptr));
+ sk_sp<SkSurface> surface(SkSurfaces::WrapBackendRenderTarget(dContext.get(),
+ target,
+ kBottomLeft_GrSurfaceOrigin,
+ colorSettings.colorType,
+ colorSpace,
+ nullptr));
return surface;
}
@@ -233,24 +237,24 @@
SkImageInfo info = SkImageInfo::MakeN32(
width, height, SkAlphaType::kPremul_SkAlphaType, SkColorSpace::MakeSRGB());
- sk_sp<SkSurface> surface(SkSurface::MakeRenderTarget(dContext.get(),
- skgpu::Budgeted::kYes,
- info,
- 0,
- kBottomLeft_GrSurfaceOrigin,
- nullptr,
- true));
+ sk_sp<SkSurface> surface(SkSurfaces::RenderTarget(dContext.get(),
+ skgpu::Budgeted::kYes,
+ info,
+ 0,
+ kBottomLeft_GrSurfaceOrigin,
+ nullptr,
+ true));
return surface;
}
sk_sp<SkSurface> MakeRenderTarget(sk_sp<GrDirectContext> dContext, SimpleImageInfo sii) {
- sk_sp<SkSurface> surface(SkSurface::MakeRenderTarget(dContext.get(),
- skgpu::Budgeted::kYes,
- toSkImageInfo(sii),
- 0,
- kBottomLeft_GrSurfaceOrigin,
- nullptr,
- true));
+ sk_sp<SkSurface> surface(SkSurfaces::RenderTarget(dContext.get(),
+ skgpu::Budgeted::kYes,
+ toSkImageInfo(sii),
+ 0,
+ kBottomLeft_GrSurfaceOrigin,
+ nullptr,
+ true));
return surface;
}
#endif // CK_ENABLE_WEBGL
@@ -284,10 +288,14 @@
info.fLevelCount = mipLevelCount;
GrBackendTexture target(width, height, info);
- return SkSurface::MakeFromBackendTexture(
- dContext.get(), target, kTopLeft_GrSurfaceOrigin, sampleCount,
+ return SkSurfaces::WrapBackendTexture(
+ dContext.get(),
+ target,
+ kTopLeft_GrSurfaceOrigin,
+ sampleCount,
colorSpace->isSRGB() ? kRGBA_8888_SkColorType : kRGBA_F16_SkColorType,
- colorSpace, nullptr);
+ colorSpace,
+ nullptr);
}
bool ReplaceBackendTexture(SkSurface& surface, uint32_t textureHandle, uint32_t textureFormat,
@@ -2158,7 +2166,7 @@
size_t rowBytes)->sk_sp<SkSurface> {
uint8_t* pixels = reinterpret_cast<uint8_t*>(pPtr);
SkImageInfo imageInfo = toSkImageInfo(ii);
- return SkSurface::MakeRasterDirect(imageInfo, pixels, rowBytes, nullptr);
+ return SkSurfaces::WrapPixels(imageInfo, pixels, rowBytes, nullptr);
}), allow_raw_pointers())
.function("_flush", optional_override([](SkSurface& self) {
self.flushAndSubmit(false);
diff --git a/modules/canvaskit/gm_bindings.cpp b/modules/canvaskit/gm_bindings.cpp
index 781bb21..db56b58 100644
--- a/modules/canvaskit/gm_bindings.cpp
+++ b/modules/canvaskit/gm_bindings.cpp
@@ -20,6 +20,7 @@
#include "include/core/SkSurface.h"
#include "include/gpu/GrContextOptions.h"
#include "include/gpu/GrDirectContext.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "include/gpu/gl/GrGLInterface.h"
#include "include/gpu/gl/GrGLTypes.h"
#include "modules/canvaskit/WasmCommon.h"
@@ -124,7 +125,7 @@
auto colorType = SkColorType::kN32_SkColorType;
SkISize size = gm->getISize();
SkImageInfo info = SkImageInfo::Make(size, colorType, alphaType);
- sk_sp<SkSurface> surface(SkSurface::MakeRenderTarget(
+ sk_sp<SkSurface> surface(SkSurfaces::RenderTarget(
ctx.get(), skgpu::Budgeted::kYes, info, 0, kBottomLeft_GrSurfaceOrigin, nullptr, true));
if (!surface) {
SkDebugf("Could not make surface\n");
diff --git a/modules/jetski/src/Surface.cpp b/modules/jetski/src/Surface.cpp
index 5534f41..ec7b76d 100644
--- a/modules/jetski/src/Surface.cpp
+++ b/modules/jetski/src/Surface.cpp
@@ -92,7 +92,7 @@
return;
}
- fSurface = SkSurface::MakeRasterDirect(info, pixels, bm_info.stride);
+ fSurface = SkSurfaces::WrapPixels(info, pixels, bm_info.stride);
if (!fSurface) {
AndroidBitmap_unlockPixels(env, bitmap);
return;
diff --git a/modules/skottie/src/SkottieTest.cpp b/modules/skottie/src/SkottieTest.cpp
index f9a0648..98839ad 100644
--- a/modules/skottie/src/SkottieTest.cpp
+++ b/modules/skottie/src/SkottieTest.cpp
@@ -499,7 +499,7 @@
sk_sp<SkImage> getFrame(float t) override {
fRequestedFrames.push_back(t);
- return SkSurface::MakeRasterN32Premul(10, 10)->makeImageSnapshot();
+ return SkSurfaces::Raster(SkImageInfo::MakeN32Premul(10, 10))->makeImageSnapshot();
}
const bool fMultiFrame;
diff --git a/modules/skottie/src/SkottieTool.cpp b/modules/skottie/src/SkottieTool.cpp
index a0d43cc..c7a7c6c 100644
--- a/modules/skottie/src/SkottieTool.cpp
+++ b/modules/skottie/src/SkottieTool.cpp
@@ -11,6 +11,7 @@
#include "include/core/SkStream.h"
#include "include/core/SkSurface.h"
#include "include/encode/SkPngEncoder.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "include/private/base/SkTPin.h"
#include "modules/skottie/include/Skottie.h"
#include "modules/skottie/utils/SkottieUtils.h"
@@ -221,7 +222,7 @@
}
#else
static std::unique_ptr<FrameGenerator> Make(FrameSink* sink, const SkMatrix& matrix) {
- auto surface = SkSurface::MakeRasterN32Premul(FLAGS_width, FLAGS_height);
+ auto surface = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(FLAGS_width, FLAGS_height));
if (!surface) {
SkDebugf("Could not allocate a %d x %d surface.\n", FLAGS_width, FLAGS_height);
return nullptr;
@@ -324,8 +325,7 @@
{
fCtx = fFactory.getContextInfo(sk_gpu_test::GrContextFactory::kGL_ContextType)
.directContext();
- fSurface =
- SkSurface::MakeRenderTarget(fCtx,
+ fSurface = SkSurfaces::RenderTarget(fCtx,
skgpu::Budgeted::kNo,
SkImageInfo::MakeN32Premul(FLAGS_width, FLAGS_height),
0,
diff --git a/modules/skottie/tests/Image.cpp b/modules/skottie/tests/Image.cpp
index ee226f9..1ae2041 100644
--- a/modules/skottie/tests/Image.cpp
+++ b/modules/skottie/tests/Image.cpp
@@ -68,8 +68,7 @@
TestImageAsset(const TestData* tst, skiatest::Reporter* r)
: fTest(tst)
, fReporter(r) {
-
- auto surf = SkSurface::MakeRasterN32Premul(200, 100);
+ auto surf = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(200, 100));
surf->getCanvas()->drawColor(0xffff0000);
fImage = surf->makeImageSnapshot();
}
@@ -110,7 +109,8 @@
REPORTER_ASSERT(r, anim);
static constexpr SkSize render_size{100, 100};
- auto surf = SkSurface::MakeRasterN32Premul(render_size.width(), render_size.height());
+ auto surf = SkSurfaces::Raster(
+ SkImageInfo::MakeN32Premul(render_size.width(), render_size.height()));
auto rect = SkRect::MakeSize(render_size);
SkPixmap pmap;
diff --git a/modules/svg/utils/SvgTool.cpp b/modules/svg/utils/SvgTool.cpp
index 7ee49a2..c1c38d2 100644
--- a/modules/svg/utils/SvgTool.cpp
+++ b/modules/svg/utils/SvgTool.cpp
@@ -55,7 +55,7 @@
return 1;
}
- auto surface = SkSurface::MakeRasterN32Premul(FLAGS_width, FLAGS_height);
+ auto surface = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(FLAGS_width, FLAGS_height));
svg_dom->setContainerSize(SkSize::Make(FLAGS_width, FLAGS_height));
svg_dom->render(surface->getCanvas());
diff --git a/platform_tools/android/apps/skottie/skottielib/src/main/cpp/native-lib.cpp b/platform_tools/android/apps/skottie/skottielib/src/main/cpp/native-lib.cpp
index f657c45..12cedbe 100644
--- a/platform_tools/android/apps/skottie/skottielib/src/main/cpp/native-lib.cpp
+++ b/platform_tools/android/apps/skottie/skottielib/src/main/cpp/native-lib.cpp
@@ -22,6 +22,7 @@
#include "include/gpu/GrBackendSurface.h"
#include "include/gpu/GrContextOptions.h"
#include "include/gpu/GrDirectContext.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "include/gpu/gl/GrGLInterface.h"
#include "include/gpu/gl/GrGLTypes.h"
@@ -236,9 +237,8 @@
SkSurfaceProps props(0, kUnknown_SkPixelGeometry);
- sk_sp<SkSurface> renderTarget(SkSurface::MakeFromBackendRenderTarget(
- dContext, backendRT, kBottomLeft_GrSurfaceOrigin, colorType,
- nullptr, &props));
+ sk_sp<SkSurface> renderTarget(SkSurfaces::WrapBackendRenderTarget(
+ dContext, backendRT, kBottomLeft_GrSurfaceOrigin, colorType, nullptr, &props));
auto canvas = renderTarget->getCanvas();
canvas->clear(backgroundColor);
diff --git a/public.bzl b/public.bzl
index fa36bbf..75eaf9b 100644
--- a/public.bzl
+++ b/public.bzl
@@ -138,9 +138,10 @@
"include/gpu/d3d/GrD3DBackendContext.h",
"include/gpu/d3d/GrD3DTypes.h",
"include/gpu/dawn/GrDawnTypes.h",
+ "include/gpu/ganesh/GrTextureGenerator.h",
"include/gpu/ganesh/SkImageGanesh.h",
"include/gpu/ganesh/SkSurfaceGanesh.h",
- "include/gpu/ganesh/GrTextureGenerator.h",
+ "include/gpu/ganesh/mtl/SkSurfaceMetal.h",
"include/gpu/gl/egl/GrGLMakeEGLInterface.h",
"include/gpu/gl/glx/GrGLMakeGLXInterface.h",
"include/gpu/gl/GrGLAssembleHelpers.h",
diff --git a/relnotes/sksurface_namespace.md b/relnotes/sksurface_namespace.md
new file mode 100644
index 0000000..5945749
--- /dev/null
+++ b/relnotes/sksurface_namespace.md
@@ -0,0 +1,17 @@
+SkSurface factory methods have been moved to the SkSurfaces namespace. Many have been renamed to
+be more succinct or self-consistent. Factory methods specific to the Ganesh GPU backend are
+defined publicly in include/gpu/ganesh/SkSurfaceGanesh.h. The Metal Ganesh backend has some
+specific factories in include/gpu/ganesh/mtl/SkSurfaceMetal.h.
+ * SkSurface::MakeFromAHardwareBuffer -> SkSurfaces::WrapAndroidHardwareBuffer
+ * SkSurface::MakeFromBackendRenderTarget -> SkSurfaces::WrapBackendRenderTarget
+ * SkSurface::MakeFromBackendTexture -> SkSurfaces::WrapBackendTexture
+ * SkSurface::MakeFromCAMetalLayer -> SkSurfaces::WrapCAMetalLayer
+ * SkSurface::MakeFromMTKView -> SkSurfaces::WrapMTKView
+ * SkSurface::MakeGraphite -> SkSurfaces::RenderTarget
+ * SkSurface::MakeGraphiteFromBackendTexture -> SkSurfaces::WrapBackendTexture
+ * SkSurface::MakeRaster -> SkSurfaces::Raster
+ * SkSurface::MakeRasterDirect -> SkSurfaces::WrapPixels
+ * SkSurface::MakeRasterDirectReleaseProc -> SkSurfaces::WrapPixels
+ * SkSurface::MakeRasterN32Premul -> SkSurfaces::Raster (clients should make SkImageInfo)
+ * SkSurface::MakeRenderTarget -> SkSurfaces::RenderTarget
+
diff --git a/src/codec/SkPixmapUtils.cpp b/src/codec/SkPixmapUtils.cpp
index 462f4bf..1080065 100644
--- a/src/codec/SkPixmapUtils.cpp
+++ b/src/codec/SkPixmapUtils.cpp
@@ -22,7 +22,7 @@
#include <utility>
static bool draw_orientation(const SkPixmap& dst, const SkPixmap& src, SkEncodedOrigin origin) {
- auto surf = SkSurface::MakeRasterDirect(dst.info(), dst.writable_addr(), dst.rowBytes());
+ auto surf = SkSurfaces::WrapPixels(dst.info(), dst.writable_addr(), dst.rowBytes());
if (!surf) {
return false;
}
diff --git a/src/core/SkBitmapDevice.cpp b/src/core/SkBitmapDevice.cpp
index f00b7f6..97ca214 100644
--- a/src/core/SkBitmapDevice.cpp
+++ b/src/core/SkBitmapDevice.cpp
@@ -608,7 +608,7 @@
///////////////////////////////////////////////////////////////////////////////
sk_sp<SkSurface> SkBitmapDevice::makeSurface(const SkImageInfo& info, const SkSurfaceProps& props) {
- return SkSurface::MakeRaster(info, &props);
+ return SkSurfaces::Raster(info, &props);
}
SkImageFilterCache* SkBitmapDevice::getImageFilterCache() {
diff --git a/src/core/SkPixmapDraw.cpp b/src/core/SkPixmapDraw.cpp
index ff4c7ba..b3bd205 100644
--- a/src/core/SkPixmapDraw.cpp
+++ b/src/core/SkPixmapDraw.cpp
@@ -72,9 +72,8 @@
&scale,
clampAsIfUnpremul);
- sk_sp<SkSurface> surface = SkSurface::MakeRasterDirect(dst.info(),
- dst.writable_addr(),
- dst.rowBytes());
+ sk_sp<SkSurface> surface =
+ SkSurfaces::WrapPixels(dst.info(), dst.writable_addr(), dst.rowBytes());
if (!shader || !surface) {
return false;
}
diff --git a/src/core/SkRuntimeEffect.cpp b/src/core/SkRuntimeEffect.cpp
index 4d6a541..6d8b163 100644
--- a/src/core/SkRuntimeEffect.cpp
+++ b/src/core/SkRuntimeEffect.cpp
@@ -46,6 +46,7 @@
#if defined(SK_GANESH)
#include "include/gpu/GrRecordingContext.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "src/gpu/SkBackingFit.h"
#include "src/gpu/ganesh/GrCaps.h"
#include "src/gpu/ganesh/GrColorInfo.h"
@@ -1681,16 +1682,16 @@
if (!rContext->priv().caps()->mipmapSupport()) {
mipmapped = false;
}
- surface = SkSurface::MakeRenderTarget(rContext,
- skgpu::Budgeted::kYes,
- resultInfo,
- 1,
- kTopLeft_GrSurfaceOrigin,
- nullptr,
- mipmapped);
+ surface = SkSurfaces::RenderTarget(rContext,
+ skgpu::Budgeted::kYes,
+ resultInfo,
+ 1,
+ kTopLeft_GrSurfaceOrigin,
+ nullptr,
+ mipmapped);
#endif
} else {
- surface = SkSurface::MakeRaster(resultInfo);
+ surface = SkSurfaces::Raster(resultInfo);
}
if (!surface) {
return nullptr;
diff --git a/src/gpu/ganesh/Device.cpp b/src/gpu/ganesh/Device.cpp
index 32ec6b9..9822430 100644
--- a/src/gpu/ganesh/Device.cpp
+++ b/src/gpu/ganesh/Device.cpp
@@ -41,6 +41,7 @@
#include "include/gpu/GrContextOptions.h"
#include "include/gpu/GrRecordingContext.h"
#include "include/gpu/GrTypes.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "include/private/SkColorData.h"
#include "include/private/base/SingleOwner.h"
#include "include/private/base/SkAssert.h"
@@ -1346,9 +1347,12 @@
ASSERT_SINGLE_OWNER
// TODO: Change the signature of newSurface to take a budgeted parameter.
static const skgpu::Budgeted kBudgeted = skgpu::Budgeted::kNo;
- return SkSurface::MakeRenderTarget(fContext.get(), kBudgeted, info,
- fSurfaceDrawContext->numSamples(),
- fSurfaceDrawContext->origin(), &props);
+ return SkSurfaces::RenderTarget(fContext.get(),
+ kBudgeted,
+ info,
+ fSurfaceDrawContext->numSamples(),
+ fSurfaceDrawContext->origin(),
+ &props);
}
SkImageFilterCache* Device::getImageFilterCache() {
diff --git a/src/gpu/ganesh/GrGpu.h b/src/gpu/ganesh/GrGpu.h
index 4c1f8d8..56fbc36 100644
--- a/src/gpu/ganesh/GrGpu.h
+++ b/src/gpu/ganesh/GrGpu.h
@@ -619,8 +619,8 @@
/**
* Creates a GrBackendRenderTarget that can be wrapped using
- * SkSurface::MakeFromBackendRenderTarget. Ideally this is a non-textureable allocation to
- * differentiate from testing with SkSurface::MakeFromBackendTexture. When sampleCnt > 1 this
+ * SkSurfaces::WrapBackendRenderTarget. Ideally this is a non-textureable allocation to
+ * differentiate from testing with SkSurfaces::WrapBackendTexture. When sampleCnt > 1 this
* is used to test client wrapped allocations with MSAA where Skia does not allocate a separate
* buffer for resolving. If the color is non-null the backing store should be cleared to the
* passed in color.
diff --git a/src/gpu/ganesh/image/GrImageUtils.cpp b/src/gpu/ganesh/image/GrImageUtils.cpp
index 0702f65..c0c902c 100644
--- a/src/gpu/ganesh/image/GrImageUtils.cpp
+++ b/src/gpu/ganesh/image/GrImageUtils.cpp
@@ -28,6 +28,7 @@
#include "include/gpu/GrRecordingContext.h"
#include "include/gpu/GrTypes.h"
#include "include/gpu/ganesh/GrTextureGenerator.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "include/private/SkIDChangeListener.h"
#include "include/private/base/SkMutex.h"
#include "include/private/gpu/ganesh/GrTypesPriv.h"
@@ -236,9 +237,13 @@
skgpu::Budgeted budgeted = texGenPolicy == GrImageTexGenPolicy::kNew_Uncached_Unbudgeted
? skgpu::Budgeted::kNo
: skgpu::Budgeted::kYes;
- auto surface = SkSurface::MakeRenderTarget(ctx, budgeted, img->imageInfo(), 0,
- kTopLeft_GrSurfaceOrigin,
- img->props(), mipmapped == GrMipmapped::kYes);
+ auto surface = SkSurfaces::RenderTarget(ctx,
+ budgeted,
+ img->imageInfo(),
+ 0,
+ kTopLeft_GrSurfaceOrigin,
+ img->props(),
+ mipmapped == GrMipmapped::kYes);
if (!surface) {
return {};
}
diff --git a/src/gpu/ganesh/surface/BUILD.bazel b/src/gpu/ganesh/surface/BUILD.bazel
index a36aa08..dfb915b 100644
--- a/src/gpu/ganesh/surface/BUILD.bazel
+++ b/src/gpu/ganesh/surface/BUILD.bazel
@@ -22,6 +22,12 @@
)
skia_filegroup(
+ name = "android_srcs",
+ srcs = ["SkSurface_AndroidFactories.cpp"],
+ visibility = ["//src:__pkg__"],
+)
+
+skia_filegroup(
name = "srcs",
srcs = [":surface_srcs"],
visibility = ["//src/gpu/ganesh:__pkg__"],
diff --git a/src/gpu/ganesh/surface/SkSurface_AndroidFactories.cpp b/src/gpu/ganesh/surface/SkSurface_AndroidFactories.cpp
new file mode 100644
index 0000000..1acde7a
--- /dev/null
+++ b/src/gpu/ganesh/surface/SkSurface_AndroidFactories.cpp
@@ -0,0 +1,152 @@
+/*
+ * Copyright 2023 Google LLC
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "include/core/SkTypes.h"
+
+#if defined(SK_BUILD_FOR_ANDROID) && __ANDROID_API__ >= 26
+
+#include "include/android/SkSurfaceAndroid.h"
+#include "include/core/SkCanvas.h"
+#include "include/core/SkColorSpace.h"
+#include "include/core/SkColorType.h"
+#include "include/core/SkDeferredDisplayList.h"
+#include "include/core/SkImage.h"
+#include "include/core/SkPoint.h"
+#include "include/core/SkRect.h"
+#include "include/core/SkSize.h"
+#include "include/core/SkSurface.h"
+#include "include/core/SkSurfaceCharacterization.h"
+#include "include/core/SkSurfaceProps.h"
+#include "include/gpu/GpuTypes.h"
+#include "include/gpu/GrBackendSurface.h"
+#include "include/gpu/GrContextThreadSafeProxy.h"
+#include "include/gpu/GrDirectContext.h"
+#include "include/gpu/GrRecordingContext.h"
+#include "include/gpu/GrTypes.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
+#include "include/private/base/SkTo.h"
+#include "include/private/gpu/ganesh/GrTypesPriv.h"
+#include "src/core/SkDevice.h"
+#include "src/core/SkSurfacePriv.h"
+#include "src/gpu/RefCntedCallback.h"
+#include "src/gpu/SkBackingFit.h"
+#include "src/gpu/SkRenderEngineAbortf.h"
+#include "src/gpu/ganesh/Device_v1.h"
+#include "src/gpu/ganesh/GrCaps.h"
+#include "src/gpu/ganesh/GrContextThreadSafeProxyPriv.h"
+#include "src/gpu/ganesh/GrDirectContextPriv.h"
+#include "src/gpu/ganesh/GrGpuResourcePriv.h"
+#include "src/gpu/ganesh/GrProxyProvider.h"
+#include "src/gpu/ganesh/GrRecordingContextPriv.h"
+#include "src/gpu/ganesh/GrRenderTarget.h"
+#include "src/gpu/ganesh/GrRenderTargetProxy.h"
+#include "src/gpu/ganesh/GrSurfaceProxy.h"
+#include "src/gpu/ganesh/GrSurfaceProxyPriv.h"
+#include "src/gpu/ganesh/GrSurfaceProxyView.h"
+#include "src/gpu/ganesh/GrTexture.h"
+#include "src/gpu/ganesh/GrTextureProxy.h"
+#include "src/gpu/ganesh/image/SkImage_Ganesh.h"
+#include "src/gpu/ganesh/surface/SkSurface_Ganesh.h"
+#include "src/image/SkImage_Base.h"
+
+#include <algorithm>
+#include <cstddef>
+#include <utility>
+
+#include "src/gpu/ganesh/GrAHardwareBufferUtils_impl.h"
+
+namespace SkSurfaces {
+
+sk_sp<SkSurface> WrapAndroidHardwareBuffer(GrDirectContext* dContext,
+ AHardwareBuffer* hardwareBuffer,
+ GrSurfaceOrigin origin,
+ sk_sp<SkColorSpace> colorSpace,
+ const SkSurfaceProps* surfaceProps,
+ bool fromWindow) {
+ AHardwareBuffer_Desc bufferDesc;
+ AHardwareBuffer_describe(hardwareBuffer, &bufferDesc);
+
+ if (!SkToBool(bufferDesc.usage & AHARDWAREBUFFER_USAGE_GPU_COLOR_OUTPUT)) {
+ return nullptr;
+ }
+
+ bool isTextureable = SkToBool(bufferDesc.usage & AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE);
+
+ GrBackendFormat backendFormat = GrAHardwareBufferUtils::GetBackendFormat(
+ dContext, hardwareBuffer, bufferDesc.format, true);
+ if (!backendFormat.isValid()) {
+ return nullptr;
+ }
+
+ if (isTextureable) {
+ GrAHardwareBufferUtils::DeleteImageProc deleteImageProc = nullptr;
+ GrAHardwareBufferUtils::UpdateImageProc updateImageProc = nullptr;
+ GrAHardwareBufferUtils::TexImageCtx deleteImageCtx = nullptr;
+
+ bool isProtectedContent =
+ SkToBool(bufferDesc.usage & AHARDWAREBUFFER_USAGE_PROTECTED_CONTENT);
+
+ bool fromWindowLocal = false;
+#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
+ fromWindowLocal = fromWindow;
+#endif
+
+ GrBackendTexture backendTexture =
+ GrAHardwareBufferUtils::MakeBackendTexture(dContext,
+ hardwareBuffer,
+ bufferDesc.width,
+ bufferDesc.height,
+ &deleteImageProc,
+ &updateImageProc,
+ &deleteImageCtx,
+ isProtectedContent,
+ backendFormat,
+ true,
+ fromWindowLocal);
+ if (!backendTexture.isValid()) {
+ return nullptr;
+ }
+
+ SkColorType colorType =
+ GrAHardwareBufferUtils::GetSkColorTypeFromBufferFormat(bufferDesc.format);
+
+ sk_sp<SkSurface> surface = SkSurfaces::WrapBackendTexture(dContext,
+ backendTexture,
+ origin,
+ 0,
+ colorType,
+ std::move(colorSpace),
+ surfaceProps,
+ deleteImageProc,
+ deleteImageCtx);
+
+ if (!surface) {
+ SkASSERT(deleteImageProc);
+ deleteImageProc(deleteImageCtx);
+ }
+
+ return surface;
+ } else {
+ return nullptr;
+ }
+}
+
+} // namespace SkSurfaces
+
+#if !defined(SK_DISABLE_LEGACY_SKSURFACE_FACTORIES)
+sk_sp<SkSurface> SkSurface::MakeFromAHardwareBuffer(GrDirectContext* context,
+ AHardwareBuffer* hardwareBuffer,
+ GrSurfaceOrigin origin,
+ sk_sp<SkColorSpace> colorSpace,
+ const SkSurfaceProps* surfaceProps,
+ bool fromWindow) {
+ return SkSurfaces::WrapAndroidHardwareBuffer(
+ context, hardwareBuffer, origin, colorSpace, surfaceProps, fromWindow);
+}
+#endif
+
+#endif
diff --git a/src/gpu/ganesh/surface/SkSurface_Ganesh.cpp b/src/gpu/ganesh/surface/SkSurface_Ganesh.cpp
index c3dd7e5..3907983 100644
--- a/src/gpu/ganesh/surface/SkSurface_Ganesh.cpp
+++ b/src/gpu/ganesh/surface/SkSurface_Ganesh.cpp
@@ -49,10 +49,6 @@
#include "src/gpu/ganesh/image/SkImage_Ganesh.h"
#include "src/image/SkImage_Base.h"
-#if defined(SK_BUILD_FOR_ANDROID) && __ANDROID_API__ >= 26
-#include "src/gpu/ganesh/GrAHardwareBufferUtils_impl.h"
-#endif
-
#include <algorithm>
#include <cstddef>
#include <utility>
@@ -140,7 +136,7 @@
GrSurfaceOrigin origin = targetView.origin();
// TODO: Make caller specify this (change virtual signature of onNewSurface).
static const skgpu::Budgeted kBudgeted = skgpu::Budgeted::kNo;
- return SkSurface::MakeRenderTarget(
+ return SkSurfaces::RenderTarget(
fDevice->recordingContext(), kBudgeted, info, sampleCount, origin, &this->props());
}
@@ -436,45 +432,6 @@
///////////////////////////////////////////////////////////////////////////////
-sk_sp<SkSurface> SkSurface::MakeRenderTarget(GrRecordingContext* rContext,
- const SkSurfaceCharacterization& c,
- skgpu::Budgeted budgeted) {
- if (!rContext || !c.isValid()) {
- return nullptr;
- }
-
- if (c.usesGLFBO0()) {
- // If we are making the surface we will never use FBO0.
- return nullptr;
- }
-
- if (c.vulkanSecondaryCBCompatible()) {
- return nullptr;
- }
-
- auto device = rContext->priv().createDevice(budgeted,
- c.imageInfo(),
- SkBackingFit::kExact,
- c.sampleCount(),
- GrMipmapped(c.isMipMapped()),
- c.isProtected(),
- c.origin(),
- c.surfaceProps(),
- skgpu::ganesh::Device::InitContents::kClear);
- if (!device) {
- return nullptr;
- }
-
- sk_sp<SkSurface> result = sk_make_sp<SkSurface_Ganesh>(std::move(device));
-#ifdef SK_DEBUG
- if (result) {
- SkASSERT(result->isCompatible(c));
- }
-#endif
-
- return result;
-}
-
static bool validate_backend_texture(const GrCaps* caps,
const GrBackendTexture& tex,
int sampleCnt,
@@ -515,108 +472,6 @@
return true;
}
-sk_sp<SkSurface> SkSurface::MakeRenderTarget(GrRecordingContext* rContext,
- skgpu::Budgeted budgeted,
- const SkImageInfo& info,
- int sampleCount,
- GrSurfaceOrigin origin,
- const SkSurfaceProps* props,
- bool shouldCreateWithMips) {
- if (!rContext) {
- return nullptr;
- }
- sampleCount = std::max(1, sampleCount);
- GrMipmapped mipmapped = shouldCreateWithMips ? GrMipmapped::kYes : GrMipmapped::kNo;
-
- if (!rContext->priv().caps()->mipmapSupport()) {
- mipmapped = GrMipmapped::kNo;
- }
-
- auto device = rContext->priv().createDevice(budgeted,
- info,
- SkBackingFit::kExact,
- sampleCount,
- mipmapped,
- GrProtected::kNo,
- origin,
- SkSurfacePropsCopyOrDefault(props),
- skgpu::ganesh::Device::InitContents::kClear);
- if (!device) {
- return nullptr;
- }
- return sk_make_sp<SkSurface_Ganesh>(std::move(device));
-}
-
-sk_sp<SkSurface> SkSurface::MakeFromBackendTexture(GrRecordingContext* rContext,
- const GrBackendTexture& tex,
- GrSurfaceOrigin origin,
- int sampleCnt,
- SkColorType colorType,
- sk_sp<SkColorSpace> colorSpace,
- const SkSurfaceProps* props,
- SkSurface::TextureReleaseProc textureReleaseProc,
- SkSurface::ReleaseContext releaseContext) {
- auto releaseHelper = skgpu::RefCntedCallback::Make(textureReleaseProc, releaseContext);
-
- if (!rContext) {
- RENDERENGINE_ABORTF("%s failed due to a null context ", __func__);
- return nullptr;
- }
- sampleCnt = std::max(1, sampleCnt);
-
- GrColorType grColorType = SkColorTypeToGrColorType(colorType);
- if (grColorType == GrColorType::kUnknown) {
- RENDERENGINE_ABORTF("%s failed due to an unsupported colorType %d", __func__, colorType);
- return nullptr;
- }
-
- if (!validate_backend_texture(rContext->priv().caps(), tex, sampleCnt, grColorType, true)) {
- return nullptr;
- }
-
- sk_sp<GrTextureProxy> proxy(rContext->priv().proxyProvider()->wrapRenderableBackendTexture(
- tex,
- sampleCnt,
- kBorrow_GrWrapOwnership,
- GrWrapCacheable::kNo,
- std::move(releaseHelper)));
- if (!proxy) {
-#ifdef SK_IN_RENDERENGINE
- GrGLTextureInfo textureInfo;
- bool retrievedTextureInfo = tex.getGLTextureInfo(&textureInfo);
- RENDERENGINE_ABORTF(
- "%s failed to wrap the texture into a renderable target "
- "\n\tGrBackendTexture: (%i x %i) hasMipmaps: %i isProtected: %i texType: %i"
- "\n\t\tGrGLTextureInfo: success: %i fTarget: %u fFormat: %u"
- "\n\tmaxRenderTargetSize: %d",
- __func__,
- tex.width(),
- tex.height(),
- tex.hasMipmaps(),
- tex.isProtected(),
- static_cast<int>(tex.textureType()),
- retrievedTextureInfo,
- textureInfo.fTarget,
- textureInfo.fFormat,
- rContext->priv().caps()->maxRenderTargetSize());
-#endif
- return nullptr;
- }
-
- auto device = rContext->priv().createDevice(grColorType,
- std::move(proxy),
- std::move(colorSpace),
- origin,
- SkSurfacePropsCopyOrDefault(props),
- skgpu::ganesh::Device::InitContents::kUninit);
- if (!device) {
- RENDERENGINE_ABORTF("%s failed to wrap the renderTarget into a surface", __func__);
- return nullptr;
- }
-
- return sk_make_sp<SkSurface_Ganesh>(std::move(device));
-}
-
bool SkSurface_Ganesh::replaceBackendTexture(const GrBackendTexture& backendTexture,
GrSurfaceOrigin origin,
ContentChangeMode mode,
@@ -701,14 +556,165 @@
return true;
}
-sk_sp<SkSurface> SkSurface::MakeFromBackendRenderTarget(GrRecordingContext* rContext,
- const GrBackendRenderTarget& rt,
- GrSurfaceOrigin origin,
- SkColorType colorType,
- sk_sp<SkColorSpace> colorSpace,
- const SkSurfaceProps* props,
- SkSurface::RenderTargetReleaseProc relProc,
- SkSurface::ReleaseContext releaseContext) {
+void SkSurface::flushAndSubmit(bool syncCpu) {
+ this->flush(BackendSurfaceAccess::kNoAccess, GrFlushInfo());
+
+ auto direct = GrAsDirectContext(this->recordingContext());
+ if (direct) {
+ direct->submit(syncCpu);
+ }
+}
+
+namespace SkSurfaces {
+sk_sp<SkSurface> RenderTarget(GrRecordingContext* rContext,
+ const SkSurfaceCharacterization& c,
+ skgpu::Budgeted budgeted) {
+ if (!rContext || !c.isValid()) {
+ return nullptr;
+ }
+
+ if (c.usesGLFBO0()) {
+ // If we are making the surface we will never use FBO0.
+ return nullptr;
+ }
+
+ if (c.vulkanSecondaryCBCompatible()) {
+ return nullptr;
+ }
+
+ auto device = rContext->priv().createDevice(budgeted,
+ c.imageInfo(),
+ SkBackingFit::kExact,
+ c.sampleCount(),
+ GrMipmapped(c.isMipMapped()),
+ c.isProtected(),
+ c.origin(),
+ c.surfaceProps(),
+ skgpu::ganesh::Device::InitContents::kClear);
+ if (!device) {
+ return nullptr;
+ }
+
+ sk_sp<SkSurface> result = sk_make_sp<SkSurface_Ganesh>(std::move(device));
+#ifdef SK_DEBUG
+ if (result) {
+ SkASSERT(result->isCompatible(c));
+ }
+#endif
+
+ return result;
+}
+
+sk_sp<SkSurface> RenderTarget(GrRecordingContext* rContext,
+ skgpu::Budgeted budgeted,
+ const SkImageInfo& info,
+ int sampleCount,
+ GrSurfaceOrigin origin,
+ const SkSurfaceProps* props,
+ bool shouldCreateWithMips) {
+ if (!rContext) {
+ return nullptr;
+ }
+ sampleCount = std::max(1, sampleCount);
+ GrMipmapped mipmapped = shouldCreateWithMips ? GrMipmapped::kYes : GrMipmapped::kNo;
+
+ if (!rContext->priv().caps()->mipmapSupport()) {
+ mipmapped = GrMipmapped::kNo;
+ }
+
+ auto device = rContext->priv().createDevice(budgeted,
+ info,
+ SkBackingFit::kExact,
+ sampleCount,
+ mipmapped,
+ GrProtected::kNo,
+ origin,
+ SkSurfacePropsCopyOrDefault(props),
+ skgpu::ganesh::Device::InitContents::kClear);
+ if (!device) {
+ return nullptr;
+ }
+ return sk_make_sp<SkSurface_Ganesh>(std::move(device));
+}
+
+sk_sp<SkSurface> WrapBackendTexture(GrRecordingContext* rContext,
+ const GrBackendTexture& tex,
+ GrSurfaceOrigin origin,
+ int sampleCnt,
+ SkColorType colorType,
+ sk_sp<SkColorSpace> colorSpace,
+ const SkSurfaceProps* props,
+ TextureReleaseProc textureReleaseProc,
+ ReleaseContext releaseContext) {
+ auto releaseHelper = skgpu::RefCntedCallback::Make(textureReleaseProc, releaseContext);
+
+ if (!rContext) {
+ RENDERENGINE_ABORTF("%s failed due to a null context ", __func__);
+ return nullptr;
+ }
+ sampleCnt = std::max(1, sampleCnt);
+
+ GrColorType grColorType = SkColorTypeToGrColorType(colorType);
+ if (grColorType == GrColorType::kUnknown) {
+ RENDERENGINE_ABORTF("%s failed due to an unsupported colorType %d", __func__, colorType);
+ return nullptr;
+ }
+
+ if (!validate_backend_texture(rContext->priv().caps(), tex, sampleCnt, grColorType, true)) {
+ return nullptr;
+ }
+
+ sk_sp<GrTextureProxy> proxy(rContext->priv().proxyProvider()->wrapRenderableBackendTexture(
+ tex,
+ sampleCnt,
+ kBorrow_GrWrapOwnership,
+ GrWrapCacheable::kNo,
+ std::move(releaseHelper)));
+ if (!proxy) {
+#ifdef SK_IN_RENDERENGINE
+ GrGLTextureInfo textureInfo;
+ bool retrievedTextureInfo = tex.getGLTextureInfo(&textureInfo);
+ RENDERENGINE_ABORTF(
+ "%s failed to wrap the texture into a renderable target "
+ "\n\tGrBackendTexture: (%i x %i) hasMipmaps: %i isProtected: %i texType: %i"
+ "\n\t\tGrGLTextureInfo: success: %i fTarget: %u fFormat: %u"
+ "\n\tmaxRenderTargetSize: %d",
+ __func__,
+ tex.width(),
+ tex.height(),
+ tex.hasMipmaps(),
+ tex.isProtected(),
+ static_cast<int>(tex.textureType()),
+ retrievedTextureInfo,
+ textureInfo.fTarget,
+ textureInfo.fFormat,
+ rContext->priv().caps()->maxRenderTargetSize());
+#endif
+ return nullptr;
+ }
+
+ auto device = rContext->priv().createDevice(grColorType,
+ std::move(proxy),
+ std::move(colorSpace),
+ origin,
+ SkSurfacePropsCopyOrDefault(props),
+ skgpu::ganesh::Device::InitContents::kUninit);
+ if (!device) {
+ RENDERENGINE_ABORTF("%s failed to wrap the renderTarget into a surface", __func__);
+ return nullptr;
+ }
+
+ return sk_make_sp<SkSurface_Ganesh>(std::move(device));
+}
+
+sk_sp<SkSurface> WrapBackendRenderTarget(GrRecordingContext* rContext,
+ const GrBackendRenderTarget& rt,
+ GrSurfaceOrigin origin,
+ SkColorType colorType,
+ sk_sp<SkColorSpace> colorSpace,
+ const SkSurfaceProps* props,
+ RenderTargetReleaseProc relProc,
+ ReleaseContext releaseContext) {
auto releaseHelper = skgpu::RefCntedCallback::Make(relProc, releaseContext);
if (!rContext) {
@@ -743,96 +749,6 @@
return sk_make_sp<SkSurface_Ganesh>(std::move(device));
}
-#if defined(SK_BUILD_FOR_ANDROID) && __ANDROID_API__ >= 26
-sk_sp<SkSurface> SkSurface::MakeFromAHardwareBuffer(GrDirectContext* dContext,
- AHardwareBuffer* hardwareBuffer,
- GrSurfaceOrigin origin,
- sk_sp<SkColorSpace> colorSpace,
- const SkSurfaceProps* surfaceProps
-#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
- ,
- bool fromWindow
-#endif
-) {
- AHardwareBuffer_Desc bufferDesc;
- AHardwareBuffer_describe(hardwareBuffer, &bufferDesc);
-
- if (!SkToBool(bufferDesc.usage & AHARDWAREBUFFER_USAGE_GPU_COLOR_OUTPUT)) {
- return nullptr;
- }
-
- bool isTextureable = SkToBool(bufferDesc.usage & AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE);
-
- GrBackendFormat backendFormat = GrAHardwareBufferUtils::GetBackendFormat(
- dContext, hardwareBuffer, bufferDesc.format, true);
- if (!backendFormat.isValid()) {
- return nullptr;
- }
-
- if (isTextureable) {
- GrAHardwareBufferUtils::DeleteImageProc deleteImageProc = nullptr;
- GrAHardwareBufferUtils::UpdateImageProc updateImageProc = nullptr;
- GrAHardwareBufferUtils::TexImageCtx deleteImageCtx = nullptr;
-
- bool isProtectedContent =
- SkToBool(bufferDesc.usage & AHARDWAREBUFFER_USAGE_PROTECTED_CONTENT);
-
- bool fromWindowLocal = false;
-#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
- fromWindowLocal = fromWindow;
-#endif
-
- GrBackendTexture backendTexture =
- GrAHardwareBufferUtils::MakeBackendTexture(dContext,
- hardwareBuffer,
- bufferDesc.width,
- bufferDesc.height,
- &deleteImageProc,
- &updateImageProc,
- &deleteImageCtx,
- isProtectedContent,
- backendFormat,
- true,
- fromWindowLocal);
- if (!backendTexture.isValid()) {
- return nullptr;
- }
-
- SkColorType colorType =
- GrAHardwareBufferUtils::GetSkColorTypeFromBufferFormat(bufferDesc.format);
-
- sk_sp<SkSurface> surface = SkSurface::MakeFromBackendTexture(dContext,
- backendTexture,
- origin,
- 0,
- colorType,
- std::move(colorSpace),
- surfaceProps,
- deleteImageProc,
- deleteImageCtx);
-
- if (!surface) {
- SkASSERT(deleteImageProc);
- deleteImageProc(deleteImageCtx);
- }
-
- return surface;
- } else {
- return nullptr;
- }
-}
-#endif
-
-void SkSurface::flushAndSubmit(bool syncCpu) {
- this->flush(BackendSurfaceAccess::kNoAccess, GrFlushInfo());
-
- auto direct = GrAsDirectContext(this->recordingContext());
- if (direct) {
- direct->submit(syncCpu);
- }
-}
-
-namespace SkSurfaces {
GrBackendTexture GetBackendTexture(SkSurface* surface, BackendHandleAccess access) {
if (surface == nullptr) {
return GrBackendTexture();
@@ -856,3 +772,81 @@
}
} // namespace SkSurfaces
+
+#if !defined(SK_DISABLE_LEGACY_SKSURFACE_FACTORIES)
+sk_sp<SkSurface> SkSurface::MakeFromBackendTexture(GrRecordingContext* context,
+ const GrBackendTexture& backendTexture,
+ GrSurfaceOrigin origin,
+ int sampleCnt,
+ SkColorType colorType,
+ sk_sp<SkColorSpace> colorSpace,
+ const SkSurfaceProps* surfaceProps,
+ TextureReleaseProc textureReleaseProc,
+ ReleaseContext releaseContext) {
+ return SkSurfaces::WrapBackendTexture(context,
+ backendTexture,
+ origin,
+ sampleCnt,
+ colorType,
+ colorSpace,
+ surfaceProps,
+ textureReleaseProc,
+ releaseContext);
+}
+
+sk_sp<SkSurface> SkSurface::MakeFromBackendRenderTarget(
+ GrRecordingContext* context,
+ const GrBackendRenderTarget& backendRenderTarget,
+ GrSurfaceOrigin origin,
+ SkColorType colorType,
+ sk_sp<SkColorSpace> colorSpace,
+ const SkSurfaceProps* surfaceProps,
+ RenderTargetReleaseProc releaseProc,
+ ReleaseContext releaseContext) {
+ return SkSurfaces::WrapBackendRenderTarget(context,
+ backendRenderTarget,
+ origin,
+ colorType,
+ colorSpace,
+ surfaceProps,
+ releaseProc,
+ releaseContext);
+}
+
+sk_sp<SkSurface> SkSurface::MakeRenderTarget(GrRecordingContext* context,
+ skgpu::Budgeted budgeted,
+ const SkImageInfo& imageInfo,
+ int sampleCount,
+ GrSurfaceOrigin surfaceOrigin,
+ const SkSurfaceProps* surfaceProps,
+ bool shouldCreateWithMips) {
+ return SkSurfaces::RenderTarget(context,
+ budgeted,
+ imageInfo,
+ sampleCount,
+ surfaceOrigin,
+ surfaceProps,
+ shouldCreateWithMips);
+}
+
+sk_sp<SkSurface> SkSurface::MakeRenderTarget(GrRecordingContext* context,
+ skgpu::Budgeted budgeted,
+ const SkImageInfo& imageInfo,
+ int sampleCount,
+ const SkSurfaceProps* surfaceProps) {
+ return SkSurfaces::RenderTarget(context, budgeted, imageInfo, sampleCount, surfaceProps);
+}
+
+sk_sp<SkSurface> SkSurface::MakeRenderTarget(GrRecordingContext* context,
+ skgpu::Budgeted budgeted,
+ const SkImageInfo& imageInfo) {
+ return SkSurfaces::RenderTarget(context, budgeted, imageInfo);
+}
+
+sk_sp<SkSurface> SkSurface::MakeRenderTarget(GrRecordingContext* context,
+ const SkSurfaceCharacterization& characterization,
+ skgpu::Budgeted budgeted) {
+ return SkSurfaces::RenderTarget(context, characterization, budgeted);
+}
+
+#endif
diff --git a/src/gpu/ganesh/surface/SkSurface_GaneshMtl.mm b/src/gpu/ganesh/surface/SkSurface_GaneshMtl.mm
index 5dfb65b..8768e97 100644
--- a/src/gpu/ganesh/surface/SkSurface_GaneshMtl.mm
+++ b/src/gpu/ganesh/surface/SkSurface_GaneshMtl.mm
@@ -8,32 +8,31 @@
#include "include/core/SkRefCnt.h"
#include "include/core/SkSurface.h"
#include "include/gpu/GrBackendSurface.h"
+#include "include/gpu/ganesh/mtl/SkSurfaceMetal.h"
#include "include/gpu/mtl/GrMtlTypes.h"
#include "src/gpu/ganesh/GrProxyProvider.h"
#include "src/gpu/ganesh/GrRecordingContextPriv.h"
#include "src/gpu/ganesh/GrResourceProvider.h"
#include "src/gpu/ganesh/GrResourceProviderPriv.h"
+#include "src/gpu/ganesh/GrSurface.h"
#include "src/gpu/ganesh/SurfaceDrawContext.h"
+#include "src/gpu/ganesh/mtl/GrMtlTextureRenderTarget.h"
#include "src/gpu/ganesh/surface/SkSurface_Ganesh.h"
-#if defined(SK_GANESH)
-
-#include "src/gpu/ganesh/GrSurface.h"
-#include "src/gpu/ganesh/mtl/GrMtlTextureRenderTarget.h"
-
-#ifdef SK_METAL
#import <Metal/Metal.h>
#import <MetalKit/MetalKit.h>
#import <QuartzCore/CAMetalLayer.h>
-sk_sp<SkSurface> SkSurface::MakeFromCAMetalLayer(GrRecordingContext* rContext,
- GrMTLHandle layer,
- GrSurfaceOrigin origin,
- int sampleCnt,
- SkColorType colorType,
- sk_sp<SkColorSpace> colorSpace,
- const SkSurfaceProps* surfaceProps,
- GrMTLHandle* drawable) {
+namespace SkSurfaces {
+
+sk_sp<SkSurface> WrapCAMetalLayer(GrRecordingContext* rContext,
+ GrMTLHandle layer,
+ GrSurfaceOrigin origin,
+ int sampleCnt,
+ SkColorType colorType,
+ sk_sp<SkColorSpace> colorSpace,
+ const SkSurfaceProps* surfaceProps,
+ GrMTLHandle* drawable) {
GrProxyProvider* proxyProvider = rContext->priv().proxyProvider();
CAMetalLayer* metalLayer = (__bridge CAMetalLayer*)layer;
@@ -99,13 +98,13 @@
return sk_make_sp<SkSurface_Ganesh>(std::move(device));
}
-sk_sp<SkSurface> SkSurface::MakeFromMTKView(GrRecordingContext* rContext,
- GrMTLHandle view,
- GrSurfaceOrigin origin,
- int sampleCnt,
- SkColorType colorType,
- sk_sp<SkColorSpace> colorSpace,
- const SkSurfaceProps* surfaceProps) {
+sk_sp<SkSurface> WrapMTKView(GrRecordingContext* rContext,
+ GrMTLHandle view,
+ GrSurfaceOrigin origin,
+ int sampleCnt,
+ SkColorType colorType,
+ sk_sp<SkColorSpace> colorSpace,
+ const SkSurfaceProps* surfaceProps) {
GrProxyProvider* proxyProvider = rContext->priv().proxyProvider();
MTKView* mtkView = (__bridge MTKView*)view;
@@ -170,6 +169,30 @@
return sk_make_sp<SkSurface_Ganesh>(std::move(device));
}
-#endif
+} // namespace SkSurfaces
+
+#if !defined(SK_DISABLE_LEGACY_SKSURFACE_FACTORIES)
+sk_sp<SkSurface> SkSurface::MakeFromCAMetalLayer(GrRecordingContext* context,
+ GrMTLHandle layer,
+ GrSurfaceOrigin origin,
+ int sampleCnt,
+ SkColorType colorType,
+ sk_sp<SkColorSpace> colorSpace,
+ const SkSurfaceProps* surfaceProps,
+ GrMTLHandle* drawable) {
+ return SkSurfaces::WrapCAMetalLayer(
+ context, layer, origin, sampleCnt, colorType, colorSpace, surfaceProps, drawable);
+}
+
+sk_sp<SkSurface> SkSurface::MakeFromMTKView(GrRecordingContext* context,
+ GrMTLHandle mtkView,
+ GrSurfaceOrigin origin,
+ int sampleCnt,
+ SkColorType colorType,
+ sk_sp<SkColorSpace> colorSpace,
+ const SkSurfaceProps* surfaceProps) {
+ return SkSurfaces::WrapMTKView(
+ context, mtkView, origin, sampleCnt, colorType, colorSpace, surfaceProps);
+}
#endif
diff --git a/src/gpu/graphite/Device.cpp b/src/gpu/graphite/Device.cpp
index 6b6199c..d802253 100644
--- a/src/gpu/graphite/Device.cpp
+++ b/src/gpu/graphite/Device.cpp
@@ -9,6 +9,7 @@
#include "include/gpu/graphite/Recorder.h"
#include "include/gpu/graphite/Recording.h"
+#include "include/gpu/graphite/Surface.h"
#include "src/gpu/AtlasTypes.h"
#include "src/gpu/graphite/Buffer.h"
#include "src/gpu/graphite/Caps.h"
@@ -344,7 +345,7 @@
}
sk_sp<SkSurface> Device::makeSurface(const SkImageInfo& ii, const SkSurfaceProps& props) {
- return SkSurface::MakeGraphite(fRecorder, ii, Mipmapped::kNo, &props);
+ return SkSurfaces::RenderTarget(fRecorder, ii, Mipmapped::kNo, &props);
}
TextureProxyView Device::createCopy(const SkIRect* subset, Mipmapped mipmapped) {
diff --git a/src/gpu/graphite/Image_Graphite.cpp b/src/gpu/graphite/Image_Graphite.cpp
index dddd0c7..9422cdb 100644
--- a/src/gpu/graphite/Image_Graphite.cpp
+++ b/src/gpu/graphite/Image_Graphite.cpp
@@ -13,6 +13,7 @@
#include "include/core/SkSurface.h"
#include "include/gpu/graphite/BackendTexture.h"
#include "include/gpu/graphite/Recorder.h"
+#include "include/gpu/graphite/Surface.h"
#include "src/gpu/RefCntedCallback.h"
#include "src/gpu/graphite/Caps.h"
#include "src/gpu/graphite/Log.h"
@@ -99,7 +100,7 @@
SkImageInfo ii = SkImageInfo::Make(this->dimensions(), targetCT, at, std::move(targetCS));
- sk_sp<SkSurface> s = SkSurface::MakeGraphite(recorder, ii, requiredProps.fMipmapped);
+ sk_sp<SkSurface> s = SkSurfaces::RenderTarget(recorder, ii, requiredProps.fMipmapped);
if (!s) {
return nullptr;
}
diff --git a/src/gpu/graphite/Surface_Graphite.cpp b/src/gpu/graphite/Surface_Graphite.cpp
index 1b42745..f1ece2a 100644
--- a/src/gpu/graphite/Surface_Graphite.cpp
+++ b/src/gpu/graphite/Surface_Graphite.cpp
@@ -10,6 +10,7 @@
#include "include/core/SkCapabilities.h"
#include "include/gpu/graphite/BackendTexture.h"
#include "include/gpu/graphite/Recorder.h"
+#include "include/gpu/graphite/Surface.h"
#include "src/gpu/graphite/Caps.h"
#include "src/gpu/graphite/Device.h"
#include "src/gpu/graphite/Image_Graphite.h"
@@ -39,7 +40,7 @@
SkCanvas* Surface::onNewCanvas() { return new SkCanvas(fDevice); }
sk_sp<SkSurface> Surface::onNewSurface(const SkImageInfo& ii) {
- return SkSurface::MakeGraphite(fDevice->recorder(), ii, Mipmapped::kNo, &this->props());
+ return SkSurfaces::RenderTarget(fDevice->recorder(), ii, Mipmapped::kNo, &this->props());
}
sk_sp<SkImage> Surface::onNewImageSnapshot(const SkIRect* subset) {
@@ -168,21 +169,21 @@
} // anonymous namespace
-sk_sp<SkSurface> SkSurface::MakeGraphite(Recorder* recorder,
- const SkImageInfo& info,
- skgpu::Mipmapped mipmapped,
- const SkSurfaceProps* props) {
+namespace SkSurfaces {
+sk_sp<SkSurface> RenderTarget(Recorder* recorder,
+ const SkImageInfo& info,
+ skgpu::Mipmapped mipmapped,
+ const SkSurfaceProps* props) {
// The client is getting the ref on this surface so it must be unbudgeted.
return skgpu::graphite::Surface::MakeGraphite(
recorder, info, skgpu::Budgeted::kNo, mipmapped, props);
}
-sk_sp<SkSurface> SkSurface::MakeGraphiteFromBackendTexture(Recorder* recorder,
- const BackendTexture& backendTex,
- SkColorType ct,
- sk_sp<SkColorSpace> cs,
- const SkSurfaceProps* props) {
-
+sk_sp<SkSurface> WrapBackendTexture(Recorder* recorder,
+ const BackendTexture& backendTex,
+ SkColorType ct,
+ sk_sp<SkColorSpace> cs,
+ const SkSurfaceProps* props) {
if (!recorder) {
return nullptr;
}
@@ -213,3 +214,23 @@
return sk_make_sp<Surface>(std::move(device));
}
+
+} // namespace SkSurfaces
+
+#if !defined(SK_DISABLE_LEGACY_SKSURFACE_FACTORIES)
+sk_sp<SkSurface> SkSurface::MakeGraphite(skgpu::graphite::Recorder* recorder,
+ const SkImageInfo& imageInfo,
+ skgpu::Mipmapped mipmapped,
+ const SkSurfaceProps* surfaceProps) {
+ return SkSurfaces::RenderTarget(recorder, imageInfo, mipmapped, surfaceProps);
+}
+
+sk_sp<SkSurface> SkSurface::MakeGraphiteFromBackendTexture(
+ skgpu::graphite::Recorder* recorder,
+ const skgpu::graphite::BackendTexture& tex,
+ SkColorType colorType,
+ sk_sp<SkColorSpace> colorSpace,
+ const SkSurfaceProps* props) {
+ return SkSurfaces::WrapBackendTexture(recorder, tex, colorType, colorSpace, props);
+}
+#endif
diff --git a/src/image/SkPictureImageGenerator.cpp b/src/image/SkPictureImageGenerator.cpp
index 864fad9..54a0add 100644
--- a/src/image/SkPictureImageGenerator.cpp
+++ b/src/image/SkPictureImageGenerator.cpp
@@ -94,6 +94,7 @@
#if defined(SK_GRAPHITE)
#include "include/core/SkSurface.h"
+#include "include/gpu/graphite/Surface.h"
#include "src/gpu/graphite/Log.h"
sk_sp<SkImage> SkPictureImageGenerator::onMakeTextureImage(skgpu::graphite::Recorder* recorder,
@@ -101,7 +102,7 @@
skgpu::Mipmapped mipmapped) {
using namespace skgpu::graphite;
- sk_sp<SkSurface> surface = SkSurface::MakeGraphite(recorder, info, mipmapped);
+ sk_sp<SkSurface> surface = SkSurfaces::RenderTarget(recorder, info, mipmapped);
if (!surface) {
SKGPU_LOG_E("Failed to create Surface");
return nullptr;
diff --git a/src/image/SkRescaleAndReadPixels.cpp b/src/image/SkRescaleAndReadPixels.cpp
index 4d96f56..2618c02 100644
--- a/src/image/SkRescaleAndReadPixels.cpp
+++ b/src/image/SkRescaleAndReadPixels.cpp
@@ -86,7 +86,7 @@
// Promote to F16 color type to preserve precision.
auto ii = SkImageInfo::Make(srcW, srcH, kRGBA_F16_SkColorType, bmp.info().alphaType(),
std::move(cs));
- auto linearSurf = SkSurface::MakeRaster(ii);
+ auto linearSurf = SkSurfaces::Raster(ii);
if (!linearSurf) {
callback(context, nullptr);
return;
@@ -127,7 +127,7 @@
// Might as well fold conversion to final info in the last step.
ii = resultInfo;
}
- auto next = SkSurface::MakeRaster(ii);
+ auto next = SkSurfaces::Raster(ii);
if (!next) {
callback(context, nullptr);
return;
diff --git a/src/image/SkSurface_Raster.cpp b/src/image/SkSurface_Raster.cpp
index c8a844f..b65e73b 100644
--- a/src/image/SkSurface_Raster.cpp
+++ b/src/image/SkSurface_Raster.cpp
@@ -76,7 +76,7 @@
SkCanvas* SkSurface_Raster::onNewCanvas() { return new SkCanvas(fBitmap, this->props()); }
sk_sp<SkSurface> SkSurface_Raster::onNewSurface(const SkImageInfo& info) {
- return SkSurface::MakeRaster(info, &this->props());
+ return SkSurfaces::Raster(info, &this->props());
}
void SkSurface_Raster::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y,
@@ -155,30 +155,34 @@
}
///////////////////////////////////////////////////////////////////////////////
-
-sk_sp<SkSurface> SkSurface::MakeRasterDirectReleaseProc(const SkImageInfo& info, void* pixels,
- size_t rb, void (*releaseProc)(void* pixels, void* context), void* context,
- const SkSurfaceProps* props) {
+namespace SkSurfaces {
+sk_sp<SkSurface> WrapPixels(const SkImageInfo& info,
+ void* pixels,
+ size_t rowBytes,
+ PixelsReleaseProc releaseProc,
+ void* context,
+ const SkSurfaceProps* props) {
if (nullptr == releaseProc) {
context = nullptr;
}
- if (!SkSurfaceValidateRasterInfo(info, rb)) {
+ if (!SkSurfaceValidateRasterInfo(info, rowBytes)) {
return nullptr;
}
if (nullptr == pixels) {
return nullptr;
}
- return sk_make_sp<SkSurface_Raster>(info, pixels, rb, releaseProc, context, props);
+ return sk_make_sp<SkSurface_Raster>(info, pixels, rowBytes, releaseProc, context, props);
}
-sk_sp<SkSurface> SkSurface::MakeRasterDirect(const SkImageInfo& info, void* pixels, size_t rowBytes,
- const SkSurfaceProps* props) {
- return MakeRasterDirectReleaseProc(info, pixels, rowBytes, nullptr, nullptr, props);
+sk_sp<SkSurface> WrapPixels(const SkImageInfo& info,
+ void* pixels,
+ size_t rowBytes,
+ const SkSurfaceProps* props) {
+ return WrapPixels(info, pixels, rowBytes, nullptr, nullptr, props);
}
-sk_sp<SkSurface> SkSurface::MakeRaster(const SkImageInfo& info, size_t rowBytes,
- const SkSurfaceProps* props) {
+sk_sp<SkSurface> Raster(const SkImageInfo& info, size_t rowBytes, const SkSurfaceProps* props) {
if (!SkSurfaceValidateRasterInfo(info)) {
return nullptr;
}
@@ -193,7 +197,45 @@
return sk_make_sp<SkSurface_Raster>(info, std::move(pr), props);
}
-sk_sp<SkSurface> SkSurface::MakeRasterN32Premul(int width, int height,
- const SkSurfaceProps* surfaceProps) {
- return MakeRaster(SkImageInfo::MakeN32Premul(width, height), surfaceProps);
+} // namespace SkSurfaces
+
+#if !defined(SK_DISABLE_LEGACY_SKSURFACE_FACTORIES)
+
+sk_sp<SkSurface> SkSurface::MakeRasterDirect(const SkImageInfo& imageInfo,
+ void* pixels,
+ size_t rowBytes,
+ const SkSurfaceProps* surfaceProps) {
+ return SkSurfaces::WrapPixels(imageInfo, pixels, rowBytes, surfaceProps);
}
+
+sk_sp<SkSurface> SkSurface::MakeRasterDirect(const SkPixmap& pm, const SkSurfaceProps* props) {
+ return SkSurfaces::WrapPixels(pm, props);
+}
+
+sk_sp<SkSurface> SkSurface::MakeRasterDirectReleaseProc(const SkImageInfo& imageInfo,
+ void* pixels,
+ size_t rowBytes,
+ void (*releaseProc)(void* pixels,
+ void* context),
+ void* context,
+ const SkSurfaceProps* surfaceProps) {
+ return SkSurfaces::WrapPixels(imageInfo, pixels, rowBytes, releaseProc, context, surfaceProps);
+}
+
+sk_sp<SkSurface> SkSurface::MakeRaster(const SkImageInfo& imageInfo,
+ size_t rowBytes,
+ const SkSurfaceProps* surfaceProps) {
+ return SkSurfaces::Raster(imageInfo, rowBytes, surfaceProps);
+}
+
+sk_sp<SkSurface> SkSurface::MakeRaster(const SkImageInfo& imageInfo, const SkSurfaceProps* props) {
+ return SkSurfaces::Raster(imageInfo, 0, props);
+}
+
+sk_sp<SkSurface> SkSurface::MakeRasterN32Premul(int width,
+ int height,
+ const SkSurfaceProps* surfaceProps) {
+ return SkSurfaces::Raster(SkImageInfo::MakeN32Premul(width, height), 0, surfaceProps);
+}
+
+#endif
diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp
index 24265b4..0fa2a7f 100644
--- a/src/pdf/SkPDFDevice.cpp
+++ b/src/pdf/SkPDFDevice.cpp
@@ -991,7 +991,7 @@
}
sk_sp<SkSurface> SkPDFDevice::makeSurface(const SkImageInfo& info, const SkSurfaceProps& props) {
- return SkSurface::MakeRaster(info, &props);
+ return SkSurfaces::Raster(info, &props);
}
static std::vector<SkPDFIndirectReference> sort(const THashSet<SkPDFIndirectReference>& src) {
@@ -1434,8 +1434,7 @@
static sk_sp<SkImage> color_filter(const SkImage* image,
SkColorFilter* colorFilter) {
- auto surface =
- SkSurface::MakeRaster(SkImageInfo::MakeN32Premul(image->dimensions()));
+ auto surface = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(image->dimensions()));
SkASSERT(surface);
SkCanvas* canvas = surface->getCanvas();
canvas->clear(SK_ColorTRANSPARENT);
@@ -1505,7 +1504,7 @@
if (imageSubset.image()->isAlphaOnly() && paint->getColorFilter()) {
// must blend alpha image and shader before applying colorfilter.
auto surface =
- SkSurface::MakeRaster(SkImageInfo::MakeN32Premul(imageSubset.image()->dimensions()));
+ SkSurfaces::Raster(SkImageInfo::MakeN32Premul(imageSubset.image()->dimensions()));
SkCanvas* canvas = surface->getCanvas();
SkPaint tmpPaint;
// In the case of alpha images with shaders, the shader's coordinate
@@ -1614,7 +1613,7 @@
SkISize wh = rect_to_size(physicalBounds).toCeil();
- auto surface = SkSurface::MakeRaster(SkImageInfo::MakeN32Premul(wh));
+ auto surface = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(wh));
if (!surface) {
return;
}
diff --git a/src/pdf/SkPDFShader.cpp b/src/pdf/SkPDFShader.cpp
index cbaa32e..3f5b4a5 100644
--- a/src/pdf/SkPDFShader.cpp
+++ b/src/pdf/SkPDFShader.cpp
@@ -287,7 +287,7 @@
SkSize scale = {SkIntToScalar(size.width()) / shaderRect.width(),
SkIntToScalar(size.height()) / shaderRect.height()};
- auto surface = SkSurface::MakeRasterN32Premul(size.width(), size.height());
+ auto surface = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(size.width(), size.height()));
SkASSERT(surface);
SkCanvas* canvas = surface->getCanvas();
canvas->clear(SK_ColorTRANSPARENT);
diff --git a/src/shaders/SkPictureShader.cpp b/src/shaders/SkPictureShader.cpp
index 84dae35..e0943bb 100644
--- a/src/shaders/SkPictureShader.cpp
+++ b/src/shaders/SkPictureShader.cpp
@@ -28,6 +28,7 @@
#if defined(SK_GANESH)
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/GrRecordingContext.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "src/gpu/ganesh/GrCaps.h"
#include "src/gpu/ganesh/GrColorInfo.h"
#include "src/gpu/ganesh/GrFPArgs.h"
@@ -41,6 +42,7 @@
#endif
#if defined(SK_GRAPHITE)
+#include "include/gpu/graphite/Surface.h"
#include "src/gpu/graphite/Caps.h"
#include "src/gpu/graphite/KeyContext.h"
#include "src/gpu/graphite/KeyHelpers.h"
@@ -292,7 +294,7 @@
sk_sp<SkImage> image;
if (!SkResourceCache::Find(key, ImageFromPictureRec::Visitor, &image)) {
- image = info.makeImage(SkSurface::MakeRaster(info.imageInfo, &info.props), fPicture.get());
+ image = info.makeImage(SkSurfaces::Raster(info.imageInfo, &info.props), fPicture.get());
if (!image) {
return nullptr;
}
@@ -417,13 +419,13 @@
} else {
const int msaaSampleCount = 0;
const bool createWithMips = false;
- auto image = info.makeImage(SkSurface::MakeRenderTarget(ctx,
- skgpu::Budgeted::kYes,
- info.imageInfo,
- msaaSampleCount,
- kTopLeft_GrSurfaceOrigin,
- &info.props,
- createWithMips),
+ auto image = info.makeImage(SkSurfaces::RenderTarget(ctx,
+ skgpu::Budgeted::kYes,
+ info.imageInfo,
+ msaaSampleCount,
+ kTopLeft_GrSurfaceOrigin,
+ &info.props,
+ createWithMips),
fPicture.get());
if (!image) {
return nullptr;
@@ -483,9 +485,9 @@
// TODO: right now we're explicitly not caching here. We could expand the ImageProvider
// API to include already Graphite-backed images, add a Recorder-local cache or add
// rendered-picture images to the global cache.
- sk_sp<SkImage> img = info.makeImage(SkSurface::MakeGraphite(recorder, info.imageInfo,
- skgpu::Mipmapped::kNo, &info.props),
- fPicture.get());
+ sk_sp<SkImage> img = info.makeImage(
+ SkSurfaces::RenderTarget(recorder, info.imageInfo, skgpu::Mipmapped::kNo, &info.props),
+ fPicture.get());
if (!img) {
SolidColorShaderBlock::BeginBlock(keyContext, builder, gatherer, {1, 0, 0, 1});
builder->endBlock();
diff --git a/tests/ApplyGammaTest.cpp b/tests/ApplyGammaTest.cpp
index 5cd4c2c..7d9eef3 100644
--- a/tests/ApplyGammaTest.cpp
+++ b/tests/ApplyGammaTest.cpp
@@ -21,6 +21,7 @@
#include "include/core/SkTypes.h"
#include "include/gpu/GpuTypes.h"
#include "include/gpu/GrDirectContext.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "include/private/base/SkTemplates.h"
#include "src/core/SkOpts.h"
#include "src/gpu/ganesh/GrCaps.h"
@@ -126,7 +127,7 @@
float error = context->priv().caps()->shaderCaps()->fHalfIs32Bits ? 0.5f : 1.2f;
for (auto toSRGB : { false, true }) {
- sk_sp<SkSurface> dst(SkSurface::MakeRenderTarget(context, skgpu::Budgeted::kNo, ii));
+ sk_sp<SkSurface> dst(SkSurfaces::RenderTarget(context, skgpu::Budgeted::kNo, ii));
if (!dst) {
ERRORF(reporter, "Could not create surfaces for copy surface test.");
diff --git a/tests/BackendAllocationTest.cpp b/tests/BackendAllocationTest.cpp
index 85a4e72..dfec529 100644
--- a/tests/BackendAllocationTest.cpp
+++ b/tests/BackendAllocationTest.cpp
@@ -16,7 +16,6 @@
#include "include/core/SkRefCnt.h"
#include "include/core/SkSamplingOptions.h"
#include "include/core/SkString.h"
-#include "include/core/SkSurface.h"
#include "include/core/SkTextureCompressionType.h"
#include "include/core/SkTypes.h"
#include "include/gpu/GpuTypes.h"
@@ -25,6 +24,7 @@
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/GrTypes.h"
#include "include/gpu/ganesh/SkImageGanesh.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "include/private/SkColorData.h"
#include "include/private/gpu/ganesh/GrTypesPriv.h"
#include "src/core/SkAutoPixmapStorage.h"
@@ -89,6 +89,7 @@
#endif
class SkImage;
+class SkSurface;
using sk_gpu_test::ManagedBackendTexture;
@@ -135,12 +136,13 @@
}
if (GrRenderable::kYes == renderable && dContext->colorTypeSupportedAsSurface(skColorType)) {
- sk_sp<SkSurface> surf = SkSurface::MakeFromBackendTexture(dContext,
- mbet->texture(),
- kTopLeft_GrSurfaceOrigin,
- 0,
- skColorType,
- nullptr, nullptr);
+ sk_sp<SkSurface> surf = SkSurfaces::WrapBackendTexture(dContext,
+ mbet->texture(),
+ kTopLeft_GrSurfaceOrigin,
+ 0,
+ skColorType,
+ nullptr,
+ nullptr);
if (!surf) {
ERRORF(reporter, "Couldn't make SkSurface from backendTexture for %s\n",
ToolUtils::colortype_name(skColorType));
diff --git a/tests/BlurTest.cpp b/tests/BlurTest.cpp
index dbbaf62..42c2b4e 100644
--- a/tests/BlurTest.cpp
+++ b/tests/BlurTest.cpp
@@ -29,6 +29,7 @@
#include "include/effects/SkPerlinNoiseShader.h"
#include "include/gpu/GpuTypes.h"
#include "include/gpu/GrDirectContext.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "include/private/base/SkFloatBits.h"
#include "include/private/base/SkTPin.h"
#include "src/base/SkMathPriv.h"
@@ -423,7 +424,7 @@
// SkBlurMask::BoxBlur wasn't being checked in SkBlurMaskFilter.cpp::GrRRectBlurEffect::Create
DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS(SmallBoxBlurBug, reporter, ctxInfo, CtsEnforcement::kNever) {
SkImageInfo info = SkImageInfo::MakeN32Premul(128, 128);
- auto surface(SkSurface::MakeRenderTarget(ctxInfo.directContext(), skgpu::Budgeted::kNo, info));
+ auto surface(SkSurfaces::RenderTarget(ctxInfo.directContext(), skgpu::Budgeted::kNo, info));
SkCanvas* canvas = surface->getCanvas();
SkRect r = SkRect::MakeXYWH(10, 10, 100, 100);
@@ -506,14 +507,14 @@
p.setMaskFilter(SkEmbossMaskFilter::Make(1, light));
p.setShader(SkPerlinNoiseShader::MakeFractalNoise(1.0f, 1.0f, 2, 0.0f));
- sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul(100, 100);
+ sk_sp<SkSurface> surface = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(100, 100));
surface->getCanvas()->drawPaint(p);
}
///////////////////////////////////////////////////////////////////////////////////////////
DEF_TEST(BlurZeroSigma, reporter) {
- auto surf = SkSurface::MakeRasterN32Premul(20, 20);
+ auto surf = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(20, 20));
SkPaint paint;
paint.setAntiAlias(true);
@@ -552,7 +553,7 @@
SkImageInfo ii = SkImageInfo::Make(32, 32, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
- sk_sp<SkSurface> dst(SkSurface::MakeRenderTarget(context, skgpu::Budgeted::kNo, ii));
+ sk_sp<SkSurface> dst(SkSurfaces::RenderTarget(context, skgpu::Budgeted::kNo, ii));
if (!dst) {
ERRORF(reporter, "Could not create surface for test.");
return;
diff --git a/tests/CanvasStateTest.cpp b/tests/CanvasStateTest.cpp
index 29ccfda..f5b9f74 100644
--- a/tests/CanvasStateTest.cpp
+++ b/tests/CanvasStateTest.cpp
@@ -155,9 +155,8 @@
for (size_t i = 0; i < std::size(colorTypes); ++i) {
sk_sp<SkImage> images[2];
for (int j = 0; j < 2; ++j) {
- auto surf = SkSurface::MakeRaster(SkImageInfo::Make(WIDTH, HEIGHT,
- colorTypes[i],
- kPremul_SkAlphaType));
+ auto surf = SkSurfaces::Raster(
+ SkImageInfo::Make(WIDTH, HEIGHT, colorTypes[i], kPremul_SkAlphaType));
SkCanvas* canvas = surf->getCanvas();
canvas->drawColor(SK_ColorRED);
@@ -249,7 +248,7 @@
sk_sp<SkImage> images[2];
for (int i = 0; i < 2; ++i) {
- auto surf = SkSurface::MakeRaster(SkImageInfo::MakeN32Premul(WIDTH, HEIGHT));
+ auto surf = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(WIDTH, HEIGHT));
SkCanvas* canvas = surf->getCanvas();
canvas->drawColor(SK_ColorRED);
diff --git a/tests/CanvasTest.cpp b/tests/CanvasTest.cpp
index 0a2f07b..e497196 100644
--- a/tests/CanvasTest.cpp
+++ b/tests/CanvasTest.cpp
@@ -148,7 +148,7 @@
proc(doc->beginPage(SkIntToScalar(w), SkIntToScalar(h)));
}
- proc(SkSurface::MakeRasterN32Premul(w, h, nullptr)->getCanvas());
+ proc(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(w, h), nullptr)->getCanvas());
}
const SkIRect gBaseRestrictedR = { 0, 0, 10, 10 };
@@ -601,7 +601,7 @@
DEF_TEST(CanvasClipType, r) {
// test rasterclip backend
- test_cliptype(SkSurface::MakeRasterN32Premul(10, 10)->getCanvas(), r);
+ test_cliptype(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(10, 10))->getCanvas(), r);
#ifdef SK_SUPPORT_PDF
// test clipstack backend
@@ -738,7 +738,7 @@
auto do_test = [&](int saveCount, int restoreCount) {
SkASSERT(restoreCount <= saveCount);
- auto surf = SkSurface::MakeRasterDirect(pm);
+ auto surf = SkSurfaces::WrapPixels(pm);
auto canvas = surf->getCanvas();
canvas->clear(SK_ColorRED);
diff --git a/tests/ClearTest.cpp b/tests/ClearTest.cpp
index 3f4a6e1..2d41ed0 100644
--- a/tests/ClearTest.cpp
+++ b/tests/ClearTest.cpp
@@ -21,6 +21,7 @@
#include "include/gpu/GpuTypes.h"
#include "include/gpu/GrContextOptions.h"
#include "include/gpu/GrDirectContext.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "include/private/SkColorData.h"
#include "include/private/gpu/ganesh/GrTypesPriv.h"
#include "src/core/SkAutoPixmapStorage.h"
@@ -317,7 +318,7 @@
void fullscreen_clear_with_layer_test(skiatest::Reporter* reporter, GrRecordingContext* rContext) {
const SkImageInfo ii = SkImageInfo::Make(400, 77, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
- sk_sp<SkSurface> surf = SkSurface::MakeRenderTarget(rContext, skgpu::Budgeted::kYes, ii);
+ sk_sp<SkSurface> surf = SkSurfaces::RenderTarget(rContext, skgpu::Budgeted::kYes, ii);
SkCanvas* canvas = surf->getCanvas();
SkPaint paints[2];
diff --git a/tests/ClipCubicTest.cpp b/tests/ClipCubicTest.cpp
index 0c7738b..4c1a425 100644
--- a/tests/ClipCubicTest.cpp
+++ b/tests/ClipCubicTest.cpp
@@ -8,6 +8,7 @@
#include "include/core/SkBitmap.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkColor.h"
+#include "include/core/SkImageInfo.h"
#include "include/core/SkPaint.h"
#include "include/core/SkPath.h"
#include "include/core/SkPoint.h"
@@ -171,7 +172,7 @@
}
DEF_TEST(test_fuzz_crbug_698714, reporter) {
- auto surface(SkSurface::MakeRasterN32Premul(500, 500));
+ auto surface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(500, 500)));
SkCanvas* canvas = surface->getCanvas();
SkPaint paint;
paint.setAntiAlias(true);
@@ -209,7 +210,7 @@
}
DEF_TEST(cubic_scan_error_crbug_844457_and_845489, reporter) {
- auto surface(SkSurface::MakeRasterN32Premul(100, 100));
+ auto surface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(100, 100)));
SkCanvas* canvas = surface->getCanvas();
SkPaint p;
diff --git a/tests/ColorFilterTest.cpp b/tests/ColorFilterTest.cpp
index e355081..420bc14 100644
--- a/tests/ColorFilterTest.cpp
+++ b/tests/ColorFilterTest.cpp
@@ -22,6 +22,7 @@
#include "include/effects/SkGradientShader.h"
#include "include/gpu/GpuTypes.h"
#include "include/gpu/GrDirectContext.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "src/base/SkAutoMalloc.h"
#include "src/base/SkRandom.h"
#include "src/core/SkColorFilterBase.h"
@@ -174,7 +175,7 @@
ctxInfo,
CtsEnforcement::kApiLevel_T) {
SkImageInfo info = SkImageInfo::MakeN32Premul(8, 8);
- auto surface = SkSurface::MakeRenderTarget(ctxInfo.directContext(), skgpu::Budgeted::kNo, info);
+ auto surface = SkSurfaces::RenderTarget(ctxInfo.directContext(), skgpu::Budgeted::kNo, info);
SkPaint paint;
// Install a non-trivial shader, so the color filter isn't just applied to the paint color:
diff --git a/tests/CompressedBackendAllocationTest.cpp b/tests/CompressedBackendAllocationTest.cpp
index 0b80adf..f2b5f5a 100644
--- a/tests/CompressedBackendAllocationTest.cpp
+++ b/tests/CompressedBackendAllocationTest.cpp
@@ -27,6 +27,7 @@
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/GrTypes.h"
#include "include/gpu/ganesh/SkImageGanesh.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "include/private/base/SkTArray.h"
#include "include/private/gpu/ganesh/GrTypesPriv.h"
#include "src/core/SkAutoPixmapStorage.h"
@@ -93,12 +94,12 @@
SkImageInfo readbackSurfaceII = SkImageInfo::Make(32, 32, kRGBA_8888_SkColorType,
kPremul_SkAlphaType);
- sk_sp<SkSurface> surf = SkSurface::MakeRenderTarget(rContext,
- skgpu::Budgeted::kNo,
- readbackSurfaceII,
- 1,
- kTopLeft_GrSurfaceOrigin,
- nullptr);
+ sk_sp<SkSurface> surf = SkSurfaces::RenderTarget(rContext,
+ skgpu::Budgeted::kNo,
+ readbackSurfaceII,
+ 1,
+ kTopLeft_GrSurfaceOrigin,
+ nullptr);
if (!surf) {
return;
}
diff --git a/tests/DMSAATest.cpp b/tests/DMSAATest.cpp
index 9002c44..448232c 100644
--- a/tests/DMSAATest.cpp
+++ b/tests/DMSAATest.cpp
@@ -32,6 +32,7 @@
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/GrTypes.h"
#include "include/gpu/ganesh/SkImageGanesh.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "include/private/SkColorData.h"
#include "include/private/gpu/ganesh/GrTypesPriv.h"
#include "src/core/SkBlendModePriv.h"
@@ -308,13 +309,13 @@
// a dmsaa surface it forces us to use the FillRRectOp instead of the normal FillQuad path. It
// is unclear why, but using the FillRRectOp is required to repro the bug.
{
- auto surface = SkSurface::MakeFromBackendTexture(context,
- texture1,
- kTopLeft_GrSurfaceOrigin,
- 1,
- kRGBA_8888_SkColorType,
- nullptr,
- &kDMSAAProps);
+ auto surface = SkSurfaces::WrapBackendTexture(context,
+ texture1,
+ kTopLeft_GrSurfaceOrigin,
+ 1,
+ kRGBA_8888_SkColorType,
+ nullptr,
+ &kDMSAAProps);
surface->getCanvas()->drawImageRect(sourceImage,
srcRect,
@@ -330,13 +331,13 @@
// trigger use to disable blending. However, when the bug is present the driver still seems to
// try and use a "src2" blend value and ends up just writing the original dst color of yellow.
{
- auto surface = SkSurface::MakeFromBackendTexture(context,
- texture2,
- kTopLeft_GrSurfaceOrigin,
- 1,
- kRGBA_8888_SkColorType,
- nullptr,
- &kBasicProps);
+ auto surface = SkSurfaces::WrapBackendTexture(context,
+ texture2,
+ kTopLeft_GrSurfaceOrigin,
+ 1,
+ kRGBA_8888_SkColorType,
+ nullptr,
+ &kBasicProps);
surface->getCanvas()->drawImageRect(sourceImage,
srcRect,
diff --git a/tests/DashPathEffectTest.cpp b/tests/DashPathEffectTest.cpp
index 6951075..a3ad69e 100644
--- a/tests/DashPathEffectTest.cpp
+++ b/tests/DashPathEffectTest.cpp
@@ -116,7 +116,7 @@
// Verify that long lines with many dashes don't cause overflows/OOMs.
DEF_TEST(DashPathEffectTest_asPoints_limit, r) {
- sk_sp<SkSurface> surface(SkSurface::MakeRaster(SkImageInfo::MakeN32Premul(256, 256)));
+ sk_sp<SkSurface> surface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(256, 256)));
SkCanvas* canvas = surface->getCanvas();
SkPaint p;
diff --git a/tests/DeferredDisplayListTest.cpp b/tests/DeferredDisplayListTest.cpp
index 12f2df0..6c9c163 100644
--- a/tests/DeferredDisplayListTest.cpp
+++ b/tests/DeferredDisplayListTest.cpp
@@ -250,10 +250,8 @@
return nullptr;
}
- sk_sp<SkSurface> result = SkSurface::MakeFromBackendRenderTarget(dContext, backendRT,
- fOrigin, fColorType,
- fColorSpace,
- &fSurfaceProps);
+ sk_sp<SkSurface> result = SkSurfaces::WrapBackendRenderTarget(
+ dContext, backendRT, fOrigin, fColorType, fColorSpace, &fSurfaceProps);
SkASSERT(result->isCompatible(c));
return result;
}
@@ -485,7 +483,7 @@
{
SkImageInfo ii = SkImageInfo::MakeN32(64, 64, kOpaque_SkAlphaType);
- sk_sp<SkSurface> rasterSurface = SkSurface::MakeRaster(ii);
+ sk_sp<SkSurface> rasterSurface = SkSurfaces::Raster(ii);
SkSurfaceCharacterization c;
REPORTER_ASSERT(reporter, !rasterSurface->characterize(&c));
}
@@ -684,10 +682,12 @@
GrBackendRenderTarget backendRT(128, 128, numSamples, kStencilBits, fboInfo);
SkAssertResult(backendRT.isValid());
- surfaces[index] = SkSurface::MakeFromBackendRenderTarget(context, backendRT,
- kTopLeft_GrSurfaceOrigin,
- kRGBA_8888_SkColorType,
- nullptr, &surfaceProps);
+ surfaces[index] = SkSurfaces::WrapBackendRenderTarget(context,
+ backendRT,
+ kTopLeft_GrSurfaceOrigin,
+ kRGBA_8888_SkColorType,
+ nullptr,
+ &surfaceProps);
++index;
}
}
@@ -836,14 +836,14 @@
// Make an SkSurface from scratch
{
- sk_sp<SkSurface> s = SkSurface::MakeRenderTarget(dContext, c, skgpu::Budgeted::kYes);
+ sk_sp<SkSurface> s = SkSurfaces::RenderTarget(dContext, c, skgpu::Budgeted::kYes);
REPORTER_ASSERT(reporter, s);
REPORTER_ASSERT(reporter, s->isCompatible(c));
}
}
////////////////////////////////////////////////////////////////////////////////
-// This tests the SkSurface::MakeRenderTarget variants that take an SkSurfaceCharacterization.
+// This tests the SkSurfaces::RenderTarget variants that take an SkSurfaceCharacterization.
// In particular, the SkSurface, backendTexture and SkSurfaceCharacterization
// should always be compatible.
void DDLMakeRenderTargetTestImpl(GrDirectContext* dContext, skiatest::Reporter* reporter) {
@@ -962,7 +962,7 @@
{
SkImageInfo ii = SkImageInfo::MakeN32Premul(32, 32);
- sk_sp<SkSurface> s = SkSurface::MakeRenderTarget(dContext, skgpu::Budgeted::kNo, ii);
+ sk_sp<SkSurface> s = SkSurfaces::RenderTarget(dContext, skgpu::Budgeted::kNo, ii);
SkSurfaceCharacterization characterization;
SkAssertResult(s->characterize(&characterization));
@@ -1116,7 +1116,7 @@
auto context = ctxInfo.directContext();
SkImageInfo ii = SkImageInfo::Make(32, 32, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
- sk_sp<SkSurface> s = SkSurface::MakeRenderTarget(context, skgpu::Budgeted::kNo, ii);
+ sk_sp<SkSurface> s = SkSurfaces::RenderTarget(context, skgpu::Budgeted::kNo, ii);
SkSurfaceCharacterization characterization;
SkAssertResult(s->characterize(&characterization));
@@ -1185,7 +1185,7 @@
auto context = ctxInfo.directContext();
SkImageInfo ii = SkImageInfo::MakeN32Premul(32, 32);
- sk_sp<SkSurface> s = SkSurface::MakeRenderTarget(context, skgpu::Budgeted::kNo, ii);
+ sk_sp<SkSurface> s = SkSurfaces::RenderTarget(context, skgpu::Budgeted::kNo, ii);
SkBitmap bitmap;
bitmap.allocPixels(ii);
@@ -1251,7 +1251,7 @@
auto context = ctxInfo.directContext();
SkImageInfo ii = SkImageInfo::MakeN32Premul(32, 32);
- sk_sp<SkSurface> s = SkSurface::MakeRenderTarget(context, skgpu::Budgeted::kNo, ii);
+ sk_sp<SkSurface> s = SkSurfaces::RenderTarget(context, skgpu::Budgeted::kNo, ii);
SkSurfaceCharacterization characterization;
SkAssertResult(s->characterize(&characterization));
diff --git a/tests/DrawPathTest.cpp b/tests/DrawPathTest.cpp
index 5b70839..0a685a5 100644
--- a/tests/DrawPathTest.cpp
+++ b/tests/DrawPathTest.cpp
@@ -34,7 +34,7 @@
SkPMColor pixel[1];
output.installPixels(SkImageInfo::MakeN32Premul(1, 1), pixel, 4);
- auto surf = SkSurface::MakeRasterN32Premul(300, 33300);
+ auto surf = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(300, 33300));
SkCanvas* canvas = surf->getCanvas();
SkRect r = { 0, 33000, 300, 33300 };
@@ -110,7 +110,7 @@
moveToH(&path, &data[0]);
cubicToH(&path, &data[2]);
- auto surface(SkSurface::MakeRasterN32Premul(640, 480));
+ auto surface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(640, 480)));
SkPaint paint;
paint.setAntiAlias(true);
@@ -192,7 +192,7 @@
SkPaint paint;
- auto surface(SkSurface::MakeRasterN32Premul(640, 480));
+ auto surface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(640, 480)));
SkCanvas* canvas = surface->getCanvas();
canvas->save();
canvas->clipRect(SkRect::MakeWH(19, 11));
@@ -231,7 +231,7 @@
SkPaint paint;
paint.setAntiAlias(true);
- auto surface(SkSurface::MakeRasterN32Premul(640, 480));
+ auto surface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(640, 480)));
surface->getCanvas()->drawPath(path, paint);
}
@@ -273,7 +273,7 @@
SkPaint paint;
paint.setAntiAlias(true);
- auto surface(SkSurface::MakeRasterN32Premul(640, 480));
+ auto surface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(640, 480)));
surface->getCanvas()->drawPath(path, paint);
}
@@ -301,7 +301,7 @@
m.postTranslate(0.001f, 0.001f);
path.transform(m, &p2);
- auto surface(SkSurface::MakeRasterN32Premul(640, 480));
+ auto surface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(640, 480)));
SkCanvas* canvas = surface->getCanvas();
canvas->translate(-16366, -1383);
canvas->drawPath(p2, paint);
@@ -322,7 +322,7 @@
static void test_giantaa() {
const int W = 400;
const int H = 400;
- auto surface(SkSurface::MakeRasterN32Premul(33000, 10));
+ auto surface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(33000, 10)));
SkPaint paint;
paint.setAntiAlias(true);
@@ -376,7 +376,7 @@
// http://crbug.com/472147
// This is a simplified version from the bug. RRect radii not properly scaled.
static void test_crbug_472147_simple(skiatest::Reporter* reporter) {
- auto surface(SkSurface::MakeRasterN32Premul(1000, 1000));
+ auto surface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(1000, 1000)));
SkCanvas* canvas = surface->getCanvas();
SkPaint p;
SkRect r = SkRect::MakeLTRB(-246.0f, 33.0f, 848.0f, 33554464.0f);
@@ -391,7 +391,7 @@
// http://crbug.com/472147
// RRect radii not properly scaled.
static void test_crbug_472147_actual(skiatest::Reporter* reporter) {
- auto surface(SkSurface::MakeRasterN32Premul(1000, 1000));
+ auto surface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(1000, 1000)));
SkCanvas* canvas = surface->getCanvas();
SkPaint p;
SkRect r = SkRect::MakeLTRB(-246.0f, 33.0f, 848.0f, 33554464.0f);
diff --git a/tests/DrawTextTest.cpp b/tests/DrawTextTest.cpp
index d352bce..9526158 100644
--- a/tests/DrawTextTest.cpp
+++ b/tests/DrawTextTest.cpp
@@ -9,9 +9,10 @@
#include "include/core/SkCanvas.h"
#include "include/core/SkColor.h"
#include "include/core/SkFont.h"
+#include "include/core/SkImageInfo.h"
#include "include/core/SkMatrix.h"
#include "include/core/SkPaint.h"
-#include "include/core/SkPathEffect.h" // IWYU pragma: keep
+#include "include/core/SkPathEffect.h" // IWYU pragma: keep
#include "include/core/SkPoint.h"
#include "include/core/SkRect.h"
#include "include/core/SkRefCnt.h"
@@ -112,7 +113,7 @@
// Test drawing text at some unusual coordinates.
// We measure success by not crashing or asserting.
DEF_TEST(DrawText_weirdCoordinates, r) {
- auto surface = SkSurface::MakeRasterN32Premul(10,10);
+ auto surface = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(10, 10));
auto canvas = surface->getCanvas();
SkScalar oddballs[] = { 0.0f, (float)INFINITY, (float)NAN, 34359738368.0f };
@@ -130,7 +131,7 @@
// Test drawing text with some unusual matricies.
// We measure success by not crashing or asserting.
DEF_TEST(DrawText_weirdMatricies, r) {
- auto surface = SkSurface::MakeRasterN32Premul(100,100);
+ auto surface = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(100, 100));
auto canvas = surface->getCanvas();
SkFont font;
@@ -167,7 +168,7 @@
// This produces no glyphs, and is to check that buffers from previous draws don't get
// reused.
DEF_TEST(DrawText_noglyphs, r) {
- auto surface = SkSurface::MakeRasterN32Premul(100,100);
+ auto surface = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(100, 100));
auto canvas = surface->getCanvas();
auto text = "Hamburgfons";
{
diff --git a/tests/EncodeTest.cpp b/tests/EncodeTest.cpp
index 2246e38..978acdb 100644
--- a/tests/EncodeTest.cpp
+++ b/tests/EncodeTest.cpp
@@ -164,7 +164,7 @@
kRGBA_F16_SkColorType }) {
for (auto at : { kPremul_SkAlphaType, kUnpremul_SkAlphaType, kOpaque_SkAlphaType }) {
auto info = SkImageInfo::Make(image->width(), image->height(), ct, at);
- auto surface = SkSurface::MakeRaster(info);
+ auto surface = SkSurfaces::Raster(info);
auto canvas = surface->getCanvas();
canvas->drawImage(image, 0, 0);
diff --git a/tests/ExtendedSkColorTypeTests.cpp b/tests/ExtendedSkColorTypeTests.cpp
index 084974f..8ba7264 100644
--- a/tests/ExtendedSkColorTypeTests.cpp
+++ b/tests/ExtendedSkColorTypeTests.cpp
@@ -20,6 +20,7 @@
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/GrTypes.h"
#include "include/gpu/ganesh/SkImageGanesh.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "include/private/base/SkTo.h"
#include "src/core/SkAutoPixmapStorage.h"
#include "src/core/SkImageInfoPriv.h"
@@ -106,7 +107,7 @@
// all colorTypes can be drawn to
{
- auto s = SkSurface::MakeRaster(nativeII);
+ auto s = SkSurfaces::Raster(nativeII);
REPORTER_ASSERT(reporter, SkToBool(s));
}
@@ -157,7 +158,7 @@
auto i = SkImages::RasterFromPixmap(srcPM, nullptr, nullptr);
REPORTER_ASSERT(reporter, SkToBool(i));
- auto s = SkSurface::MakeRaster(f32Unpremul);
+ auto s = SkSurfaces::Raster(f32Unpremul);
REPORTER_ASSERT(reporter, SkToBool(s));
{
@@ -203,7 +204,7 @@
// We had better not be able to render to prohibited colorTypes
if (!test.fGpuCanMakeSurfaces) {
- auto s = SkSurface::MakeRenderTarget(dContext, skgpu::Budgeted::kNo, nativeII);
+ auto s = SkSurfaces::RenderTarget(dContext, skgpu::Budgeted::kNo, nativeII);
REPORTER_ASSERT(reporter, !SkToBool(s));
}
@@ -264,7 +265,7 @@
// SkSurface::readPixels with the same colorType as the source pixels round trips
// (when allowed)
if (dContext->colorTypeSupportedAsSurface(test.fColorType)) {
- auto s = SkSurface::MakeRenderTarget(dContext, skgpu::Budgeted::kNo, nativeII);
+ auto s = SkSurfaces::RenderTarget(dContext, skgpu::Budgeted::kNo, nativeII);
REPORTER_ASSERT(reporter, SkToBool(s));
{
@@ -303,8 +304,7 @@
kRGBA_8888_SkColorType,
kPremul_SkAlphaType);
- auto s =
- SkSurface::MakeRenderTarget(dContext, skgpu::Budgeted::kNo, rgba8888Premul);
+ auto s = SkSurfaces::RenderTarget(dContext, skgpu::Budgeted::kNo, rgba8888Premul);
REPORTER_ASSERT(reporter, SkToBool(s));
{
diff --git a/tests/GLBackendSurfaceTest.cpp b/tests/GLBackendSurfaceTest.cpp
index d2f1a5d..e4d0193 100644
--- a/tests/GLBackendSurfaceTest.cpp
+++ b/tests/GLBackendSurfaceTest.cpp
@@ -24,6 +24,7 @@
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/GrTypes.h"
#include "include/gpu/ganesh/SkImageGanesh.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "include/gpu/gl/GrGLTypes.h"
#include "include/private/gpu/ganesh/GrGLTypesPriv.h"
#include "src/gpu/ganesh/GrDirectContextPriv.h"
@@ -103,7 +104,7 @@
GrGLTextureParameters::NonsamplerState invalidNSState;
invalidNSState.invalidate();
- auto surf = SkSurface::MakeRenderTarget(
+ auto surf = SkSurfaces::RenderTarget(
dContext,
skgpu::Budgeted::kYes,
SkImageInfo::Make(1, 1, kRGBA_8888_SkColorType, kPremul_SkAlphaType),
diff --git a/tests/GpuDrawPathTest.cpp b/tests/GpuDrawPathTest.cpp
index bead4ec..16a3837 100644
--- a/tests/GpuDrawPathTest.cpp
+++ b/tests/GpuDrawPathTest.cpp
@@ -23,6 +23,7 @@
#include "include/effects/SkDashPathEffect.h"
#include "include/gpu/GpuTypes.h"
#include "include/gpu/GrDirectContext.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "tests/CtsEnforcement.h"
#include <initializer_list>
@@ -84,7 +85,7 @@
for (auto& test_func : { &test_drawPathEmpty, &test_drawSameRectOvals }) {
for (auto& sampleCount : {1, 4, 16}) {
SkImageInfo info = SkImageInfo::MakeN32Premul(255, 255);
- auto surface(SkSurface::MakeRenderTarget(
+ auto surface(SkSurfaces::RenderTarget(
ctxInfo.directContext(), skgpu::Budgeted::kNo, info, sampleCount, nullptr));
if (!surface) {
continue;
@@ -102,7 +103,7 @@
// path to be accepted by AAConvexPathRenderer, then be transformed to something without a
// computable first direction by a perspective matrix.
SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100);
- auto surface(SkSurface::MakeRenderTarget(ctxInfo.directContext(), skgpu::Budgeted::kNo, info));
+ auto surface(SkSurfaces::RenderTarget(ctxInfo.directContext(), skgpu::Budgeted::kNo, info));
SkPaint paint;
paint.setAntiAlias(true);
@@ -129,7 +130,7 @@
// AAHairlinePathRenderer chops this path to quads that include infinities (and then NaNs).
// It used to trigger asserts, now the degenerate quad segments should cause it to be rejected.
SkImageInfo info = SkImageInfo::MakeN32Premul(256, 256);
- auto surface(SkSurface::MakeRenderTarget(ctxInfo.directContext(), skgpu::Budgeted::kNo, info));
+ auto surface(SkSurfaces::RenderTarget(ctxInfo.directContext(), skgpu::Budgeted::kNo, info));
SkPaint paint;
paint.setAntiAlias(true);
diff --git a/tests/GrAHardwareBufferTest.cpp b/tests/GrAHardwareBufferTest.cpp
index e1f9f59..211f078 100644
--- a/tests/GrAHardwareBufferTest.cpp
+++ b/tests/GrAHardwareBufferTest.cpp
@@ -12,12 +12,14 @@
#if defined(SK_GANESH) && defined(SK_BUILD_FOR_ANDROID) && __ANDROID_API__ >= 26
#include "include/android/SkImageAndroid.h"
+#include "include/android/SkSurfaceAndroid.h"
#include "include/core/SkBitmap.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkColorSpace.h"
#include "include/core/SkImage.h"
#include "include/core/SkSurface.h"
#include "include/gpu/GrDirectContext.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "src/gpu/ganesh/GrAHardwareBufferImageGenerator.h"
#include "src/gpu/ganesh/GrDirectContextPriv.h"
#include "src/gpu/ganesh/GrGpu.h"
@@ -181,8 +183,7 @@
SkImageInfo imageInfo = SkImageInfo::Make(DEV_W, DEV_H, kRGBA_8888_SkColorType,
kPremul_SkAlphaType);
- sk_sp<SkSurface> surface =
- SkSurface::MakeRenderTarget(context, skgpu::Budgeted::kNo, imageInfo);
+ sk_sp<SkSurface> surface = SkSurfaces::RenderTarget(context, skgpu::Budgeted::kNo, imageInfo);
REPORTER_ASSERT(reporter, surface);
///////////////////////////////////////////////////////////////////////////
@@ -260,8 +261,8 @@
return;
}
- sk_sp<SkSurface> surface = SkSurface::MakeFromAHardwareBuffer(context, buffer, surfaceOrigin,
- nullptr, nullptr);
+ sk_sp<SkSurface> surface =
+ SkSurfaces::WrapAndroidHardwareBuffer(context, buffer, surfaceOrigin, nullptr, nullptr);
if (!surface) {
ERRORF(reporter, "Failed to make SkSurface.");
cleanup_resources(buffer);
diff --git a/tests/GrContextOOM.cpp b/tests/GrContextOOM.cpp
index 316a589..4854b54 100644
--- a/tests/GrContextOOM.cpp
+++ b/tests/GrContextOOM.cpp
@@ -18,6 +18,7 @@
#include "include/gpu/GrContextOptions.h"
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/GrTypes.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "tests/CtsEnforcement.h"
#include "tests/Test.h"
@@ -43,8 +44,8 @@
// issuing a small number calls by reusing scratch resources created in a previous
// iteration.
context->freeGpuResources();
- auto surf = SkSurface::MakeRenderTarget(
- context, skgpu::Budgeted::kYes, info, 1, nullptr);
+ auto surf =
+ SkSurfaces::RenderTarget(context, skgpu::Budgeted::kYes, info, 1, nullptr);
SkPaint paint;
surf->getCanvas()->drawRect(SkRect::MakeLTRB(100, 100, 2000, 2000), paint);
surf->flushAndSubmit();
diff --git a/tests/GrDDLImageTest.cpp b/tests/GrDDLImageTest.cpp
index cb8ec27..012a86e 100644
--- a/tests/GrDDLImageTest.cpp
+++ b/tests/GrDDLImageTest.cpp
@@ -21,6 +21,7 @@
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/GrTypes.h"
#include "include/gpu/ganesh/SkImageGanesh.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "tests/CtsEnforcement.h"
#include "tests/Test.h"
@@ -56,7 +57,7 @@
REPORTER_ASSERT(reporter, subImg2->isValid(static_cast<GrRecordingContext*>(nullptr)));
// Texture image:
- auto surf = SkSurface::MakeRenderTarget(dContext, skgpu::Budgeted::kNo, ii);
+ auto surf = SkSurfaces::RenderTarget(dContext, skgpu::Budgeted::kNo, ii);
SkSurfaceCharacterization sc;
REPORTER_ASSERT(reporter, surf->characterize(&sc));
GrBackendTexture tex = dContext->createBackendTexture(ii.width(),
diff --git a/tests/GrFinishedFlushTest.cpp b/tests/GrFinishedFlushTest.cpp
index 4b07225..2f46f29 100644
--- a/tests/GrFinishedFlushTest.cpp
+++ b/tests/GrFinishedFlushTest.cpp
@@ -19,6 +19,7 @@
#include "include/gpu/GpuTypes.h"
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/GrTypes.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "src/gpu/ganesh/GrCaps.h"
#include "src/gpu/ganesh/GrDirectContextPriv.h"
#include "tests/CtsEnforcement.h"
@@ -61,7 +62,7 @@
SkImageInfo info =
SkImageInfo::Make(8, 8, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
- sk_sp<SkSurface> surface = SkSurface::MakeRenderTarget(dContext, skgpu::Budgeted::kNo, info);
+ sk_sp<SkSurface> surface = SkSurfaces::RenderTarget(dContext, skgpu::Budgeted::kNo, info);
SkCanvas* canvas = surface->getCanvas();
canvas->clear(SK_ColorGREEN);
@@ -191,16 +192,15 @@
return;
}
- auto surface = SkSurface::MakeFromBackendTexture(
- dContext,
- mbet->texture(),
- kTopLeft_GrSurfaceOrigin,
- /*sample count*/ 1,
- kRGBA_8888_SkColorType,
- /*color space*/ nullptr,
- /*surface props*/ nullptr,
- sk_gpu_test::ManagedBackendTexture::ReleaseProc,
- mbet->releaseContext(nullptr, nullptr));
+ auto surface = SkSurfaces::WrapBackendTexture(dContext,
+ mbet->texture(),
+ kTopLeft_GrSurfaceOrigin,
+ /*sample count*/ 1,
+ kRGBA_8888_SkColorType,
+ /*color space*/ nullptr,
+ /*surface props*/ nullptr,
+ sk_gpu_test::ManagedBackendTexture::ReleaseProc,
+ mbet->releaseContext(nullptr, nullptr));
if (!surface) {
return;
diff --git a/tests/GrMipMappedTest.cpp b/tests/GrMipMappedTest.cpp
index f84ddd4..decc4eb 100644
--- a/tests/GrMipMappedTest.cpp
+++ b/tests/GrMipMappedTest.cpp
@@ -29,6 +29,7 @@
#include "include/gpu/GrTypes.h"
#include "include/gpu/ganesh/GrTextureGenerator.h"
#include "include/gpu/ganesh/SkImageGanesh.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "include/gpu/mock/GrMockTypes.h"
#include "include/private/SkColorData.h"
#include "include/private/gpu/ganesh/GrTypesPriv.h"
@@ -117,7 +118,7 @@
sk_sp<GrTextureProxy> proxy;
sk_sp<SkImage> image;
if (renderable == GrRenderable::kYes) {
- sk_sp<SkSurface> surface = SkSurface::MakeFromBackendTexture(
+ sk_sp<SkSurface> surface = SkSurfaces::WrapBackendTexture(
dContext,
mbet->texture(),
kTopLeft_GrSurfaceOrigin,
@@ -358,13 +359,13 @@
/* sample count */ 1,
mipmapped);
} else {
- surface = SkSurface::MakeRenderTarget(dContext,
- skgpu::Budgeted::kYes,
- info,
- /* sample count */ 1,
- kTopLeft_GrSurfaceOrigin,
- nullptr,
- willUseMips);
+ surface = SkSurfaces::RenderTarget(dContext,
+ skgpu::Budgeted::kYes,
+ info,
+ /* sample count */ 1,
+ kTopLeft_GrSurfaceOrigin,
+ nullptr,
+ willUseMips);
}
REPORTER_ASSERT(reporter, surface);
auto device = ((SkSurface_Ganesh*)surface.get())->getDevice();
@@ -401,7 +402,7 @@
// Make surface to draw into
SkImageInfo info = SkImageInfo::MakeN32(16, 16, kPremul_SkAlphaType);
- sk_sp<SkSurface> surface = SkSurface::MakeRenderTarget(dContext, skgpu::Budgeted::kNo, info);
+ sk_sp<SkSurface> surface = SkSurfaces::RenderTarget(dContext, skgpu::Budgeted::kNo, info);
// Make 1x1 raster bitmap
SkBitmap bmp;
diff --git a/tests/GrOpListFlushTest.cpp b/tests/GrOpListFlushTest.cpp
index ee162c5..fcfb75e 100644
--- a/tests/GrOpListFlushTest.cpp
+++ b/tests/GrOpListFlushTest.cpp
@@ -20,6 +20,7 @@
#include "include/core/SkTypes.h"
#include "include/gpu/GpuTypes.h"
#include "include/gpu/GrDirectContext.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "src/gpu/ganesh/GrDirectContextPriv.h"
#include "src/gpu/ganesh/GrGpu.h"
#include "tests/CtsEnforcement.h"
@@ -51,13 +52,11 @@
SkImageInfo imageInfo = SkImageInfo::Make(1000, 1, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
- sk_sp<SkSurface> surface1 =
- SkSurface::MakeRenderTarget(context, skgpu::Budgeted::kYes, imageInfo);
+ sk_sp<SkSurface> surface1 = SkSurfaces::RenderTarget(context, skgpu::Budgeted::kYes, imageInfo);
if (!surface1) {
return;
}
- sk_sp<SkSurface> surface2 =
- SkSurface::MakeRenderTarget(context, skgpu::Budgeted::kYes, imageInfo);
+ sk_sp<SkSurface> surface2 = SkSurfaces::RenderTarget(context, skgpu::Budgeted::kYes, imageInfo);
if (!surface2) {
return;
}
diff --git a/tests/GrSlugTest.cpp b/tests/GrSlugTest.cpp
index 12f1aa5..7403277 100644
--- a/tests/GrSlugTest.cpp
+++ b/tests/GrSlugTest.cpp
@@ -17,6 +17,7 @@
#include "include/core/SkTypes.h"
#include "include/gpu/GpuTypes.h"
#include "include/gpu/GrDirectContext.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "include/private/base/SkTDArray.h"
#include "include/private/chromium/Slug.h"
#include "tests/CtsEnforcement.h"
@@ -34,7 +35,7 @@
CtsEnforcement::kApiLevel_T) {
auto dContext = ctxInfo.directContext();
SkImageInfo info = SkImageInfo::MakeN32Premul(256, 256);
- auto surface(SkSurface::MakeRenderTarget(dContext, skgpu::Budgeted::kNo, info));
+ auto surface(SkSurfaces::RenderTarget(dContext, skgpu::Budgeted::kNo, info));
auto canvas = surface->getCanvas();
static const char* kText = " ";
diff --git a/tests/GrStyledShapeTest.cpp b/tests/GrStyledShapeTest.cpp
index 281dc3c..ea5fd9d 100644
--- a/tests/GrStyledShapeTest.cpp
+++ b/tests/GrStyledShapeTest.cpp
@@ -91,7 +91,7 @@
static constexpr int kTol = 2;
static_assert(kRes % 4 == 0);
SkImageInfo info = SkImageInfo::MakeA8(kRes, kRes);
- sk_sp<SkSurface> surface = SkSurface::MakeRaster(info);
+ sk_sp<SkSurface> surface = SkSurfaces::Raster(info);
surface->getCanvas()->clear(0x0);
SkRect clip = SkRect::MakeXYWH(kRes/4, kRes/4, kRes/2, kRes/2);
SkMatrix matrix = SkMatrix::RectToRect(bounds, clip);
diff --git a/tests/GrSubmittedFlushTest.cpp b/tests/GrSubmittedFlushTest.cpp
index fbdc3e9..51eb823 100644
--- a/tests/GrSubmittedFlushTest.cpp
+++ b/tests/GrSubmittedFlushTest.cpp
@@ -16,6 +16,7 @@
#include "include/gpu/GpuTypes.h"
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/GrTypes.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "tests/CtsEnforcement.h"
#include "tests/Test.h"
#include "tools/gpu/FenceSync.h"
@@ -44,7 +45,7 @@
auto ctx = ctxInfo.directContext();
SkImageInfo info = SkImageInfo::Make(8, 8, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
- sk_sp<SkSurface> surface = SkSurface::MakeRenderTarget(ctx, skgpu::Budgeted::kNo, info);
+ sk_sp<SkSurface> surface = SkSurfaces::RenderTarget(ctx, skgpu::Budgeted::kNo, info);
SkCanvas* canvas = surface->getCanvas();
canvas->clear(SK_ColorGREEN);
diff --git a/tests/GrSurfaceResolveTest.cpp b/tests/GrSurfaceResolveTest.cpp
index 55c81ea..fe31cdc 100644
--- a/tests/GrSurfaceResolveTest.cpp
+++ b/tests/GrSurfaceResolveTest.cpp
@@ -23,6 +23,7 @@
#include "include/gpu/GrBackendSurface.h"
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/GrTypes.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "include/private/SkColorData.h"
#include "include/private/gpu/ganesh/GrTypesPriv.h"
#include "src/gpu/SkBackingFit.h"
@@ -64,12 +65,13 @@
// We have to do the readback of the backend texture wrapped in a different Skia surface than
// the one used in the main body of the test or else the readPixels call will trigger resolves
// itself.
- sk_sp<SkSurface> surface = SkSurface::MakeFromBackendTexture(dContext,
- tex,
- kTopLeft_GrSurfaceOrigin,
- /*sampleCnt=*/4,
- kRGBA_8888_SkColorType,
- nullptr, nullptr);
+ sk_sp<SkSurface> surface = SkSurfaces::WrapBackendTexture(dContext,
+ tex,
+ kTopLeft_GrSurfaceOrigin,
+ /*sampleCnt=*/4,
+ kRGBA_8888_SkColorType,
+ nullptr,
+ nullptr);
SkBitmap actual;
actual.allocPixels(info);
if (!surface->readPixels(actual, 0, 0)) {
@@ -112,12 +114,13 @@
auto tex = managedTex->texture();
// Wrap the backend surface but tell it rendering with MSAA so that the wrapped texture is the
// resolve.
- sk_sp<SkSurface> surface = SkSurface::MakeFromBackendTexture(dContext,
- tex,
- kTopLeft_GrSurfaceOrigin,
- /*sampleCnt=*/4,
- kRGBA_8888_SkColorType,
- nullptr, nullptr);
+ sk_sp<SkSurface> surface = SkSurfaces::WrapBackendTexture(dContext,
+ tex,
+ kTopLeft_GrSurfaceOrigin,
+ /*sampleCnt=*/4,
+ kRGBA_8888_SkColorType,
+ nullptr,
+ nullptr);
if (!surface) {
return;
@@ -186,7 +189,7 @@
// First clear out dirty msaa from previous test
surface->flush();
- auto otherSurface = SkSurface::MakeRenderTarget(dContext, skgpu::Budgeted::kYes, info);
+ auto otherSurface = SkSurfaces::RenderTarget(dContext, skgpu::Budgeted::kYes, info);
REPORTER_ASSERT(reporter, otherSurface);
otherSurface->getCanvas()->clear(SK_ColorRED);
surface->resolveMSAA();
diff --git a/tests/GrTextBlobTest.cpp b/tests/GrTextBlobTest.cpp
index 476d529..defbbdf 100644
--- a/tests/GrTextBlobTest.cpp
+++ b/tests/GrTextBlobTest.cpp
@@ -26,6 +26,7 @@
#include "include/core/SkTypes.h"
#include "include/gpu/GpuTypes.h"
#include "include/gpu/GrDirectContext.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "src/core/SkDevice.h"
#include "src/core/SkScalerContext.h"
#include "src/text/GlyphRun.h"
@@ -56,7 +57,7 @@
const SkMatrix& matrix) {
const SkImageInfo info =
SkImageInfo::Make(500, 500, kN32_SkColorType, kPremul_SkAlphaType);
- auto surface = SkSurface::MakeRenderTarget(rContext, skgpu::Budgeted::kNo, info);
+ auto surface = SkSurfaces::RenderTarget(rContext, skgpu::Budgeted::kNo, info);
auto canvas = surface->getCanvas();
canvas->drawColor(SK_ColorWHITE);
canvas->concat(matrix);
@@ -136,7 +137,7 @@
SkPaint paint;
const SkImageInfo info =
SkImageInfo::Make(350, 80, kN32_SkColorType, kPremul_SkAlphaType);
- auto surface = SkSurface::MakeRenderTarget(dContext, skgpu::Budgeted::kNo, info);
+ auto surface = SkSurfaces::RenderTarget(dContext, skgpu::Budgeted::kNo, info);
auto canvas = surface->getCanvas();
canvas->drawColor(SK_ColorWHITE);
canvas->concat(matrix);
diff --git a/tests/GrTextureMipMapInvalidationTest.cpp b/tests/GrTextureMipMapInvalidationTest.cpp
index 012bff5..2db471c 100644
--- a/tests/GrTextureMipMapInvalidationTest.cpp
+++ b/tests/GrTextureMipMapInvalidationTest.cpp
@@ -23,6 +23,7 @@
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/GrTypes.h"
#include "include/gpu/ganesh/SkImageGanesh.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "src/gpu/ganesh/GrCaps.h"
#include "src/gpu/ganesh/GrDirectContextPriv.h"
#include "src/gpu/ganesh/GrTexture.h"
@@ -66,14 +67,14 @@
auto info = SkImageInfo::MakeN32Premul(256, 256);
for (auto allocateMips : {false, true}) {
- auto surf1 = SkSurface::MakeRenderTarget(context,
- skgpu::Budgeted::kYes,
- info,
- 0,
- kBottomLeft_GrSurfaceOrigin,
- nullptr,
- allocateMips);
- auto surf2 = SkSurface::MakeRenderTarget(context, skgpu::Budgeted::kYes, info);
+ auto surf1 = SkSurfaces::RenderTarget(context,
+ skgpu::Budgeted::kYes,
+ info,
+ 0,
+ kBottomLeft_GrSurfaceOrigin,
+ nullptr,
+ allocateMips);
+ auto surf2 = SkSurfaces::RenderTarget(context, skgpu::Budgeted::kYes, info);
// Draw something just in case we ever had a solid color optimization
surf1->getCanvas()->drawCircle(128, 128, 50, SkPaint());
surf1->flushAndSubmit();
@@ -109,7 +110,7 @@
return;
}
static constexpr auto kCreateWithMipMaps = true;
- auto surf = SkSurface::MakeRenderTarget(
+ auto surf = SkSurfaces::RenderTarget(
dContext,
skgpu::Budgeted::kYes,
SkImageInfo::Make(100, 100, kRGBA_8888_SkColorType, kPremul_SkAlphaType),
@@ -144,7 +145,7 @@
nullptr);
const auto singlePixelInfo =
SkImageInfo::Make(1, 1, kRGBA_8888_SkColorType, kPremul_SkAlphaType, nullptr);
- surf = SkSurface::MakeRenderTarget(
+ surf = SkSurfaces::RenderTarget(
dContext, skgpu::Budgeted::kYes, singlePixelInfo, 1, kTopLeft_GrSurfaceOrigin, nullptr);
surf->getCanvas()->drawImageRect(img, SkRect::MakeWH(1, 1),
diff --git a/tests/GrThreadSafeCacheTest.cpp b/tests/GrThreadSafeCacheTest.cpp
index 7ffd2ad..70e267f 100644
--- a/tests/GrThreadSafeCacheTest.cpp
+++ b/tests/GrThreadSafeCacheTest.cpp
@@ -31,6 +31,7 @@
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/GrRecordingContext.h"
#include "include/gpu/GrTypes.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "include/private/SkColorData.h"
#include "include/private/base/SkDebug.h"
#include "include/private/base/SkMalloc.h"
@@ -174,7 +175,7 @@
GrThreadSafeCache::IsNewerBetter isNewerBetter = default_is_newer_better)
: fDContext(dContext)
, fIsNewerBetter(isNewerBetter) {
- fDst = SkSurface::MakeRenderTarget(dContext, skgpu::Budgeted::kNo, default_ii(kImageWH));
+ fDst = SkSurfaces::RenderTarget(dContext, skgpu::Budgeted::kNo, default_ii(kImageWH));
SkAssertResult(fDst);
SkSurfaceCharacterization characterization;
@@ -428,7 +429,7 @@
bool checkImage(skiatest::Reporter* reporter, sk_sp<SkDeferredDisplayList> ddl) {
sk_sp<SkSurface> tmp =
- SkSurface::MakeRenderTarget(fDContext, skgpu::Budgeted::kNo, default_ii(kImageWH));
+ SkSurfaces::RenderTarget(fDContext, skgpu::Budgeted::kNo, default_ii(kImageWH));
if (!tmp) {
return false;
}
diff --git a/tests/GradientTest.cpp b/tests/GradientTest.cpp
index e4debff..8bd3ffd 100644
--- a/tests/GradientTest.cpp
+++ b/tests/GradientTest.cpp
@@ -322,7 +322,7 @@
}
static void test_nearly_vertical(skiatest::Reporter* reporter) {
- auto surface(SkSurface::MakeRasterN32Premul(200, 200));
+ auto surface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(200, 200)));
const SkPoint pts[] = {{ 100, 50 }, { 100.0001f, 50000 }};
const SkColor colors[] = { SK_ColorBLACK, SK_ColorWHITE };
@@ -334,7 +334,7 @@
}
static void test_vertical(skiatest::Reporter* reporter) {
- auto surface(SkSurface::MakeRasterN32Premul(200, 200));
+ auto surface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(200, 200)));
const SkPoint pts[] = {{ 100, 50 }, { 100, 50 }};
const SkColor colors[] = { SK_ColorBLACK, SK_ColorWHITE };
@@ -350,7 +350,7 @@
// The old code had an assert which this test triggered.
// We now explicitly clamp the resulting fx value.
static void test_linear_fuzz(skiatest::Reporter* reporter) {
- auto surface(SkSurface::MakeRasterN32Premul(1300, 630));
+ auto surface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(1300, 630)));
const SkPoint pts[] = {{ 179.5f, -179.5f }, { 1074.5f, 715.5f }};
const SkColor colors[] = { SK_ColorBLACK, SK_ColorWHITE, SK_ColorBLACK, SK_ColorWHITE };
@@ -366,7 +366,7 @@
// https://bugs.chromium.org/p/skia/issues/detail?id=5023
// We should still shade pixels for which the radius is exactly 0.
static void test_two_point_conical_zero_radius(skiatest::Reporter* reporter) {
- auto surface(SkSurface::MakeRasterN32Premul(5, 5));
+ auto surface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(5, 5)));
surface->getCanvas()->clear(SK_ColorRED);
const SkColor colors[] = { SK_ColorGREEN, SK_ColorBLUE };
@@ -392,7 +392,7 @@
p.setShader(SkGradientShader::MakeLinear(pts1, colors, nullptr, 2, SkTileMode::kClamp));
- sk_sp<SkSurface> surface(SkSurface::MakeRasterN32Premul(50, 50));
+ sk_sp<SkSurface> surface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(50, 50)));
surface->getCanvas()->scale(100, 100);
surface->getCanvas()->drawPaint(p);
@@ -413,7 +413,7 @@
};
p.setShader(SkGradientShader::MakeLinear(pts, colors, nullptr, 2, SkTileMode::kClamp));
- sk_sp<SkSurface> surface(SkSurface::MakeRasterN32Premul(50, 50));
+ sk_sp<SkSurface> surface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(50, 50)));
surface->getCanvas()->drawPaint(p);
// Passes if we don't trigger asserts.
@@ -538,11 +538,8 @@
SkPaint paint;
for (const SkColorSpace* colorSpace : colorSpaces) {
-
- sk_sp<SkSurface> surface = SkSurface::MakeRaster(SkImageInfo::Make(100, 100,
- kN32_SkColorType,
- kPremul_SkAlphaType,
- sk_ref_sp(colorSpace)));
+ sk_sp<SkSurface> surface = SkSurfaces::Raster(SkImageInfo::Make(
+ 100, 100, kN32_SkColorType, kPremul_SkAlphaType, sk_ref_sp(colorSpace)));
SkCanvas* canvas = surface->getCanvas();
for (const auto& config : gConfigs) {
@@ -596,7 +593,7 @@
},
};
- sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul(100, 100);
+ sk_sp<SkSurface> surface = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(100, 100));
SkCanvas* canvas = surface->getCanvas();
SkPaint paint;
diff --git a/tests/ImageFilterTest.cpp b/tests/ImageFilterTest.cpp
index 55dfec9..9f27da4 100644
--- a/tests/ImageFilterTest.cpp
+++ b/tests/ImageFilterTest.cpp
@@ -42,6 +42,7 @@
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/GrRecordingContext.h"
#include "include/gpu/GrTypes.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "include/private/base/SkTArray.h"
#include "include/private/base/SkTo.h"
#include "src/core/SkColorFilterBase.h"
@@ -335,7 +336,7 @@
}
static sk_sp<SkImage> make_small_image() {
- auto surface(SkSurface::MakeRasterN32Premul(kBitmapSize, kBitmapSize));
+ auto surface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(kBitmapSize, kBitmapSize)));
SkCanvas* canvas = surface->getCanvas();
canvas->clear(0x00000000);
SkPaint darkPaint;
@@ -409,10 +410,10 @@
static sk_sp<SkSurface> create_surface(GrRecordingContext* rContext, int width, int height) {
const SkImageInfo info = SkImageInfo::MakeN32(width, height, kOpaque_SkAlphaType);
if (rContext) {
- return SkSurface::MakeRenderTarget(
+ return SkSurfaces::RenderTarget(
rContext, skgpu::Budgeted::kNo, info, 0, kTestSurfaceOrigin, nullptr);
} else {
- return SkSurface::MakeRaster(info);
+ return SkSurfaces::Raster(info);
}
}
@@ -1538,7 +1539,8 @@
}
DEF_TEST(XfermodeImageFilterCroppedInput, reporter) {
- test_xfermode_cropped_input(SkSurface::MakeRasterN32Premul(100, 100).get(), reporter);
+ test_xfermode_cropped_input(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(100, 100)).get(),
+ reporter);
}
static void test_composed_imagefilter_offset(skiatest::Reporter* reporter,
@@ -1679,7 +1681,7 @@
// Verify that SkImageSource survives serialization
DEF_TEST(ImageFilterImageSourceSerialization, reporter) {
- auto surface(SkSurface::MakeRasterN32Premul(10, 10));
+ auto surface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(10, 10)));
surface->getCanvas()->clear(SK_ColorGREEN);
sk_sp<SkImage> image(surface->makeImageSnapshot());
sk_sp<SkImageFilter> filter(SkImageFilters::Image(std::move(image)));
@@ -1753,7 +1755,7 @@
}
DEF_TEST(ImageFilterBlurLargeImage, reporter) {
- auto surface(SkSurface::MakeRaster(SkImageInfo::MakeN32Premul(100, 100)));
+ auto surface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(100, 100)));
test_large_blur_input(reporter, surface->getCanvas());
}
@@ -1847,7 +1849,7 @@
reporter,
ctxInfo,
CtsEnforcement::kNever) {
- sk_sp<SkSurface> surf(SkSurface::MakeRenderTarget(
+ sk_sp<SkSurface> surf(SkSurfaces::RenderTarget(
ctxInfo.directContext(), skgpu::Budgeted::kNo, SkImageInfo::MakeN32Premul(100, 100)));
SkCanvas* canvas = surf->getCanvas();
@@ -1859,7 +1861,7 @@
reporter,
ctxInfo,
CtsEnforcement::kNever) {
- sk_sp<SkSurface> surf(SkSurface::MakeRenderTarget(
+ sk_sp<SkSurface> surf(SkSurfaces::RenderTarget(
ctxInfo.directContext(),
skgpu::Budgeted::kNo,
SkImageInfo::Make(1, 1, kRGBA_8888_SkColorType, kPremul_SkAlphaType)));
@@ -1871,7 +1873,7 @@
reporter,
ctxInfo,
CtsEnforcement::kNever) {
- auto surface(SkSurface::MakeRenderTarget(
+ auto surface(SkSurfaces::RenderTarget(
ctxInfo.directContext(),
skgpu::Budgeted::kYes,
SkImageInfo::Make(100, 100, kRGBA_8888_SkColorType, kPremul_SkAlphaType)));
@@ -2184,7 +2186,7 @@
DEF_TEST(DropShadowImageFilter_Huge, reporter) {
// Successful if it doesn't crash or trigger ASAN. (crbug.com/1264705)
- auto surf = SkSurface::MakeRasterN32Premul(300, 150);
+ auto surf = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(300, 150));
SkPaint paint;
paint.setImageFilter(SkImageFilters::DropShadowOnly(
diff --git a/tests/ImageIsOpaqueTest.cpp b/tests/ImageIsOpaqueTest.cpp
index f91d449..ae3c12b 100644
--- a/tests/ImageIsOpaqueTest.cpp
+++ b/tests/ImageIsOpaqueTest.cpp
@@ -17,6 +17,7 @@
#include "include/core/SkTypes.h"
#include "include/gpu/GpuTypes.h"
#include "include/gpu/GrDirectContext.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "tests/CtsEnforcement.h"
#include "tests/Test.h"
#include "tools/Resources.h"
@@ -35,11 +36,11 @@
DEF_TEST(ImageIsOpaqueTest, reporter) {
SkImageInfo infoTransparent = SkImageInfo::MakeN32Premul(5, 5);
- auto surfaceTransparent(SkSurface::MakeRaster(infoTransparent));
+ auto surfaceTransparent(SkSurfaces::Raster(infoTransparent));
check_isopaque(reporter, surfaceTransparent, false);
SkImageInfo infoOpaque = SkImageInfo::MakeN32(5, 5, kOpaque_SkAlphaType);
- auto surfaceOpaque(SkSurface::MakeRaster(infoOpaque));
+ auto surfaceOpaque(SkSurfaces::Raster(infoOpaque));
check_isopaque(reporter, surfaceOpaque, true);
}
@@ -50,11 +51,11 @@
auto context = ctxInfo.directContext();
SkImageInfo infoTransparent = SkImageInfo::MakeN32Premul(5, 5);
auto surfaceTransparent(
- SkSurface::MakeRenderTarget(context, skgpu::Budgeted::kNo, infoTransparent));
+ SkSurfaces::RenderTarget(context, skgpu::Budgeted::kNo, infoTransparent));
check_isopaque(reporter, surfaceTransparent, false);
SkImageInfo infoOpaque = SkImageInfo::MakeN32(5, 5, kOpaque_SkAlphaType);
- auto surfaceOpaque(SkSurface::MakeRenderTarget(context, skgpu::Budgeted::kNo, infoOpaque));
+ auto surfaceOpaque(SkSurfaces::RenderTarget(context, skgpu::Budgeted::kNo, infoOpaque));
check_isopaque(reporter, surfaceOpaque, true);
}
diff --git a/tests/ImageNewShaderTest.cpp b/tests/ImageNewShaderTest.cpp
index 1c13630..1c8afcf 100644
--- a/tests/ImageNewShaderTest.cpp
+++ b/tests/ImageNewShaderTest.cpp
@@ -22,6 +22,7 @@
#include "include/core/SkTypes.h"
#include "include/gpu/GpuTypes.h"
#include "include/gpu/GrDirectContext.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "tests/CtsEnforcement.h"
#include "tests/Test.h"
#include "tools/Resources.h"
@@ -114,8 +115,8 @@
DEF_TEST(ImageNewShader, reporter) {
SkImageInfo info = SkImageInfo::MakeN32Premul(5, 5);
- auto sourceSurface(SkSurface::MakeRaster(info));
- auto destinationSurface(SkSurface::MakeRaster(info));
+ auto sourceSurface(SkSurfaces::Raster(info));
+ auto destinationSurface(SkSurfaces::Raster(info));
run_shader_test(reporter, sourceSurface.get(), destinationSurface.get(), info);
}
@@ -123,8 +124,8 @@
static void gpu_to_gpu(skiatest::Reporter* reporter, GrRecordingContext* rContext) {
SkImageInfo info = SkImageInfo::MakeN32Premul(5, 5);
- auto sourceSurface(SkSurface::MakeRenderTarget(rContext, skgpu::Budgeted::kNo, info));
- auto destinationSurface(SkSurface::MakeRenderTarget(rContext, skgpu::Budgeted::kNo, info));
+ auto sourceSurface(SkSurfaces::RenderTarget(rContext, skgpu::Budgeted::kNo, info));
+ auto destinationSurface(SkSurfaces::RenderTarget(rContext, skgpu::Budgeted::kNo, info));
run_shader_test(reporter, sourceSurface.get(), destinationSurface.get(), info);
}
@@ -132,8 +133,8 @@
static void raster_to_gpu(skiatest::Reporter* reporter, GrRecordingContext* rContext) {
SkImageInfo info = SkImageInfo::MakeN32Premul(5, 5);
- auto sourceSurface(SkSurface::MakeRaster(info));
- auto destinationSurface(SkSurface::MakeRenderTarget(rContext, skgpu::Budgeted::kNo, info));
+ auto sourceSurface(SkSurfaces::Raster(info));
+ auto destinationSurface(SkSurfaces::RenderTarget(rContext, skgpu::Budgeted::kNo, info));
run_shader_test(reporter, sourceSurface.get(), destinationSurface.get(), info);
}
diff --git a/tests/ImageTest.cpp b/tests/ImageTest.cpp
index d22937f..9592a9a 100644
--- a/tests/ImageTest.cpp
+++ b/tests/ImageTest.cpp
@@ -40,6 +40,7 @@
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/GrTypes.h"
#include "include/gpu/ganesh/SkImageGanesh.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "include/private/SkColorData.h"
#include "include/private/base/SkCPUTypes.h"
#include "include/private/base/SkDebug.h"
@@ -136,7 +137,7 @@
}
static sk_sp<SkImage> create_image() {
const SkImageInfo info = SkImageInfo::MakeN32(20, 20, kOpaque_SkAlphaType);
- auto surface(SkSurface::MakeRaster(info));
+ auto surface(SkSurfaces::Raster(info));
draw_image_test_pattern(surface->getCanvas());
return surface->makeImageSnapshot();
}
@@ -159,7 +160,7 @@
}
static sk_sp<SkImage> create_image_large(int maxTextureSize) {
const SkImageInfo info = SkImageInfo::MakeN32(maxTextureSize + 1, 32, kOpaque_SkAlphaType);
- auto surface(SkSurface::MakeRaster(info));
+ auto surface(SkSurfaces::Raster(info));
surface->getCanvas()->clear(SK_ColorWHITE);
SkPaint paint;
paint.setColor(SK_ColorBLACK);
@@ -209,8 +210,8 @@
bool withMips = false,
skgpu::Budgeted budgeted = skgpu::Budgeted::kYes) {
const SkImageInfo info = SkImageInfo::MakeN32(20, 20, kOpaque_SkAlphaType);
- auto surface = SkSurface::MakeRenderTarget(rContext, budgeted, info, 0,
- kBottomLeft_GrSurfaceOrigin, nullptr, withMips);
+ auto surface = SkSurfaces::RenderTarget(
+ rContext, budgeted, info, 0, kBottomLeft_GrSurfaceOrigin, nullptr, withMips);
draw_image_test_pattern(surface->getCanvas());
return surface->makeImageSnapshot();
}
@@ -282,7 +283,7 @@
// Test that image encoding failures do not break picture serialization/deserialization.
DEF_TEST(Image_Serialize_Encoding_Failure, reporter) {
- auto surface(SkSurface::MakeRasterN32Premul(100, 100));
+ auto surface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(100, 100)));
surface->getCanvas()->clear(SK_ColorGREEN);
sk_sp<SkImage> image(surface->makeImageSnapshot());
REPORTER_ASSERT(reporter, image);
@@ -319,7 +320,7 @@
const SkPMColor red = SkPackARGB32(0xFF, 0xFF, 0, 0);
const SkPMColor green = SkPackARGB32(0xFF, 0, 0xFF, 0);
SkImageInfo info = SkImageInfo::MakeN32Premul(2, 2);
- auto surface(SkSurface::MakeRaster(info));
+ auto surface(SkSurfaces::Raster(info));
surface->getCanvas()->clear(0xFF00FF00);
SkPMColor pixels[4];
@@ -405,7 +406,7 @@
sk_sp<SkImage> image(create_gpu_image(ctxInfo.directContext()));
const auto desc = SkBitmapCacheDesc::Make(image.get());
- auto surface(SkSurface::MakeRaster(info));
+ auto surface(SkSurfaces::Raster(info));
// now we can test drawing a gpu-backed image into a cpu-backed surface
@@ -665,7 +666,7 @@
}
sk_sp<SkImage> img;
- auto gsurf = SkSurface::MakeRenderTarget(
+ auto gsurf = SkSurfaces::RenderTarget(
factory->get(type),
skgpu::Budgeted::kYes,
SkImageInfo::Make(100, 100, kRGBA_8888_SkColorType, kPremul_SkAlphaType),
@@ -677,7 +678,7 @@
img = gsurf->makeImageSnapshot();
gsurf.reset();
- auto rsurf = SkSurface::MakeRaster(SkImageInfo::MakeN32Premul(100, 100));
+ auto rsurf = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(100, 100));
REPORTER_ASSERT(reporter, img->isValid(factory->get(type)));
REPORTER_ASSERT(reporter, img->isValid(rsurf->getCanvas()->recordingContext()));
@@ -1010,10 +1011,9 @@
}
SkImageInfo info = SkImageInfo::MakeN32Premul(128, 128);
- sk_sp<SkSurface> surface =
- SkSurface::MakeRenderTarget(dContext, skgpu::Budgeted::kNo, info);
+ sk_sp<SkSurface> surface = SkSurfaces::RenderTarget(dContext, skgpu::Budgeted::kNo, info);
if (!surface) {
- ERRORF(reporter, "SkSurface::MakeRenderTarget failed for %s.", testName);
+ ERRORF(reporter, "SkSurfaces::RenderTarget failed for %s.", testName);
continue;
}
@@ -1051,7 +1051,7 @@
continue;
}
- surface = SkSurface::MakeRenderTarget(otherCtx, skgpu::Budgeted::kNo, info);
+ surface = SkSurfaces::RenderTarget(otherCtx, skgpu::Budgeted::kNo, info);
canvas = surface->getCanvas();
// Case #4: Create image, draw*, flush*, free image
@@ -1321,12 +1321,12 @@
image = bitmap.asImage();
REPORTER_ASSERT(r, SkColorSpace::Equals(rec2020.get(), image->colorSpace()));
- sk_sp<SkSurface> surface = SkSurface::MakeRaster(
- SkImageInfo::MakeN32Premul(SkISize::Make(10, 10)));
+ sk_sp<SkSurface> surface =
+ SkSurfaces::Raster(SkImageInfo::MakeN32Premul(SkISize::Make(10, 10)));
image = surface->makeImageSnapshot();
REPORTER_ASSERT(r, nullptr == image->colorSpace());
- surface = SkSurface::MakeRaster(info);
+ surface = SkSurfaces::Raster(info);
image = surface->makeImageSnapshot();
REPORTER_ASSERT(r, SkColorSpace::Equals(rec2020.get(), image->colorSpace()));
}
@@ -1482,7 +1482,7 @@
// Test raster image
SkImageInfo info = SkImageInfo::MakeN32Premul(1, 1);
- sk_sp<SkSurface> surface = SkSurface::MakeRaster(info);
+ sk_sp<SkSurface> surface = SkSurfaces::Raster(info);
surface->getCanvas()->clear(red);
sk_sp<SkImage> rasterImage = surface->makeImageSnapshot();
test_scale_pixels(reporter, rasterImage.get(), pmRed);
@@ -1502,7 +1502,7 @@
SkImageInfo info = SkImageInfo::MakeN32Premul(16, 16);
sk_sp<SkSurface> surface =
- SkSurface::MakeRenderTarget(ctxInfo.directContext(), skgpu::Budgeted::kNo, info);
+ SkSurfaces::RenderTarget(ctxInfo.directContext(), skgpu::Budgeted::kNo, info);
surface->getCanvas()->clear(red);
sk_sp<SkImage> gpuImage = surface->makeImageSnapshot();
test_scale_pixels(reporter, gpuImage.get(), pmRed);
@@ -1513,7 +1513,7 @@
}
DEF_TEST(Image_nonfinite_dst, reporter) {
- auto surf = SkSurface::MakeRasterN32Premul(10, 10);
+ auto surf = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(10, 10));
auto img = any_image_will_do();
for (SkScalar bad : { SK_ScalarInfinity, SK_ScalarNaN}) {
@@ -1551,7 +1551,7 @@
DEF_GANESH_TEST_FOR_ALL_CONTEXTS(ImageFlush, reporter, ctxInfo, CtsEnforcement::kApiLevel_T) {
auto dContext = ctxInfo.directContext();
auto ii = SkImageInfo::Make(10, 10, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
- auto s = SkSurface::MakeRenderTarget(dContext, skgpu::Budgeted::kYes, ii, 1, nullptr);
+ auto s = SkSurfaces::RenderTarget(dContext, skgpu::Budgeted::kYes, ii, 1, nullptr);
s->getCanvas()->clear(SK_ColorRED);
auto i0 = s->makeImageSnapshot();
diff --git a/tests/IndexedPngOverflowTest.cpp b/tests/IndexedPngOverflowTest.cpp
index ac9266a..5823ef4 100644
--- a/tests/IndexedPngOverflowTest.cpp
+++ b/tests/IndexedPngOverflowTest.cpp
@@ -7,6 +7,7 @@
#include "include/core/SkBitmap.h"
#include "include/core/SkCanvas.h"
+#include "include/core/SkImageInfo.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkSurface.h"
#include "tests/CodecPriv.h"
@@ -33,5 +34,7 @@
bool success = decode_memory(gPng, sizeof(gPng), &bm);
REPORTER_ASSERT(reporter, success);
- SkSurface::MakeRasterN32Premul(20, 1)->getCanvas()->drawImage(bm.asImage(), 0, 0);
+ SkSurfaces::Raster(SkImageInfo::MakeN32Premul(20, 1))
+ ->getCanvas()
+ ->drawImage(bm.asImage(), 0, 0);
}
diff --git a/tests/LazyStencilAttachmentTest.cpp b/tests/LazyStencilAttachmentTest.cpp
index b9e6e6c..aff0e3b 100644
--- a/tests/LazyStencilAttachmentTest.cpp
+++ b/tests/LazyStencilAttachmentTest.cpp
@@ -20,6 +20,7 @@
#include "include/core/SkTypes.h"
#include "include/gpu/GpuTypes.h"
#include "include/gpu/GrDirectContext.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "src/core/SkAutoPixmapStorage.h"
#include "tests/CtsEnforcement.h"
#include "tests/Test.h"
@@ -41,9 +42,8 @@
kRGBA_8888_SkColorType,
kPremul_SkAlphaType,
nullptr);
- sk_sp<SkSurface> surfs[2]{
- SkSurface::MakeRenderTarget(dc, skgpu::Budgeted::kYes, ii, 1, nullptr),
- SkSurface::MakeRenderTarget(dc, skgpu::Budgeted::kYes, ii, 1, nullptr)};
+ sk_sp<SkSurface> surfs[2]{SkSurfaces::RenderTarget(dc, skgpu::Budgeted::kYes, ii, 1, nullptr),
+ SkSurfaces::RenderTarget(dc, skgpu::Budgeted::kYes, ii, 1, nullptr)};
// Make sure the surfaces' proxies are instantiated without stencil. Creating textures lazily
// can invalidate the current tracked FBO since FBO state must be modified to during
diff --git a/tests/MatrixColorFilterTest.cpp b/tests/MatrixColorFilterTest.cpp
index d7f48c9..acffb81 100644
--- a/tests/MatrixColorFilterTest.cpp
+++ b/tests/MatrixColorFilterTest.cpp
@@ -21,6 +21,7 @@
#include "include/effects/SkColorMatrix.h"
#include "include/gpu/GpuTypes.h"
#include "include/gpu/GrDirectContext.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "src/core/SkAutoPixmapStorage.h"
#include "tests/CtsEnforcement.h"
#include "tests/Test.h"
@@ -38,7 +39,7 @@
auto context = info.directContext();
// Make a transparent black image rather than use a paint color to avoid an optimization that
// applies the color filter on the CPU to paint colors.
- auto imgSurf = SkSurface::MakeRenderTarget(
+ auto imgSurf = SkSurfaces::RenderTarget(
context, skgpu::Budgeted::kYes, SkImageInfo::MakeN32(5, 5, kPremul_SkAlphaType));
imgSurf->getCanvas()->drawColor(0x0000000);
auto shader = imgSurf->makeImageSnapshot()->makeShader(SkSamplingOptions());
@@ -48,7 +49,7 @@
p.setColorFilter(SkColorFilters::Matrix(m));
p.setShader(shader);
p.setBlendMode(SkBlendMode::kSrc);
- auto surf = SkSurface::MakeRenderTarget(
+ auto surf = SkSurfaces::RenderTarget(
context, skgpu::Budgeted::kYes, SkImageInfo::MakeN32(5, 5, kPremul_SkAlphaType));
// Seed the output surface with red so we would notice if we failed to draw at all.
surf->getCanvas()->clear(SK_ColorRED);
diff --git a/tests/MipMapTest.cpp b/tests/MipMapTest.cpp
index 807f63a..e3c4653 100644
--- a/tests/MipMapTest.cpp
+++ b/tests/MipMapTest.cpp
@@ -231,7 +231,7 @@
int count = builder->countLevels();
for (int i = 0; i < count; ++i) {
SkPixmap pm = builder->level(i);
- auto surf = SkSurface::MakeRasterDirect(pm);
+ auto surf = SkSurfaces::WrapPixels(pm);
surf->getCanvas()->drawImageRect(img, SkRect::MakeIWH(pm.width(), pm.height()),
SkSamplingOptions());
}
diff --git a/tests/MultiPictureDocumentTest.cpp b/tests/MultiPictureDocumentTest.cpp
index 6612ca1..19485a0 100644
--- a/tests/MultiPictureDocumentTest.cpp
+++ b/tests/MultiPictureDocumentTest.cpp
@@ -110,7 +110,7 @@
static const int HEIGHT = 256;
// Make an image to be used in a later step.
- auto surface(SkSurface::MakeRasterN32Premul(100, 100));
+ auto surface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(100, 100)));
surface->getCanvas()->clear(SK_ColorGREEN);
sk_sp<SkImage> image(surface->makeImageSnapshot());
REPORTER_ASSERT(reporter, image);
@@ -129,7 +129,7 @@
draw_advanced(pictureCanvas, i, image, sub);
multipic->endPage();
// Also draw the picture to an image for later comparison
- auto surf = SkSurface::MakeRaster(info);
+ auto surf = SkSurfaces::Raster(info);
draw_advanced(surf->getCanvas(), i, image, sub);
expectedImages.push_back(surf->makeImageSnapshot());
}
@@ -169,7 +169,7 @@
REPORTER_ASSERT(reporter, bounds.height() == HEIGHT,
"Page height: expected (%d) got (%d)", HEIGHT, (int)bounds.height());
- auto surf = SkSurface::MakeRaster(info);
+ auto surf = SkSurfaces::Raster(info);
surf->getCanvas()->drawPicture(frame.fPicture);
auto img = surf->makeImageSnapshot();
REPORTER_ASSERT(reporter, ToolUtils::equal_pixels(img.get(), expectedImages[i].get()));
@@ -367,7 +367,7 @@
draw_basic(pictureCanvas, 0, image);
multipic->endPage();
// Also draw the picture to an image for later comparison
- auto surf = SkSurface::MakeRaster(info);
+ auto surf = SkSurfaces::Raster(info);
draw_basic(surf->getCanvas(), 0, image);
expectedImages.push_back(surf->makeImageSnapshot());
@@ -410,7 +410,7 @@
REPORTER_ASSERT(reporter, bounds.height() == HEIGHT,
"Page height: expected (%d) got (%d)", HEIGHT, (int)bounds.height());
- auto surf2 = SkSurface::MakeRaster(info);
+ auto surf2 = SkSurfaces::Raster(info);
surf2->getCanvas()->drawPicture(frames[0].fPicture);
auto img = surf2->makeImageSnapshot();
REPORTER_ASSERT(reporter, ToolUtils::equal_pixels(img.get(), expectedImages[0].get()));
diff --git a/tests/PathTest.cpp b/tests/PathTest.cpp
index f377267..7cba247 100644
--- a/tests/PathTest.cpp
+++ b/tests/PathTest.cpp
@@ -11,6 +11,7 @@
#include "include/core/SkData.h"
#include "include/core/SkFont.h"
#include "include/core/SkFontTypes.h"
+#include "include/core/SkImageInfo.h"
#include "include/core/SkMatrix.h"
#include "include/core/SkPaint.h"
#include "include/core/SkPath.h"
@@ -141,7 +142,7 @@
// Without the pinning code in sect_with_horizontal(), this would assert in the lineclipper
SkPaint paint;
- SkSurface::MakeRasterN32Premul(10, 10)->getCanvas()->drawPath(path, paint);
+ SkSurfaces::Raster(SkImageInfo::MakeN32Premul(10, 10))->getCanvas()->drawPath(path, paint);
}
static void test_iterative_intersect_line() {
@@ -159,14 +160,13 @@
SkPaint paint;
paint.setStyle(SkPaint::kStroke_Style);
- SkSurface::MakeRasterN32Premul(256, 256)->getCanvas()->drawPath(path, paint);
-
+ SkSurfaces::Raster(SkImageInfo::MakeN32Premul(256, 256))->getCanvas()->drawPath(path, paint);
}
static void test_path_crbug364224() {
SkPath path;
SkPaint paint;
- auto surface(SkSurface::MakeRasterN32Premul(84, 88));
+ auto surface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(84, 88)));
SkCanvas* canvas = surface->getCanvas();
make_path_crbug364224_simplified(&path);
@@ -177,7 +177,7 @@
}
static void test_draw_AA_path(int width, int height, const SkPath& path) {
- auto surface(SkSurface::MakeRasterN32Premul(width, height));
+ auto surface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(width, height)));
SkCanvas* canvas = surface->getCanvas();
SkPaint paint;
paint.setAntiAlias(true);
@@ -219,7 +219,7 @@
}
static void test_fuzz_crbug_662780() {
- auto surface(SkSurface::MakeRasterN32Premul(250, 250));
+ auto surface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(250, 250)));
SkCanvas* canvas = surface->getCanvas();
SkPaint paint;
paint.setAntiAlias(true);
@@ -725,7 +725,7 @@
}
static void test_clipped_cubic() {
- auto surface(SkSurface::MakeRasterN32Premul(640, 480));
+ auto surface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(640, 480)));
// This path used to assert, because our cubic-chopping code incorrectly
// moved control points after the chop. This test should be run in SK_DEBUG
@@ -4536,7 +4536,7 @@
path.lineTo(SkBits2Float(0x4109999a), SkBits2Float(0x411c0000)); // 8.6f, 9.75f
path.close();
- auto surface = SkSurface::MakeRasterN32Premul(100, 100);
+ auto surface = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(100, 100));
SkPaint paint;
paint.setAntiAlias(true);
surface->getCanvas()->clipPath(path, true);
@@ -4544,7 +4544,7 @@
}
static void test_path_crbugskia6003() {
- auto surface(SkSurface::MakeRasterN32Premul(500, 500));
+ auto surface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(500, 500)));
SkCanvas* canvas = surface->getCanvas();
SkPaint paint;
paint.setAntiAlias(true);
@@ -4796,7 +4796,9 @@
path.quadTo(SkBits2Float(0x7eef4a19), SkBits2Float(0xfef000ee), SkBits2Float(0x7edf4859), SkBits2Float(0xfee000de)); // 1.59035e+38f, -1.5951e+38f, 1.48397e+38f, -1.48876e+38f
path.lineTo(SkBits2Float(0x7f07a445), SkBits2Float(0xff080087)); // 1.80299e+38f, -1.80778e+38f
path.close();
- SkSurface::MakeRasterN32Premul(250, 250, nullptr)->getCanvas()->drawPath(path, paint);
+ SkSurfaces::Raster(SkImageInfo::MakeN32Premul(250, 250), nullptr)
+ ->getCanvas()
+ ->drawPath(path, paint);
}
static void test_interp(skiatest::Reporter* reporter) {
@@ -4850,7 +4852,9 @@
path.moveTo(0, 512);
// this call should not assert
- SkSurface::MakeRasterN32Premul(255, 255, nullptr)->getCanvas()->drawPath(path, SkPaint());
+ SkSurfaces::Raster(SkImageInfo::MakeN32Premul(255, 255), nullptr)
+ ->getCanvas()
+ ->drawPath(path, SkPaint());
}
DEF_TEST(PathContains, reporter) {
@@ -5191,7 +5195,7 @@
* Try a range of crazy values, just to ensure that we don't assert/crash.
*/
DEF_TEST(HugeGeometry, reporter) {
- auto surf = SkSurface::MakeRasterN32Premul(100, 100);
+ auto surf = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(100, 100));
auto canvas = surf->getCanvas();
const bool aas[] = { false, true };
@@ -5223,7 +5227,7 @@
// Treat nonfinite paths as "empty" or "full", depending on inverse-filltype
DEF_TEST(ClipPath_nonfinite, reporter) {
- auto surf = SkSurface::MakeRasterN32Premul(10, 10);
+ auto surf = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(10, 10));
SkCanvas* canvas = surf->getCanvas();
REPORTER_ASSERT(reporter, !canvas->isClipEmpty());
@@ -5446,7 +5450,7 @@
}
DEF_TEST(triangle_onehalf, reporter) {
- auto surface(SkSurface::MakeRasterN32Premul(100, 100));
+ auto surface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(100, 100)));
const SkPoint pts[] = {
{ 0.499069244f, 9.63295173f },
@@ -5457,7 +5461,7 @@
}
DEF_TEST(triangle_big, reporter) {
- auto surface(SkSurface::MakeRasterN32Premul(4, 4304));
+ auto surface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(4, 4304)));
// The first two points, when sent through our fixed-point SkEdge, can walk negative beyond
// -0.5 due to accumulated += error of the slope. We have since make the bounds calculation
@@ -5920,7 +5924,7 @@
// crbug.com/1154864
DEF_TEST(path_walk_simple_edges_1154864, r) {
// Drawing this path triggered an assert in walk_simple_edges:
- auto surface = SkSurface::MakeRasterN32Premul(32, 32);
+ auto surface = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(32, 32));
SkPath path;
path.setFillType(SkPathFillType::kWinding);
diff --git a/tests/PictureShaderTest.cpp b/tests/PictureShaderTest.cpp
index 8d9cb6e..6195c76 100644
--- a/tests/PictureShaderTest.cpp
+++ b/tests/PictureShaderTest.cpp
@@ -7,6 +7,7 @@
#include "include/core/SkCanvas.h"
#include "include/core/SkColor.h"
+#include "include/core/SkImageInfo.h"
#include "include/core/SkPaint.h"
#include "include/core/SkPicture.h"
#include "include/core/SkPictureRecorder.h"
@@ -32,7 +33,7 @@
sk_sp<SkPicture> picture = makePicture();
REPORTER_ASSERT(reporter, picture->unique());
- sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul(100, 100);
+ sk_sp<SkSurface> surface = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(100, 100));
{
SkPaint paint;
@@ -90,7 +91,7 @@
// Draw with a view variants of picture-shaders that all use the same picture.
// Only expect 1 cache entry for all (since same CTM for all).
- sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul(100, 100);
+ sk_sp<SkSurface> surface = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(100, 100));
for (SkTileMode m : {
SkTileMode::kClamp, SkTileMode::kRepeat, SkTileMode::kRepeat, SkTileMode::kDecal
}) {
diff --git a/tests/PinnedImageTest.cpp b/tests/PinnedImageTest.cpp
index 77417b0..9328584 100644
--- a/tests/PinnedImageTest.cpp
+++ b/tests/PinnedImageTest.cpp
@@ -22,6 +22,7 @@
#include "include/core/SkTypes.h"
#include "include/gpu/GpuTypes.h"
#include "include/gpu/GrDirectContext.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "include/gpu/mock/GrMockTypes.h"
#include "src/gpu/ganesh/GrFragmentProcessor.h" // IWYU pragma: keep
#include "src/gpu/ganesh/SkGr.h"
@@ -68,7 +69,7 @@
sk_sp<SkImage> img = SkImages::PinnableRasterFromBitmap(bm);
REPORTER_ASSERT(reporter, img, "PinnableImageFromBitmap returned null");
- sk_sp<SkSurface> gpuSurface = SkSurface::MakeRenderTarget(rContext, skgpu::Budgeted::kYes, ii);
+ sk_sp<SkSurface> gpuSurface = SkSurfaces::RenderTarget(rContext, skgpu::Budgeted::kYes, ii);
SkCanvas* canvas = gpuSurface->getCanvas();
// w/o pinning - the gpu draw always reflects the current state of the underlying bitmap
diff --git a/tests/PremulAlphaRoundTripTest.cpp b/tests/PremulAlphaRoundTripTest.cpp
index b00e7ab..cfeb7e9 100644
--- a/tests/PremulAlphaRoundTripTest.cpp
+++ b/tests/PremulAlphaRoundTripTest.cpp
@@ -15,6 +15,7 @@
#include "include/core/SkTypes.h"
#include "include/gpu/GpuTypes.h"
#include "include/gpu/GrDirectContext.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "include/private/base/SkDebug.h"
#include "src/core/SkConvertPixels.h"
#include "src/gpu/ganesh/GrDataUtils.h"
@@ -110,7 +111,7 @@
DEF_TEST(PremulAlphaRoundTrip, reporter) {
const SkImageInfo info = SkImageInfo::MakeN32Premul(256, 256);
- sk_sp<SkSurface> surf(SkSurface::MakeRaster(info));
+ sk_sp<SkSurface> surf(SkSurfaces::Raster(info));
test_premul_alpha_roundtrip(reporter, surf.get());
}
@@ -121,7 +122,7 @@
const SkImageInfo info = SkImageInfo::MakeN32Premul(256, 256);
sk_sp<SkSurface> surf(
- SkSurface::MakeRenderTarget(ctxInfo.directContext(), skgpu::Budgeted::kNo, info));
+ SkSurfaces::RenderTarget(ctxInfo.directContext(), skgpu::Budgeted::kNo, info));
test_premul_alpha_roundtrip(reporter, surf.get());
}
diff --git a/tests/PromiseImageTest.cpp b/tests/PromiseImageTest.cpp
index f5549da..f4ab92f 100644
--- a/tests/PromiseImageTest.cpp
+++ b/tests/PromiseImageTest.cpp
@@ -27,6 +27,7 @@
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/GrTypes.h"
#include "include/gpu/ganesh/SkImageGanesh.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "include/private/base/SkTArray.h"
#include "include/private/gpu/ganesh/GrTypesPriv.h"
#include "src/gpu/ganesh/GrCaps.h"
@@ -179,7 +180,7 @@
&promiseChecker));
SkImageInfo info = SkImageInfo::MakeN32Premul(kWidth, kHeight);
- sk_sp<SkSurface> surface = SkSurface::MakeRenderTarget(ctx, skgpu::Budgeted::kNo, info);
+ sk_sp<SkSurface> surface = SkSurfaces::RenderTarget(ctx, skgpu::Budgeted::kNo, info);
SkCanvas* canvas = surface->getCanvas();
canvas->drawImage(refImg, 0, 0);
@@ -269,7 +270,7 @@
SkImageInfo info = SkImageInfo::Make(kWidth, kHeight, kRGBA_8888_SkColorType,
kPremul_SkAlphaType);
- sk_sp<SkSurface> surface = SkSurface::MakeRenderTarget(ctx, skgpu::Budgeted::kNo, info);
+ sk_sp<SkSurface> surface = SkSurfaces::RenderTarget(ctx, skgpu::Budgeted::kNo, info);
SkCanvas* canvas = surface->getCanvas();
PromiseTextureChecker promiseChecker(mbet->texture(), reporter, false);
@@ -320,7 +321,7 @@
SkImageInfo info =
SkImageInfo::Make(kWidth, kHeight, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
- sk_sp<SkSurface> surface = SkSurface::MakeRenderTarget(dContext, skgpu::Budgeted::kNo, info);
+ sk_sp<SkSurface> surface = SkSurfaces::RenderTarget(dContext, skgpu::Budgeted::kNo, info);
SkCanvas* canvas = surface->getCanvas();
PromiseTextureChecker promiseChecker(backendTex, reporter, false);
@@ -426,7 +427,7 @@
&counts));
SkImageInfo info = SkImageInfo::MakeN32Premul(kWidth, kHeight);
- sk_sp<SkSurface> surface = SkSurface::MakeRenderTarget(dContext, skgpu::Budgeted::kNo, info);
+ sk_sp<SkSurface> surface = SkSurfaces::RenderTarget(dContext, skgpu::Budgeted::kNo, info);
SkCanvas* canvas = surface->getCanvas();
// Draw the image a few different ways.
canvas->drawImage(refImg, 0, 0);
diff --git a/tests/ReadPixelsTest.cpp b/tests/ReadPixelsTest.cpp
index a484460..32f58a2 100644
--- a/tests/ReadPixelsTest.cpp
+++ b/tests/ReadPixelsTest.cpp
@@ -394,7 +394,7 @@
DEF_TEST(ReadPixels, reporter) {
const SkImageInfo info = SkImageInfo::MakeN32Premul(DEV_W, DEV_H);
- auto surface(SkSurface::MakeRaster(info));
+ auto surface(SkSurfaces::Raster(info));
test_readpixels(reporter, surface, info);
}
@@ -538,7 +538,7 @@
DEF_TEST(ReadPixels_InvalidRowBytes, reporter) {
auto srcII = SkImageInfo::Make({10, 10}, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
- auto surf = SkSurface::MakeRaster(srcII);
+ auto surf = SkSurfaces::Raster(srcII);
for (int ct = 0; ct < kLastEnum_SkColorType + 1; ++ct) {
auto colorType = static_cast<SkColorType>(ct);
size_t bpp = SkColorTypeBytesPerPixel(colorType);
diff --git a/tests/ReadWritePixelsGpuTest.cpp b/tests/ReadWritePixelsGpuTest.cpp
index aac6ab1..cbd20cc 100644
--- a/tests/ReadWritePixelsGpuTest.cpp
+++ b/tests/ReadWritePixelsGpuTest.cpp
@@ -33,6 +33,7 @@
#include "include/gpu/GrRecordingContext.h"
#include "include/gpu/GrTypes.h"
#include "include/gpu/ganesh/SkImageGanesh.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "include/private/base/SkTArray.h"
#include "include/private/gpu/ganesh/GrTypesPriv.h"
#include "src/base/SkRectMemcpy.h"
@@ -238,7 +239,7 @@
static SkAutoPixmapStorage make_ref_data(const SkImageInfo& info, bool forceOpaque) {
SkAutoPixmapStorage result;
result.alloc(info);
- auto surface = SkSurface::MakeRasterDirect(make_pixmap_have_valid_alpha_type(result));
+ auto surface = SkSurfaces::WrapPixels(make_pixmap_have_valid_alpha_type(result));
if (!surface) {
return result;
}
@@ -572,7 +573,7 @@
ctxInfo,
CtsEnforcement::kApiLevel_T) {
auto srcII = SkImageInfo::Make({10, 10}, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
- auto surf = SkSurface::MakeRenderTarget(ctxInfo.directContext(), skgpu::Budgeted::kYes, srcII);
+ auto surf = SkSurfaces::RenderTarget(ctxInfo.directContext(), skgpu::Budgeted::kYes, srcII);
for (int ct = 0; ct < kLastEnum_SkColorType + 1; ++ct) {
auto colorType = static_cast<SkColorType>(ct);
size_t bpp = SkColorTypeBytesPerPixel(colorType);
@@ -591,7 +592,7 @@
ctxInfo,
CtsEnforcement::kApiLevel_T) {
auto dstII = SkImageInfo::Make({10, 10}, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
- auto surf = SkSurface::MakeRenderTarget(ctxInfo.directContext(), skgpu::Budgeted::kYes, dstII);
+ auto surf = SkSurfaces::RenderTarget(ctxInfo.directContext(), skgpu::Budgeted::kYes, dstII);
for (int ct = 0; ct < kLastEnum_SkColorType + 1; ++ct) {
auto colorType = static_cast<SkColorType>(ct);
size_t bpp = SkColorTypeBytesPerPixel(colorType);
@@ -662,12 +663,8 @@
for (GrSurfaceOrigin origin : {kTopLeft_GrSurfaceOrigin, kBottomLeft_GrSurfaceOrigin}) {
auto factory = std::function<GpuSrcFactory<Surface>>(
[context = ctxInfo.directContext(), origin](const SkPixmap& src) {
- auto surf = SkSurface::MakeRenderTarget(context,
- skgpu::Budgeted::kYes,
- src.info(),
- 1,
- origin,
- nullptr);
+ auto surf = SkSurfaces::RenderTarget(
+ context, skgpu::Budgeted::kYes, src.info(), 1, origin, nullptr);
if (surf) {
surf->writePixels(src, 0, 0);
}
@@ -795,8 +792,7 @@
if (!direct->priv().caps()->transferFromSurfaceToBufferSupport()) {
continue;
}
- auto surf = SkSurface::MakeRenderTarget(direct, skgpu::Budgeted::kYes, ii, 1,
- nullptr);
+ auto surf = SkSurfaces::RenderTarget(direct, skgpu::Budgeted::kYes, ii, 1, nullptr);
if (!surf) {
continue;
}
diff --git a/tests/RecordDrawTest.cpp b/tests/RecordDrawTest.cpp
index b5a049e..a899b5e 100644
--- a/tests/RecordDrawTest.cpp
+++ b/tests/RecordDrawTest.cpp
@@ -9,6 +9,7 @@
#include "include/core/SkCanvas.h"
#include "include/core/SkColor.h"
#include "include/core/SkImageFilter.h"
+#include "include/core/SkImageInfo.h"
#include "include/core/SkM44.h"
#include "include/core/SkMatrix.h"
#include "include/core/SkPaint.h"
@@ -293,7 +294,7 @@
bool fDrawImageRectCalled;
};
- auto surface(SkSurface::MakeRasterN32Premul(10, 10));
+ auto surface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(10, 10)));
surface->getCanvas()->clear(SK_ColorGREEN);
sk_sp<SkImage> image(surface->makeImageSnapshot());
diff --git a/tests/RecordOptsTest.cpp b/tests/RecordOptsTest.cpp
index ee55a8e..7d52567 100644
--- a/tests/RecordOptsTest.cpp
+++ b/tests/RecordOptsTest.cpp
@@ -390,8 +390,8 @@
//
static void do_savelayer_srcmode(skiatest::Reporter* r, SkColor color) {
for (int doPicture = 0; doPicture <= 1; ++doPicture) {
- sk_sp<SkSurface> surf0 = SkSurface::MakeRasterN32Premul(10, 10);
- sk_sp<SkSurface> surf1 = SkSurface::MakeRasterN32Premul(10, 10);
+ sk_sp<SkSurface> surf0 = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(10, 10));
+ sk_sp<SkSurface> surf1 = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(10, 10));
SkCanvas* c0 = surf0->getCanvas();
SkCanvas* c1 = surf1->getCanvas();
diff --git a/tests/RecorderTest.cpp b/tests/RecorderTest.cpp
index 00a3ebf..7e743b6 100644
--- a/tests/RecorderTest.cpp
+++ b/tests/RecorderTest.cpp
@@ -82,7 +82,7 @@
sk_sp<SkImage> image;
{
- auto surface(SkSurface::MakeRasterN32Premul(100, 100));
+ auto surface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(100, 100)));
surface->getCanvas()->clear(SK_ColorGREEN);
image = surface->makeImageSnapshot();
}
diff --git a/tests/RecordingXfermodeTest.cpp b/tests/RecordingXfermodeTest.cpp
index 9d19293..47c8012 100644
--- a/tests/RecordingXfermodeTest.cpp
+++ b/tests/RecordingXfermodeTest.cpp
@@ -34,7 +34,7 @@
class Drawer {
public:
explicit Drawer() : fImageInfo(SkImageInfo::MakeN32Premul(200, 100)) {
- auto surf = SkSurface::MakeRasterN32Premul(100, 100);
+ auto surf = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(100, 100));
surf->getCanvas()->clear(0xffffffff);
SkPaint circlePaint;
circlePaint.setColor(0xff000000);
diff --git a/tests/RectTest.cpp b/tests/RectTest.cpp
index e7dfe65..e4afd28 100644
--- a/tests/RectTest.cpp
+++ b/tests/RectTest.cpp
@@ -386,7 +386,7 @@
const int h = 1;
const auto info = SkImageInfo::MakeN32Premul(w, h);
- auto surf = SkSurface::MakeRaster(info);
+ auto surf = SkSurfaces::Raster(info);
auto canvas = surf->getCanvas();
const SkRect r = { 257, 213, 67109120, 214 };
diff --git a/tests/RepeatedClippedBlurTest.cpp b/tests/RepeatedClippedBlurTest.cpp
index 470d06f..bafbce2 100644
--- a/tests/RepeatedClippedBlurTest.cpp
+++ b/tests/RepeatedClippedBlurTest.cpp
@@ -24,6 +24,7 @@
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/GrTypes.h"
#include "include/gpu/ganesh/SkImageGanesh.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "src/gpu/ganesh/GrDirectContextPriv.h"
#include "src/gpu/ganesh/GrResourceCache.h"
#include "tests/CtsEnforcement.h"
@@ -52,7 +53,7 @@
const SkImageInfo ii = SkImageInfo::Make(1024, 600, kRGBA_8888_SkColorType,
kPremul_SkAlphaType);
- sk_sp<SkSurface> dst(SkSurface::MakeRenderTarget(dContext, skgpu::Budgeted::kNo, ii));
+ sk_sp<SkSurface> dst(SkSurfaces::RenderTarget(dContext, skgpu::Budgeted::kNo, ii));
if (!dst) {
ERRORF(reporter, "Could not create surfaces for repeated clipped blur test.");
return;
@@ -86,7 +87,7 @@
SkImageInfo screenII = SkImageInfo::Make(1024, 600, kRGBA_8888_SkColorType,
kPremul_SkAlphaType);
- sk_sp<SkSurface> s = SkSurface::MakeRenderTarget(
+ sk_sp<SkSurface> s = SkSurfaces::RenderTarget(
dContext, skgpu::Budgeted::kYes, screenII, 1, kTopLeft_GrSurfaceOrigin, nullptr);
SkCanvas* c = s->getCanvas();
diff --git a/tests/ResourceAllocatorTest.cpp b/tests/ResourceAllocatorTest.cpp
index 63e508f..648848a 100644
--- a/tests/ResourceAllocatorTest.cpp
+++ b/tests/ResourceAllocatorTest.cpp
@@ -18,6 +18,7 @@
#include "include/gpu/GrBackendSurface.h"
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/GrTypes.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "include/private/base/SkTArray.h"
#include "include/private/base/SkTo.h"
#include "include/private/gpu/ganesh/GrTypesPriv.h"
@@ -359,7 +360,7 @@
static void draw(GrRecordingContext* rContext) {
SkImageInfo ii = SkImageInfo::Make(1024, 1024, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
- sk_sp<SkSurface> s = SkSurface::MakeRenderTarget(
+ sk_sp<SkSurface> s = SkSurfaces::RenderTarget(
rContext, skgpu::Budgeted::kYes, ii, 1, kTopLeft_GrSurfaceOrigin, nullptr);
SkCanvas* c = s->getCanvas();
diff --git a/tests/ResourceCacheTest.cpp b/tests/ResourceCacheTest.cpp
index a05d5e6..38e05a8 100644
--- a/tests/ResourceCacheTest.cpp
+++ b/tests/ResourceCacheTest.cpp
@@ -24,6 +24,7 @@
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/GrRecordingContext.h"
#include "include/gpu/GrTypes.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "include/private/base/SkDebug.h"
#include "include/private/base/SkTDArray.h"
#include "include/private/base/SkTo.h"
@@ -73,7 +74,7 @@
CtsEnforcement::kApiLevel_T) {
auto context = ctxInfo.directContext();
SkImageInfo info = SkImageInfo::MakeN32Premul(gWidth, gHeight);
- auto surface(SkSurface::MakeRenderTarget(context, skgpu::Budgeted::kNo, info));
+ auto surface(SkSurfaces::RenderTarget(context, skgpu::Budgeted::kNo, info));
SkCanvas* canvas = surface->getCanvas();
const SkIRect size = SkIRect::MakeWH(gWidth, gHeight);
@@ -1888,8 +1889,8 @@
};
auto info = SkImageInfo::Make(10, 10, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
- auto surf1 = SkSurface::MakeRenderTarget(context, skgpu::Budgeted::kYes, info, 1, nullptr);
- auto surf2 = SkSurface::MakeRenderTarget(context, skgpu::Budgeted::kYes, info, 1, nullptr);
+ auto surf1 = SkSurfaces::RenderTarget(context, skgpu::Budgeted::kYes, info, 1, nullptr);
+ auto surf2 = SkSurfaces::RenderTarget(context, skgpu::Budgeted::kYes, info, 1, nullptr);
drawToSurf(surf1.get());
drawToSurf(surf2.get());
diff --git a/tests/RuntimeBlendTest.cpp b/tests/RuntimeBlendTest.cpp
index 8dde797..713e168 100644
--- a/tests/RuntimeBlendTest.cpp
+++ b/tests/RuntimeBlendTest.cpp
@@ -19,6 +19,7 @@
#include "include/core/SkTypes.h"
#include "include/gpu/GpuTypes.h"
#include "include/gpu/GrDirectContext.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "tests/CtsEnforcement.h"
#include "tests/Test.h"
#include "tools/RuntimeBlendUtils.h"
@@ -100,7 +101,7 @@
DEF_TEST(SkRuntimeBlender_CPU, r) {
const SkImageInfo info = SkImageInfo::MakeN32Premul(/*width=*/1, /*height=*/1);
- sk_sp<SkSurface> surface(SkSurface::MakeRaster(info));
+ sk_sp<SkSurface> surface(SkSurfaces::Raster(info));
test_blend(r, surface.get());
}
@@ -111,6 +112,6 @@
CtsEnforcement::kApiLevel_T) {
const SkImageInfo info = SkImageInfo::MakeN32Premul(/*width=*/1, /*height=*/1);
sk_sp<SkSurface> surface(
- SkSurface::MakeRenderTarget(ctxInfo.directContext(), skgpu::Budgeted::kNo, info));
+ SkSurfaces::RenderTarget(ctxInfo.directContext(), skgpu::Budgeted::kNo, info));
test_blend(r, surface.get());
}
diff --git a/tests/SVGDeviceTest.cpp b/tests/SVGDeviceTest.cpp
index 92fd3d8..4a68e84 100644
--- a/tests/SVGDeviceTest.cpp
+++ b/tests/SVGDeviceTest.cpp
@@ -184,7 +184,7 @@
void SetImageShader(SkPaint* paint, int imageWidth, int imageHeight, SkTileMode xTile,
SkTileMode yTile) {
- auto surface = SkSurface::MakeRasterN32Premul(imageWidth, imageHeight);
+ auto surface = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(imageWidth, imageHeight));
paint->setShader(surface->makeImageSnapshot()->makeShader(xTile, yTile, SkSamplingOptions()));
}
diff --git a/tests/SamplingTest.cpp b/tests/SamplingTest.cpp
index 240bbb0..d71363b 100644
--- a/tests/SamplingTest.cpp
+++ b/tests/SamplingTest.cpp
@@ -7,6 +7,7 @@
#include "include/core/SkCanvas.h"
#include "include/core/SkImage.h"
+#include "include/core/SkImageInfo.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkSamplingOptions.h"
#include "include/core/SkSurface.h"
@@ -30,7 +31,7 @@
SkRandom rand;
for (auto name : names) {
auto src = GetResourceAsImage(name);
- auto surf = SkSurface::MakeRasterN32Premul(src->width(), src->height());
+ auto surf = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(src->width(), src->height()));
auto canvas = surf->getCanvas();
auto dotest = [&](const SkSamplingOptions& sampling, bool expect_same) {
diff --git a/tests/SaveLayerOriginTest.cpp b/tests/SaveLayerOriginTest.cpp
index 5b3a327..0eb2260 100644
--- a/tests/SaveLayerOriginTest.cpp
+++ b/tests/SaveLayerOriginTest.cpp
@@ -20,6 +20,7 @@
#include "include/gpu/GrBackendSurface.h"
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/GrTypes.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "include/private/gpu/ganesh/GrTypesPriv.h"
#include "tests/CtsEnforcement.h"
#include "tests/Test.h"
@@ -80,8 +81,8 @@
return;
}
- auto surface = SkSurface::MakeFromBackendTexture(context, beTexture, origin, 0,
- kRGBA_8888_SkColorType, nullptr, nullptr);
+ auto surface = SkSurfaces::WrapBackendTexture(
+ context, beTexture, origin, 0, kRGBA_8888_SkColorType, nullptr, nullptr);
REPORTER_ASSERT(reporter, surface);
if (!surface) {
return;
diff --git a/tests/SerialProcsTest.cpp b/tests/SerialProcsTest.cpp
index bade15d..00e0cb0 100644
--- a/tests/SerialProcsTest.cpp
+++ b/tests/SerialProcsTest.cpp
@@ -11,6 +11,7 @@
#include "include/core/SkDataTable.h"
#include "include/core/SkFont.h"
#include "include/core/SkImage.h"
+#include "include/core/SkImageInfo.h"
#include "include/core/SkPaint.h"
#include "include/core/SkPicture.h"
#include "include/core/SkPictureRecorder.h"
@@ -35,7 +36,7 @@
static sk_sp<SkImage> picture_to_image(sk_sp<SkPicture> pic) {
SkIRect r = pic->cullRect().round();
- auto surf = SkSurface::MakeRasterN32Premul(r.width(), r.height());
+ auto surf = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(r.width(), r.height()));
surf->getCanvas()->drawPicture(pic);
return surf->makeImageSnapshot();
}
diff --git a/tests/SerializationTest.cpp b/tests/SerializationTest.cpp
index 338edc5..4d9a27b 100644
--- a/tests/SerializationTest.cpp
+++ b/tests/SerializationTest.cpp
@@ -623,8 +623,8 @@
}
static sk_sp<SkImage> render(const SkPicture& p) {
- auto surf = SkSurface::MakeRasterN32Premul(SkScalarRoundToInt(p.cullRect().width()),
- SkScalarRoundToInt(p.cullRect().height()));
+ auto surf = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(
+ SkScalarRoundToInt(p.cullRect().width()), SkScalarRoundToInt(p.cullRect().height())));
if (!surf) {
return nullptr; // bounds are empty?
}
diff --git a/tests/ShaderImageFilterTest.cpp b/tests/ShaderImageFilterTest.cpp
index 3966183..d7740a8 100644
--- a/tests/ShaderImageFilterTest.cpp
+++ b/tests/ShaderImageFilterTest.cpp
@@ -27,6 +27,7 @@
#include "include/effects/SkRuntimeEffect.h"
#include "include/gpu/GpuTypes.h"
#include "include/gpu/GrDirectContext.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "src/effects/imagefilters/SkRuntimeImageFilter.h"
#include "tests/CtsEnforcement.h"
#include "tests/Test.h"
@@ -200,7 +201,7 @@
DEF_TEST(SkRuntimeShaderImageFilter_CPU, r) {
const SkImageInfo info = SkImageInfo::MakeN32Premul(/*width=*/1, /*height=*/1);
- sk_sp<SkSurface> surface(SkSurface::MakeRaster(info));
+ sk_sp<SkSurface> surface(SkSurfaces::Raster(info));
test_runtime_shader(r, surface.get());
}
@@ -210,6 +211,6 @@
CtsEnforcement::kApiLevel_T) {
const SkImageInfo info = SkImageInfo::MakeN32Premul(/*width=*/1, /*height=*/1);
sk_sp<SkSurface> surface(
- SkSurface::MakeRenderTarget(ctxInfo.directContext(), skgpu::Budgeted::kNo, info));
+ SkSurfaces::RenderTarget(ctxInfo.directContext(), skgpu::Budgeted::kNo, info));
test_runtime_shader(r, surface.get());
}
diff --git a/tests/SkRemoteGlyphCacheTest.cpp b/tests/SkRemoteGlyphCacheTest.cpp
index 57ec672..34284c7 100644
--- a/tests/SkRemoteGlyphCacheTest.cpp
+++ b/tests/SkRemoteGlyphCacheTest.cpp
@@ -32,6 +32,7 @@
#include "include/gpu/GrContextOptions.h"
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/GrRecordingContext.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "include/private/base/SkMalloc.h"
#include "include/private/base/SkMutex.h"
#include "include/private/chromium/SkChromeRemoteGlyphCache.h"
@@ -201,7 +202,7 @@
sk_sp<SkSurface> MakeSurface(int width, int height, GrRecordingContext* rContext) {
const SkImageInfo info =
SkImageInfo::Make(width, height, kN32_SkColorType, kPremul_SkAlphaType);
- return SkSurface::MakeRenderTarget(rContext, skgpu::Budgeted::kNo, info);
+ return SkSurfaces::RenderTarget(rContext, skgpu::Budgeted::kNo, info);
}
SkSurfaceProps FindSurfaceProps(GrRecordingContext* rContext) {
diff --git a/tests/SkResourceCacheTest.cpp b/tests/SkResourceCacheTest.cpp
index e2d450d..5c29e8c 100644
--- a/tests/SkResourceCacheTest.cpp
+++ b/tests/SkResourceCacheTest.cpp
@@ -10,6 +10,7 @@
#include "include/core/SkColor.h"
#include "include/core/SkColorSpace.h"
#include "include/core/SkImage.h"
+#include "include/core/SkImageInfo.h"
#include "include/core/SkMatrix.h"
#include "include/core/SkPictureRecorder.h"
#include "include/core/SkRefCnt.h"
@@ -155,7 +156,7 @@
static void test_discarded_image(skiatest::Reporter* reporter, const SkMatrix& transform,
sk_sp<SkImage> (*buildImage)()) {
- auto surface(SkSurface::MakeRasterN32Premul(10, 10));
+ auto surface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(10, 10)));
SkCanvas* canvas = surface->getCanvas();
// SkBitmapCache is global, so other threads could be evicting our bitmaps. Loop a few times
@@ -201,7 +202,7 @@
for (size_t i = 0; i < std::size(xforms); ++i) {
test_discarded_image(reporter, xforms[i], []() {
- auto surface(SkSurface::MakeRasterN32Premul(10, 10));
+ auto surface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(10, 10)));
surface->getCanvas()->clear(SK_ColorCYAN);
return surface->makeImageSnapshot();
});
diff --git a/tests/SkRuntimeEffectTest.cpp b/tests/SkRuntimeEffectTest.cpp
index e648c1d..84d066b 100644
--- a/tests/SkRuntimeEffectTest.cpp
+++ b/tests/SkRuntimeEffectTest.cpp
@@ -31,6 +31,7 @@
#include "include/effects/SkRuntimeEffect.h"
#include "include/gpu/GpuTypes.h"
#include "include/gpu/GrDirectContext.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "include/private/SkColorData.h"
#include "include/private/SkSLSampleUsage.h"
#include "include/private/base/SkTArray.h"
@@ -73,6 +74,7 @@
#include "include/gpu/graphite/Context.h"
#include "include/gpu/graphite/Recorder.h"
#include "include/gpu/graphite/Recording.h"
+#include "include/gpu/graphite/Surface.h"
#include "src/gpu/graphite/Surface_Graphite.h"
struct GraphiteInfo {
@@ -431,12 +433,12 @@
sk_sp<SkSurface> surface;
if (graphite) {
#if defined(SK_GRAPHITE)
- surface = SkSurface::MakeGraphite(graphite->recorder, info);
+ surface = SkSurfaces::RenderTarget(graphite->recorder, info);
#endif
} else if (grContext) {
- surface = SkSurface::MakeRenderTarget(grContext, skgpu::Budgeted::kNo, info);
+ surface = SkSurfaces::RenderTarget(grContext, skgpu::Budgeted::kNo, info);
} else {
- surface = SkSurface::MakeRaster(info);
+ surface = SkSurfaces::Raster(info);
}
SkASSERT(surface);
return surface;
@@ -831,7 +833,7 @@
DEF_TEST(SkRuntimeEffectObeysCapabilities_CPU, r) {
SkImageInfo info = SkImageInfo::Make(2, 2, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
- sk_sp<SkSurface> surface = SkSurface::MakeRaster(info);
+ sk_sp<SkSurface> surface = SkSurfaces::Raster(info);
REPORTER_ASSERT(r, surface);
test_RuntimeEffectObeysCapabilities(r, surface.get());
}
@@ -842,7 +844,7 @@
CtsEnforcement::kApiLevel_T) {
SkImageInfo info = SkImageInfo::Make(2, 2, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
sk_sp<SkSurface> surface =
- SkSurface::MakeRenderTarget(ctxInfo.directContext(), skgpu::Budgeted::kNo, info);
+ SkSurfaces::RenderTarget(ctxInfo.directContext(), skgpu::Budgeted::kNo, info);
REPORTER_ASSERT(r, surface);
test_RuntimeEffectObeysCapabilities(r, surface.get());
}
diff --git a/tests/SkSLES2ConformanceTest.cpp b/tests/SkSLES2ConformanceTest.cpp
index f499397..f479a18 100644
--- a/tests/SkSLES2ConformanceTest.cpp
+++ b/tests/SkSLES2ConformanceTest.cpp
@@ -27,6 +27,7 @@
#include "include/effects/SkRuntimeEffect.h"
#include "include/gpu/GpuTypes.h"
#include "include/gpu/GrDirectContext.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "src/core/SkOSFile.h"
#include "src/utils/SkOSPath.h"
#include "tests/CtsEnforcement.h"
@@ -108,7 +109,7 @@
DEF_TEST(SkSL_ES2Conformance_Pass_CPU, r) {
const SkImageInfo info = SkImageInfo::MakeN32Premul(1, 1);
- sk_sp<SkSurface> surface(SkSurface::MakeRaster(info));
+ sk_sp<SkSurface> surface(SkSurfaces::Raster(info));
iterate_dir("sksl/es2_conformance/pass/", [&](const char* path) {
test_expect_pass(r, surface.get(), path);
@@ -121,7 +122,7 @@
CtsEnforcement::kApiLevel_T) {
const SkImageInfo info = SkImageInfo::MakeN32Premul(1, 1);
sk_sp<SkSurface> surface(
- SkSurface::MakeRenderTarget(ctxInfo.directContext(), skgpu::Budgeted::kNo, info));
+ SkSurfaces::RenderTarget(ctxInfo.directContext(), skgpu::Budgeted::kNo, info));
iterate_dir("sksl/es2_conformance/pass/", [&](const char* path) {
test_expect_pass(r, surface.get(), path);
});
diff --git a/tests/SkSLTest.cpp b/tests/SkSLTest.cpp
index 9cd01de..0cf3ae2 100644
--- a/tests/SkSLTest.cpp
+++ b/tests/SkSLTest.cpp
@@ -21,6 +21,7 @@
#include "include/effects/SkRuntimeEffect.h"
#include "include/gpu/GpuTypes.h"
#include "include/gpu/GrDirectContext.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "include/private/base/SkTArray.h"
#include "include/sksl/SkSLVersion.h"
#include "src/base/SkArenaAlloc.h"
@@ -194,7 +195,7 @@
REPORTER_ASSERT(r, effect);
const SkImageInfo info = SkImageInfo::MakeN32Premul(kWidth, kHeight);
- sk_sp<SkSurface> surface(SkSurface::MakeRenderTarget(ctx, skgpu::Budgeted::kNo, info));
+ sk_sp<SkSurface> surface(SkSurfaces::RenderTarget(ctx, skgpu::Budgeted::kNo, info));
SkBitmap bitmap = bitmap_from_shader(r, surface.get(), effect);
REPORTER_ASSERT(r, !bitmap.empty());
@@ -289,7 +290,7 @@
// Create a raster-backed surface.
const SkImageInfo info = SkImageInfo::MakeN32Premul(kWidth, kHeight);
- sk_sp<SkSurface> surface(SkSurface::MakeRaster(info));
+ sk_sp<SkSurface> surface(SkSurfaces::Raster(info));
test_permutations(r, surface.get(), testFile, /*strictES2=*/true);
}
@@ -313,7 +314,7 @@
// Create a GPU-backed surface.
const SkImageInfo info = SkImageInfo::MakeN32Premul(kWidth, kHeight);
- sk_sp<SkSurface> surface(SkSurface::MakeRenderTarget(ctx, skgpu::Budgeted::kNo, info));
+ sk_sp<SkSurface> surface(SkSurfaces::RenderTarget(ctx, skgpu::Budgeted::kNo, info));
if (shouldRunGPU) {
test_permutations(r, surface.get(), testFile, /*strictES2=*/true);
diff --git a/tests/Skbug12214.cpp b/tests/Skbug12214.cpp
index 8661556..a4b2ea2 100644
--- a/tests/Skbug12214.cpp
+++ b/tests/Skbug12214.cpp
@@ -13,6 +13,7 @@
#include "include/core/SkTypes.h"
#include "include/gpu/GpuTypes.h"
#include "include/gpu/GrDirectContext.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "tests/CtsEnforcement.h"
#include "tests/Test.h"
@@ -21,9 +22,9 @@
DEF_GANESH_TEST_FOR_ALL_CONTEXTS(skbug12214, r, contextInfo, CtsEnforcement::kApiLevel_T) {
auto imageInfo = SkImageInfo::Make(/*width=*/32, /*height=*/32, kRGBA_8888_SkColorType,
kPremul_SkAlphaType);
- sk_sp<SkSurface> surface1 = SkSurface::MakeRenderTarget(
- contextInfo.directContext(), skgpu::Budgeted::kNo, imageInfo);
- sk_sp<SkSurface> surface2 = SkSurface::MakeRaster(imageInfo);
+ sk_sp<SkSurface> surface1 =
+ SkSurfaces::RenderTarget(contextInfo.directContext(), skgpu::Budgeted::kNo, imageInfo);
+ sk_sp<SkSurface> surface2 = SkSurfaces::Raster(imageInfo);
// The test succeeds if this draw does not crash. (See skia:12214)
surface1->draw(surface2->getCanvas(), /*x=*/0, /*y=*/0);
diff --git a/tests/Skbug5221.cpp b/tests/Skbug5221.cpp
index 3779236..75e1972 100644
--- a/tests/Skbug5221.cpp
+++ b/tests/Skbug5221.cpp
@@ -16,6 +16,7 @@
#include "include/core/SkTypes.h"
#include "include/gpu/GpuTypes.h"
#include "include/gpu/GrDirectContext.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "tests/CtsEnforcement.h"
#include "tests/Test.h"
@@ -28,12 +29,12 @@
}
DEF_TEST(skbug5221, r) {
- sk_sp<SkSurface> surface(SkSurface::MakeRaster(SkImageInfo::MakeN32Premul(256, 256)));
+ sk_sp<SkSurface> surface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(256, 256)));
test(surface->getCanvas());
}
DEF_GANESH_TEST_FOR_ALL_CONTEXTS(skbug5221_GPU, r, contextInfo, CtsEnforcement::kNever) {
- sk_sp<SkSurface> surface(SkSurface::MakeRenderTarget(
+ sk_sp<SkSurface> surface(SkSurfaces::RenderTarget(
contextInfo.directContext(),
skgpu::Budgeted::kYes,
SkImageInfo::Make(256, 256, kRGBA_8888_SkColorType, kPremul_SkAlphaType)));
diff --git a/tests/Skbug6389.cpp b/tests/Skbug6389.cpp
index f4bf9e2..38f15d4 100644
--- a/tests/Skbug6389.cpp
+++ b/tests/Skbug6389.cpp
@@ -7,6 +7,7 @@
#include "include/core/SkBlurTypes.h"
#include "include/core/SkCanvas.h"
+#include "include/core/SkImageInfo.h"
#include "include/core/SkMaskFilter.h"
#include "include/core/SkPaint.h"
#include "include/core/SkRefCnt.h"
@@ -17,7 +18,7 @@
#include "tools/Resources.h"
DEF_TEST(skbug_6389, r) {
- auto s = SkSurface::MakeRasterN32Premul(100, 100);
+ auto s = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(100, 100));
SkPaint p;
p.setMaskFilter(SkMaskFilter::MakeBlur(SkBlurStyle::kNormal_SkBlurStyle, 5));
p.setImageFilter(SkImageFilters::Image(GetResourceAsImage("images/mandrill_512.png"),
diff --git a/tests/Skbug6653.cpp b/tests/Skbug6653.cpp
index 12ec597..cccc9ec 100644
--- a/tests/Skbug6653.cpp
+++ b/tests/Skbug6653.cpp
@@ -19,6 +19,7 @@
#include "include/gpu/GpuTypes.h"
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/GrTypes.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "include/private/base/SkDebug.h"
#include "tests/CtsEnforcement.h"
#include "tests/Test.h"
@@ -40,7 +41,7 @@
static sk_sp<SkSurface> make_surface(GrRecordingContext* rContext) {
SkImageInfo info = SkImageInfo::Make(50, 50, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
- return SkSurface::MakeRenderTarget(
+ return SkSurfaces::RenderTarget(
rContext, skgpu::Budgeted::kNo, info, 4, kBottomLeft_GrSurfaceOrigin, nullptr);
}
diff --git a/tests/SrcSrcOverBatchTest.cpp b/tests/SrcSrcOverBatchTest.cpp
index d1c0b1e..f1e71bc 100644
--- a/tests/SrcSrcOverBatchTest.cpp
+++ b/tests/SrcSrcOverBatchTest.cpp
@@ -23,6 +23,7 @@
#include "include/gpu/GpuTypes.h"
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/GrTypes.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "tests/CtsEnforcement.h"
#include "tests/Test.h"
@@ -38,7 +39,7 @@
const SkImageInfo ii = SkImageInfo::Make(kSize, kSize, kRGBA_8888_SkColorType,
kPremul_SkAlphaType);
- sk_sp<SkSurface> surface(SkSurface::MakeRenderTarget(
+ sk_sp<SkSurface> surface(SkSurfaces::RenderTarget(
ctx, skgpu::Budgeted::kNo, ii, 0, kTopLeft_GrSurfaceOrigin, nullptr));
auto canvas = surface->getCanvas();
diff --git a/tests/SurfaceSemaphoreTest.cpp b/tests/SurfaceSemaphoreTest.cpp
index a7d1047..55a924a 100644
--- a/tests/SurfaceSemaphoreTest.cpp
+++ b/tests/SurfaceSemaphoreTest.cpp
@@ -104,7 +104,7 @@
kPremul_SkAlphaType);
auto childDContext = childInfo.directContext();
- sk_sp<SkSurface> childSurface(SkSurface::MakeRenderTarget(
+ sk_sp<SkSurface> childSurface(SkSurfaces::RenderTarget(
childDContext, skgpu::Budgeted::kNo, childII, 0, kTopLeft_GrSurfaceOrigin, nullptr));
sk_sp<SkImage> childImage = SkImages::BorrowTextureFrom(childDContext,
@@ -151,7 +151,7 @@
const SkImageInfo ii = SkImageInfo::Make(MAIN_W, MAIN_H, kRGBA_8888_SkColorType,
kPremul_SkAlphaType);
- sk_sp<SkSurface> mainSurface(SkSurface::MakeRenderTarget(
+ sk_sp<SkSurface> mainSurface(SkSurfaces::RenderTarget(
mainCtx, skgpu::Budgeted::kNo, ii, 0, kTopLeft_GrSurfaceOrigin, nullptr));
SkCanvas* mainCanvas = mainSurface->getCanvas();
auto blueSurface = mainSurface->makeSurface(ii);
@@ -267,7 +267,7 @@
const SkImageInfo ii = SkImageInfo::Make(MAIN_W, MAIN_H, kRGBA_8888_SkColorType,
kPremul_SkAlphaType);
- sk_sp<SkSurface> mainSurface(SkSurface::MakeRenderTarget(
+ sk_sp<SkSurface> mainSurface(SkSurfaces::RenderTarget(
ctx, skgpu::Budgeted::kNo, ii, 0, kTopLeft_GrSurfaceOrigin, nullptr));
// Flush surface once without semaphores to make sure there is no peneding IO for it.
diff --git a/tests/SurfaceTest.cpp b/tests/SurfaceTest.cpp
index 233aec9..fea7514 100644
--- a/tests/SurfaceTest.cpp
+++ b/tests/SurfaceTest.cpp
@@ -91,7 +91,7 @@
if (requestedInfo) {
*requestedInfo = info;
}
- return SkSurface::MakeRaster(info);
+ return SkSurfaces::Raster(info);
}
static sk_sp<SkSurface> create_direct_surface(SkAlphaType at = kPremul_SkAlphaType,
SkImageInfo* requestedInfo = nullptr) {
@@ -101,9 +101,7 @@
}
const size_t rowBytes = info.minRowBytes();
void* storage = sk_malloc_throw(info.computeByteSize(rowBytes));
- return SkSurface::MakeRasterDirectReleaseProc(info, storage, rowBytes,
- release_direct_surface_storage,
- storage);
+ return SkSurfaces::WrapPixels(info, storage, rowBytes, release_direct_surface_storage, storage);
}
static sk_sp<SkSurface> create_gpu_surface(GrRecordingContext* rContext,
SkAlphaType at = kPremul_SkAlphaType,
@@ -112,7 +110,7 @@
if (requestedInfo) {
*requestedInfo = info;
}
- return SkSurface::MakeRenderTarget(rContext, skgpu::Budgeted::kNo, info);
+ return SkSurfaces::RenderTarget(rContext, skgpu::Budgeted::kNo, info);
}
static sk_sp<SkSurface> create_gpu_scratch_surface(GrRecordingContext* rContext,
SkAlphaType at = kPremul_SkAlphaType,
@@ -121,14 +119,13 @@
if (requestedInfo) {
*requestedInfo = info;
}
- return SkSurface::MakeRenderTarget(rContext, skgpu::Budgeted::kYes, info);
+ return SkSurfaces::RenderTarget(rContext, skgpu::Budgeted::kYes, info);
}
DEF_TEST(SurfaceEmpty, reporter) {
const SkImageInfo info = SkImageInfo::Make(0, 0, kN32_SkColorType, kPremul_SkAlphaType);
- REPORTER_ASSERT(reporter, nullptr == SkSurface::MakeRaster(info));
- REPORTER_ASSERT(reporter, nullptr == SkSurface::MakeRasterDirect(info, nullptr, 0));
-
+ REPORTER_ASSERT(reporter, nullptr == SkSurfaces::Raster(info));
+ REPORTER_ASSERT(reporter, nullptr == SkSurfaces::WrapPixels(info, nullptr, 0));
}
DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS(SurfaceEmpty_Gpu,
reporter,
@@ -136,7 +133,7 @@
CtsEnforcement::kApiLevel_T) {
const SkImageInfo info = SkImageInfo::Make(0, 0, kN32_SkColorType, kPremul_SkAlphaType);
REPORTER_ASSERT(reporter,
- nullptr == SkSurface::MakeRenderTarget(
+ nullptr == SkSurfaces::RenderTarget(
ctxInfo.directContext(), skgpu::Budgeted::kNo, info));
}
@@ -154,8 +151,7 @@
{
bool can = context->colorTypeSupportedAsSurface(colorType);
- auto surf =
- SkSurface::MakeRenderTarget(context, skgpu::Budgeted::kYes, info, 1, nullptr);
+ auto surf = SkSurfaces::RenderTarget(context, skgpu::Budgeted::kYes, info, 1, nullptr);
REPORTER_ASSERT(reporter, can == SkToBool(surf), "ct: %d, can: %d, surf: %d",
colorType, can, SkToBool(surf));
@@ -173,7 +169,7 @@
static constexpr int kSampleCnt = 2;
bool can = context->maxSurfaceSampleCountForColorType(colorType) >= kSampleCnt;
- auto surf = SkSurface::MakeRenderTarget(
+ auto surf = SkSurfaces::RenderTarget(
context, skgpu::Budgeted::kYes, info, kSampleCnt, nullptr);
REPORTER_ASSERT(reporter, can == SkToBool(surf), "ct: %d, can: %d, surf: %d",
colorType, can, SkToBool(surf));
@@ -670,7 +666,7 @@
SkImageInfo info = SkImageInfo::MakeN32Premul(8,8);
GrDirectContext* dContext = ctxInfo.directContext();
for (auto budgeted : {skgpu::Budgeted::kNo, skgpu::Budgeted::kYes}) {
- auto surface(SkSurface::MakeRenderTarget(dContext, budgeted, info));
+ auto surface(SkSurfaces::RenderTarget(dContext, budgeted, info));
SkASSERT(surface);
REPORTER_ASSERT(reporter, budgeted == is_budgeted(surface));
@@ -756,22 +752,22 @@
DEF_TEST(surface_rowbytes, reporter) {
const SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100);
- auto surf0(SkSurface::MakeRaster(info));
+ auto surf0(SkSurfaces::Raster(info));
check_rowbytes_remain_consistent(surf0.get(), reporter);
// specify a larger rowbytes
- auto surf1(SkSurface::MakeRaster(info, 500, nullptr));
+ auto surf1(SkSurfaces::Raster(info, 500, nullptr));
check_rowbytes_remain_consistent(surf1.get(), reporter);
// Try some illegal rowByte values
- auto s = SkSurface::MakeRaster(info, 396, nullptr); // needs to be at least 400
+ auto s = SkSurfaces::Raster(info, 396, nullptr); // needs to be at least 400
REPORTER_ASSERT(reporter, nullptr == s);
- s = SkSurface::MakeRaster(info, std::numeric_limits<size_t>::max(), nullptr);
+ s = SkSurfaces::Raster(info, std::numeric_limits<size_t>::max(), nullptr);
REPORTER_ASSERT(reporter, nullptr == s);
}
DEF_TEST(surface_raster_zeroinitialized, reporter) {
- sk_sp<SkSurface> s(SkSurface::MakeRasterN32Premul(100, 100));
+ sk_sp<SkSurface> s(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(100, 100)));
SkPixmap pixmap;
REPORTER_ASSERT(reporter, s->peekPixels(&pixmap));
@@ -1032,7 +1028,7 @@
continue;
}
- surface = SkSurface::MakeFromBackendTexture(
+ surface = SkSurfaces::WrapBackendTexture(
ctx,
mbet->texture(),
texOrigin,
@@ -1048,11 +1044,14 @@
if (!backendRT.isValid()) {
continue;
}
- surface = SkSurface::MakeFromBackendRenderTarget(ctx, backendRT, texOrigin,
- kRGBA_8888_SkColorType,
- nullptr, nullptr,
- ReleaseChecker::Release,
- &releaseChecker);
+ surface = SkSurfaces::WrapBackendRenderTarget(ctx,
+ backendRT,
+ texOrigin,
+ kRGBA_8888_SkColorType,
+ nullptr,
+ nullptr,
+ ReleaseChecker::Release,
+ &releaseChecker);
}
if (!surface) {
ERRORF(reporter, "Failed to create surface");
@@ -1137,9 +1136,13 @@
continue;
}
- auto surf = SkSurface::MakeFromBackendTexture(
- context, mbet1->texture(), kTopLeft_GrSurfaceOrigin, sampleCnt,
- kRGBA_8888_SkColorType, ii.refColorSpace(), nullptr);
+ auto surf = SkSurfaces::WrapBackendTexture(context,
+ mbet1->texture(),
+ kTopLeft_GrSurfaceOrigin,
+ sampleCnt,
+ kRGBA_8888_SkColorType,
+ ii.refColorSpace(),
+ nullptr);
if (!surf) {
continue;
}
@@ -1173,9 +1176,13 @@
}
}
// The original texture should still be all blue.
- surf = SkSurface::MakeFromBackendTexture(
- context, mbet1->texture(), kBottomLeft_GrSurfaceOrigin, sampleCnt,
- kRGBA_8888_SkColorType, ii.refColorSpace(), nullptr);
+ surf = SkSurfaces::WrapBackendTexture(context,
+ mbet1->texture(),
+ kBottomLeft_GrSurfaceOrigin,
+ sampleCnt,
+ kRGBA_8888_SkColorType,
+ ii.refColorSpace(),
+ nullptr);
if (!surf) {
ERRORF(reporter, "Could not create second surface.");
continue;
@@ -1203,7 +1210,7 @@
REPORTER_ASSERT(reporter,
!surf->replaceBackendTexture(mbet3->texture(), kTopLeft_GrSurfaceOrigin));
// Can't replace texture of non-wrapped SkSurface.
- surf = SkSurface::MakeRenderTarget(context, skgpu::Budgeted::kYes, ii, sampleCnt, nullptr);
+ surf = SkSurfaces::RenderTarget(context, skgpu::Budgeted::kYes, ii, sampleCnt, nullptr);
REPORTER_ASSERT(reporter, surf);
if (surf) {
REPORTER_ASSERT(reporter, !surf->replaceBackendTexture(mbet1->texture(),
@@ -1257,7 +1264,7 @@
DEF_TEST(surface_image_unity, reporter) {
auto do_test = [reporter](const SkImageInfo& info) {
size_t rowBytes = info.minRowBytes();
- auto surf = SkSurface::MakeRaster(info, rowBytes, nullptr);
+ auto surf = SkSurfaces::Raster(info, rowBytes, nullptr);
if (surf) {
auto img = surf->makeImageSnapshot();
if ((false)) { // change to true to document the differences
@@ -1324,6 +1331,6 @@
REPORTER_ASSERT(r, !SkShaders::Color(filtered, nullptr));
// Now try to draw this paint. Before the fixing the bug, this would crash (null dereference)
- auto surface = SkSurface::MakeRasterN32Premul(8, 8);
+ auto surface = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(8, 8));
surface->getCanvas()->drawPaint(paint);
}
diff --git a/tests/TextBlobCacheTest.cpp b/tests/TextBlobCacheTest.cpp
index e3f1d87..34a3441 100644
--- a/tests/TextBlobCacheTest.cpp
+++ b/tests/TextBlobCacheTest.cpp
@@ -32,6 +32,7 @@
#include "include/encode/SkPngEncoder.h"
#include "include/gpu/GpuTypes.h"
#include "include/gpu/GrDirectContext.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "include/private/base/SkTArray.h"
#include "include/private/base/SkTemplates.h"
#include "include/private/base/SkTo.h"
@@ -101,7 +102,7 @@
SkImageInfo info = SkImageInfo::Make(kWidth, kHeight, kRGBA_8888_SkColorType,
kPremul_SkAlphaType);
- auto surface(SkSurface::MakeRenderTarget(dContext, skgpu::Budgeted::kNo, info, 0, &props));
+ auto surface(SkSurfaces::RenderTarget(dContext, skgpu::Budgeted::kNo, info, 0, &props));
REPORTER_ASSERT(reporter, surface);
if (!surface) {
return;
@@ -303,7 +304,7 @@
auto dContext = ctxInfo.directContext();
const SkImageInfo info =
SkImageInfo::Make(kScreenDim, kScreenDim, kN32_SkColorType, kPremul_SkAlphaType);
- auto surface = SkSurface::MakeRenderTarget(dContext, skgpu::Budgeted::kNo, info);
+ auto surface = SkSurfaces::RenderTarget(dContext, skgpu::Budgeted::kNo, info);
auto blob = make_large_blob();
int y = 40;
@@ -328,7 +329,7 @@
auto direct = ctxInfo.directContext();
const SkImageInfo info =
SkImageInfo::Make(kScreenDim, kScreenDim, kN32_SkColorType, kPremul_SkAlphaType);
- auto surface = SkSurface::MakeRenderTarget(direct, skgpu::Budgeted::kNo, info);
+ auto surface = SkSurfaces::RenderTarget(direct, skgpu::Budgeted::kNo, info);
auto blob = make_blob();
@@ -387,7 +388,7 @@
auto direct = ctxInfo.directContext();
const SkImageInfo info =
SkImageInfo::Make(kScreenDim, kScreenDim, kN32_SkColorType, kPremul_SkAlphaType);
- auto surface = SkSurface::MakeRenderTarget(direct, skgpu::Budgeted::kNo, info);
+ auto surface = SkSurfaces::RenderTarget(direct, skgpu::Budgeted::kNo, info);
auto movingBlob = make_blob();
diff --git a/tests/TextBlobTest.cpp b/tests/TextBlobTest.cpp
index 936a944..11b6dc7 100644
--- a/tests/TextBlobTest.cpp
+++ b/tests/TextBlobTest.cpp
@@ -12,6 +12,7 @@
#include "include/core/SkFontStyle.h"
#include "include/core/SkFontTypes.h"
#include "include/core/SkImage.h"
+#include "include/core/SkImageInfo.h"
#include "include/core/SkPaint.h"
#include "include/core/SkPoint.h"
#include "include/core/SkRect.h"
@@ -380,8 +381,9 @@
}
static sk_sp<SkImage> render(const SkTextBlob* blob) {
- auto surf = SkSurface::MakeRasterN32Premul(SkScalarRoundToInt(blob->bounds().width()),
- SkScalarRoundToInt(blob->bounds().height()));
+ auto surf = SkSurfaces::Raster(
+ SkImageInfo::MakeN32Premul(SkScalarRoundToInt(blob->bounds().width()),
+ SkScalarRoundToInt(blob->bounds().height())));
if (!surf) {
return nullptr; // bounds are empty?
}
diff --git a/tests/TextureBindingsResetTest.cpp b/tests/TextureBindingsResetTest.cpp
index dc317ff..abd0203 100644
--- a/tests/TextureBindingsResetTest.cpp
+++ b/tests/TextureBindingsResetTest.cpp
@@ -25,6 +25,7 @@
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/GrTypes.h"
#include "include/gpu/ganesh/SkImageGanesh.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "include/gpu/gl/GrGLFunctions.h"
#include "include/gpu/gl/GrGLInterface.h"
#include "include/gpu/gl/GrGLTypes.h"
@@ -126,7 +127,7 @@
// Test drawing and then resetting bindings. This should force a MIP regeneration if MIP
// maps are supported as well.
auto info = SkImageInfo::Make(10, 10, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
- auto surf = SkSurface::MakeRenderTarget(dContext, skgpu::Budgeted::kYes, info, 1, nullptr);
+ auto surf = SkSurfaces::RenderTarget(dContext, skgpu::Budgeted::kYes, info, 1, nullptr);
surf->getCanvas()->clear(0x80FF0000);
auto img = surf->makeImageSnapshot();
surf->getCanvas()->clear(SK_ColorBLUE);
diff --git a/tests/TextureStripAtlasManagerTest.cpp b/tests/TextureStripAtlasManagerTest.cpp
index b01afa4..77fd5ca 100644
--- a/tests/TextureStripAtlasManagerTest.cpp
+++ b/tests/TextureStripAtlasManagerTest.cpp
@@ -21,6 +21,7 @@
#include "include/effects/SkGradientShader.h"
#include "include/gpu/GpuTypes.h"
#include "include/gpu/GrDirectContext.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "tests/CtsEnforcement.h"
#include "tests/Test.h"
#include "tools/Resources.h"
@@ -55,7 +56,7 @@
SkTileMode::kClamp));
SkImageInfo info = SkImageInfo::MakeN32Premul(128, 128);
- auto surface(SkSurface::MakeRenderTarget(context, skgpu::Budgeted::kNo, info));
+ auto surface(SkSurfaces::RenderTarget(context, skgpu::Budgeted::kNo, info));
SkCanvas* canvas = surface->getCanvas();
SkRect r = SkRect::MakeXYWH(10, 10, 100, 100);
@@ -84,7 +85,7 @@
p.setColorFilter(SkColorFilters::Table(identity));
SkImageInfo info = SkImageInfo::MakeN32Premul(128, 128);
- auto surface(SkSurface::MakeRenderTarget(context, skgpu::Budgeted::kNo, info));
+ auto surface(SkSurfaces::RenderTarget(context, skgpu::Budgeted::kNo, info));
SkCanvas* canvas = surface->getCanvas();
canvas->drawImage(std::move(img), 0, 0, SkSamplingOptions(), &p);
diff --git a/tests/VerticesTest.cpp b/tests/VerticesTest.cpp
index b323f0c..2839725 100644
--- a/tests/VerticesTest.cpp
+++ b/tests/VerticesTest.cpp
@@ -8,6 +8,7 @@
#include "include/core/SkBlendMode.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkColor.h"
+#include "include/core/SkImageInfo.h"
#include "include/core/SkPaint.h"
#include "include/core/SkPoint.h"
#include "include/core/SkRefCnt.h"
@@ -155,7 +156,7 @@
// A very large triangle has to be geometrically clipped (since its "fast" clipping is
// normally done in after building SkFixed coordinates). Check that we handle this.
// (and don't assert).
- auto surf = SkSurface::MakeRasterN32Premul(3, 3);
+ auto surf = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(3, 3));
SkPoint pts[] = { { -10, 1 }, { -10, 2 }, { 1e9f, 1.5f } };
fill_triangle(surf->getCanvas(), pts, SK_ColorBLACK);
diff --git a/tests/VkDrawableTest.cpp b/tests/VkDrawableTest.cpp
index af5a3b4..7e0b3c1 100644
--- a/tests/VkDrawableTest.cpp
+++ b/tests/VkDrawableTest.cpp
@@ -28,6 +28,7 @@
#include "include/gpu/GrBackendDrawableInfo.h"
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/GrTypes.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "include/gpu/vk/GrVkTypes.h"
#include "include/private/chromium/GrVkSecondaryCBDrawContext.h"
#include "src/gpu/ganesh/GrDirectContextPriv.h"
@@ -171,7 +172,7 @@
// Draw to an offscreen target so that we end up with a mix of "real" secondary command
// buffers and the imported secondary command buffer.
sk_sp<SkSurface> surf =
- SkSurface::MakeRenderTarget(td->fDContext, skgpu::Budgeted::kYes, bufferInfo);
+ SkSurfaces::RenderTarget(td->fDContext, skgpu::Budgeted::kYes, bufferInfo);
surf->getCanvas()->clear(SK_ColorRED);
SkRect dstRect = SkRect::MakeXYWH(3*td->fWidth/4, 0, td->fWidth/4, td->fHeight);
@@ -244,7 +245,7 @@
const SkImageInfo ii = SkImageInfo::Make(DEV_W, DEV_H, kRGBA_8888_SkColorType,
kPremul_SkAlphaType);
- sk_sp<SkSurface> surface(SkSurface::MakeRenderTarget(
+ sk_sp<SkSurface> surface(SkSurfaces::RenderTarget(
dContext, skgpu::Budgeted::kNo, ii, 0, kTopLeft_GrSurfaceOrigin, nullptr));
SkCanvas* canvas = surface->getCanvas();
canvas->clear(SK_ColorBLUE);
diff --git a/tests/VkHardwareBufferTest.cpp b/tests/VkHardwareBufferTest.cpp
index c0e8e98..5df261b 100644
--- a/tests/VkHardwareBufferTest.cpp
+++ b/tests/VkHardwareBufferTest.cpp
@@ -19,6 +19,7 @@
#include "include/gpu/GrBackendSemaphore.h"
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/ganesh/SkImageGanesh.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "include/gpu/vk/GrVkBackendContext.h"
#include "include/gpu/vk/VulkanExtensions.h"
#include "src/base/SkAutoMalloc.h"
@@ -300,12 +301,13 @@
GrBackendTexture backendTex(DEV_W, DEV_H, GrMipmapped::kNo, textureInfo);
REPORTER_ASSERT(reporter, backendTex.isValid());
- sk_sp<SkSurface> surface = SkSurface::MakeFromBackendTexture(fDirectContext,
- backendTex,
- kTopLeft_GrSurfaceOrigin,
- 0,
- kRGBA_8888_SkColorType,
- nullptr, nullptr);
+ sk_sp<SkSurface> surface = SkSurfaces::WrapBackendTexture(fDirectContext,
+ backendTex,
+ kTopLeft_GrSurfaceOrigin,
+ 0,
+ kRGBA_8888_SkColorType,
+ nullptr,
+ nullptr);
if (!surface) {
ERRORF(reporter, "Failed to make wrapped GL SkSurface");
@@ -979,12 +981,13 @@
GrBackendTexture backendTex(DEV_W, DEV_H, imageInfo);
- sk_sp<SkSurface> surface = SkSurface::MakeFromBackendTexture(fDirectContext.get(),
- backendTex,
- kTopLeft_GrSurfaceOrigin,
- 0,
- kRGBA_8888_SkColorType,
- nullptr, nullptr);
+ sk_sp<SkSurface> surface = SkSurfaces::WrapBackendTexture(fDirectContext.get(),
+ backendTex,
+ kTopLeft_GrSurfaceOrigin,
+ 0,
+ kRGBA_8888_SkColorType,
+ nullptr,
+ nullptr);
if (!surface.get()) {
ERRORF(reporter, "Failed to create wrapped Vulkan SkSurface");
@@ -1261,7 +1264,7 @@
SkImageInfo imageInfo = SkImageInfo::Make(DEV_W, DEV_H, kRGBA_8888_SkColorType,
kPremul_SkAlphaType, nullptr);
- sk_sp<SkSurface> dstSurf = SkSurface::MakeRenderTarget(
+ sk_sp<SkSurface> dstSurf = SkSurfaces::RenderTarget(
direct, skgpu::Budgeted::kNo, imageInfo, 0, kTopLeft_GrSurfaceOrigin, nullptr, false);
if (!dstSurf.get()) {
ERRORF(reporter, "Failed to create destination SkSurface");
diff --git a/tests/VkYcbcrSamplerTest.cpp b/tests/VkYcbcrSamplerTest.cpp
index b9624e6..52cec73 100644
--- a/tests/VkYcbcrSamplerTest.cpp
+++ b/tests/VkYcbcrSamplerTest.cpp
@@ -21,6 +21,7 @@
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/GrTypes.h"
#include "include/gpu/ganesh/SkImageGanesh.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "tests/CtsEnforcement.h"
#include "tests/Test.h"
#include "tools/gpu/vk/VkTestHelper.h"
@@ -76,7 +77,7 @@
return;
}
- sk_sp<SkSurface> surface = SkSurface::MakeRenderTarget(
+ sk_sp<SkSurface> surface = SkSurfaces::RenderTarget(
testHelper.directContext(),
skgpu::Budgeted::kNo,
SkImageInfo::Make(kImageWidth, kImageHeight, kN32_SkColorType, kPremul_SkAlphaType));
diff --git a/tests/WritePixelsTest.cpp b/tests/WritePixelsTest.cpp
index f201251..23267da 100644
--- a/tests/WritePixelsTest.cpp
+++ b/tests/WritePixelsTest.cpp
@@ -25,7 +25,9 @@
#include "include/gpu/GrTypes.h"
#if defined(SK_GRAPHITE)
#include "include/gpu/graphite/Context.h"
+#include "include/gpu/graphite/Surface.h"
#endif
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "include/private/SkColorData.h"
#include "include/private/base/SkCPUTypes.h"
#include "include/private/base/SkMalloc.h"
@@ -319,10 +321,6 @@
return true;
}
-static void free_pixels(void* pixels, void* ctx) {
- sk_free(pixels);
-}
-
static bool setup_bitmap(SkBitmap* bm, SkColorType ct, SkAlphaType at, int w, int h, int tightRB) {
size_t rowBytes = tightRB ? 0 : 4 * w + 60;
SkImageInfo info = SkImageInfo::Make(w, h, ct, at);
@@ -345,7 +343,7 @@
DEF_TEST(WritePixelsSurfaceGenID, reporter) {
const SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100);
- auto surface(SkSurface::MakeRaster(info));
+ auto surface(SkSurfaces::Raster(info));
uint32_t genID1 = surface->generationID();
call_writepixels(surface.get());
uint32_t genID2 = surface->generationID();
@@ -446,6 +444,8 @@
}
}
+static void free_pixels(void* pixels, void* ctx) { sk_free(pixels); }
+
DEF_TEST(WritePixels, reporter) {
const SkImageInfo info = SkImageInfo::MakeN32Premul(DEV_W, DEV_H);
for (auto& tightRowBytes : { true, false }) {
@@ -456,8 +456,7 @@
if (!tightRowBytes) {
memset(pixels, DEV_PAD, size);
}
- auto surface(SkSurface::MakeRasterDirectReleaseProc(info, pixels, rowBytes,
- free_pixels, nullptr));
+ auto surface(SkSurfaces::WrapPixels(info, pixels, rowBytes, free_pixels, nullptr));
test_write_pixels(reporter, surface.get(), info);
}
}
@@ -467,7 +466,7 @@
int sampleCnt) {
const SkImageInfo ii = SkImageInfo::MakeN32Premul(DEV_W, DEV_H);
for (auto& origin : { kTopLeft_GrSurfaceOrigin, kBottomLeft_GrSurfaceOrigin }) {
- sk_sp<SkSurface> surface(SkSurface::MakeRenderTarget(
+ sk_sp<SkSurface> surface(SkSurfaces::RenderTarget(
rContext, skgpu::Budgeted::kNo, ii, sampleCnt, origin, nullptr));
if (surface) {
test_write_pixels(reporter, surface.get(), ii);
@@ -494,8 +493,7 @@
skgpu::graphite::Recorder* recorder,
int sampleCnt) {
const SkImageInfo ii = SkImageInfo::MakeN32Premul(DEV_W, DEV_H);
- sk_sp<SkSurface> surface = SkSurface::MakeGraphite(recorder,
- ii);
+ sk_sp<SkSurface> surface = SkSurfaces::RenderTarget(recorder, ii);
if (surface) {
test_write_pixels(reporter, surface.get(), ii);
}
@@ -549,7 +547,7 @@
const SkImageInfo ii = SkImageInfo::Make(width, height,
kRGBA_8888_SkColorType, kPremul_SkAlphaType);
- sk_sp<SkSurface> surf = SkSurface::MakeRenderTarget(rContext, skgpu::Budgeted::kYes, ii);
+ sk_sp<SkSurface> surf = SkSurfaces::RenderTarget(rContext, skgpu::Budgeted::kYes, ii);
surf->flushAndSubmit();
return surf;
}
@@ -590,7 +588,7 @@
const SkImageInfo halfII = SkImageInfo::Make(kHalfSize, kFullSize,
kRGBA_8888_SkColorType, kPremul_SkAlphaType);
- sk_sp<SkSurface> dest = SkSurface::MakeRenderTarget(context, skgpu::Budgeted::kYes, fullII);
+ sk_sp<SkSurface> dest = SkSurfaces::RenderTarget(context, skgpu::Budgeted::kYes, fullII);
{
// Seed the resource cached with a scratch texture that will be reused by writePixels
@@ -648,7 +646,7 @@
DEF_TEST(WritePixels_InvalidRowBytes, reporter) {
auto dstII = SkImageInfo::Make({10, 10}, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
- auto surf = SkSurface::MakeRaster(dstII);
+ auto surf = SkSurfaces::Raster(dstII);
for (int ct = 0; ct < kLastEnum_SkColorType + 1; ++ct) {
auto colorType = static_cast<SkColorType>(ct);
diff --git a/tests/graphite/BackendTextureTest.cpp b/tests/graphite/BackendTextureTest.cpp
index 6af5d15..7e73069 100644
--- a/tests/graphite/BackendTextureTest.cpp
+++ b/tests/graphite/BackendTextureTest.cpp
@@ -10,6 +10,7 @@
#include "include/gpu/graphite/BackendTexture.h"
#include "include/gpu/graphite/Context.h"
#include "include/gpu/graphite/Recorder.h"
+#include "include/gpu/graphite/Surface.h"
#include "src/gpu/graphite/Caps.h"
#include "src/gpu/graphite/ContextPriv.h"
#include "src/gpu/graphite/ResourceTypes.h"
@@ -104,22 +105,22 @@
auto texture = recorder->createBackendTexture(kSize, info);
REPORTER_ASSERT(reporter, texture.isValid());
- sk_sp<SkSurface> surface = SkSurface::MakeGraphiteFromBackendTexture(recorder.get(),
- texture,
- kRGBA_8888_SkColorType,
- /*colorSpace=*/nullptr,
- /*props=*/nullptr);
+ sk_sp<SkSurface> surface = SkSurfaces::WrapBackendTexture(recorder.get(),
+ texture,
+ kRGBA_8888_SkColorType,
+ /*colorSpace=*/nullptr,
+ /*props=*/nullptr);
REPORTER_ASSERT(reporter, surface);
surface.reset();
// We should fail when trying to wrap the same texture in a surface with a non-compatible
// color type.
- surface = SkSurface::MakeGraphiteFromBackendTexture(recorder.get(),
- texture,
- kAlpha_8_SkColorType,
- /*colorSpace=*/nullptr,
- /*props=*/nullptr);
+ surface = SkSurfaces::WrapBackendTexture(recorder.get(),
+ texture,
+ kAlpha_8_SkColorType,
+ /*colorSpace=*/nullptr,
+ /*props=*/nullptr);
REPORTER_ASSERT(reporter, !surface);
recorder->deleteBackendTexture(texture);
@@ -132,11 +133,11 @@
texture = recorder->createBackendTexture(kSize, info);
REPORTER_ASSERT(reporter, texture.isValid());
- surface = SkSurface::MakeGraphiteFromBackendTexture(recorder.get(),
- texture,
- kRGBA_8888_SkColorType,
- /*colorSpace=*/nullptr,
- /*props=*/nullptr);
+ surface = SkSurfaces::WrapBackendTexture(recorder.get(),
+ texture,
+ kRGBA_8888_SkColorType,
+ /*colorSpace=*/nullptr,
+ /*props=*/nullptr);
REPORTER_ASSERT(reporter, !surface);
recorder->deleteBackendTexture(texture);
diff --git a/tests/graphite/GraphitePromiseImageTest.cpp b/tests/graphite/GraphitePromiseImageTest.cpp
index 2890cb9..9808975 100644
--- a/tests/graphite/GraphitePromiseImageTest.cpp
+++ b/tests/graphite/GraphitePromiseImageTest.cpp
@@ -13,6 +13,7 @@
#include "include/core/SkSurface.h"
#include "include/gpu/graphite/Context.h"
#include "include/gpu/graphite/Recording.h"
+#include "include/gpu/graphite/Surface.h"
#include "src/gpu/graphite/Caps.h"
#include "src/gpu/graphite/ContextPriv.h"
#include "src/gpu/graphite/RecordingPriv.h"
@@ -229,7 +230,7 @@
PromiseTextureChecker::TextureRelease,
&testCtx->fPromiseChecker);
- testCtx->fSurface = SkSurface::MakeGraphite(testCtx->fRecorder.get(), ii);
+ testCtx->fSurface = SkSurfaces::RenderTarget(testCtx->fRecorder.get(), ii);
}
} // anonymous namespace
diff --git a/tests/graphite/GraphiteResourceCacheTest.cpp b/tests/graphite/GraphiteResourceCacheTest.cpp
index 219f95b..92397d6 100644
--- a/tests/graphite/GraphiteResourceCacheTest.cpp
+++ b/tests/graphite/GraphiteResourceCacheTest.cpp
@@ -14,6 +14,7 @@
#include "include/gpu/graphite/Context.h"
#include "include/gpu/graphite/Recorder.h"
#include "include/gpu/graphite/Recording.h"
+#include "include/gpu/graphite/Surface.h"
#include "src/core/SkCanvasPriv.h"
#include "src/gpu/graphite/Device.h"
#include "src/gpu/graphite/RecorderPriv.h"
@@ -209,7 +210,7 @@
REPORTER_ASSERT(reporter, imageResourcePtr->budgeted() == skgpu::Budgeted::kYes);
// Now try an SkSurface. This is simpler since we can directly create Graphite SkSurface's.
- sk_sp<SkSurface> surface = SkSurface::MakeGraphite(recorder.get(), info);
+ sk_sp<SkSurface> surface = SkSurfaces::RenderTarget(recorder.get(), info);
if (!surface) {
ERRORF(reporter, "Failed to make surface");
return;
diff --git a/tests/graphite/ImageProviderTest.cpp b/tests/graphite/ImageProviderTest.cpp
index 5572426..2293b27 100644
--- a/tests/graphite/ImageProviderTest.cpp
+++ b/tests/graphite/ImageProviderTest.cpp
@@ -14,6 +14,7 @@
#include "include/gpu/graphite/Context.h"
#include "include/gpu/graphite/Image.h"
#include "include/gpu/graphite/Recording.h"
+#include "include/gpu/graphite/Surface.h"
#include "src/core/SkMipmapBuilder.h"
#include "src/gpu/graphite/Caps.h"
#include "src/gpu/graphite/RecorderPriv.h"
@@ -171,7 +172,7 @@
SkAssertResult(result.peekPixels(&pm));
{
- sk_sp<SkSurface> surface = SkSurface::MakeGraphite(recorder, ii);
+ sk_sp<SkSurface> surface = SkSurfaces::RenderTarget(recorder, ii);
if (!surface) {
ERRORF(reporter, "Surface creation failed");
return false;
diff --git a/tests/graphite/ImageShaderTest.cpp b/tests/graphite/ImageShaderTest.cpp
index 63800b5..66860ef 100644
--- a/tests/graphite/ImageShaderTest.cpp
+++ b/tests/graphite/ImageShaderTest.cpp
@@ -9,6 +9,7 @@
#include "include/core/SkBitmap.h"
#include "include/gpu/graphite/Context.h"
+#include "include/gpu/graphite/Surface.h"
#include "src/gpu/graphite/Surface_Graphite.h"
#include "src/shaders/SkImageShader.h"
#include "tools/ToolUtils.h"
@@ -35,7 +36,7 @@
SkSamplingOptions samplingOptions,
std::vector<Expectation> expectations) {
std::unique_ptr<Recorder> recorder = context->makeRecorder();
- sk_sp<SkSurface> surface = SkSurface::MakeGraphite(
+ sk_sp<SkSurface> surface = SkSurfaces::RenderTarget(
recorder.get(),
SkImageInfo::Make(canvasSize, kRGBA_8888_SkColorType, kPremul_SkAlphaType));
SkCanvas* canvas = surface->getCanvas();
diff --git a/tests/graphite/MultisampleTest.cpp b/tests/graphite/MultisampleTest.cpp
index 9588e70c..0155829 100644
--- a/tests/graphite/MultisampleTest.cpp
+++ b/tests/graphite/MultisampleTest.cpp
@@ -14,6 +14,7 @@
#include "include/gpu/graphite/Context.h"
#include "include/gpu/graphite/Recorder.h"
#include "include/gpu/graphite/Recording.h"
+#include "include/gpu/graphite/Surface.h"
#include "src/gpu/graphite/Surface_Graphite.h"
namespace skgpu::graphite {
@@ -25,7 +26,7 @@
16, 16, SkColorType::kRGBA_8888_SkColorType, SkAlphaType::kPremul_SkAlphaType);
std::unique_ptr<Recorder> surfaceRecorder = context->makeRecorder();
- sk_sp<SkSurface> surface = SkSurface::MakeGraphite(surfaceRecorder.get(), surfaceImageInfo);
+ sk_sp<SkSurface> surface = SkSurfaces::RenderTarget(surfaceRecorder.get(), surfaceImageInfo);
// Clear entire surface to red
SkCanvas* surfaceCanvas = surface->getCanvas();
diff --git a/tests/graphite/MutableImagesTest.cpp b/tests/graphite/MutableImagesTest.cpp
index a4824f3..91445b6 100644
--- a/tests/graphite/MutableImagesTest.cpp
+++ b/tests/graphite/MutableImagesTest.cpp
@@ -15,6 +15,7 @@
#include "include/gpu/graphite/Context.h"
#include "include/gpu/graphite/Recorder.h"
#include "include/gpu/graphite/Recording.h"
+#include "include/gpu/graphite/Surface.h"
#include "src/core/SkAutoPixmapStorage.h"
#include "src/gpu/graphite/Caps.h"
#include "src/gpu/graphite/ContextPriv.h"
@@ -106,7 +107,7 @@
SkImageInfo ii = SkImageInfo::Make(kSurfaceSize,
kRGBA_8888_SkColorType,
kPremul_SkAlphaType);
- fImgDrawSurface = SkSurface::MakeGraphite(fRecorder, ii, Mipmapped::kNo);
+ fImgDrawSurface = SkSurfaces::RenderTarget(fRecorder, ii, Mipmapped::kNo);
REPORTER_ASSERT(fReporter, fImgDrawSurface);
fImgDrawRecording = MakeRedrawRecording(fRecorder, fImgDrawSurface.get(), imageToDraw);
@@ -421,8 +422,8 @@
std::unique_ptr<Recording> init(const Caps* /* caps */) override {
SkImageInfo ii = SkImageInfo::Make(kImageSize, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
- fMutatingSurface = SkSurface::MakeGraphite(fRecorder, ii,
- fWithMips ? Mipmapped::kYes : Mipmapped::kNo);
+ fMutatingSurface = SkSurfaces::RenderTarget(
+ fRecorder, ii, fWithMips ? Mipmapped::kYes : Mipmapped::kNo);
REPORTER_ASSERT(fReporter, fMutatingSurface);
fMutatingSurface->getCanvas()->clear(kInitialColor);
diff --git a/tests/graphite/PaintParamsKeyTest.cpp b/tests/graphite/PaintParamsKeyTest.cpp
index 02f90f9..4dc33fe 100644
--- a/tests/graphite/PaintParamsKeyTest.cpp
+++ b/tests/graphite/PaintParamsKeyTest.cpp
@@ -21,6 +21,7 @@
#include "include/effects/SkGradientShader.h"
#include "include/effects/SkRuntimeEffect.h"
#include "include/gpu/graphite/Recorder.h"
+#include "include/gpu/graphite/Surface.h"
#include "src/base/SkRandom.h"
#include "src/core/SkBlenderBase.h"
#include "src/core/SkRuntimeEffectPriv.h"
@@ -594,7 +595,7 @@
kRGBA_8888_SkColorType,
kPremul_SkAlphaType);
- sk_sp<SkSurface> surf = SkSurface::MakeGraphite(recorder, ii);
+ sk_sp<SkSurface> surf = SkSurfaces::RenderTarget(recorder, ii);
SkCanvas* canvas = surf->getCanvas();
switch (dt) {
diff --git a/tests/graphite/ReadWritePixelsGraphiteTest.cpp b/tests/graphite/ReadWritePixelsGraphiteTest.cpp
index 3c8a01d..3a49181 100644
--- a/tests/graphite/ReadWritePixelsGraphiteTest.cpp
+++ b/tests/graphite/ReadWritePixelsGraphiteTest.cpp
@@ -17,6 +17,7 @@
#include "include/gpu/graphite/Context.h"
#include "include/gpu/graphite/Recorder.h"
#include "include/gpu/graphite/Recording.h"
+#include "include/gpu/graphite/Surface.h"
#include "include/gpu/graphite/TextureInfo.h"
#include "src/base/SkRectMemcpy.h"
#include "src/core/SkAutoPixmapStorage.h"
@@ -184,7 +185,7 @@
static SkAutoPixmapStorage make_ref_data(const SkImageInfo& info, bool forceOpaque) {
SkAutoPixmapStorage result;
result.alloc(info);
- auto surface = SkSurface::MakeRasterDirect(make_pixmap_have_valid_alpha_type(result));
+ auto surface = SkSurfaces::WrapPixels(make_pixmap_have_valid_alpha_type(result));
if (!surface) {
return result;
}
@@ -625,24 +626,23 @@
rules.fAllowUnpremulSrc = true;
rules.fUncontainedRectSucceeds = false;
- auto factory = std::function<GraphiteSrcFactory<Surface>>([&](
- skgpu::graphite::Recorder* recorder,
- const SkPixmap& src) {
- Surface surface = SkSurface::MakeGraphite(recorder,
- src.info(),
- Mipmapped::kNo,
- /*surfaceProps=*/nullptr);
- if (surface) {
- surface->writePixels(src, 0, 0);
+ auto factory = std::function<GraphiteSrcFactory<Surface>>(
+ [&](skgpu::graphite::Recorder* recorder, const SkPixmap& src) {
+ Surface surface = SkSurfaces::RenderTarget(recorder,
+ src.info(),
+ Mipmapped::kNo,
+ /*surfaceProps=*/nullptr);
+ if (surface) {
+ surface->writePixels(src, 0, 0);
- std::unique_ptr<skgpu::graphite::Recording> recording = recorder->snap();
- skgpu::graphite::InsertRecordingInfo recordingInfo;
- recordingInfo.fRecording = recording.get();
- context->insertRecording(recordingInfo);
- }
+ std::unique_ptr<skgpu::graphite::Recording> recording = recorder->snap();
+ skgpu::graphite::InsertRecordingInfo recordingInfo;
+ recordingInfo.fRecording = recording.get();
+ context->insertRecording(recordingInfo);
+ }
- return surface;
- });
+ return surface;
+ });
graphite_read_pixels_test_driver(reporter, context, rules, factory, reader, {});
// It's possible that we've created an Image using the factory, but then don't try to do
diff --git a/tests/graphite/RecordingOrderTest.cpp b/tests/graphite/RecordingOrderTest.cpp
index 14c0339..e3b6996 100644
--- a/tests/graphite/RecordingOrderTest.cpp
+++ b/tests/graphite/RecordingOrderTest.cpp
@@ -10,6 +10,7 @@
#include "include/core/SkBitmap.h"
#include "include/gpu/graphite/Context.h"
#include "include/gpu/graphite/Recording.h"
+#include "include/gpu/graphite/Surface.h"
#include "src/gpu/graphite/ContextPriv.h"
#include "src/gpu/graphite/Surface_Graphite.h"
#include "tests/TestUtils.h"
@@ -36,7 +37,7 @@
SkAssertResult(result0.peekPixels(&pm0));
SkAssertResult(result1.peekPixels(&pm1));
- sk_sp<SkSurface> surface = SkSurface::MakeGraphite(recorder, ii);
+ sk_sp<SkSurface> surface = SkSurfaces::RenderTarget(recorder, ii);
if (!surface) {
ERRORF(reporter, "Surface creation failed");
return false;
diff --git a/tests/graphite/RecordingSurfacesTest.cpp b/tests/graphite/RecordingSurfacesTest.cpp
index 84db0a2..49aa6fe 100644
--- a/tests/graphite/RecordingSurfacesTest.cpp
+++ b/tests/graphite/RecordingSurfacesTest.cpp
@@ -13,6 +13,7 @@
#include "include/gpu/graphite/Context.h"
#include "include/gpu/graphite/Recorder.h"
#include "include/gpu/graphite/Recording.h"
+#include "include/gpu/graphite/Surface.h"
#include "src/gpu/graphite/Surface_Graphite.h"
namespace skgpu::graphite {
@@ -36,7 +37,7 @@
surfaceSize, SkColorType::kRGBA_8888_SkColorType, SkAlphaType::kPremul_SkAlphaType);
std::unique_ptr<Recorder> surfaceRecorder = context->makeRecorder();
- sk_sp<SkSurface> surface = SkSurface::MakeGraphite(surfaceRecorder.get(), surfaceImageInfo);
+ sk_sp<SkSurface> surface = SkSurfaces::RenderTarget(surfaceRecorder.get(), surfaceImageInfo);
Surface* graphiteSurface = static_cast<Surface*>(surface.get());
const TextureInfo& textureInfo = graphiteSurface->backingTextureProxy()->textureInfo();
diff --git a/tests/graphite/UpdateBackendTextureTest.cpp b/tests/graphite/UpdateBackendTextureTest.cpp
index 6fc2072..c4d6458 100644
--- a/tests/graphite/UpdateBackendTextureTest.cpp
+++ b/tests/graphite/UpdateBackendTextureTest.cpp
@@ -11,6 +11,7 @@
#include "include/gpu/graphite/BackendTexture.h"
#include "include/gpu/graphite/Context.h"
#include "include/gpu/graphite/Recorder.h"
+#include "include/gpu/graphite/Surface.h"
#include "src/core/SkAutoPixmapStorage.h"
#include "src/gpu/graphite/Caps.h"
#include "src/gpu/graphite/ContextPriv.h"
@@ -113,7 +114,7 @@
: SkSamplingOptions(SkFilterMode::kNearest);
SkImageInfo surfaceII = SkImageInfo::Make(kSize, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
- sk_sp<SkSurface> surf = SkSurface::MakeGraphite(recorder, surfaceII, Mipmapped::kNo);
+ sk_sp<SkSurface> surf = SkSurfaces::RenderTarget(recorder, surfaceII, Mipmapped::kNo);
SkCanvas* canvas = surf->getCanvas();
for (int i = 0, drawSize = kSize.width(); i < numLevels; ++i, drawSize /= 2) {
diff --git a/tools/DDLTileHelper.cpp b/tools/DDLTileHelper.cpp
index cd817a4..771feff 100644
--- a/tools/DDLTileHelper.cpp
+++ b/tools/DDLTileHelper.cpp
@@ -14,6 +14,7 @@
#include "include/core/SkSurfaceCharacterization.h"
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/ganesh/SkImageGanesh.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "src/base/SkRandom.h"
#include "src/core/SkDeferredDisplayListPriv.h"
#include "src/core/SkTaskGroup.h"
@@ -123,13 +124,13 @@
// Here we are, unfortunately, aliasing the backend texture held by the SkPromiseImageTexture.
// Both the tile's destination surface and the promise image used to draw the tile will be
// backed by the same backendTexture - unbeknownst to Ganesh.
- return SkSurface::MakeFromBackendTexture(rContext,
- promiseImageTexture->backendTexture(),
- fPlaybackChar.origin(),
- fPlaybackChar.sampleCount(),
- fPlaybackChar.colorType(),
- fPlaybackChar.refColorSpace(),
- &fPlaybackChar.surfaceProps());
+ return SkSurfaces::WrapBackendTexture(rContext,
+ promiseImageTexture->backendTexture(),
+ fPlaybackChar.origin(),
+ fPlaybackChar.sampleCount(),
+ fPlaybackChar.colorType(),
+ fPlaybackChar.refColorSpace(),
+ &fPlaybackChar.surfaceProps());
}
void DDLTileHelper::TileData::drawSKPDirectly(GrDirectContext* dContext,
diff --git a/tools/ToolUtils.cpp b/tools/ToolUtils.cpp
index ffebb18..e2f38bd 100644
--- a/tools/ToolUtils.cpp
+++ b/tools/ToolUtils.cpp
@@ -169,7 +169,7 @@
}
sk_sp<SkImage> create_checkerboard_image(int w, int h, SkColor c1, SkColor c2, int checkSize) {
- auto surf = SkSurface::MakeRasterN32Premul(w, h);
+ auto surf = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(w, h));
ToolUtils::draw_checkerboard(surf->getCanvas(), c1, c2, checkSize);
return surf->makeImageSnapshot();
}
@@ -523,7 +523,7 @@
const SkSurfaceProps* props) {
auto surf = canvas->makeSurface(info, props);
if (!surf) {
- surf = SkSurface::MakeRaster(info, props);
+ surf = SkSurfaces::Raster(info, props);
}
return surf;
}
diff --git a/tools/blob_cache_sim.cpp b/tools/blob_cache_sim.cpp
index 6e0d55d..8f08f74 100644
--- a/tools/blob_cache_sim.cpp
+++ b/tools/blob_cache_sim.cpp
@@ -71,8 +71,8 @@
continue;
}
static constexpr SkColor kBackground = SK_ColorWHITE;
- sk_sp<SkSurface> surf = SkSurface::MakeRasterN32Premul(iBounds.width() + 16,
- iBounds.height() + 16);
+ sk_sp<SkSurface> surf = SkSurfaces::Raster(
+ SkImageInfo::MakeN32Premul(iBounds.width() + 16, iBounds.height() + 16));
SkCanvas* canvas = surf->getCanvas();
canvas->translate(8.0f - iBounds.x(), 8.0f - iBounds.y());
canvas->clear(kBackground);
diff --git a/tools/debugger/DebugLayerManager.cpp b/tools/debugger/DebugLayerManager.cpp
index d3a7405..355e622 100644
--- a/tools/debugger/DebugLayerManager.cpp
+++ b/tools/debugger/DebugLayerManager.cpp
@@ -107,8 +107,8 @@
// the color type and alpha type are chosen here to match wasm-skp-debugger/cpu.js which was
// chosen to match the capabilities of HTML canvas, which this ultimately has to be drawn into.
// TODO(nifong): introduce a method of letting the user choose the backend for this.
- auto surface = SkSurface::MakeRaster(SkImageInfo::Make(drawEvent.layerBounds,
- kRGBA_8888_SkColorType, kUnpremul_SkAlphaType, nullptr));
+ auto surface = SkSurfaces::Raster(SkImageInfo::Make(
+ drawEvent.layerBounds, kRGBA_8888_SkColorType, kUnpremul_SkAlphaType, nullptr));
// draw everything from the last full redraw up to the current frame.
// other frames drawn are partial, meaning they were clipped to not completely cover the layer.
// count back up with i
diff --git a/tools/fiddle/draw.cpp b/tools/fiddle/draw.cpp
index e0db50b..a33e753 100644
--- a/tools/fiddle/draw.cpp
+++ b/tools/fiddle/draw.cpp
@@ -9,6 +9,7 @@
// assembled by the fiddler program to compile into a fiddle: an
// implementation of the GetDrawOptions() and draw() functions.
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "tools/fiddle/fiddle_main.h"
#include "tools/gpu/ManagedBackendTexture.h"
@@ -38,19 +39,20 @@
nullptr);
constexpr int kSampleCnt = 0;
- sk_sp<SkSurface> tmp2 = SkSurface::MakeFromBackendTexture(
- dContext,
- backEndTextureRenderTarget,
- kTopLeft_GrSurfaceOrigin,
- kSampleCnt,
- kRGBA_8888_SkColorType,
- nullptr, nullptr);
+ sk_sp<SkSurface> tmp2 = SkSurfaces::WrapBackendTexture(dContext,
+ backEndTextureRenderTarget,
+ kTopLeft_GrSurfaceOrigin,
+ kSampleCnt,
+ kRGBA_8888_SkColorType,
+ nullptr,
+ nullptr);
// Note: this surface should only be renderable (i.e., not textureable)
- sk_sp<SkSurface> tmp3 = SkSurface::MakeFromBackendRenderTarget(dContext,
- backEndRenderTarget,
- kTopLeft_GrSurfaceOrigin,
- kRGBA_8888_SkColorType,
- nullptr, nullptr);
+ sk_sp<SkSurface> tmp3 = SkSurfaces::WrapBackendRenderTarget(dContext,
+ backEndRenderTarget,
+ kTopLeft_GrSurfaceOrigin,
+ kRGBA_8888_SkColorType,
+ nullptr,
+ nullptr);
}
}
diff --git a/tools/fiddle/fiddle_main.cpp b/tools/fiddle/fiddle_main.cpp
index ad8a338..1a3ac9f 100644
--- a/tools/fiddle/fiddle_main.cpp
+++ b/tools/fiddle/fiddle_main.cpp
@@ -24,6 +24,7 @@
#include "include/encode/SkPngEncoder.h"
#include "include/gpu/GrBackendSurface.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "src/gpu/ganesh/GrDirectContextPriv.h"
#include "src/gpu/ganesh/GrGpu.h"
#include "src/gpu/ganesh/GrRenderTarget.h"
@@ -270,7 +271,7 @@
SkImageInfo info = SkImageInfo::Make(options.size.width(), options.size.height(), colorType,
kPremul_SkAlphaType, colorSpace);
if (options.raster) {
- auto rasterSurface = SkSurface::MakeRaster(info);
+ auto rasterSurface = SkSurfaces::Raster(info);
srand(0);
draw(prepare_canvas(rasterSurface->getCanvas()));
rasterData = encode_snapshot(nullptr, rasterSurface);
@@ -287,7 +288,7 @@
exit(1);
}
- auto surface = SkSurface::MakeRenderTarget(direct.get(), skgpu::Budgeted::kNo, info);
+ auto surface = SkSurfaces::RenderTarget(direct.get(), skgpu::Budgeted::kNo, info);
if (!surface) {
fputs("Unable to get render surface.\n", stderr);
exit(1);
diff --git a/tools/fm/fm.cpp b/tools/fm/fm.cpp
index 84a3712..596e41e 100644
--- a/tools/fm/fm.cpp
+++ b/tools/fm/fm.cpp
@@ -11,6 +11,7 @@
#include "include/docs/SkPDFDocument.h"
#include "include/gpu/GrContextOptions.h"
#include "include/gpu/GrDirectContext.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "src/core/SkColorSpacePriv.h"
#include "src/core/SkMD5.h"
#include "src/core/SkOSFile.h"
@@ -254,7 +255,7 @@
static sk_sp<SkImage> draw_with_cpu(std::function<bool(SkCanvas*)> draw,
SkImageInfo info) {
- if (sk_sp<SkSurface> surface = SkSurface::MakeRaster(info)) {
+ if (sk_sp<SkSurface> surface = SkSurfaces::Raster(info)) {
if (draw(surface->getCanvas())) {
return surface->makeImageSnapshot();
}
@@ -319,7 +320,7 @@
switch (surfaceType) {
case SurfaceType::kDefault:
- surface = SkSurface::MakeRenderTarget(
+ surface = SkSurfaces::RenderTarget(
context, skgpu::Budgeted::kNo, info, FLAGS_samples, &props);
break;
diff --git a/tools/fonts/TestSVGTypeface.cpp b/tools/fonts/TestSVGTypeface.cpp
index 5b524a4..fc14042 100644
--- a/tools/fonts/TestSVGTypeface.cpp
+++ b/tools/fonts/TestSVGTypeface.cpp
@@ -850,7 +850,7 @@
continue;
}
SkImageInfo image_info = SkImageInfo::MakeN32Premul(ibounds.width(), ibounds.height());
- sk_sp<SkSurface> surface(SkSurface::MakeRaster(image_info));
+ sk_sp<SkSurface> surface(SkSurfaces::Raster(image_info));
SkASSERT(surface);
SkCanvas* canvas = surface->getCanvas();
canvas->clear(0);
@@ -1072,7 +1072,7 @@
continue;
}
SkImageInfo image_info = SkImageInfo::MakeN32Premul(ibounds.width(), ibounds.height());
- sk_sp<SkSurface> surface(SkSurface::MakeRaster(image_info));
+ sk_sp<SkSurface> surface(SkSurfaces::Raster(image_info));
SkASSERT(surface);
SkCanvas* canvas = surface->getCanvas();
canvas->clear(0);
diff --git a/tools/gpu/BackendSurfaceFactory.cpp b/tools/gpu/BackendSurfaceFactory.cpp
index 790a8ca..0855251 100644
--- a/tools/gpu/BackendSurfaceFactory.cpp
+++ b/tools/gpu/BackendSurfaceFactory.cpp
@@ -9,6 +9,7 @@
#include "include/core/SkSurface.h"
#include "include/gpu/GrDirectContext.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "src/gpu/ganesh/GrDirectContextPriv.h"
#include "src/gpu/ganesh/GrGpu.h"
#include "tools/gpu/ManagedBackendTexture.h"
@@ -35,15 +36,15 @@
if (!mbet) {
return nullptr;
}
- return SkSurface::MakeFromBackendTexture(dContext,
- mbet->texture(),
- origin,
- sampleCnt,
- ii.colorType(),
- ii.refColorSpace(),
- props,
- ManagedBackendTexture::ReleaseProc,
- mbet->releaseContext());
+ return SkSurfaces::WrapBackendTexture(dContext,
+ mbet->texture(),
+ origin,
+ sampleCnt,
+ ii.colorType(),
+ ii.refColorSpace(),
+ props,
+ ManagedBackendTexture::ReleaseProc,
+ mbet->releaseContext());
}
sk_sp<SkSurface> MakeBackendTextureSurface(GrDirectContext* dContext,
@@ -88,7 +89,7 @@
delete rc;
};
- return SkSurface::MakeFromBackendRenderTarget(
+ return SkSurfaces::WrapBackendRenderTarget(
dContext, bert, origin, ii.colorType(), ii.refColorSpace(), props, proc, rc);
}
diff --git a/tools/gpu/YUVUtils.cpp b/tools/gpu/YUVUtils.cpp
index d3c5177..a11935d 100644
--- a/tools/gpu/YUVUtils.cpp
+++ b/tools/gpu/YUVUtils.cpp
@@ -16,6 +16,7 @@
#include "include/gpu/GrRecordingContext.h"
#include "include/gpu/GrYUVABackendTextures.h"
#include "include/gpu/ganesh/SkImageGanesh.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "src/codec/SkCodecImageGenerator.h"
#include "src/core/SkYUVAInfoLocation.h"
#include "src/core/SkYUVMath.h"
@@ -164,9 +165,9 @@
SkImageInfo info = SkImageInfo::MakeA8(dims[i]);
sk_sp<SkSurface> surf;
if (rContext) {
- surf = SkSurface::MakeRenderTarget(rContext, skgpu::Budgeted::kYes, info, 1, nullptr);
+ surf = SkSurfaces::RenderTarget(rContext, skgpu::Budgeted::kYes, info, 1, nullptr);
} else {
- surf = SkSurface::MakeRaster(info);
+ surf = SkSurfaces::Raster(info);
}
if (!surf) {
return {};
diff --git a/tools/imgcvt.cpp b/tools/imgcvt.cpp
index ea1285f..60086c3 100644
--- a/tools/imgcvt.cpp
+++ b/tools/imgcvt.cpp
@@ -141,7 +141,7 @@
}
{ // transform with writePixels()
- sk_sp<SkSurface> surface = SkSurface::MakeRaster(pixmap.info().makeColorSpace(dst_cs));
+ sk_sp<SkSurface> surface = SkSurfaces::Raster(pixmap.info().makeColorSpace(dst_cs));
if (!surface) {
SkDebugf("couldn't create a surface\n");
return 1;
@@ -153,7 +153,7 @@
}
{ // transform by drawing
- sk_sp<SkSurface> surface = SkSurface::MakeRaster(pixmap.info().makeColorSpace(dst_cs));
+ sk_sp<SkSurface> surface = SkSurfaces::Raster(pixmap.info().makeColorSpace(dst_cs));
if (!surface) {
SkDebugf("couldn't create a surface\n");
return 1;
diff --git a/tools/rewrite_includes.py b/tools/rewrite_includes.py
index 9df0621..788bd5b 100755
--- a/tools/rewrite_includes.py
+++ b/tools/rewrite_includes.py
@@ -46,6 +46,8 @@
# Some node_modules/ files (used by CanvasKit et al) have c++ code which we should ignore.
'node_modules',
'include/third_party/skcms',
+ # Used by Jetski and Graphite
+ 'Surface.h',
# Temporary shims
'SkEncodedImageFormat.h',
'SkICC.h',
diff --git a/tools/sk_app/DawnWindowContext.cpp b/tools/sk_app/DawnWindowContext.cpp
index e609a77..fc66c3c 100644
--- a/tools/sk_app/DawnWindowContext.cpp
+++ b/tools/sk_app/DawnWindowContext.cpp
@@ -4,12 +4,13 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
+#include "tools/sk_app/DawnWindowContext.h"
#include "include/core/SkSurface.h"
#include "include/gpu/GrBackendSurface.h"
#include "include/gpu/GrDirectContext.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "src/base/SkAutoMalloc.h"
-#include "tools/sk_app/DawnWindowContext.h"
#include "dawn/dawn_proc.h"
@@ -86,12 +87,12 @@
rtInfo.fLevelCount = 1; // FIXME
GrBackendRenderTarget backendRenderTarget(fWidth, fHeight, fDisplayParams.fMSAASampleCount, 8,
rtInfo);
- fSurface = SkSurface::MakeFromBackendRenderTarget(fContext.get(),
- backendRenderTarget,
- this->getRTOrigin(),
- fDisplayParams.fColorType,
- fDisplayParams.fColorSpace,
- &fDisplayParams.fSurfaceProps);
+ fSurface = SkSurfaces::WrapBackendRenderTarget(fContext.get(),
+ backendRenderTarget,
+ this->getRTOrigin(),
+ fDisplayParams.fColorType,
+ fDisplayParams.fColorSpace,
+ &fDisplayParams.fSurfaceProps);
return fSurface;
}
diff --git a/tools/sk_app/GLWindowContext.cpp b/tools/sk_app/GLWindowContext.cpp
index b6ed6f5..0548710 100644
--- a/tools/sk_app/GLWindowContext.cpp
+++ b/tools/sk_app/GLWindowContext.cpp
@@ -5,18 +5,19 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
+#include "tools/sk_app/GLWindowContext.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkSurface.h"
#include "include/gpu/GrBackendSurface.h"
#include "include/gpu/GrDirectContext.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "src/base/SkMathPriv.h"
#include "src/gpu/ganesh/GrCaps.h"
#include "src/gpu/ganesh/GrDirectContextPriv.h"
#include "src/gpu/ganesh/gl/GrGLDefines_impl.h"
#include "src/gpu/ganesh/gl/GrGLUtil.h"
#include "src/image/SkImage_Base.h"
-#include "tools/sk_app/GLWindowContext.h"
namespace sk_app {
@@ -70,11 +71,12 @@
fStencilBits,
fbInfo);
- fSurface = SkSurface::MakeFromBackendRenderTarget(fContext.get(), backendRT,
- kBottomLeft_GrSurfaceOrigin,
- kRGBA_8888_SkColorType,
- fDisplayParams.fColorSpace,
- &fDisplayParams.fSurfaceProps);
+ fSurface = SkSurfaces::WrapBackendRenderTarget(fContext.get(),
+ backendRT,
+ kBottomLeft_GrSurfaceOrigin,
+ kRGBA_8888_SkColorType,
+ fDisplayParams.fColorSpace,
+ &fDisplayParams.fSurfaceProps);
}
}
diff --git a/tools/sk_app/GraphiteDawnWindowContext.cpp b/tools/sk_app/GraphiteDawnWindowContext.cpp
index 974f600..453df39 100644
--- a/tools/sk_app/GraphiteDawnWindowContext.cpp
+++ b/tools/sk_app/GraphiteDawnWindowContext.cpp
@@ -14,6 +14,7 @@
#include "include/gpu/graphite/GraphiteTypes.h"
#include "include/gpu/graphite/Recorder.h"
#include "include/gpu/graphite/Recording.h"
+#include "include/gpu/graphite/Surface.h"
#include "include/gpu/graphite/dawn/DawnBackendContext.h"
#include "include/gpu/graphite/dawn/DawnUtils.h"
#include "tools/ToolUtils.h"
@@ -85,12 +86,11 @@
info,
textureView.Get());
SkASSERT(this->graphiteRecorder());
- auto surface = SkSurface::MakeGraphiteFromBackendTexture(
- this->graphiteRecorder(),
- backendTex,
- kBGRA_8888_SkColorType,
- fDisplayParams.fColorSpace,
- &fDisplayParams.fSurfaceProps);
+ auto surface = SkSurfaces::WrapBackendTexture(this->graphiteRecorder(),
+ backendTex,
+ kBGRA_8888_SkColorType,
+ fDisplayParams.fColorSpace,
+ &fDisplayParams.fSurfaceProps);
SkASSERT(surface);
return surface;
}
diff --git a/tools/sk_app/GraphiteMetalWindowContext.mm b/tools/sk_app/GraphiteMetalWindowContext.mm
index 54279d1..9d5fe14 100644
--- a/tools/sk_app/GraphiteMetalWindowContext.mm
+++ b/tools/sk_app/GraphiteMetalWindowContext.mm
@@ -5,18 +5,19 @@
* found in the LICENSE file.
*/
-#include "include/core/SkSurface.h"
-#include "src/base/SkMathPriv.h"
#include "tools/sk_app/GraphiteMetalWindowContext.h"
+#include "include/core/SkSurface.h"
#include "include/gpu/graphite/BackendTexture.h"
#include "include/gpu/graphite/Context.h"
#include "include/gpu/graphite/ContextOptions.h"
#include "include/gpu/graphite/Recorder.h"
#include "include/gpu/graphite/Recording.h"
+#include "include/gpu/graphite/Surface.h"
#include "include/gpu/graphite/mtl/MtlBackendContext.h"
#include "include/gpu/graphite/mtl/MtlGraphiteTypes.h"
#include "include/gpu/graphite/mtl/MtlGraphiteUtils.h"
+#include "src/base/SkMathPriv.h"
#include "tools/ToolUtils.h"
using sk_app::DisplayParams;
@@ -90,11 +91,11 @@
skgpu::graphite::BackendTexture backendTex(this->dimensions(),
(skgpu::graphite::MtlHandle)currentDrawable.texture);
- surface = SkSurface::MakeGraphiteFromBackendTexture(this->graphiteRecorder(),
- backendTex,
- kBGRA_8888_SkColorType,
- fDisplayParams.fColorSpace,
- &fDisplayParams.fSurfaceProps);
+ surface = SkSurfaces::WrapBackendTexture(this->graphiteRecorder(),
+ backendTex,
+ kBGRA_8888_SkColorType,
+ fDisplayParams.fColorSpace,
+ &fDisplayParams.fSurfaceProps);
fDrawableHandle = CFRetain((skgpu::graphite::MtlHandle) currentDrawable);
diff --git a/tools/sk_app/MetalWindowContext.mm b/tools/sk_app/MetalWindowContext.mm
index 9ed1b95..509e2dc 100644
--- a/tools/sk_app/MetalWindowContext.mm
+++ b/tools/sk_app/MetalWindowContext.mm
@@ -5,17 +5,20 @@
* found in the LICENSE file.
*/
+#include "tools/sk_app/MetalWindowContext.h"
+
#include "include/core/SkCanvas.h"
#include "include/core/SkSurface.h"
#include "include/gpu/GrBackendSurface.h"
#include "include/gpu/GrDirectContext.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
+#include "include/gpu/ganesh/mtl/SkSurfaceMetal.h"
#include "include/gpu/mtl/GrMtlBackendContext.h"
#include "include/gpu/mtl/GrMtlTypes.h"
#include "src/base/SkMathPriv.h"
#include "src/gpu/ganesh/GrCaps.h"
#include "src/gpu/ganesh/GrDirectContextPriv.h"
#include "src/image/SkImage_Base.h"
-#include "tools/sk_app/MetalWindowContext.h"
using sk_app::DisplayParams;
using sk_app::MetalWindowContext;
@@ -120,13 +123,14 @@
sk_sp<SkSurface> surface;
if (fContext) {
if (fDisplayParams.fDelayDrawableAcquisition) {
- surface = SkSurface::MakeFromCAMetalLayer(fContext.get(),
- (__bridge GrMTLHandle)fMetalLayer,
- kTopLeft_GrSurfaceOrigin, fSampleCount,
- kBGRA_8888_SkColorType,
- fDisplayParams.fColorSpace,
- &fDisplayParams.fSurfaceProps,
- &fDrawableHandle);
+ surface = SkSurfaces::WrapCAMetalLayer(fContext.get(),
+ (__bridge GrMTLHandle)fMetalLayer,
+ kTopLeft_GrSurfaceOrigin,
+ fSampleCount,
+ kBGRA_8888_SkColorType,
+ fDisplayParams.fColorSpace,
+ &fDisplayParams.fSurfaceProps,
+ &fDrawableHandle);
} else {
id<CAMetalDrawable> currentDrawable = [fMetalLayer nextDrawable];
@@ -138,11 +142,12 @@
fSampleCount,
fbInfo);
- surface = SkSurface::MakeFromBackendRenderTarget(fContext.get(), backendRT,
- kTopLeft_GrSurfaceOrigin,
- kBGRA_8888_SkColorType,
- fDisplayParams.fColorSpace,
- &fDisplayParams.fSurfaceProps);
+ surface = SkSurfaces::WrapBackendRenderTarget(fContext.get(),
+ backendRT,
+ kTopLeft_GrSurfaceOrigin,
+ kBGRA_8888_SkColorType,
+ fDisplayParams.fColorSpace,
+ &fDisplayParams.fSurfaceProps);
fDrawableHandle = CFRetain((GrMTLHandle) currentDrawable);
}
diff --git a/tools/sk_app/VulkanWindowContext.cpp b/tools/sk_app/VulkanWindowContext.cpp
index 026905d..d3f1245 100644
--- a/tools/sk_app/VulkanWindowContext.cpp
+++ b/tools/sk_app/VulkanWindowContext.cpp
@@ -12,10 +12,10 @@
#include "include/gpu/GrBackendSemaphore.h"
#include "include/gpu/GrBackendSurface.h"
#include "include/gpu/GrDirectContext.h"
-#include "src/base/SkAutoMalloc.h"
-
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "include/gpu/vk/GrVkTypes.h"
#include "include/gpu/vk/VulkanExtensions.h"
+#include "src/base/SkAutoMalloc.h"
#include "src/gpu/ganesh/vk/GrVkImage.h"
#include "src/gpu/ganesh/vk/GrVkUtil.h"
#include "src/gpu/vk/VulkanInterface.h"
@@ -357,19 +357,24 @@
if (usageFlags & VK_IMAGE_USAGE_SAMPLED_BIT) {
GrBackendTexture backendTexture(fWidth, fHeight, info);
- fSurfaces[i] = SkSurface::MakeFromBackendTexture(
- fContext.get(), backendTexture, kTopLeft_GrSurfaceOrigin,
- fDisplayParams.fMSAASampleCount,
- colorType, fDisplayParams.fColorSpace, &fDisplayParams.fSurfaceProps);
+ fSurfaces[i] = SkSurfaces::WrapBackendTexture(fContext.get(),
+ backendTexture,
+ kTopLeft_GrSurfaceOrigin,
+ fDisplayParams.fMSAASampleCount,
+ colorType,
+ fDisplayParams.fColorSpace,
+ &fDisplayParams.fSurfaceProps);
} else {
if (fDisplayParams.fMSAASampleCount > 1) {
return false;
}
GrBackendRenderTarget backendRT(fWidth, fHeight, fSampleCount, info);
- fSurfaces[i] = SkSurface::MakeFromBackendRenderTarget(
- fContext.get(), backendRT, kTopLeft_GrSurfaceOrigin, colorType,
- fDisplayParams.fColorSpace, &fDisplayParams.fSurfaceProps);
-
+ fSurfaces[i] = SkSurfaces::WrapBackendRenderTarget(fContext.get(),
+ backendRT,
+ kTopLeft_GrSurfaceOrigin,
+ colorType,
+ fDisplayParams.fColorSpace,
+ &fDisplayParams.fSurfaceProps);
}
if (!fSurfaces[i]) {
return false;
diff --git a/tools/sk_app/android/RasterWindowContext_android.cpp b/tools/sk_app/android/RasterWindowContext_android.cpp
index 7448dc8..09b0a0b 100644
--- a/tools/sk_app/android/RasterWindowContext_android.cpp
+++ b/tools/sk_app/android/RasterWindowContext_android.cpp
@@ -78,8 +78,8 @@
fDisplayParams.fColorType,
kPremul_SkAlphaType,
fDisplayParams.fColorSpace);
- fBackbufferSurface = SkSurface::MakeRasterDirect(
- info, fBuffer.bits, fBuffer.stride * bytePerPixel, nullptr);
+ fBackbufferSurface =
+ SkSurfaces::WrapPixels(info, fBuffer.bits, fBuffer.stride * bytePerPixel, nullptr);
}
return fBackbufferSurface;
}
diff --git a/tools/sk_app/ios/RasterWindowContext_ios.mm b/tools/sk_app/ios/RasterWindowContext_ios.mm
index 2535465..88014f6 100644
--- a/tools/sk_app/ios/RasterWindowContext_ios.mm
+++ b/tools/sk_app/ios/RasterWindowContext_ios.mm
@@ -140,7 +140,7 @@
// make the offscreen image
SkImageInfo info = SkImageInfo::Make(fWidth, fHeight, fDisplayParams.fColorType,
kPremul_SkAlphaType, fDisplayParams.fColorSpace);
- fBackbufferSurface = SkSurface::MakeRaster(info);
+ fBackbufferSurface = SkSurfaces::Raster(info);
return GrGLMakeNativeInterface();
}
diff --git a/tools/sk_app/mac/RasterWindowContext_mac.mm b/tools/sk_app/mac/RasterWindowContext_mac.mm
index aa46526..9a1f447 100644
--- a/tools/sk_app/mac/RasterWindowContext_mac.mm
+++ b/tools/sk_app/mac/RasterWindowContext_mac.mm
@@ -144,7 +144,7 @@
// make the offscreen image
SkImageInfo info = SkImageInfo::Make(fWidth, fHeight, fDisplayParams.fColorType,
kPremul_SkAlphaType, fDisplayParams.fColorSpace);
- fBackbufferSurface = SkSurface::MakeRaster(info);
+ fBackbufferSurface = SkSurfaces::Raster(info);
return GrGLMakeNativeInterface();
}
diff --git a/tools/sk_app/unix/RasterWindowContext_unix.cpp b/tools/sk_app/unix/RasterWindowContext_unix.cpp
index 0033493..270234e 100644
--- a/tools/sk_app/unix/RasterWindowContext_unix.cpp
+++ b/tools/sk_app/unix/RasterWindowContext_unix.cpp
@@ -53,8 +53,7 @@
void RasterWindowContext_xlib::resize(int w, int h) {
SkImageInfo info = SkImageInfo::Make(w, h, fDisplayParams.fColorType, kPremul_SkAlphaType,
fDisplayParams.fColorSpace);
- fBackbufferSurface = SkSurface::MakeRaster(info, &fDisplayParams.fSurfaceProps);
-
+ fBackbufferSurface = SkSurfaces::Raster(info, &fDisplayParams.fSurfaceProps);
}
sk_sp<SkSurface> RasterWindowContext_xlib::getBackbufferSurface() { return fBackbufferSurface; }
diff --git a/tools/sk_app/win/D3D12WindowContext_win.cpp b/tools/sk_app/win/D3D12WindowContext_win.cpp
index aff2454..5b08922 100644
--- a/tools/sk_app/win/D3D12WindowContext_win.cpp
+++ b/tools/sk_app/win/D3D12WindowContext_win.cpp
@@ -5,14 +5,13 @@
* found in the LICENSE file.
*/
-#include "tools/sk_app/WindowContext.h"
-#include "tools/sk_app/win/WindowContextFactory_win.h"
-
-#include "tools/gpu/d3d/D3DTestUtils.h"
-
#include "include/core/SkSurface.h"
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/d3d/GrD3DBackendContext.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
+#include "tools/gpu/d3d/D3DTestUtils.h"
+#include "tools/sk_app/WindowContext.h"
+#include "tools/sk_app/win/WindowContextFactory_win.h"
#include <d3d12.h>
#include <dxgi1_4.h>
@@ -153,14 +152,21 @@
info.fResource = fBuffers[i];
if (fSampleCount > 1) {
GrBackendTexture backendTexture(width, height, info);
- fSurfaces[i] = SkSurface::MakeFromBackendTexture(
- fContext.get(), backendTexture, kTopLeft_GrSurfaceOrigin, fSampleCount,
- kRGBA_8888_SkColorType, fDisplayParams.fColorSpace, &fDisplayParams.fSurfaceProps);
+ fSurfaces[i] = SkSurfaces::WrapBackendTexture(fContext.get(),
+ backendTexture,
+ kTopLeft_GrSurfaceOrigin,
+ fSampleCount,
+ kRGBA_8888_SkColorType,
+ fDisplayParams.fColorSpace,
+ &fDisplayParams.fSurfaceProps);
} else {
GrBackendRenderTarget backendRT(width, height, info);
- fSurfaces[i] = SkSurface::MakeFromBackendRenderTarget(
- fContext.get(), backendRT, kTopLeft_GrSurfaceOrigin, kRGBA_8888_SkColorType,
- fDisplayParams.fColorSpace, &fDisplayParams.fSurfaceProps);
+ fSurfaces[i] = SkSurfaces::WrapBackendRenderTarget(fContext.get(),
+ backendRT,
+ kTopLeft_GrSurfaceOrigin,
+ kRGBA_8888_SkColorType,
+ fDisplayParams.fColorSpace,
+ &fDisplayParams.fSurfaceProps);
}
}
}
diff --git a/tools/sk_app/win/RasterWindowContext_win.cpp b/tools/sk_app/win/RasterWindowContext_win.cpp
index 49f3591..e93a8e6 100644
--- a/tools/sk_app/win/RasterWindowContext_win.cpp
+++ b/tools/sk_app/win/RasterWindowContext_win.cpp
@@ -67,7 +67,7 @@
SkImageInfo info = SkImageInfo::Make(w, h, fDisplayParams.fColorType, kPremul_SkAlphaType,
fDisplayParams.fColorSpace);
- fBackbufferSurface = SkSurface::MakeRasterDirect(info, pixels, sizeof(uint32_t) * w);
+ fBackbufferSurface = SkSurfaces::WrapPixels(info, pixels, sizeof(uint32_t) * w);
}
sk_sp<SkSurface> RasterWindowContext_win::getBackbufferSurface() { return fBackbufferSurface; }
diff --git a/tools/skiaserve/Request.cpp b/tools/skiaserve/Request.cpp
index 4fa4c93..6616def 100644
--- a/tools/skiaserve/Request.cpp
+++ b/tools/skiaserve/Request.cpp
@@ -13,6 +13,7 @@
#include "include/core/SkColorSpace.h"
#include "include/core/SkPictureRecorder.h"
#include "include/gpu/GrDirectContext.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "src/utils/SkJSONWriter.h"
#include "tools/ToolUtils.h"
#include "tools/debugger/DrawCommand.h"
@@ -151,7 +152,7 @@
: SkColorSpace::MakeSRGB();
SkImageInfo info = SkImageInfo::Make(bounds.size(), cap.fColorType, kPremul_SkAlphaType,
cap.fSRGB ? colorSpace : nullptr);
- return SkSurface::MakeRaster(info).release();
+ return SkSurfaces::Raster(info).release();
}
SkSurface* Request::createGPUSurface() {
@@ -163,7 +164,7 @@
: SkColorSpace::MakeSRGB();
SkImageInfo info = SkImageInfo::Make(bounds.size(), cap.fColorType, kPremul_SkAlphaType,
cap.fSRGB ? colorSpace : nullptr);
- SkSurface* surface = SkSurface::MakeRenderTarget(context, skgpu::Budgeted::kNo, info).release();
+ SkSurface* surface = SkSurfaces::RenderTarget(context, skgpu::Budgeted::kNo, info).release();
return surface;
}
diff --git a/tools/skottie2movie.cpp b/tools/skottie2movie.cpp
index a1faadc..dec7e14 100644
--- a/tools/skottie2movie.cpp
+++ b/tools/skottie2movie.cpp
@@ -20,6 +20,7 @@
#include "tools/gpu/GrContextFactory.h"
#include "include/gpu/GrContextOptions.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
static DEFINE_string2(input, i, "", "skottie animation to render");
static DEFINE_string2(output, o, "", "mp4 file to create");
@@ -110,18 +111,18 @@
if (!surf) {
if (FLAGS_gpu) {
grctx = factory.getContextInfo(contextType).directContext();
- surf = SkSurface::MakeRenderTarget(grctx,
- skgpu::Budgeted::kNo,
- info,
- 0,
- GrSurfaceOrigin::kTopLeft_GrSurfaceOrigin,
- nullptr);
+ surf = SkSurfaces::RenderTarget(grctx,
+ skgpu::Budgeted::kNo,
+ info,
+ 0,
+ GrSurfaceOrigin::kTopLeft_GrSurfaceOrigin,
+ nullptr);
if (!surf) {
grctx = nullptr;
}
}
if (!surf) {
- surf = SkSurface::MakeRaster(info);
+ surf = SkSurfaces::Raster(info);
}
surf->getCanvas()->scale(scale, scale);
}
diff --git a/tools/skottie_ios_app/SkMetalViewBridge.mm b/tools/skottie_ios_app/SkMetalViewBridge.mm
index 31889b3..975eb94 100644
--- a/tools/skottie_ios_app/SkMetalViewBridge.mm
+++ b/tools/skottie_ios_app/SkMetalViewBridge.mm
@@ -9,6 +9,7 @@
#include "include/gpu/GrBackendSurface.h"
#include "include/gpu/GrContextOptions.h"
#include "include/gpu/GrDirectContext.h"
+#include "include/gpu/ganesh/mtl/SkSurfaceMetal.h"
#include "include/gpu/mtl/GrMtlTypes.h"
#import <Metal/Metal.h>
@@ -27,8 +28,13 @@
const SkSurfaceProps surfaceProps;
int sampleCount = (int)[mtkView sampleCount];
- return SkSurface::MakeFromMTKView(rContext, (__bridge GrMTLHandle)mtkView, origin, sampleCount,
- colorType, colorSpace, &surfaceProps);
+ return SkSurfaces::WrapMTKView(rContext,
+ (__bridge GrMTLHandle)mtkView,
+ origin,
+ sampleCount,
+ colorType,
+ colorSpace,
+ &surfaceProps);
}
GrContextHolder SkMetalDeviceToGrContext(id<MTLDevice> device, id<MTLCommandQueue> queue) {
diff --git a/tools/skottie_ios_app/SkiaGLContext.mm b/tools/skottie_ios_app/SkiaGLContext.mm
index 00e1625..a4f31f7 100644
--- a/tools/skottie_ios_app/SkiaGLContext.mm
+++ b/tools/skottie_ios_app/SkiaGLContext.mm
@@ -8,6 +8,7 @@
#include "include/core/SkTime.h"
#include "include/gpu/GrBackendSurface.h"
#include "include/gpu/GrDirectContext.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "include/gpu/gl/GrGLInterface.h"
#include "include/gpu/gl/GrGLTypes.h"
@@ -32,7 +33,7 @@
}
GLint fboid = 0;
glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &fboid);
- return SkSurface::MakeFromBackendRenderTarget(
+ return SkSurfaces::WrapBackendRenderTarget(
dContext,
GrBackendRenderTarget(width,
height,
diff --git a/tools/skpbench/skpbench.cpp b/tools/skpbench/skpbench.cpp
index 2b9f216..ff11cff 100644
--- a/tools/skpbench/skpbench.cpp
+++ b/tools/skpbench/skpbench.cpp
@@ -16,6 +16,7 @@
#include "include/core/SkSurfaceProps.h"
#include "include/effects/SkPerlinNoiseShader.h"
#include "include/gpu/GrDirectContext.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "src/core/SkOSFile.h"
#include "src/core/SkTaskGroup.h"
#include "src/gpu/ganesh/GrCaps.h"
@@ -599,8 +600,8 @@
SkImageInfo info = SkImageInfo::Make(
width, height, config->getColorType(), config->getAlphaType(), config->refColorSpace());
SkSurfaceProps props(config->getSurfaceFlags(), kRGB_H_SkPixelGeometry);
- sk_sp<SkSurface> surface = SkSurface::MakeRenderTarget(
- ctx, skgpu::Budgeted::kNo, info, config->getSamples(), &props);
+ sk_sp<SkSurface> surface =
+ SkSurfaces::RenderTarget(ctx, skgpu::Budgeted::kNo, info, config->getSamples(), &props);
if (!surface) {
exitf(ExitErr::kUnavailable, "failed to create %ix%i render target for config %s",
width, height, config->getTag().c_str());
diff --git a/tools/viewer/AtlasSlide.cpp b/tools/viewer/AtlasSlide.cpp
index 6588b22..548596b 100644
--- a/tools/viewer/AtlasSlide.cpp
+++ b/tools/viewer/AtlasSlide.cpp
@@ -44,7 +44,7 @@
static sk_sp<SkImage> make_atlas(int atlasSize, int cellSize) {
SkImageInfo info = SkImageInfo::MakeN32Premul(atlasSize, atlasSize);
- auto surface(SkSurface::MakeRaster(info));
+ auto surface(SkSurfaces::Raster(info));
SkCanvas* canvas = surface->getCanvas();
SkPaint paint;
diff --git a/tools/viewer/FatBitsSlide.cpp b/tools/viewer/FatBitsSlide.cpp
index 9c9a0fd..3bcdda5 100644
--- a/tools/viewer/FatBitsSlide.cpp
+++ b/tools/viewer/FatBitsSlide.cpp
@@ -109,9 +109,9 @@
fShader = fShader0;
SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
- fMinSurface = SkSurface::MakeRaster(info);
+ fMinSurface = SkSurfaces::Raster(info);
info = info.makeWH(width * zoom, height * zoom);
- fMaxSurface = SkSurface::MakeRaster(info);
+ fMaxSurface = SkSurfaces::Raster(info);
}
void drawBG(SkCanvas*);
diff --git a/tools/viewer/QuadStrokerSlide.cpp b/tools/viewer/QuadStrokerSlide.cpp
index 176e5e8..e97b2b1 100644
--- a/tools/viewer/QuadStrokerSlide.cpp
+++ b/tools/viewer/QuadStrokerSlide.cpp
@@ -488,9 +488,9 @@
fShader = ToolUtils::create_checkerboard_shader(0xFFCCCCCC, 0xFFFFFFFF, zoom);
SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
- fMinSurface = SkSurface::MakeRaster(info);
+ fMinSurface = SkSurfaces::Raster(info);
info = info.makeWH(width * zoom, height * zoom);
- fMaxSurface = SkSurface::MakeRaster(info);
+ fMaxSurface = SkSurfaces::Raster(info);
}
void draw_points(SkCanvas* canvas, const SkPath& path, SkColor color,
diff --git a/tools/viewer/TextureUploadSlide.cpp b/tools/viewer/TextureUploadSlide.cpp
index bb58ee3..c8eb9b7 100644
--- a/tools/viewer/TextureUploadSlide.cpp
+++ b/tools/viewer/TextureUploadSlide.cpp
@@ -10,6 +10,7 @@
#include "include/core/SkSurface.h"
#include "include/core/SkTypes.h"
#include "include/gpu/GrDirectContext.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "tools/timer/TimeUtils.h"
#include "tools/viewer/Slide.h"
@@ -92,7 +93,7 @@
SkSurfaceProps surfaceProps(0, kRGB_H_SkPixelGeometry);
SkImageInfo imageInfo = SkImageInfo::Make(size, size, kRGBA_8888_SkColorType,
kPremul_SkAlphaType);
- fSurface = SkSurface::MakeRenderTarget(
+ fSurface = SkSurfaces::RenderTarget(
direct, skgpu::Budgeted::kNo, imageInfo, 0, &surfaceProps);
}
@@ -130,7 +131,7 @@
SkScalar fActiveTileIndex = 0;
sk_sp<SkSurface> getFilledRasterSurface(SkColor color, int size) {
- sk_sp<SkSurface> surface(SkSurface::MakeRasterN32Premul(size, size));
+ sk_sp<SkSurface> surface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(size, size)));
SkCanvas* canvas = surface->getCanvas();
canvas->clear(color);
return surface;
diff --git a/tools/viewer/ThinAASlide.cpp b/tools/viewer/ThinAASlide.cpp
index ee24754..e5bef00 100644
--- a/tools/viewer/ThinAASlide.cpp
+++ b/tools/viewer/ThinAASlide.cpp
@@ -185,8 +185,7 @@
auto info = SkImageInfo::Make(fSupersampleFactor * kTileWidth,
fSupersampleFactor * kTileHeight,
kRGBA_8888_SkColorType, kPremul_SkAlphaType);
- auto surface = fForceRasterBackend ? SkSurface::MakeRaster(info)
- : canvas->makeSurface(info);
+ auto surface = fForceRasterBackend ? SkSurfaces::Raster(info) : canvas->makeSurface(info);
surface->getCanvas()->save();
// Make fully transparent so it is easy to determine pixels that are touched by partial cov.
diff --git a/tools/viewer/TimingSlide.cpp b/tools/viewer/TimingSlide.cpp
index b4188d9..66288e4 100644
--- a/tools/viewer/TimingSlide.cpp
+++ b/tools/viewer/TimingSlide.cpp
@@ -17,7 +17,7 @@
TimingSlide() { fName = "Timing";}
void load(SkScalar w, SkScalar h) override {
- sk_sp<SkSurface> surf = SkSurface::MakeRasterN32Premul(W,H);
+ sk_sp<SkSurface> surf = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(W, H));
surf->getCanvas()->drawString("abc", 2,H-4, SkFont{}, SkPaint{});
fImg = surf->makeImageSnapshot();
}
diff --git a/tools/viewer/Viewer.cpp b/tools/viewer/Viewer.cpp
index 4ea1eed..2cbac96 100644
--- a/tools/viewer/Viewer.cpp
+++ b/tools/viewer/Viewer.cpp
@@ -1627,8 +1627,8 @@
SkImageInfo info = SkImageInfo::Make(w, h, colorType, kPremul_SkAlphaType, colorSpace);
return Window::kRaster_BackendType == this->fBackendType
- ? SkSurface::MakeRaster(info, &props)
- : slideCanvas->makeSurface(info, &props);
+ ? SkSurfaces::Raster(info, &props)
+ : slideCanvas->makeSurface(info, &props);
};
// We need to render offscreen if we're...
diff --git a/tools/window/GLWindowContext.cpp b/tools/window/GLWindowContext.cpp
index c115fa4..4033f27 100644
--- a/tools/window/GLWindowContext.cpp
+++ b/tools/window/GLWindowContext.cpp
@@ -5,17 +5,18 @@
* found in the LICENSE file.
*/
+#include "tools/window/GLWindowContext.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkSurface.h"
#include "include/gpu/GrBackendSurface.h"
#include "include/gpu/GrDirectContext.h"
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "src/base/SkMathPriv.h"
#include "src/gpu/ganesh/GrCaps.h"
#include "src/gpu/ganesh/GrDirectContextPriv.h"
#include "src/gpu/ganesh/gl/GrGLDefines_impl.h"
#include "src/gpu/ganesh/gl/GrGLUtil.h"
#include "src/image/SkImage_Base.h"
-#include "tools/window/GLWindowContext.h"
namespace skwindow::internal {
@@ -69,11 +70,12 @@
fStencilBits,
fbInfo);
- fSurface = SkSurface::MakeFromBackendRenderTarget(fContext.get(), backendRT,
- kBottomLeft_GrSurfaceOrigin,
- kRGBA_8888_SkColorType,
- fDisplayParams.fColorSpace,
- &fDisplayParams.fSurfaceProps);
+ fSurface = SkSurfaces::WrapBackendRenderTarget(fContext.get(),
+ backendRT,
+ kBottomLeft_GrSurfaceOrigin,
+ kRGBA_8888_SkColorType,
+ fDisplayParams.fColorSpace,
+ &fDisplayParams.fSurfaceProps);
}
}
diff --git a/tools/window/VulkanWindowContext.cpp b/tools/window/VulkanWindowContext.cpp
index e37d86f..3a516a0 100644
--- a/tools/window/VulkanWindowContext.cpp
+++ b/tools/window/VulkanWindowContext.cpp
@@ -11,10 +11,10 @@
#include "include/gpu/GrBackendSemaphore.h"
#include "include/gpu/GrBackendSurface.h"
#include "include/gpu/GrDirectContext.h"
-#include "src/base/SkAutoMalloc.h"
-
+#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "include/gpu/vk/GrVkTypes.h"
#include "include/gpu/vk/VulkanExtensions.h"
+#include "src/base/SkAutoMalloc.h"
#include "src/gpu/ganesh/vk/GrVkImage.h"
#include "src/gpu/ganesh/vk/GrVkUtil.h"
#include "src/gpu/vk/VulkanInterface.h"
@@ -356,19 +356,24 @@
if (usageFlags & VK_IMAGE_USAGE_SAMPLED_BIT) {
GrBackendTexture backendTexture(fWidth, fHeight, info);
- fSurfaces[i] = SkSurface::MakeFromBackendTexture(
- fContext.get(), backendTexture, kTopLeft_GrSurfaceOrigin,
- fDisplayParams.fMSAASampleCount,
- colorType, fDisplayParams.fColorSpace, &fDisplayParams.fSurfaceProps);
+ fSurfaces[i] = SkSurfaces::WrapBackendTexture(fContext.get(),
+ backendTexture,
+ kTopLeft_GrSurfaceOrigin,
+ fDisplayParams.fMSAASampleCount,
+ colorType,
+ fDisplayParams.fColorSpace,
+ &fDisplayParams.fSurfaceProps);
} else {
if (fDisplayParams.fMSAASampleCount > 1) {
return false;
}
GrBackendRenderTarget backendRT(fWidth, fHeight, fSampleCount, info);
- fSurfaces[i] = SkSurface::MakeFromBackendRenderTarget(
- fContext.get(), backendRT, kTopLeft_GrSurfaceOrigin, colorType,
- fDisplayParams.fColorSpace, &fDisplayParams.fSurfaceProps);
-
+ fSurfaces[i] = SkSurfaces::WrapBackendRenderTarget(fContext.get(),
+ backendRT,
+ kTopLeft_GrSurfaceOrigin,
+ colorType,
+ fDisplayParams.fColorSpace,
+ &fDisplayParams.fSurfaceProps);
}
if (!fSurfaces[i]) {
return false;