diff options
author | reed <reed@google.com> | 2016-03-23 18:59:25 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-23 18:59:25 -0700 |
commit | e8f3062a36d3682f4019309a32b5b84dc9eddf8c (patch) | |
tree | ff5cd50c65edb6e3b77f77327165ad0162557137 /samplecode | |
parent | 041c870425eb0a3e2b0cbc46581b3da2f50571d9 (diff) |
switch surface to sk_sp
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1817383002
CQ_EXTRA_TRYBOTS=client.skia.compile:Build-Ubuntu-GCC-x86_64-Release-CMake-Trybot,Build-Mac-Clang-x86_64-Release-CMake-Trybot
Review URL: https://codereview.chromium.org/1817383002
Diffstat (limited to 'samplecode')
-rw-r--r-- | samplecode/SampleApp.cpp | 4 | ||||
-rw-r--r-- | samplecode/SampleAtlas.cpp | 2 | ||||
-rw-r--r-- | samplecode/SampleFatBits.cpp | 16 | ||||
-rw-r--r-- | samplecode/SampleFilterQuality.cpp | 16 | ||||
-rw-r--r-- | samplecode/SampleQuadStroker.cpp | 10 | ||||
-rw-r--r-- | samplecode/SampleTextureDomain.cpp | 2 |
6 files changed, 25 insertions, 25 deletions
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp index afd942bf1f..3149711d86 100644 --- a/samplecode/SampleApp.cpp +++ b/samplecode/SampleApp.cpp @@ -291,7 +291,7 @@ public: #if SK_SUPPORT_GPU if (IsGpuDeviceType(dType) && fCurContext) { SkSurfaceProps props(win->getSurfaceProps()); - return SkSurface::NewRenderTargetDirect(fCurRenderTarget, &props); + return SkSurface::MakeRenderTargetDirect(fCurRenderTarget, &props).release(); } #endif return nullptr; @@ -1066,7 +1066,7 @@ void SampleWindow::draw(SkCanvas* canvas) { const SkScalar w = SkScalarCeilToScalar(tile.width()); const SkScalar h = SkScalarCeilToScalar(tile.height()); SkImageInfo info = SkImageInfo::MakeN32Premul(SkScalarTruncToInt(w), SkScalarTruncToInt(h)); - SkAutoTUnref<SkSurface> surface(canvas->newSurface(info)); + auto surface(canvas->makeSurface(info)); SkCanvas* tileCanvas = surface->getCanvas(); for (SkScalar y = 0; y < height(); y += h) { diff --git a/samplecode/SampleAtlas.cpp b/samplecode/SampleAtlas.cpp index 1075f4d12e..3061b14281 100644 --- a/samplecode/SampleAtlas.cpp +++ b/samplecode/SampleAtlas.cpp @@ -41,7 +41,7 @@ static void draw_atlas_sim(SkCanvas* canvas, SkImage* atlas, const SkRSXform xfo static sk_sp<SkImage> make_atlas(int atlasSize, int cellSize) { SkImageInfo info = SkImageInfo::MakeN32Premul(atlasSize, atlasSize); - SkAutoTUnref<SkSurface> surface(SkSurface::NewRaster(info)); + auto surface(SkSurface::MakeRaster(info)); SkCanvas* canvas = surface->getCanvas(); SkPaint paint; diff --git a/samplecode/SampleFatBits.cpp b/samplecode/SampleFatBits.cpp index 4b15e370e4..dd588816a0 100644 --- a/samplecode/SampleFatBits.cpp +++ b/samplecode/SampleFatBits.cpp @@ -91,9 +91,9 @@ public: fShader = sk_tool_utils::create_checkerboard_shader(0xFFCCCCCC, 0xFFFFFFFF, zoom); SkImageInfo info = SkImageInfo::MakeN32Premul(width, height); - fMinSurface.reset(SkSurface::NewRaster(info)); + fMinSurface = SkSurface::MakeRaster(info); info = info.makeWH(width * zoom, height * zoom); - fMaxSurface.reset(SkSurface::NewRaster(info)); + fMaxSurface = SkSurface::MakeRaster(info); } void drawBG(SkCanvas*); @@ -111,8 +111,8 @@ private: SkMatrix fMatrix, fInverse; SkRect fBounds, fClipRect; sk_sp<SkShader> fShader; - SkAutoTUnref<SkSurface> fMinSurface; - SkAutoTUnref<SkSurface> fMaxSurface; + sk_sp<SkSurface> fMinSurface; + sk_sp<SkSurface> fMaxSurface; void setupPaint(SkPaint* paint) { bool aa = this->getAA(); @@ -162,7 +162,7 @@ private: } void copyMinToMax() { - erase(fMaxSurface); + erase(fMaxSurface.get()); SkCanvas* canvas = fMaxSurface->getCanvas(); canvas->save(); canvas->concat(fMatrix); @@ -275,7 +275,7 @@ void FatBits::drawLine(SkCanvas* canvas, SkPoint pts[]) { apply_grid(pts, 2); } - erase(fMinSurface); + erase(fMinSurface.get()); this->setupPaint(&paint); paint.setColor(FAT_PIXEL_COLOR); if (fUseClip) { @@ -310,7 +310,7 @@ void FatBits::drawRect(SkCanvas* canvas, SkPoint pts[2]) { SkRect r; r.set(pts, 2); - erase(fMinSurface); + erase(fMinSurface.get()); this->setupPaint(&paint); paint.setColor(FAT_PIXEL_COLOR); { @@ -356,7 +356,7 @@ void FatBits::drawTriangle(SkCanvas* canvas, SkPoint pts[3]) { path.lineTo(pts[2]); path.close(); - erase(fMinSurface); + erase(fMinSurface.get()); this->setupPaint(&paint); paint.setColor(FAT_PIXEL_COLOR); fMinSurface->getCanvas()->drawPath(path, paint); diff --git a/samplecode/SampleFilterQuality.cpp b/samplecode/SampleFilterQuality.cpp index 9098901959..ee998456c1 100644 --- a/samplecode/SampleFilterQuality.cpp +++ b/samplecode/SampleFilterQuality.cpp @@ -19,10 +19,10 @@ #include "SkRandom.h" #include "SkTime.h" -static SkSurface* make_surface(SkCanvas* canvas, const SkImageInfo& info) { - SkSurface* surface = canvas->newSurface(info); +static sk_sp<SkSurface> make_surface(SkCanvas* canvas, const SkImageInfo& info) { + auto surface = canvas->makeSurface(info); if (!surface) { - surface = SkSurface::NewRaster(info); + surface = SkSurface::MakeRaster(info); } return surface; } @@ -41,7 +41,7 @@ static sk_sp<SkShader> make_shader(const SkRect& bounds) { static sk_sp<SkImage> make_image() { SkImageInfo info = SkImageInfo::MakeN32(N, N, kOpaque_SkAlphaType); - SkAutoTUnref<SkSurface> surface(SkSurface::NewRaster(info)); + auto surface(SkSurface::MakeRaster(info)); SkCanvas* canvas = surface->getCanvas(); canvas->drawColor(SK_ColorWHITE); @@ -66,7 +66,7 @@ static sk_sp<SkImage> zoom_up(SkSurface* origSurf, SkImage* orig) { SkImageInfo info = SkImageInfo::MakeN32(orig->width() * D, orig->height() * D, kOpaque_SkAlphaType); - SkAutoTUnref<SkSurface> surface(origSurf->newSurface(info)); + auto surface(origSurf->makeSurface(info)); SkCanvas* canvas = surface->getCanvas(); canvas->drawColor(SK_ColorWHITE); canvas->scale(S, S); @@ -217,12 +217,12 @@ protected: SkISize size = SkISize::Make(fImage->width(), fImage->height()); - SkAutoTUnref<SkSurface> surface; + sk_sp<SkSurface> surface; if (fShowFatBits) { // scale up so we don't clip rotations SkImageInfo info = SkImageInfo::MakeN32(fImage->width() * 2, fImage->height() * 2, kOpaque_SkAlphaType); - surface.reset(make_surface(canvas, info)); + surface = make_surface(canvas, info); canvas = surface->getCanvas(); canvas->drawColor(SK_ColorWHITE); size.set(info.width(), info.height()); @@ -234,7 +234,7 @@ protected: if (surface) { sk_sp<SkImage> orig(surface->makeImageSnapshot()); - sk_sp<SkImage> zoomed(zoom_up(surface, orig.get())); + sk_sp<SkImage> zoomed(zoom_up(surface.get(), orig.get())); origCanvas->drawImage(zoomed.get(), SkScalarHalf(fCell.width() - zoomed->width()), SkScalarHalf(fCell.height() - zoomed->height())); diff --git a/samplecode/SampleQuadStroker.cpp b/samplecode/SampleQuadStroker.cpp index 48f29f7f50..40f01fd105 100644 --- a/samplecode/SampleQuadStroker.cpp +++ b/samplecode/SampleQuadStroker.cpp @@ -76,7 +76,7 @@ static void getContourCounts(const SkPath& path, SkTArray<int>* contourCounts) { } } -static void erase(SkSurface* surface) { +static void erase(const sk_sp<SkSurface>& surface) { SkCanvas* canvas = surface->getCanvas(); if (canvas) { canvas->clear(SK_ColorTRANSPARENT); @@ -110,8 +110,8 @@ class QuadStrokerView : public SampleView { SkRect fBounds; SkMatrix fMatrix, fInverse; sk_sp<SkShader> fShader; - SkAutoTUnref<SkSurface> fMinSurface; - SkAutoTUnref<SkSurface> fMaxSurface; + sk_sp<SkSurface> fMinSurface; + sk_sp<SkSurface> fMaxSurface; StrokeTypeButton fCubicButton; StrokeTypeButton fConicButton; StrokeTypeButton fQuadButton; @@ -267,9 +267,9 @@ protected: fShader = sk_tool_utils::create_checkerboard_shader(0xFFCCCCCC, 0xFFFFFFFF, zoom); SkImageInfo info = SkImageInfo::MakeN32Premul(width, height); - fMinSurface.reset(SkSurface::NewRaster(info)); + fMinSurface = SkSurface::MakeRaster(info); info = info.makeWH(width * zoom, height * zoom); - fMaxSurface.reset(SkSurface::NewRaster(info)); + fMaxSurface = SkSurface::MakeRaster(info); } void draw_points(SkCanvas* canvas, const SkPath& path, SkColor color, diff --git a/samplecode/SampleTextureDomain.cpp b/samplecode/SampleTextureDomain.cpp index 2c6dd64301..59d0822b44 100644 --- a/samplecode/SampleTextureDomain.cpp +++ b/samplecode/SampleTextureDomain.cpp @@ -60,7 +60,7 @@ protected: // Note: GPU-backed bitmaps follow a different rendering path // when copying from one GPU device to another. SkImageInfo info = SkImageInfo::MakeN32(5, 5, kOpaque_SkAlphaType); - SkAutoTUnref<SkSurface> surface(canvas->newSurface(info)); + auto surface(canvas->makeSurface(info)); srcRect.setXYWH(1, 1, 3, 3); dstRect.setXYWH(1, 1, 3, 3); |