aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/pdf/SkPDFBitmap.h
blob: 2c8653f3158769f712de7f01085e54e5d1193053 (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
/*
 * Copyright 2015 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */
#ifndef SkPDFBitmap_DEFINED
#define SkPDFBitmap_DEFINED

#include "SkPDFTypes.h"
#include "SkBitmap.h"

class SkPDFCanon;

/**
 * SkPDFBitmap wraps a SkBitmap and serializes it as an image Xobject.
 * It is designed to use a minimal amout of memory, aside from refing
 * the bitmap's pixels, and its emitObject() does not cache any data.
 *
 * If !bitmap.isImmutable(), then a copy of the bitmap must be made;
 * there is no way around this.
 *
 * The SkPDFBitmap::Create function will check the canon for duplicates.
 */
class SkPDFBitmap : public SkPDFObject {
public:
    // Returns NULL on unsupported bitmap;
    static SkPDFBitmap* Create(SkPDFCanon*, const SkBitmap&);
    bool equals(const SkBitmap& other) const {
        return fBitmap.getGenerationID() == other.getGenerationID() &&
               fBitmap.pixelRefOrigin() == other.pixelRefOrigin() &&
               fBitmap.dimensions() == other.dimensions();
    }

protected:
    const SkBitmap fBitmap;
    SkPDFBitmap(const SkBitmap& bm) : fBitmap(bm) {}
};

#endif  // SkPDFBitmap_DEFINED