mtklein | 30bf3e2 | 2014-06-03 13:57:14 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #ifndef DMPDFRasterizeTask_DEFINED |
| 9 | #define DMPDFRasterizeTask_DEFINED |
| 10 | |
mtklein | 30bf3e2 | 2014-06-03 13:57:14 -0700 | [diff] [blame] | 11 | #include "DMTask.h" |
| 12 | #include "SkBitmap.h" |
| 13 | #include "SkData.h" |
| 14 | #include "SkStream.h" |
| 15 | #include "SkString.h" |
| 16 | #include "SkTemplates.h" |
| 17 | |
| 18 | namespace DM { |
| 19 | |
| 20 | typedef bool (*RasterizePdfProc)(SkStream* pdf, SkBitmap* output); |
| 21 | |
| 22 | class PDFRasterizeTask : public CpuTask { |
| 23 | public: |
halcanary | a4c6094 | 2014-08-26 10:38:07 -0700 | [diff] [blame] | 24 | // takes ownership of SkStreamAsset. |
mtklein | 30bf3e2 | 2014-06-03 13:57:14 -0700 | [diff] [blame] | 25 | PDFRasterizeTask(const Task& parent, |
halcanary | a4c6094 | 2014-08-26 10:38:07 -0700 | [diff] [blame] | 26 | SkStreamAsset* pdf, |
mtklein | 30bf3e2 | 2014-06-03 13:57:14 -0700 | [diff] [blame] | 27 | RasterizePdfProc); |
| 28 | |
| 29 | virtual void draw() SK_OVERRIDE; |
| 30 | virtual bool shouldSkip() const SK_OVERRIDE { return NULL == fRasterize; } |
| 31 | virtual SkString name() const SK_OVERRIDE { return fName; } |
| 32 | |
| 33 | private: |
| 34 | const SkString fName; |
halcanary | a4c6094 | 2014-08-26 10:38:07 -0700 | [diff] [blame] | 35 | SkAutoTDelete<SkStreamAsset> fPdf; |
mtklein | 30bf3e2 | 2014-06-03 13:57:14 -0700 | [diff] [blame] | 36 | RasterizePdfProc fRasterize; |
| 37 | }; |
| 38 | |
| 39 | } // namespace DM |
| 40 | |
| 41 | #endif // DMPDFRasterizeTask_DEFINED |