1ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com/* 2ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Copyright 2011 Google Inc. 3ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * 4ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Use of this source code is governed by a BSD-style license that can be 5ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * found in the LICENSE file. 6ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com */ 758af9a64701540c7f8083bc22a42d0bae3a5583creed@google.com 8c4cae85752e3e486cf4eac8cd8128f57b6f40563reed@android.com#ifndef SkBlitRow_DEFINED 9c4cae85752e3e486cf4eac8cd8128f57b6f40563reed@android.com#define SkBlitRow_DEFINED 10c4cae85752e3e486cf4eac8cd8128f57b6f40563reed@android.com 11c4cae85752e3e486cf4eac8cd8128f57b6f40563reed@android.com#include "SkBitmap.h" 12c4cae85752e3e486cf4eac8cd8128f57b6f40563reed@android.com#include "SkColor.h" 13c4cae85752e3e486cf4eac8cd8128f57b6f40563reed@android.com 14c4cae85752e3e486cf4eac8cd8128f57b6f40563reed@android.comclass SkBlitRow { 15c4cae85752e3e486cf4eac8cd8128f57b6f40563reed@android.compublic: 16c4cae85752e3e486cf4eac8cd8128f57b6f40563reed@android.com enum Flags16 { 17c4cae85752e3e486cf4eac8cd8128f57b6f40563reed@android.com //! If set, the alpha parameter will be != 255 18c4cae85752e3e486cf4eac8cd8128f57b6f40563reed@android.com kGlobalAlpha_Flag = 0x01, 19c4cae85752e3e486cf4eac8cd8128f57b6f40563reed@android.com //! If set, the src colors may have alpha != 255 20c4cae85752e3e486cf4eac8cd8128f57b6f40563reed@android.com kSrcPixelAlpha_Flag = 0x02, 21c4cae85752e3e486cf4eac8cd8128f57b6f40563reed@android.com //! If set, the resulting 16bit colors should be dithered 22c4cae85752e3e486cf4eac8cd8128f57b6f40563reed@android.com kDither_Flag = 0x04 23c4cae85752e3e486cf4eac8cd8128f57b6f40563reed@android.com }; 24c4cae85752e3e486cf4eac8cd8128f57b6f40563reed@android.com 25c4cae85752e3e486cf4eac8cd8128f57b6f40563reed@android.com /** Function pointer that reads a scanline of src SkPMColors, and writes 26c4cae85752e3e486cf4eac8cd8128f57b6f40563reed@android.com a corresponding scanline of 16bit colors (specific format based on the 27c4cae85752e3e486cf4eac8cd8128f57b6f40563reed@android.com config passed to the Factory. 28981d4798007b91e2e19c13b171583927a56df63breed@google.com 29c4cae85752e3e486cf4eac8cd8128f57b6f40563reed@android.com The x,y params are useful just for dithering 30981d4798007b91e2e19c13b171583927a56df63breed@google.com 31c4cae85752e3e486cf4eac8cd8128f57b6f40563reed@android.com @param alpha A global alpha to be applied to all of the src colors 32c4cae85752e3e486cf4eac8cd8128f57b6f40563reed@android.com @param x The x coordinate of the beginning of the scanline 33c4cae85752e3e486cf4eac8cd8128f57b6f40563reed@android.com @param y THe y coordinate of the scanline 34c4cae85752e3e486cf4eac8cd8128f57b6f40563reed@android.com */ 35a87cd2af4c7f46ba8437c2e500805c9deb9e3a40tomhudson@google.com typedef void (*Proc)(uint16_t* dst, 36a87cd2af4c7f46ba8437c2e500805c9deb9e3a40tomhudson@google.com const SkPMColor* src, 37c4cae85752e3e486cf4eac8cd8128f57b6f40563reed@android.com int count, U8CPU alpha, int x, int y); 38c4cae85752e3e486cf4eac8cd8128f57b6f40563reed@android.com 39cba73780bbd12fd254229517aec04fcbf0b64b52commit-bot@chromium.org static Proc Factory(unsigned flags, SkColorType); 40c4cae85752e3e486cf4eac8cd8128f57b6f40563reed@android.com 41c4cae85752e3e486cf4eac8cd8128f57b6f40563reed@android.com ///////////// D32 version 42c4cae85752e3e486cf4eac8cd8128f57b6f40563reed@android.com 43c4cae85752e3e486cf4eac8cd8128f57b6f40563reed@android.com enum Flags32 { 44c4cae85752e3e486cf4eac8cd8128f57b6f40563reed@android.com kGlobalAlpha_Flag32 = 1 << 0, 451f90287df3129cb267422e482c52ebeca6a8990ftomhudson@google.com kSrcPixelAlpha_Flag32 = 1 << 1 46c4cae85752e3e486cf4eac8cd8128f57b6f40563reed@android.com }; 47c4cae85752e3e486cf4eac8cd8128f57b6f40563reed@android.com 48c4cae85752e3e486cf4eac8cd8128f57b6f40563reed@android.com /** Function pointer that blends 32bit colors onto a 32bit destination. 49c4cae85752e3e486cf4eac8cd8128f57b6f40563reed@android.com @param dst array of dst 32bit colors 50c4cae85752e3e486cf4eac8cd8128f57b6f40563reed@android.com @param src array of src 32bit colors (w/ or w/o alpha) 51c4cae85752e3e486cf4eac8cd8128f57b6f40563reed@android.com @param count number of colors to blend 52c4cae85752e3e486cf4eac8cd8128f57b6f40563reed@android.com @param alpha global alpha to be applied to all src colors 53c4cae85752e3e486cf4eac8cd8128f57b6f40563reed@android.com */ 54a87cd2af4c7f46ba8437c2e500805c9deb9e3a40tomhudson@google.com typedef void (*Proc32)(uint32_t* dst, 55a87cd2af4c7f46ba8437c2e500805c9deb9e3a40tomhudson@google.com const SkPMColor* src, 56c4cae85752e3e486cf4eac8cd8128f57b6f40563reed@android.com int count, U8CPU alpha); 57c4cae85752e3e486cf4eac8cd8128f57b6f40563reed@android.com 58c4cae85752e3e486cf4eac8cd8128f57b6f40563reed@android.com static Proc32 Factory32(unsigned flags32); 59981d4798007b91e2e19c13b171583927a56df63breed@google.com 608dd90a926a8660da2bacc7af149f4ac5b2e7c64ctomhudson@google.com /** Function pointer that blends a single color with a row of 32-bit colors 618dd90a926a8660da2bacc7af149f4ac5b2e7c64ctomhudson@google.com onto a 32-bit destination 628dd90a926a8660da2bacc7af149f4ac5b2e7c64ctomhudson@google.com */ 638dd90a926a8660da2bacc7af149f4ac5b2e7c64ctomhudson@google.com typedef void (*ColorProc)(SkPMColor* dst, const SkPMColor* src, int count, 648dd90a926a8660da2bacc7af149f4ac5b2e7c64ctomhudson@google.com SkPMColor color); 658dd90a926a8660da2bacc7af149f4ac5b2e7c64ctomhudson@google.com 66c4cae85752e3e486cf4eac8cd8128f57b6f40563reed@android.com /** Blend a single color onto a row of S32 pixels, writing the result 67c4cae85752e3e486cf4eac8cd8128f57b6f40563reed@android.com into a row of D32 pixels. src and dst may be the same memory, but 68c4cae85752e3e486cf4eac8cd8128f57b6f40563reed@android.com if they are not, they may not overlap. 69c4cae85752e3e486cf4eac8cd8128f57b6f40563reed@android.com */ 70981d4798007b91e2e19c13b171583927a56df63breed@google.com static void Color32(SkPMColor dst[], const SkPMColor src[], 7129e5054dd07c97c2195c5f64bf67aaa6b5afa204senorblanco@chromium.org int count, SkPMColor color); 72c4cae85752e3e486cf4eac8cd8128f57b6f40563reed@android.com 738dd90a926a8660da2bacc7af149f4ac5b2e7c64ctomhudson@google.com //! Public entry-point to return a blit function ptr 7429e5054dd07c97c2195c5f64bf67aaa6b5afa204senorblanco@chromium.org static ColorProc ColorProcFactory(); 75c4cae85752e3e486cf4eac8cd8128f57b6f40563reed@android.com 768dd90a926a8660da2bacc7af149f4ac5b2e7c64ctomhudson@google.com /** Function pointer that blends a single color onto a 32-bit rectangle. */ 778dd90a926a8660da2bacc7af149f4ac5b2e7c64ctomhudson@google.com typedef void (*ColorRectProc)(SkPMColor* dst, int width, int height, 788dd90a926a8660da2bacc7af149f4ac5b2e7c64ctomhudson@google.com size_t rowBytes, SkPMColor color); 798dd90a926a8660da2bacc7af149f4ac5b2e7c64ctomhudson@google.com 808dd90a926a8660da2bacc7af149f4ac5b2e7c64ctomhudson@google.com /** Blend a single color into a rectangle of D32 pixels. */ 818dd90a926a8660da2bacc7af149f4ac5b2e7c64ctomhudson@google.com static void ColorRect32(SkPMColor* dst, int width, int height, 828dd90a926a8660da2bacc7af149f4ac5b2e7c64ctomhudson@google.com size_t rowBytes, SkPMColor color); 838dd90a926a8660da2bacc7af149f4ac5b2e7c64ctomhudson@google.com 848dd90a926a8660da2bacc7af149f4ac5b2e7c64ctomhudson@google.com //! Public entry-point to return a blit function ptr 858dd90a926a8660da2bacc7af149f4ac5b2e7c64ctomhudson@google.com static ColorRectProc ColorRectProcFactory(); 868dd90a926a8660da2bacc7af149f4ac5b2e7c64ctomhudson@google.com 879272761b22746d2d22439c26f5555028f8e824dasenorblanco@chromium.org /** These static functions are called by the Factory and Factory32 889272761b22746d2d22439c26f5555028f8e824dasenorblanco@chromium.org functions, and should return either NULL, or a 899272761b22746d2d22439c26f5555028f8e824dasenorblanco@chromium.org platform-specific function-ptr to be used in place of the 909272761b22746d2d22439c26f5555028f8e824dasenorblanco@chromium.org system default. 919272761b22746d2d22439c26f5555028f8e824dasenorblanco@chromium.org */ 929272761b22746d2d22439c26f5555028f8e824dasenorblanco@chromium.org 93f0f4e9abba62a405b7a41e40fcee20b45eb348eereed@android.com static Proc32 PlatformProcs32(unsigned flags); 94f0f4e9abba62a405b7a41e40fcee20b45eb348eereed@android.com static Proc PlatformProcs565(unsigned flags); 95c3856384e4ab9a7ad5902696a5c972ab595b8467senorblanco@chromium.org static ColorProc PlatformColorProc(); 969272761b22746d2d22439c26f5555028f8e824dasenorblanco@chromium.org 97c4cae85752e3e486cf4eac8cd8128f57b6f40563reed@android.comprivate: 98c4cae85752e3e486cf4eac8cd8128f57b6f40563reed@android.com enum { 99c4cae85752e3e486cf4eac8cd8128f57b6f40563reed@android.com kFlags16_Mask = 7, 100c4cae85752e3e486cf4eac8cd8128f57b6f40563reed@android.com kFlags32_Mask = 3 101c4cae85752e3e486cf4eac8cd8128f57b6f40563reed@android.com }; 102c4cae85752e3e486cf4eac8cd8128f57b6f40563reed@android.com}; 103c4cae85752e3e486cf4eac8cd8128f57b6f40563reed@android.com 104c4cae85752e3e486cf4eac8cd8128f57b6f40563reed@android.com#endif 105