180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru/*
280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Copyright 2011 Google Inc.
380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru *
480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Use of this source code is governed by a BSD-style license that can be
580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * found in the LICENSE file.
680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru */
780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#ifndef SkBlitMask_DEFINED
980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#define SkBlitMask_DEFINED
1080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
1180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkBitmap.h"
1280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkColor.h"
1380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkMask.h"
1480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
1580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass SkBlitMask {
1680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querupublic:
1780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /**
1880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  Returns true if the device config and mask format were supported.
1980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  else return false (nothing was drawn)
2080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     */
2180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    static bool BlitColor(const SkBitmap& device, const SkMask& mask,
2280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                          const SkIRect& clip, SkColor color);
2380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
2480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /**
2580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  Function pointer that blits the mask into a device (dst) colorized
2680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  by color. The number of pixels to blit is specified by width and height,
2780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  but each scanline is offset by dstRB (rowbytes) and srcRB respectively.
2880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     */
2980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    typedef void (*ColorProc)(void* dst, size_t dstRB,
3080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                              const void* mask, size_t maskRB,
3180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                              SkColor color, int width, int height);
3280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
3380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /**
3480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  Function pointer that blits a row of mask(lcd16) into a row of dst
3580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  colorized by a single color. The number of pixels to blit is specified
3680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  by width.
3780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     */
3880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    typedef void (*BlitLCD16RowProc)(SkPMColor dst[], const uint16_t src[],
3980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                                     SkColor color, int width,
4080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                                     SkPMColor opaqueDst);
4180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
4280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /**
4380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  Function pointer that blits a row of src colors through a row of a mask
4480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  onto a row of dst colors. The RowFactory that returns this function ptr
4580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  will have been told the formats for the mask and the dst.
4680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     */
4780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    typedef void (*RowProc)(void* dst, const void* mask,
4880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                            const SkPMColor* src, int width);
4980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
5080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /**
5180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  Public entry-point to return a blitmask ColorProc.
5280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  May return NULL if config or format are not supported.
5380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     */
5480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    static ColorProc ColorFactory(SkBitmap::Config, SkMask::Format, SkColor);
5580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
5680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /**
5780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  Return either platform specific optimized blitmask ColorProc,
5880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  or NULL if no optimized routine is available.
5980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     */
6080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    static ColorProc PlatformColorProcs(SkBitmap::Config, SkMask::Format, SkColor);
6180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
6280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /**
6380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  Public entry-point to return a blitcolor BlitLCD16RowProc.
6480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     */
6580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    static BlitLCD16RowProc BlitLCD16RowFactory(bool isOpaque);
6680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
6780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /**
6880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  Return either platform specific optimized blitcolor BlitLCD16RowProc,
6980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  or NULL if no optimized routine is available.
7080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     */
7180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    static BlitLCD16RowProc PlatformBlitRowProcs16(bool isOpaque);
7280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
7380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    enum RowFlags {
7480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kSrcIsOpaque_RowFlag    = 1 << 0
7580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    };
7680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
7780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /**
7880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  Public entry-point to return a blitmask RowProc.
7980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  May return NULL if config or format are not supported.
8080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     */
8180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    static RowProc RowFactory(SkBitmap::Config, SkMask::Format, RowFlags);
8280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
8380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /**
8480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  Return either platform specific optimized blitmask RowProc,
8580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  or NULL if no optimized routine is available.
8680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     */
8780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    static RowProc PlatformRowProcs(SkBitmap::Config, SkMask::Format, RowFlags);
8880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru};
8980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
9080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif
91