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

Unified Diff: dm/DMSrcSink.cpp

Issue 986103002: DM: allow SKPs to be smaller than 1000x1000 (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Created 5 years, 9 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: dm/DMSrcSink.cpp
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
index 5ca66c50e207c4809f41396e907d354d4d78a17d..91f4e238c28b2aa96ec761b019f3816ffc8f171f 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -7,6 +7,7 @@
#include "SkMultiPictureDraw.h"
#include "SkNullCanvas.h"
#include "SkOSFile.h"
+#include "SkPictureData.h"
#include "SkPictureRecorder.h"
#include "SkRandom.h"
#include "SkSVGCanvas.h"
@@ -177,8 +178,19 @@ Error SKPSrc::draw(SkCanvas* canvas) const {
}
SkISize SKPSrc::size() const {
- // This may be unnecessarily large.
- return kSKPViewport.roundOut().size();
+ SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(fPath.c_str()));
+ if (!stream) {
+ return SkISize::Make(0,0);
+ }
+ SkPictInfo info;
+ if (!SkPicture::InternalOnly_StreamIsSKP(stream, &info)) {
+ return SkISize::Make(0,0);
+ }
+ SkRect viewport = kSKPViewport;
+ if (!viewport.intersect(info.fCullRect)) {
+ return SkISize::Make(0,0);
+ }
+ return viewport.roundOut().size();
}
Name SKPSrc::name() const { return SkOSPath::Basename(fPath.c_str()); }
« 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