SkOpts.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. #ifndef SkOpts_DEFINED
  8. #define SkOpts_DEFINED
  9. #include "include/core/SkTypes.h"
  10. #include "src/core/SkRasterPipeline.h"
  11. #include "src/core/SkXfermodePriv.h"
  12. struct SkBitmapProcState;
  13. namespace SkOpts {
  14. // Call to replace pointers to portable functions with pointers to CPU-specific functions.
  15. // Thread-safe and idempotent.
  16. // Called by SkGraphics::Init().
  17. void Init();
  18. // Declare function pointers here...
  19. // May return nullptr if we haven't specialized the given Mode.
  20. extern SkXfermode* (*create_xfermode)(SkBlendMode);
  21. extern void (*blit_mask_d32_a8)(SkPMColor*, size_t, const SkAlpha*, size_t, SkColor, int, int);
  22. extern void (*blit_row_color32)(SkPMColor*, const SkPMColor*, int, SkPMColor);
  23. extern void (*blit_row_s32a_opaque)(SkPMColor*, const SkPMColor*, int, U8CPU);
  24. // Swizzle input into some sort of 8888 pixel, {premul,unpremul} x {rgba,bgra}.
  25. typedef void (*Swizzle_8888_u32)(uint32_t*, const uint32_t*, int);
  26. extern Swizzle_8888_u32 RGBA_to_BGRA, // i.e. just swap RB
  27. RGBA_to_rgbA, // i.e. just premultiply
  28. RGBA_to_bgrA, // i.e. swap RB and premultiply
  29. inverted_CMYK_to_RGB1, // i.e. convert color space
  30. inverted_CMYK_to_BGR1; // i.e. convert color space
  31. typedef void (*Swizzle_8888_u8)(uint32_t*, const uint8_t*, int);
  32. extern Swizzle_8888_u8 RGB_to_RGB1, // i.e. insert an opaque alpha
  33. RGB_to_BGR1, // i.e. swap RB and insert an opaque alpha
  34. gray_to_RGB1, // i.e. expand to color channels + an opaque alpha
  35. grayA_to_RGBA, // i.e. expand to color channels
  36. grayA_to_rgbA; // i.e. expand to color channels and premultiply
  37. extern void (*memset16)(uint16_t[], uint16_t, int);
  38. extern void SK_API (*memset32)(uint32_t[], uint32_t, int);
  39. extern void (*memset64)(uint64_t[], uint64_t, int);
  40. extern void (*rect_memset16)(uint16_t[], uint16_t, int, size_t, int);
  41. extern void (*rect_memset32)(uint32_t[], uint32_t, int, size_t, int);
  42. extern void (*rect_memset64)(uint64_t[], uint64_t, int, size_t, int);
  43. extern float (*cubic_solver)(float, float, float, float);
  44. // The fastest high quality 32-bit hash we can provide on this platform.
  45. extern uint32_t (*hash_fn)(const void*, size_t, uint32_t seed);
  46. static inline uint32_t hash(const void* data, size_t bytes, uint32_t seed=0) {
  47. return hash_fn(data, bytes, seed);
  48. }
  49. // SkBitmapProcState optimized Shader, Sample, or Matrix procs.
  50. // This is the only one that can use anything past SSE2/NEON.
  51. extern void (*S32_alpha_D32_filter_DX)(const SkBitmapProcState&,
  52. const uint32_t* xy, int count, SkPMColor*);
  53. #define M(st) +1
  54. // We can't necessarily express the type of SkJumper stage functions here,
  55. // so we just use this void(*)(void) as a stand-in.
  56. using StageFn = void(*)(void);
  57. extern StageFn stages_highp[SK_RASTER_PIPELINE_STAGES(M)], just_return_highp;
  58. extern StageFn stages_lowp [SK_RASTER_PIPELINE_STAGES(M)], just_return_lowp;
  59. extern void (*start_pipeline_highp)(size_t,size_t,size_t,size_t, void**);
  60. extern void (*start_pipeline_lowp )(size_t,size_t,size_t,size_t, void**);
  61. #undef M
  62. }
  63. #endif//SkOpts_DEFINED