1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/skia/trunk/include/core/SkBlitRow.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,104 @@ 1.4 +/* 1.5 + * Copyright 2011 Google Inc. 1.6 + * 1.7 + * Use of this source code is governed by a BSD-style license that can be 1.8 + * found in the LICENSE file. 1.9 + */ 1.10 + 1.11 +#ifndef SkBlitRow_DEFINED 1.12 +#define SkBlitRow_DEFINED 1.13 + 1.14 +#include "SkBitmap.h" 1.15 +#include "SkColor.h" 1.16 + 1.17 +class SkBlitRow { 1.18 +public: 1.19 + enum Flags16 { 1.20 + //! If set, the alpha parameter will be != 255 1.21 + kGlobalAlpha_Flag = 0x01, 1.22 + //! If set, the src colors may have alpha != 255 1.23 + kSrcPixelAlpha_Flag = 0x02, 1.24 + //! If set, the resulting 16bit colors should be dithered 1.25 + kDither_Flag = 0x04 1.26 + }; 1.27 + 1.28 + /** Function pointer that reads a scanline of src SkPMColors, and writes 1.29 + a corresponding scanline of 16bit colors (specific format based on the 1.30 + config passed to the Factory. 1.31 + 1.32 + The x,y params are useful just for dithering 1.33 + 1.34 + @param alpha A global alpha to be applied to all of the src colors 1.35 + @param x The x coordinate of the beginning of the scanline 1.36 + @param y THe y coordinate of the scanline 1.37 + */ 1.38 + typedef void (*Proc)(uint16_t* dst, 1.39 + const SkPMColor* src, 1.40 + int count, U8CPU alpha, int x, int y); 1.41 + 1.42 + static Proc Factory(unsigned flags, SkBitmap::Config); 1.43 + 1.44 + ///////////// D32 version 1.45 + 1.46 + enum Flags32 { 1.47 + kGlobalAlpha_Flag32 = 1 << 0, 1.48 + kSrcPixelAlpha_Flag32 = 1 << 1 1.49 + }; 1.50 + 1.51 + /** Function pointer that blends 32bit colors onto a 32bit destination. 1.52 + @param dst array of dst 32bit colors 1.53 + @param src array of src 32bit colors (w/ or w/o alpha) 1.54 + @param count number of colors to blend 1.55 + @param alpha global alpha to be applied to all src colors 1.56 + */ 1.57 + typedef void (*Proc32)(uint32_t* dst, 1.58 + const SkPMColor* src, 1.59 + int count, U8CPU alpha); 1.60 + 1.61 + static Proc32 Factory32(unsigned flags32); 1.62 + 1.63 + /** Function pointer that blends a single color with a row of 32-bit colors 1.64 + onto a 32-bit destination 1.65 + */ 1.66 + typedef void (*ColorProc)(SkPMColor* dst, const SkPMColor* src, int count, 1.67 + SkPMColor color); 1.68 + 1.69 + /** Blend a single color onto a row of S32 pixels, writing the result 1.70 + into a row of D32 pixels. src and dst may be the same memory, but 1.71 + if they are not, they may not overlap. 1.72 + */ 1.73 + static void Color32(SkPMColor dst[], const SkPMColor src[], 1.74 + int count, SkPMColor color); 1.75 + 1.76 + //! Public entry-point to return a blit function ptr 1.77 + static ColorProc ColorProcFactory(); 1.78 + 1.79 + /** Function pointer that blends a single color onto a 32-bit rectangle. */ 1.80 + typedef void (*ColorRectProc)(SkPMColor* dst, int width, int height, 1.81 + size_t rowBytes, SkPMColor color); 1.82 + 1.83 + /** Blend a single color into a rectangle of D32 pixels. */ 1.84 + static void ColorRect32(SkPMColor* dst, int width, int height, 1.85 + size_t rowBytes, SkPMColor color); 1.86 + 1.87 + //! Public entry-point to return a blit function ptr 1.88 + static ColorRectProc ColorRectProcFactory(); 1.89 + 1.90 + /** These static functions are called by the Factory and Factory32 1.91 + functions, and should return either NULL, or a 1.92 + platform-specific function-ptr to be used in place of the 1.93 + system default. 1.94 + */ 1.95 + 1.96 + static Proc32 PlatformProcs32(unsigned flags); 1.97 + static Proc PlatformProcs565(unsigned flags); 1.98 + static ColorProc PlatformColorProc(); 1.99 + 1.100 +private: 1.101 + enum { 1.102 + kFlags16_Mask = 7, 1.103 + kFlags32_Mask = 3 1.104 + }; 1.105 +}; 1.106 + 1.107 +#endif