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

Side by Side Diff: experimental/PdfViewer/SkPdfRenderer.cpp

Issue 18093008: pdfviewer: add option to run the load or render multiple times, --benchLoad, --benchRender (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | experimental/PdfViewer/pdf_viewer_main.cpp » ('j') | 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 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
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
OLDNEW
« no previous file with comments | « no previous file | experimental/PdfViewer/pdf_viewer_main.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698