Commit 7815ed01 authored by fmalita@chromium.org's avatar fmalita@chromium.org

Use picture-backed SkImages for SVGImage::imageForCurrentFrame()

Instead of a (record-time-rasterized) bitmap SkImage, return an SkImage
backed by a recording of the SVG image.

R=reed@google.com,schenney@chromium.org,junov@chromium.org

Review URL: https://codereview.chromium.org/1327473003

git-svn-id: svn://svn.chromium.org/blink/trunk@201730 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 3b76a0e4
...@@ -58,7 +58,6 @@ ...@@ -58,7 +58,6 @@
#include "platform/graphics/paint/DrawingRecorder.h" #include "platform/graphics/paint/DrawingRecorder.h"
#include "platform/graphics/paint/SkPictureBuilder.h" #include "platform/graphics/paint/SkPictureBuilder.h"
#include "third_party/skia/include/core/SkPicture.h" #include "third_party/skia/include/core/SkPicture.h"
#include "third_party/skia/include/core/SkSurface.h"
#include "wtf/PassRefPtr.h" #include "wtf/PassRefPtr.h"
namespace blink { namespace blink {
...@@ -218,21 +217,16 @@ void SVGImage::drawForContainer(SkCanvas* canvas, const SkPaint& paint, const Fl ...@@ -218,21 +217,16 @@ void SVGImage::drawForContainer(SkCanvas* canvas, const SkPaint& paint, const Fl
PassRefPtr<SkImage> SVGImage::imageForCurrentFrame() PassRefPtr<SkImage> SVGImage::imageForCurrentFrame()
{ {
// TODO(fmalita): instead of rasterizing, investigate returning a SkPicture-backed image.
if (!m_page) if (!m_page)
return nullptr; return nullptr;
IntSize size = this->size(); SkPictureRecorder recorder;
SkImageInfo imageInfo = SkImageInfo::MakeN32(size.width(), size.height(), kPremul_SkAlphaType); SkCanvas* canvas = recorder.beginRecording(width(), height());
SkSurfaceProps disableLCDProps(0, kUnknown_SkPixelGeometry); drawForContainer(canvas, SkPaint(), size(), 1, rect(), rect());
RefPtr<SkSurface> surface = adoptRef(SkSurface::NewRaster(imageInfo, &disableLCDProps)); RefPtr<SkPicture> picture = adoptRef(recorder.endRecording());
if (!surface)
return nullptr;
drawForContainer(surface->getCanvas(), SkPaint(), size, 1, rect(), rect());
return adoptRef(surface->newImageSnapshot()); return adoptRef(
SkImage::NewFromPicture(picture.get(), SkISize::Make(width(), height()), nullptr, nullptr));
} }
void SVGImage::drawPatternForContainer(GraphicsContext* context, const FloatSize containerSize, void SVGImage::drawPatternForContainer(GraphicsContext* context, const FloatSize containerSize,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment