Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(661)

Side by Side Diff: dm/DMSrcSink.cpp

Issue 1061493002: Prevent DM crash in the PDF sink when src width/height are zero. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 354
355 int xPages = ((width - 1) / kLetterWidth) + 1; 355 int xPages = ((width - 1) / kLetterWidth) + 1;
356 int yPages = ((height - 1) / kLetterHeight) + 1; 356 int yPages = ((height - 1) / kLetterHeight) + 1;
357 357
358 for (int y = 0; y < yPages; ++y) { 358 for (int y = 0; y < yPages; ++y) {
359 for (int x = 0; x < xPages; ++x) { 359 for (int x = 0; x < xPages; ++x) {
360 int w = SkTMin(kLetterWidth, width - (x * kLetterWidth)); 360 int w = SkTMin(kLetterWidth, width - (x * kLetterWidth));
361 int h = SkTMin(kLetterHeight, height - (y * kLetterHeight)); 361 int h = SkTMin(kLetterHeight, height - (y * kLetterHeight));
362 SkCanvas* canvas = 362 SkCanvas* canvas =
363 doc->beginPage(SkIntToScalar(w), SkIntToScalar(h)); 363 doc->beginPage(SkIntToScalar(w), SkIntToScalar(h));
364 if (!canvas) {
365 return "SkDocument::beginPage(w,h) returned NULL";
djsollen 2015/04/03 13:35:01 I think it may be better if we could just produce
366 }
364 canvas->clipRect(letter); 367 canvas->clipRect(letter);
365 canvas->translate(-letter.width() * x, -letter.height() * y); 368 canvas->translate(-letter.width() * x, -letter.height() * y);
366 Error err = src.draw(canvas); 369 Error err = src.draw(canvas);
367 if (!err.isEmpty()) { 370 if (!err.isEmpty()) {
368 return err; 371 return err;
369 } 372 }
370 doc->endPage(); 373 doc->endPage();
371 } 374 }
372 } 375 }
373 doc->close(); 376 doc->close();
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 surfaces.unrefAll(); 632 surfaces.unrefAll();
630 return ""; 633 return "";
631 } 634 }
632 SkISize size() const override { return fSize; } 635 SkISize size() const override { return fSize; }
633 Name name() const override { sk_throw(); return ""; } // No one should be calling this. 636 Name name() const override { sk_throw(); return ""; } // No one should be calling this.
634 } proxy(fW, fH, pic, src.size()); 637 } proxy(fW, fH, pic, src.size());
635 return fSink->draw(proxy, bitmap, stream, log); 638 return fSink->draw(proxy, bitmap, stream, log);
636 } 639 }
637 640
638 } // namespace DM 641 } // namespace DM
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698