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

Unified Diff: experimental/tools/PageCachingDocument.cpp

Issue 1233093004: experimental: remove old PDF benchmarking tools (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « experimental/tools/PageCachingDocument.h ('k') | experimental/tools/SkDmuxWStream.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: experimental/tools/PageCachingDocument.cpp
diff --git a/experimental/tools/PageCachingDocument.cpp b/experimental/tools/PageCachingDocument.cpp
deleted file mode 100644
index 9baf45c72169e89b7ebada9ad00f65915ecfe5e7..0000000000000000000000000000000000000000
--- a/experimental/tools/PageCachingDocument.cpp
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright 2014 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "PageCachingDocument.h"
-#include "SkCanvas.h"
-#include "SkDocument.h"
-#include "SkPictureRecorder.h"
-#include "SkRect.h"
-#include "SkTDArray.h"
-
-namespace {
-
-typedef void (*DoneProc)(SkWStream*, bool);
-typedef SkData* (*Encoder)(size_t*, const SkBitmap&);
-
-// This class allows us to compare the relative memory consumption of
-// the PDF and SkPicture backends.
-class PageCachingDocument : public SkDocument {
-public:
- PageCachingDocument(SkWStream*, DoneProc, Encoder, SkScalar rasterDpi);
- virtual ~PageCachingDocument();
- virtual SkCanvas* onBeginPage(SkScalar width,
- SkScalar height,
- const SkRect& content) override;
- void onEndPage() override;
- bool onClose(SkWStream*) override;
- void onAbort() override;
-
-private:
- struct Page {
- SkScalar fWidth;
- SkScalar fHeight;
- SkAutoTUnref<SkPicture> fPic;
- };
- SkPictureRecorder fRecorder;
- SkTDArray<Page> fPages;
- Encoder fEncoder;
- SkScalar fRasterDpi;
-};
-
-PageCachingDocument::PageCachingDocument(SkWStream* stream,
- DoneProc done,
- Encoder encoder,
- SkScalar rasterDpi)
- : SkDocument(stream, done), fEncoder(encoder), fRasterDpi(rasterDpi) {
-}
-
-PageCachingDocument::~PageCachingDocument() {
- for (Page* p = fPages.begin(); p != fPages.end(); ++p) {
- p->~Page();
- }
-}
-
-SkCanvas* PageCachingDocument::onBeginPage(SkScalar width,
- SkScalar height,
- const SkRect& content) {
- Page* page = fPages.push();
- sk_bzero(page, sizeof(*page));
- page->fWidth = width;
- page->fHeight = height;
- SkASSERT(!page->fPic.get());
- SkCanvas* canvas = fRecorder.beginRecording(content);
- return canvas;
-}
-
-void PageCachingDocument::onEndPage() {
- SkASSERT(fPages.count() > 0);
- SkASSERT(!fPages[fPages.count() - 1].fPic);
- fPages[fPages.count() - 1].fPic.reset(fRecorder.endRecording());
-}
-
-bool PageCachingDocument::onClose(SkWStream* stream) {
- SkAutoTUnref<SkDocument> doc(
- SkDocument::CreatePDF(stream, NULL, fEncoder, fRasterDpi));
- for (Page* page = fPages.begin(); page != fPages.end(); ++page) {
- SkRect cullRect = page->fPic->cullRect();
- SkCanvas* canvas =
- doc->beginPage(page->fWidth, page->fHeight, &cullRect);
- canvas->drawPicture(page->fPic);
- doc->endPage();
- }
- return doc->close();
-}
-
-void PageCachingDocument::onAbort() {
-}
-} // namespace
-
-SkDocument* CreatePageCachingDocument(SkWStream* stream,
- DoneProc done,
- Encoder encoder,
- SkScalar rasterDpi) {
- return SkNEW_ARGS(PageCachingDocument, (stream, done, encoder, rasterDpi));
-}
« no previous file with comments | « experimental/tools/PageCachingDocument.h ('k') | experimental/tools/SkDmuxWStream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698