Index: dm/DMSrcSink.cpp |
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp |
index f467a61a1e4aade9f016e7be58b07d93b1e985cc..a57192e8818045a4aeb84c864f5689b9190b2e5a 100644 |
--- a/dm/DMSrcSink.cpp |
+++ b/dm/DMSrcSink.cpp |
@@ -4,7 +4,6 @@ |
#include "SkDocument.h" |
#include "SkMultiPictureDraw.h" |
#include "SkOSFile.h" |
-#include "SkPictureData.h" |
#include "SkPictureRecorder.h" |
#include "SkRandom.h" |
#include "SkStream.h" |
@@ -102,6 +101,8 @@ |
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ |
+static const SkRect kSKPViewport = {0,0, 1000,1000}; |
+ |
SKPSrc::SKPSrc(SkString path) : fPath(path) {} |
Error SKPSrc::draw(SkCanvas* canvas) const { |
@@ -114,34 +115,19 @@ |
return SkStringPrintf("Couldn't decode %s as a picture.", fPath.c_str()); |
} |
stream.reset((SkStream*)NULL); // Might as well drop this when we're done with it. |
+ canvas->clipRect(kSKPViewport); |
canvas->drawPicture(pic); |
return ""; |
} |
SkISize SKPSrc::size() const { |
- SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(fPath.c_str())); |
- SkPictInfo info; |
- if (!stream || !SkPicture::InternalOnly_StreamIsSKP(stream, &info)) { |
- return SkISize::Make(0,0); |
- } |
- return info.fCullRect.roundOut().size(); |
+ // This may be unnecessarily large. |
+ return kSKPViewport.roundOut().size(); |
} |
Name SKPSrc::name() const { return SkOSPath::Basename(fPath.c_str()); } |
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ |
- |
-static SkISize limit_raster_dimensions(const SkISize& size) { |
- // Clamp both dimensions to 2K to stay within typical GPU maximum texture limits. |
- int width = SkTMin(2048, size.width()), |
- height = SkTMin(2048, size.height()); |
- // Clamp our largest dimension until we're no more than 2.25 megapixels, to keep RAM usage sane. |
- int& largest = width > height ? width : height; |
- while (width * height > 2359296) { |
- largest /= 2; |
- } |
- return SkISize::Make(width, height); |
-} |
GPUSink::GPUSink(GrContextFactory::GLContextType ct, |
GrGLStandard api, |
@@ -160,7 +146,7 @@ |
Error GPUSink::draw(const Src& src, SkBitmap* dst, SkWStream*) const { |
GrContextFactory factory; |
- const SkISize size = limit_raster_dimensions(src.size()); |
+ const SkISize size = src.size(); |
const SkImageInfo info = |
SkImageInfo::Make(size.width(), size.height(), kN32_SkColorType, kPremul_SkAlphaType); |
SkAutoTUnref<SkSurface> surface( |
@@ -243,7 +229,7 @@ |
RasterSink::RasterSink(SkColorType colorType) : fColorType(colorType) {} |
Error RasterSink::draw(const Src& src, SkBitmap* dst, SkWStream*) const { |
- const SkISize size = limit_raster_dimensions(src.size()); |
+ const SkISize size = src.size(); |
// If there's an appropriate alpha type for this color type, use it, otherwise use premul. |
SkAlphaType alphaType = kPremul_SkAlphaType; |
(void)SkColorTypeValidateAlphaType(fColorType, alphaType, &alphaType); |