blob: f36f9f3d829a6c562b0de119d4d5531172efd113 [file] [log] [blame]
reed@google.com58af9a62011-10-12 13:43:52 +00001/*
2 * Copyright 2011 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 SkBlitMask_DEFINED
9#define SkBlitMask_DEFINED
10
reed@google.come901b4c2011-11-14 21:56:45 +000011#include "SkColor.h"
reed@google.com58af9a62011-10-12 13:43:52 +000012#include "SkMask.h"
reed41e010c2015-06-09 12:16:53 -070013#include "SkPixmap.h"
reed@google.com58af9a62011-10-12 13:43:52 +000014
15class SkBlitMask {
16public:
17 /**
reed@google.comedb606c2011-10-18 13:56:50 +000018 * Returns true if the device config and mask format were supported.
19 * else return false (nothing was drawn)
20 */
reed41e010c2015-06-09 12:16:53 -070021 static bool BlitColor(const SkPixmap& device, const SkMask& mask,
reed@google.comedb606c2011-10-18 13:56:50 +000022 const SkIRect& clip, SkColor color);
23
24 /**
reed@google.com58af9a62011-10-12 13:43:52 +000025 * Function pointer that blits the mask into a device (dst) colorized
26 * by color. The number of pixels to blit is specified by width and height,
27 * but each scanline is offset by dstRB (rowbytes) and srcRB respectively.
28 */
reed@google.come901b4c2011-11-14 21:56:45 +000029 typedef void (*ColorProc)(void* dst, size_t dstRB,
30 const void* mask, size_t maskRB,
31 SkColor color, int width, int height);
rmistry@google.comfbfcd562012-08-23 18:09:54 +000032
tomhudson@google.comd6770e62012-02-14 16:01:15 +000033 /**
rmistry@google.comfbfcd562012-08-23 18:09:54 +000034 * Function pointer that blits a row of mask(lcd16) into a row of dst
tomhudson@google.comd6770e62012-02-14 16:01:15 +000035 * colorized by a single color. The number of pixels to blit is specified
36 * by width.
37 */
38 typedef void (*BlitLCD16RowProc)(SkPMColor dst[], const uint16_t src[],
rmistry@google.comfbfcd562012-08-23 18:09:54 +000039 SkColor color, int width,
tomhudson@google.comd6770e62012-02-14 16:01:15 +000040 SkPMColor opaqueDst);
reed@google.com58af9a62011-10-12 13:43:52 +000041
reed@google.comedb606c2011-10-18 13:56:50 +000042 /**
reed@google.come901b4c2011-11-14 21:56:45 +000043 * Function pointer that blits a row of src colors through a row of a mask
44 * onto a row of dst colors. The RowFactory that returns this function ptr
45 * will have been told the formats for the mask and the dst.
46 */
47 typedef void (*RowProc)(void* dst, const void* mask,
48 const SkPMColor* src, int width);
rmistry@google.comfbfcd562012-08-23 18:09:54 +000049
reed@google.come901b4c2011-11-14 21:56:45 +000050 /**
tomhudson@google.comd6770e62012-02-14 16:01:15 +000051 * Public entry-point to return a blitcolor BlitLCD16RowProc.
52 */
53 static BlitLCD16RowProc BlitLCD16RowFactory(bool isOpaque);
54
55 /**
56 * Return either platform specific optimized blitcolor BlitLCD16RowProc,
halcanary96fcdcc2015-08-27 07:41:13 -070057 * or nullptr if no optimized routine is available.
tomhudson@google.comd6770e62012-02-14 16:01:15 +000058 */
59 static BlitLCD16RowProc PlatformBlitRowProcs16(bool isOpaque);
reed@google.com1750bf12011-11-15 19:51:02 +000060
61 enum RowFlags {
62 kSrcIsOpaque_RowFlag = 1 << 0
63 };
64
65 /**
66 * Public entry-point to return a blitmask RowProc.
halcanary96fcdcc2015-08-27 07:41:13 -070067 * May return nullptr if config or format are not supported.
reed@google.com1750bf12011-11-15 19:51:02 +000068 */
commit-bot@chromium.orgcba73782014-05-29 15:57:47 +000069 static RowProc RowFactory(SkColorType, SkMask::Format, RowFlags);
rmistry@google.comfbfcd562012-08-23 18:09:54 +000070
reed@google.come901b4c2011-11-14 21:56:45 +000071 /**
72 * Return either platform specific optimized blitmask RowProc,
halcanary96fcdcc2015-08-27 07:41:13 -070073 * or nullptr if no optimized routine is available.
reed@google.come901b4c2011-11-14 21:56:45 +000074 */
commit-bot@chromium.orgcba73782014-05-29 15:57:47 +000075 static RowProc PlatformRowProcs(SkColorType, SkMask::Format, RowFlags);
reed@google.com58af9a62011-10-12 13:43:52 +000076};
77
78#endif