reed@google.com | 58af9a6 | 2011-10-12 13:43:52 +0000 | [diff] [blame] | 1 | /* |
| 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.com | e901b4c | 2011-11-14 21:56:45 +0000 | [diff] [blame] | 11 | #include "SkColor.h" |
reed@google.com | 58af9a6 | 2011-10-12 13:43:52 +0000 | [diff] [blame] | 12 | #include "SkMask.h" |
reed | 41e010c | 2015-06-09 12:16:53 -0700 | [diff] [blame] | 13 | #include "SkPixmap.h" |
reed@google.com | 58af9a6 | 2011-10-12 13:43:52 +0000 | [diff] [blame] | 14 | |
| 15 | class SkBlitMask { |
| 16 | public: |
| 17 | /** |
reed@google.com | edb606c | 2011-10-18 13:56:50 +0000 | [diff] [blame] | 18 | * Returns true if the device config and mask format were supported. |
| 19 | * else return false (nothing was drawn) |
| 20 | */ |
reed | 41e010c | 2015-06-09 12:16:53 -0700 | [diff] [blame] | 21 | static bool BlitColor(const SkPixmap& device, const SkMask& mask, |
reed@google.com | edb606c | 2011-10-18 13:56:50 +0000 | [diff] [blame] | 22 | const SkIRect& clip, SkColor color); |
| 23 | |
| 24 | /** |
reed@google.com | 58af9a6 | 2011-10-12 13:43:52 +0000 | [diff] [blame] | 25 | * 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.com | e901b4c | 2011-11-14 21:56:45 +0000 | [diff] [blame] | 29 | typedef void (*ColorProc)(void* dst, size_t dstRB, |
| 30 | const void* mask, size_t maskRB, |
| 31 | SkColor color, int width, int height); |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 32 | |
tomhudson@google.com | d6770e6 | 2012-02-14 16:01:15 +0000 | [diff] [blame] | 33 | /** |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 34 | * Function pointer that blits a row of mask(lcd16) into a row of dst |
tomhudson@google.com | d6770e6 | 2012-02-14 16:01:15 +0000 | [diff] [blame] | 35 | * 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.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 39 | SkColor color, int width, |
tomhudson@google.com | d6770e6 | 2012-02-14 16:01:15 +0000 | [diff] [blame] | 40 | SkPMColor opaqueDst); |
reed@google.com | 58af9a6 | 2011-10-12 13:43:52 +0000 | [diff] [blame] | 41 | |
reed@google.com | edb606c | 2011-10-18 13:56:50 +0000 | [diff] [blame] | 42 | /** |
reed@google.com | e901b4c | 2011-11-14 21:56:45 +0000 | [diff] [blame] | 43 | * 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.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 49 | |
reed@google.com | e901b4c | 2011-11-14 21:56:45 +0000 | [diff] [blame] | 50 | /** |
tomhudson@google.com | d6770e6 | 2012-02-14 16:01:15 +0000 | [diff] [blame] | 51 | * 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, |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 57 | * or nullptr if no optimized routine is available. |
tomhudson@google.com | d6770e6 | 2012-02-14 16:01:15 +0000 | [diff] [blame] | 58 | */ |
| 59 | static BlitLCD16RowProc PlatformBlitRowProcs16(bool isOpaque); |
reed@google.com | 1750bf1 | 2011-11-15 19:51:02 +0000 | [diff] [blame] | 60 | |
| 61 | enum RowFlags { |
| 62 | kSrcIsOpaque_RowFlag = 1 << 0 |
| 63 | }; |
| 64 | |
| 65 | /** |
| 66 | * Public entry-point to return a blitmask RowProc. |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 67 | * May return nullptr if config or format are not supported. |
reed@google.com | 1750bf1 | 2011-11-15 19:51:02 +0000 | [diff] [blame] | 68 | */ |
commit-bot@chromium.org | cba7378 | 2014-05-29 15:57:47 +0000 | [diff] [blame] | 69 | static RowProc RowFactory(SkColorType, SkMask::Format, RowFlags); |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 70 | |
reed@google.com | e901b4c | 2011-11-14 21:56:45 +0000 | [diff] [blame] | 71 | /** |
| 72 | * Return either platform specific optimized blitmask RowProc, |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 73 | * or nullptr if no optimized routine is available. |
reed@google.com | e901b4c | 2011-11-14 21:56:45 +0000 | [diff] [blame] | 74 | */ |
commit-bot@chromium.org | cba7378 | 2014-05-29 15:57:47 +0000 | [diff] [blame] | 75 | static RowProc PlatformRowProcs(SkColorType, SkMask::Format, RowFlags); |
reed@google.com | 58af9a6 | 2011-10-12 13:43:52 +0000 | [diff] [blame] | 76 | }; |
| 77 | |
| 78 | #endif |