OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkCanvas.h" | 8 #include "SkCanvas.h" |
9 #include "SkDevice.h" | 9 #include "SkDevice.h" |
10 #include "SkForceLinking.h" | 10 #include "SkForceLinking.h" |
(...skipping 1985 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1996 | 1996 |
1997 canvas->flush(); | 1997 canvas->flush(); |
1998 return true; | 1998 return true; |
1999 } | 1999 } |
2000 | 2000 |
2001 bool SkPdfRenderer::load(const SkString inputFileName) { | 2001 bool SkPdfRenderer::load(const SkString inputFileName) { |
2002 unload(); | 2002 unload(); |
2003 | 2003 |
2004 // TODO(edisonn): create static function that could return NULL if there are
errors | 2004 // TODO(edisonn): create static function that could return NULL if there are
errors |
2005 fPdfDoc = new SkNativeParsedPDF(inputFileName.c_str()); | 2005 fPdfDoc = new SkNativeParsedPDF(inputFileName.c_str()); |
| 2006 if (fPdfDoc->pages() == 0) { |
| 2007 delete fPdfDoc; |
| 2008 fPdfDoc = NULL; |
| 2009 } |
2006 | 2010 |
2007 return fPdfDoc != NULL; | 2011 return fPdfDoc != NULL; |
2008 } | 2012 } |
2009 | 2013 |
2010 int SkPdfRenderer::pages() const { | 2014 int SkPdfRenderer::pages() const { |
2011 return fPdfDoc != NULL ? fPdfDoc->pages() : 0; | 2015 return fPdfDoc != NULL ? fPdfDoc->pages() : 0; |
2012 } | 2016 } |
2013 | 2017 |
2014 void SkPdfRenderer::unload() { | 2018 void SkPdfRenderer::unload() { |
2015 delete fPdfDoc; | 2019 delete fPdfDoc; |
2016 fPdfDoc = NULL; | 2020 fPdfDoc = NULL; |
2017 } | 2021 } |
2018 | 2022 |
2019 SkRect SkPdfRenderer::MediaBox(int page) const { | 2023 SkRect SkPdfRenderer::MediaBox(int page) const { |
2020 SkASSERT(fPdfDoc); | 2024 SkASSERT(fPdfDoc); |
2021 return fPdfDoc->MediaBox(page); | 2025 return fPdfDoc->MediaBox(page); |
2022 } | 2026 } |
2023 | 2027 |
2024 size_t SkPdfRenderer::bytesUsed() const { | 2028 size_t SkPdfRenderer::bytesUsed() const { |
2025 return fPdfDoc ? fPdfDoc->bytesUsed() : 0; | 2029 return fPdfDoc ? fPdfDoc->bytesUsed() : 0; |
2026 } | 2030 } |
2027 | |
OLD | NEW |