1 /* 2 * Copyright 2015 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 SkOpts_DEFINED 9 #define SkOpts_DEFINED 10 11 #include "SkRasterPipeline.h" 12 #include "SkTypes.h" 13 #include "SkXfermodePriv.h" 14 15 struct ProcCoeff; 16 17 namespace SkOpts { 18 // Call to replace pointers to portable functions with pointers to CPU-specific functions. 19 // Thread-safe and idempotent. 20 // Called by SkGraphics::Init(). 21 void Init(); 22 23 // Declare function pointers here... 24 25 // May return nullptr if we haven't specialized the given Mode. 26 extern SkXfermode* (*create_xfermode)(SkBlendMode); 27 28 typedef void (*Morph)(const SkPMColor*, SkPMColor*, int, int, int, int, int); 29 extern Morph dilate_x, dilate_y, erode_x, erode_y; 30 31 extern void (*blit_mask_d32_a8)(SkPMColor*, size_t, const SkAlpha*, size_t, SkColor, int, int); 32 extern void (*blit_row_color32)(SkPMColor*, const SkPMColor*, int, SkPMColor); 33 extern void (*blit_row_s32a_opaque)(SkPMColor*, const SkPMColor*, int, U8CPU); 34 35 // Swizzle input into some sort of 8888 pixel, {premul,unpremul} x {rgba,bgra}. 36 typedef void (*Swizzle_8888)(uint32_t*, const void*, int); 37 extern Swizzle_8888 RGBA_to_BGRA, // i.e. just swap RB 38 RGBA_to_rgbA, // i.e. just premultiply 39 RGBA_to_bgrA, // i.e. swap RB and premultiply 40 RGB_to_RGB1, // i.e. insert an opaque alpha 41 RGB_to_BGR1, // i.e. swap RB and insert an opaque alpha 42 gray_to_RGB1, // i.e. expand to color channels + an opaque alpha 43 grayA_to_RGBA, // i.e. expand to color channels 44 grayA_to_rgbA, // i.e. expand to color channels and premultiply 45 inverted_CMYK_to_RGB1, // i.e. convert color space 46 inverted_CMYK_to_BGR1; // i.e. convert color space 47 48 extern void (*memset16)(uint16_t[], uint16_t, int); 49 extern void SK_API (*memset32)(uint32_t[], uint32_t, int); 50 extern void (*memset64)(uint64_t[], uint64_t, int); 51 52 // The fastest high quality 32-bit hash we can provide on this platform. 53 extern uint32_t (*hash_fn)(const void*, size_t, uint32_t seed); 54 static inline uint32_t hash(const void* data, size_t bytes, uint32_t seed=0) { 55 return hash_fn(data, bytes, seed); 56 } 57 } 58 59 #endif//SkOpts_DEFINED 60