Revert of DM::SKPSrc::size() reports correct size. (patchset #1 id:1 of https://coder...
authormtklein <mtklein@google.com>
Wed, 28 Jan 2015 20:04:08 +0000 (12:04 -0800)
committerCommit bot <commit-bot@chromium.org>
Wed, 28 Jan 2015 20:04:08 +0000 (12:04 -0800)
Reason for revert:
OOM on 32-bit machines.

Original issue's description:
> DM::SKPSrc::size() reports correct size.
>
> Also, DM::GPUSink and DM::RasterSink crop DM::Src::size() to 2048x2048.
>
> Motivation:
>   Improve PDF testing by printing the entire SKP.
>
> Source: http://crrev.com/863243004
>
> BUG=skia:3365
>
> Committed: https://skia.googlesource.com/skia/+/441b10eac09a1f44983e35da827a6b438a409e63

TBR=halcanary@google.com,mtklein@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:3365

Review URL: https://codereview.chromium.org/884743003

dm/DMSrcSink.cpp

index 3fd1a4d..a57192e 100644 (file)
@@ -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 @@ Name ImageSrc::name() const {
 
 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
 
+static const SkRect kSKPViewport = {0,0, 1000,1000};
+
 SKPSrc::SKPSrc(SkString path) : fPath(path) {}
 
 Error SKPSrc::draw(SkCanvas* canvas) const {
@@ -114,28 +115,20 @@ Error SKPSrc::draw(SkCanvas* canvas) const {
         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) {
-    // This fits within a typical maximum texture, and puts a reasonable 16MB cap on raster bitmaps.
-    return SkISize::Make(SkTMin(2048, size.width()), SkTMin(2048, size.height()));
-}
-
 GPUSink::GPUSink(GrContextFactory::GLContextType ct,
                  GrGLStandard api,
                  int samples,
@@ -153,7 +146,7 @@ int GPUSink::enclave() const {
 
 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(
@@ -236,7 +229,7 @@ Error SKPSink::draw(const Src& src, SkBitmap*, SkWStream* dst) const {
 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);