aboutsummaryrefslogtreecommitdiffhomepage
path: root/dm/DMPDFRasterizeTask.h
blob: 8148499061cd4e1c5f13bcf2b061a8d4d74c1d75 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
 * Copyright 2014 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef DMPDFRasterizeTask_DEFINED
#define DMPDFRasterizeTask_DEFINED

#include "DMTask.h"
#include "SkBitmap.h"
#include "SkData.h"
#include "SkStream.h"
#include "SkString.h"
#include "SkTemplates.h"

namespace DM {

typedef bool (*RasterizePdfProc)(SkStream* pdf, SkBitmap* output);

class PDFRasterizeTask : public CpuTask {
public:
    // takes ownership of SkStreamAsset.
    PDFRasterizeTask(const Task& parent,
                     SkStreamAsset* pdf,
                     RasterizePdfProc);

    void draw() SK_OVERRIDE;
    bool shouldSkip() const SK_OVERRIDE { return NULL == fRasterize; }
    SkString name()   const SK_OVERRIDE { return fName; }

private:
    const SkString fName;
    SkAutoTDelete<SkStreamAsset> fPdf;
    RasterizePdfProc fRasterize;
};

}  // namespace DM

#endif  // DMPDFRasterizeTask_DEFINED