skia2/dm/DMPDFRasterizeTask.cpp
mtklein e4d3e605f7 DM: SKP source / PDF backend
Removed expectations code for PDF backend for now, given that we don't have any, and refactored a little to make that cleaner.

We can now test .skp -> .pdf -> .png in DM.  Neat eh?

BUG=skia:2598
R=halcanary@google.com, mtklein@google.com

Author: mtklein@chromium.org

Review URL: https://codereview.chromium.org/316643003
2014-06-06 09:28:43 -07:00

38 lines
897 B
C++

/*
* 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 "DMPDFRasterizeTask.h"
#include "DMExpectationsTask.h"
#include "DMUtil.h"
#include "DMWriteTask.h"
#include "SkBitmap.h"
#include "SkCanvas.h"
#include "SkStream.h"
namespace DM {
PDFRasterizeTask::PDFRasterizeTask(const Task& parent,
SkData* pdf,
RasterizePdfProc proc)
: CpuTask(parent)
, fName(UnderJoin(parent.name().c_str(), "rasterize"))
, fPdf(SkRef(pdf))
, fRasterize(proc) {}
void PDFRasterizeTask::draw() {
SkMemoryStream pdfStream(fPdf.get());
SkBitmap bitmap;
if (fRasterize(&pdfStream, &bitmap)) {
this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap)));
} else {
this->fail();
}
}
} // namespace DM