| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "DMPDFRasterizeTask.h" | 8 #include "DMPDFRasterizeTask.h" |
| 9 #include "DMExpectationsTask.h" | 9 #include "DMExpectationsTask.h" |
| 10 #include "DMUtil.h" | 10 #include "DMUtil.h" |
| 11 #include "DMWriteTask.h" | 11 #include "DMWriteTask.h" |
| 12 #include "SkBitmap.h" | 12 #include "SkBitmap.h" |
| 13 #include "SkCanvas.h" | 13 #include "SkCanvas.h" |
| 14 #include "SkStream.h" | 14 #include "SkStream.h" |
| 15 | 15 |
| 16 namespace DM { | 16 namespace DM { |
| 17 | 17 |
| 18 PDFRasterizeTask::PDFRasterizeTask(const Task& parent, | 18 PDFRasterizeTask::PDFRasterizeTask(const Task& parent, |
| 19 SkData* pdf, | 19 SkData* pdf, |
| 20 const Expectations& expectations, | |
| 21 RasterizePdfProc proc) | 20 RasterizePdfProc proc) |
| 22 : CpuTask(parent) | 21 : CpuTask(parent) |
| 23 , fName(UnderJoin(parent.name().c_str(), "rasterize")) | 22 , fName(UnderJoin(parent.name().c_str(), "rasterize")) |
| 24 , fPdf(SkRef(pdf)) | 23 , fPdf(SkRef(pdf)) |
| 25 , fExpectations(expectations) | |
| 26 , fRasterize(proc) {} | 24 , fRasterize(proc) {} |
| 27 | 25 |
| 28 void PDFRasterizeTask::draw() { | 26 void PDFRasterizeTask::draw() { |
| 29 SkMemoryStream pdfStream(fPdf.get()); | 27 SkMemoryStream pdfStream(fPdf.get()); |
| 30 SkBitmap bitmap; | 28 SkBitmap bitmap; |
| 31 | 29 |
| 32 if (!fRasterize(&pdfStream, &bitmap)) { | 30 if (fRasterize(&pdfStream, &bitmap)) { |
| 31 this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap))); |
| 32 } else { |
| 33 this->fail(); | 33 this->fail(); |
| 34 } | 34 } |
| 35 if (!fExpectations.check(*this, bitmap)) { | |
| 36 this->fail(); | |
| 37 this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap))); | |
| 38 } | |
| 39 } | 35 } |
| 40 | 36 |
| 41 } // namespace DM | 37 } // namespace DM |
| OLD | NEW |