diff options
author | 2016-03-23 18:59:25 -0700 | |
---|---|---|
committer | 2016-03-23 18:59:25 -0700 | |
commit | e8f3062a36d3682f4019309a32b5b84dc9eddf8c (patch) | |
tree | ff5cd50c65edb6e3b77f77327165ad0162557137 /dm | |
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 'dm')
-rw-r--r-- | dm/DMGpuSupport.h | 16 | ||||
-rw-r--r-- | dm/DMSrcSink.cpp | 13 |
2 files changed, 14 insertions, 15 deletions
diff --git a/dm/DMGpuSupport.h b/dm/DMGpuSupport.h index ed276454fb..73adeb0302 100644 --- a/dm/DMGpuSupport.h +++ b/dm/DMGpuSupport.h @@ -28,16 +28,16 @@ namespace DM { static const bool kGPUDisabled = false; -static inline SkSurface* NewGpuSurface(GrContextFactory* grFactory, - GrContextFactory::GLContextType type, - GrContextFactory::GLContextOptions options, - SkImageInfo info, - int samples, - bool useDIText) { +static inline sk_sp<SkSurface> NewGpuSurface(GrContextFactory* grFactory, + GrContextFactory::GLContextType type, + GrContextFactory::GLContextOptions options, + SkImageInfo info, + int samples, + bool useDIText) { uint32_t flags = useDIText ? SkSurfaceProps::kUseDeviceIndependentFonts_Flag : 0; SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType); - return SkSurface::NewRenderTarget(grFactory->get(type, options), SkBudgeted::kNo, - info, samples, &props); + return SkSurface::MakeRenderTarget(grFactory->get(type, options), SkBudgeted::kNo, + info, samples, &props); } } // namespace DM diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp index 6fd46c80ed..78782a0866 100644 --- a/dm/DMSrcSink.cpp +++ b/dm/DMSrcSink.cpp @@ -990,7 +990,7 @@ Error GPUSink::draw(const Src& src, SkBitmap* dst, SkWStream*, SkString* log) co } #endif - SkAutoTUnref<SkSurface> surface( + auto surface( NewGpuSurface(&factory, fContextType, fContextOptions, info, fSampleCount, fUseDIText)); if (!surface) { return "Could not create a surface."; @@ -1309,19 +1309,19 @@ Error ViaTiles::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkStri const int xTiles = (size.width() + fW - 1) / fW, yTiles = (size.height() + fH - 1) / fH; SkMultiPictureDraw mpd(xTiles*yTiles); - SkTDArray<SkSurface*> surfaces; - surfaces.setReserve(xTiles*yTiles); + SkTArray<sk_sp<SkSurface>> surfaces; +// surfaces.setReserve(xTiles*yTiles); SkImageInfo info = canvas->imageInfo().makeWH(fW, fH); for (int j = 0; j < yTiles; j++) { for (int i = 0; i < xTiles; i++) { // This lets our ultimate Sink determine the best kind of surface. // E.g., if it's a GpuSink, the surfaces and images are textures. - SkSurface* s = canvas->newSurface(info); + auto s = canvas->makeSurface(info); if (!s) { - s = SkSurface::NewRaster(info); // Some canvases can't create surfaces. + s = SkSurface::MakeRaster(info); // Some canvases can't create surfaces. } - surfaces.push(s); + surfaces.push_back(s); SkCanvas* c = s->getCanvas(); c->translate(SkIntToScalar(-i * fW), SkIntToScalar(-j * fH)); // Line up the canvas with this tile. @@ -1335,7 +1335,6 @@ Error ViaTiles::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkStri canvas->drawImage(image, SkIntToScalar(i*fW), SkIntToScalar(j*fH)); } } - surfaces.unrefAll(); return ""; }); } |