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()); } |