| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "DMSrcSink.h" | 8 #include "DMSrcSink.h" |
| 9 #include "SamplePipeControllers.h" | 9 #include "SamplePipeControllers.h" |
| 10 #include "SkCommonFlags.h" | 10 #include "SkCommonFlags.h" |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 Error SKPSrc::draw(SkCanvas* canvas) const { | 236 Error SKPSrc::draw(SkCanvas* canvas) const { |
| 237 SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(fPath.c_str())); | 237 SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(fPath.c_str())); |
| 238 if (!stream) { | 238 if (!stream) { |
| 239 return SkStringPrintf("Couldn't read %s.", fPath.c_str()); | 239 return SkStringPrintf("Couldn't read %s.", fPath.c_str()); |
| 240 } | 240 } |
| 241 SkAutoTUnref<SkPicture> pic(SkPicture::CreateFromStream(stream, &lazy_decode
_bitmap)); | 241 SkAutoTUnref<SkPicture> pic(SkPicture::CreateFromStream(stream, &lazy_decode
_bitmap)); |
| 242 if (!pic) { | 242 if (!pic) { |
| 243 return SkStringPrintf("Couldn't decode %s as a picture.", fPath.c_str())
; | 243 return SkStringPrintf("Couldn't decode %s as a picture.", fPath.c_str())
; |
| 244 } | 244 } |
| 245 stream.reset((SkStream*)NULL); // Might as well drop this when we're done w
ith it. | 245 stream.reset((SkStream*)NULL); // Might as well drop this when we're done w
ith it. |
| 246 | |
| 247 canvas->clipRect(kSKPViewport); | 246 canvas->clipRect(kSKPViewport); |
| 248 // Testing TextBlob batching requires that we see individual text blobs more
than once | |
| 249 // TODO remove this and add a flag to DM so we can run skps multiple times | |
| 250 //#define DOUBLE_LOOP | |
| 251 #ifdef DOUBLE_LOOP | |
| 252 { | |
| 253 SkAutoCanvasRestore acr(canvas, true); | |
| 254 #endif | |
| 255 canvas->drawPicture(pic); | |
| 256 #ifdef DOUBLE_LOOP | |
| 257 } | |
| 258 canvas->clear(0); | |
| 259 canvas->drawPicture(pic); | 247 canvas->drawPicture(pic); |
| 260 #endif | |
| 261 return ""; | 248 return ""; |
| 262 } | 249 } |
| 263 | 250 |
| 264 SkISize SKPSrc::size() const { | 251 SkISize SKPSrc::size() const { |
| 265 SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(fPath.c_str())); | 252 SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(fPath.c_str())); |
| 266 if (!stream) { | 253 if (!stream) { |
| 267 return SkISize::Make(0,0); | 254 return SkISize::Make(0,0); |
| 268 } | 255 } |
| 269 SkPictInfo info; | 256 SkPictInfo info; |
| 270 if (!SkPicture::InternalOnly_StreamIsSKP(stream, &info)) { | 257 if (!SkPicture::InternalOnly_StreamIsSKP(stream, &info)) { |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 surfaces.unrefAll(); | 616 surfaces.unrefAll(); |
| 630 return ""; | 617 return ""; |
| 631 } | 618 } |
| 632 SkISize size() const override { return fSize; } | 619 SkISize size() const override { return fSize; } |
| 633 Name name() const override { sk_throw(); return ""; } // No one should
be calling this. | 620 Name name() const override { sk_throw(); return ""; } // No one should
be calling this. |
| 634 } proxy(fW, fH, pic, src.size()); | 621 } proxy(fW, fH, pic, src.size()); |
| 635 return fSink->draw(proxy, bitmap, stream, log); | 622 return fSink->draw(proxy, bitmap, stream, log); |
| 636 } | 623 } |
| 637 | 624 |
| 638 } // namespace DM | 625 } // namespace DM |
| OLD | NEW |