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 "include/core/SkTypes.h" 12 #include "src/core/SkConvolver.h" 13 #include "src/core/SkRasterPipeline.h" 14 #include "src/core/SkXfermodePriv.h" 15 16 struct SkBitmapProcState; 17 18 namespace SkOpts { 19 // Call to replace pointers to portable functions with pointers to CPU-specific functions. 20 // Thread-safe and idempotent. 21 // Called by SkGraphics::Init(). 22 void Init(); 23 24 // Declare function pointers here... 25 26 // May return nullptr if we haven't specialized the given Mode. 27 extern SkXfermode* (*create_xfermode)(SkBlendMode); 28 29 extern void (*blit_mask_d32_a8)(SkPMColor*, size_t, const SkAlpha*, size_t, SkColor, int, int); 30 extern void (*blit_row_color32)(SkPMColor*, const SkPMColor*, int, SkPMColor); 31 extern void (*blit_row_s32a_opaque)(SkPMColor*, const SkPMColor*, int, U8CPU); 32 33 // Swizzle input into some sort of 8888 pixel, {premul,unpremul} x {rgba,bgra}. 34 typedef void (*Swizzle_8888_u32)(uint32_t*, const uint32_t*, int); 35 extern Swizzle_8888_u32 RGBA_to_BGRA, // i.e. just swap RB 36 RGBA_to_rgbA, // i.e. just premultiply 37 RGBA_to_bgrA, // i.e. swap RB and premultiply 38 inverted_CMYK_to_RGB1, // i.e. convert color space 39 inverted_CMYK_to_BGR1; // i.e. convert color space 40 41 typedef void (*Swizzle_8888_u8)(uint32_t*, const uint8_t*, int); 42 extern Swizzle_8888_u8 RGB_to_RGB1, // i.e. insert an opaque alpha 43 RGB_to_BGR1, // i.e. swap RB and insert an opaque alpha 44 gray_to_RGB1, // i.e. expand to color channels + an opaque alpha 45 grayA_to_RGBA, // i.e. expand to color channels 46 grayA_to_rgbA; // i.e. expand to color channels and premultiply 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 extern void (*rect_memset16)(uint16_t[], uint16_t, int, size_t, int); 53 extern void (*rect_memset32)(uint32_t[], uint32_t, int, size_t, int); 54 extern void (*rect_memset64)(uint64_t[], uint64_t, int, size_t, int); 55 56 extern float (*cubic_solver)(float, float, float, float); 57 58 // The fastest high quality 32-bit hash we can provide on this platform. 59 extern uint32_t (*hash_fn)(const void*, size_t, uint32_t seed); 60 static inline uint32_t hash(const void* data, size_t bytes, uint32_t seed=0) { 61 return hash_fn(data, bytes, seed); 62 } 63 64 // SkBitmapProcState optimized Shader, Sample, or Matrix procs. 65 // This is the only one that can use anything past SSE2/NEON. 66 extern void (*S32_alpha_D32_filter_DX)(const SkBitmapProcState&, 67 const uint32_t* xy, int count, SkPMColor*); 68 69 #define M(st) +1 70 // We can't necessarily express the type of SkJumper stage functions here, 71 // so we just use this void(*)(void) as a stand-in. 72 using StageFn = void(*)(void); 73 extern StageFn stages_highp[SK_RASTER_PIPELINE_STAGES(M)], just_return_highp; 74 extern StageFn stages_lowp [SK_RASTER_PIPELINE_STAGES(M)], just_return_lowp; 75 76 extern void (*start_pipeline_highp)(size_t,size_t,size_t,size_t, void**); 77 extern void (*start_pipeline_lowp )(size_t,size_t,size_t,size_t, void**); 78 #undef M 79 80 extern void (*convolve_vertically)(const SkConvolutionFilter1D::ConvolutionFixed* filter_values, 81 int filter_length, unsigned char* const* source_data_rows, 82 int pixel_width, unsigned char* out_row, bool has_alpha); 83 extern void (*convolve_4_rows_horizontally)(const unsigned char* src_data[4], 84 const SkConvolutionFilter1D& filter, 85 unsigned char* out_row[4], size_t out_row_bytes); 86 extern void (*convolve_horizontally)(const unsigned char* src_data, const SkConvolutionFilter1D& filter, 87 unsigned char* out_row, bool has_alpha); 88 } 89 90 #endif//SkOpts_DEFINED 91