diff options
author | 2015-03-16 10:38:07 -0700 | |
---|---|---|
committer | 2015-03-16 10:38:07 -0700 | |
commit | ffa901aa7e360ed5115a0955221f4c2d2632d418 (patch) | |
tree | faba54d676b912741321146dd649930ebd69e85d /dm | |
parent | e7903c7397c694e343c2c0fcc5cabea351212f23 (diff) |
DM: allow SKPs to be smaller than 1000x1000
This sniffs the .skp dimensions and intersects them with our 1000x1000 viewport.
This fixes things like desk_carsvg.skp, which is only 902 pixels tall. In 565 now,
the remaining 98 pixels draw as black, which looks funny and is confusing to triage.
No apparent affect on DM memory usage. (We're about to map the file anyway.)
BUG=skia:
Review URL: https://codereview.chromium.org/986103002
Diffstat (limited to 'dm')
-rw-r--r-- | dm/DMSrcSink.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp index 22dd5679e3..6f6664f27c 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" @@ -189,8 +190,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()); } |