michael@0: /* michael@0: * Copyright 2011 Google Inc. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: michael@0: #ifndef SkBlitRow_DEFINED michael@0: #define SkBlitRow_DEFINED michael@0: michael@0: #include "SkBitmap.h" michael@0: #include "SkColor.h" michael@0: michael@0: class SkBlitRow { michael@0: public: michael@0: enum Flags16 { michael@0: //! If set, the alpha parameter will be != 255 michael@0: kGlobalAlpha_Flag = 0x01, michael@0: //! If set, the src colors may have alpha != 255 michael@0: kSrcPixelAlpha_Flag = 0x02, michael@0: //! If set, the resulting 16bit colors should be dithered michael@0: kDither_Flag = 0x04 michael@0: }; michael@0: michael@0: /** Function pointer that reads a scanline of src SkPMColors, and writes michael@0: a corresponding scanline of 16bit colors (specific format based on the michael@0: config passed to the Factory. michael@0: michael@0: The x,y params are useful just for dithering michael@0: michael@0: @param alpha A global alpha to be applied to all of the src colors michael@0: @param x The x coordinate of the beginning of the scanline michael@0: @param y THe y coordinate of the scanline michael@0: */ michael@0: typedef void (*Proc)(uint16_t* dst, michael@0: const SkPMColor* src, michael@0: int count, U8CPU alpha, int x, int y); michael@0: michael@0: static Proc Factory(unsigned flags, SkBitmap::Config); michael@0: michael@0: ///////////// D32 version michael@0: michael@0: enum Flags32 { michael@0: kGlobalAlpha_Flag32 = 1 << 0, michael@0: kSrcPixelAlpha_Flag32 = 1 << 1 michael@0: }; michael@0: michael@0: /** Function pointer that blends 32bit colors onto a 32bit destination. michael@0: @param dst array of dst 32bit colors michael@0: @param src array of src 32bit colors (w/ or w/o alpha) michael@0: @param count number of colors to blend michael@0: @param alpha global alpha to be applied to all src colors michael@0: */ michael@0: typedef void (*Proc32)(uint32_t* dst, michael@0: const SkPMColor* src, michael@0: int count, U8CPU alpha); michael@0: michael@0: static Proc32 Factory32(unsigned flags32); michael@0: michael@0: /** Function pointer that blends a single color with a row of 32-bit colors michael@0: onto a 32-bit destination michael@0: */ michael@0: typedef void (*ColorProc)(SkPMColor* dst, const SkPMColor* src, int count, michael@0: SkPMColor color); michael@0: michael@0: /** Blend a single color onto a row of S32 pixels, writing the result michael@0: into a row of D32 pixels. src and dst may be the same memory, but michael@0: if they are not, they may not overlap. michael@0: */ michael@0: static void Color32(SkPMColor dst[], const SkPMColor src[], michael@0: int count, SkPMColor color); michael@0: michael@0: //! Public entry-point to return a blit function ptr michael@0: static ColorProc ColorProcFactory(); michael@0: michael@0: /** Function pointer that blends a single color onto a 32-bit rectangle. */ michael@0: typedef void (*ColorRectProc)(SkPMColor* dst, int width, int height, michael@0: size_t rowBytes, SkPMColor color); michael@0: michael@0: /** Blend a single color into a rectangle of D32 pixels. */ michael@0: static void ColorRect32(SkPMColor* dst, int width, int height, michael@0: size_t rowBytes, SkPMColor color); michael@0: michael@0: //! Public entry-point to return a blit function ptr michael@0: static ColorRectProc ColorRectProcFactory(); michael@0: michael@0: /** These static functions are called by the Factory and Factory32 michael@0: functions, and should return either NULL, or a michael@0: platform-specific function-ptr to be used in place of the michael@0: system default. michael@0: */ michael@0: michael@0: static Proc32 PlatformProcs32(unsigned flags); michael@0: static Proc PlatformProcs565(unsigned flags); michael@0: static ColorProc PlatformColorProc(); michael@0: michael@0: private: michael@0: enum { michael@0: kFlags16_Mask = 7, michael@0: kFlags32_Mask = 3 michael@0: }; michael@0: }; michael@0: michael@0: #endif