Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1526)

Unified Diff: Source/core/svg/graphics/SVGImage.cpp

Issue 1327473003: Use picture-backed SkImages for SVGImage::imageForCurrentFrame() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/svg/graphics/SVGImage.cpp
diff --git a/Source/core/svg/graphics/SVGImage.cpp b/Source/core/svg/graphics/SVGImage.cpp
index 4b751100e3ed6f6e9ef5760e57ecf64872a60641..ca2cc3f6bb3804707b77e8066bb8aa936231ba70 100644
--- a/Source/core/svg/graphics/SVGImage.cpp
+++ b/Source/core/svg/graphics/SVGImage.cpp
@@ -58,7 +58,6 @@
#include "platform/graphics/paint/DrawingRecorder.h"
#include "platform/graphics/paint/SkPictureBuilder.h"
#include "third_party/skia/include/core/SkPicture.h"
-#include "third_party/skia/include/core/SkSurface.h"
#include "wtf/PassRefPtr.h"
namespace blink {
@@ -218,21 +217,16 @@ void SVGImage::drawForContainer(SkCanvas* canvas, const SkPaint& paint, const Fl
PassRefPtr<SkImage> SVGImage::imageForCurrentFrame()
{
- // TODO(fmalita): instead of rasterizing, investigate returning a SkPicture-backed image.
-
if (!m_page)
return nullptr;
- IntSize size = this->size();
- SkImageInfo imageInfo = SkImageInfo::MakeN32(size.width(), size.height(), kPremul_SkAlphaType);
- SkSurfaceProps disableLCDProps(0, kUnknown_SkPixelGeometry);
- RefPtr<SkSurface> surface = adoptRef(SkSurface::NewRaster(imageInfo, &disableLCDProps));
- if (!surface)
- return nullptr;
-
- drawForContainer(surface->getCanvas(), SkPaint(), size, 1, rect(), rect());
+ SkPictureRecorder recorder;
+ SkCanvas* canvas = recorder.beginRecording(width(), height());
+ drawForContainer(canvas, SkPaint(), size(), 1, rect(), rect());
+ RefPtr<SkPicture> picture = adoptRef(recorder.endRecording());
- return adoptRef(surface->newImageSnapshot());
+ return adoptRef(
+ SkImage::NewFromPicture(picture.get(), SkISize::Make(width(), height()), nullptr, nullptr));
}
void SVGImage::drawPatternForContainer(GraphicsContext* context, const FloatSize containerSize,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698