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 "SkMatrix.h" 12 #include "SkTextureCompressor.h" 13 #include "SkTypes.h" 14 #include "SkXfermode.h" 15 16 struct ProcCoeff; 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(), and automatically #if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS. 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)(const ProcCoeff&, SkXfermode::Mode); 28 29 typedef void (*BoxBlur)(const SkPMColor*, int, const SkIRect& srcBounds, SkPMColor*, int, int, int, int, int); 30 extern BoxBlur box_blur_xx, box_blur_xy, box_blur_yx; 31 32 typedef void (*Morph)(const SkPMColor*, SkPMColor*, int, int, int, int, int); 33 extern Morph dilate_x, dilate_y, erode_x, erode_y; 34 35 typedef bool (*TextureCompressor)(uint8_t* dst, const uint8_t* src, 36 int width, int height, size_t rowBytes); 37 extern TextureCompressor (*texture_compressor)(SkColorType, SkTextureCompressor::Format); 38 extern bool (*fill_block_dimensions)(SkTextureCompressor::Format, int* x, int* y); 39 40 extern void (*blit_mask_d32_a8)(SkPMColor*, size_t, const SkAlpha*, size_t, SkColor, int, int); 41 extern void (*blit_row_color32)(SkPMColor*, const SkPMColor*, int, SkPMColor); 42 43 // This function is an optimized version of SkColorCubeFilter::filterSpan 44 extern void (*color_cube_filter_span)(const SkPMColor[], 45 int, 46 SkPMColor[], 47 const int * [2], 48 const SkScalar * [2], 49 int, 50 const SkColor*); 51 52 extern SkMatrix::MapPtsProc matrix_translate, matrix_scale_translate, matrix_affine; 53 54 // Swizzle input into some sort of 8888 pixel, {premul,unpremul} x {rgba,bgra}. 55 typedef void (*Swizzle_8888)(uint32_t*, const void*, int); 56 extern Swizzle_8888 RGBA_to_BGRA, // i.e. just swap RB 57 RGBA_to_rgbA, // i.e. just premultiply 58 RGBA_to_bgrA, // i.e. swap RB and premultiply 59 RGB_to_RGB1, // i.e. insert an opaque alpha 60 RGB_to_BGR1, // i.e. swap RB and insert an opaque alpha 61 gray_to_RGB1, // i.e. expand to color channels + an opaque alpha 62 grayA_to_RGBA, // i.e. expand to color channels 63 grayA_to_rgbA, // i.e. expand to color channels and premultiply 64 inverted_CMYK_to_RGB1, // i.e. convert color space 65 inverted_CMYK_to_BGR1; // i.e. convert color space 66 67 extern void (*half_to_float)(float[], const uint16_t[], int); 68 extern void (*float_to_half)(uint16_t[], const float[], int); 69 } 70 71 #endif//SkOpts_DEFINED 72