aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkBlitMask.h
blob: 299f6d1e5c38ba6efa5f41f90b09df65a097a3b4 (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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
 * Copyright 2011 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef SkBlitMask_DEFINED
#define SkBlitMask_DEFINED

#include "SkBitmap.h"
#include "SkColor.h"
#include "SkMask.h"

class SkBlitMask {
public:
    /**
     *  Returns true if the device config and mask format were supported.
     *  else return false (nothing was drawn)
     */
    static bool BlitColor(const SkBitmap& device, const SkMask& mask,
                          const SkIRect& clip, SkColor color);

    /**
     *  Function pointer that blits the mask into a device (dst) colorized
     *  by color. The number of pixels to blit is specified by width and height,
     *  but each scanline is offset by dstRB (rowbytes) and srcRB respectively.
     */
    typedef void (*ColorProc)(void* dst, size_t dstRB,
                              const void* mask, size_t maskRB,
                              SkColor color, int width, int height);

    /**
     *  Function pointer that blits a row of src colors through a row of a mask
     *  onto a row of dst colors. The RowFactory that returns this function ptr
     *  will have been told the formats for the mask and the dst.
     */
    typedef void (*RowProc)(void* dst, const void* mask,
                            const SkPMColor* src, int width);
    
    /**
     *  Public entry-point to return a blitmask ColorProc.
     *  May return NULL if config or format are not supported.
     */
    static ColorProc ColorFactory(SkBitmap::Config, SkMask::Format, SkColor);
    
    /**
     *  Return either platform specific optimized blitmask ColorProc,
     *  or NULL if no optimized routine is available.
     */
    static ColorProc PlatformColorProcs(SkBitmap::Config, SkMask::Format, SkColor);

    enum RowFlags {
        kSrcIsOpaque_RowFlag    = 1 << 0
    };

    /**
     *  Public entry-point to return a blitmask RowProc.
     *  May return NULL if config or format are not supported.
     */
    static RowProc RowFactory(SkBitmap::Config, SkMask::Format, RowFlags);
    
    /**
     *  Return either platform specific optimized blitmask RowProc,
     *  or NULL if no optimized routine is available.
     */
    static RowProc PlatformRowProcs(SkBitmap::Config, SkMask::Format, RowFlags);
};

#endif