skia_paint_util.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Copyright (c) 2017 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef UI_GFX_SKIA_PAINT_UTIL_H_
  5. #define UI_GFX_SKIA_PAINT_UTIL_H_
  6. #include <memory>
  7. #include <vector>
  8. #include "cc/paint/paint_shader.h"
  9. #include "ui/gfx/gfx_export.h"
  10. #include "ui/gfx/shadow_value.h"
  11. class SkDrawLooper;
  12. class SkMatrix;
  13. namespace gfx {
  14. class ImageSkiaRep;
  15. // Creates a bitmap shader for the image rep with the image rep's scale factor.
  16. // Sets the created shader's local matrix such that it displays the image rep at
  17. // the correct scale factor.
  18. // The shader's local matrix should not be changed after the shader is created.
  19. // TODO(pkotwicz): Allow shader's local matrix to be changed after the shader
  20. // is created.
  21. //
  22. GFX_EXPORT sk_sp<cc::PaintShader> CreateImageRepShader(
  23. const gfx::ImageSkiaRep& image_rep,
  24. SkTileMode tile_mode_x,
  25. SkTileMode tile_mode_y,
  26. const SkMatrix& local_matrix);
  27. // Creates a bitmap shader for the image rep with the passed in scale factor.
  28. GFX_EXPORT sk_sp<cc::PaintShader> CreateImageRepShaderForScale(
  29. const gfx::ImageSkiaRep& image_rep,
  30. SkTileMode tile_mode_x,
  31. SkTileMode tile_mode_y,
  32. const SkMatrix& local_matrix,
  33. SkScalar scale);
  34. // Creates a gradient shader. The caller owns the shader.
  35. GFX_EXPORT sk_sp<cc::PaintShader> CreateGradientShader(
  36. const gfx::Point& start_point,
  37. const gfx::Point& end_point,
  38. SkColor start_color,
  39. SkColor end_color);
  40. // Creates a draw looper to generate |shadows|. The caller owns the draw looper.
  41. // NULL is returned if |shadows| is empty since no draw looper is needed in
  42. // this case.
  43. GFX_EXPORT sk_sp<SkDrawLooper> CreateShadowDrawLooper(
  44. const std::vector<ShadowValue>& shadows);
  45. } // namespace gfx
  46. #endif // UI_GFX_SKIA_PAINT_UTIL_H_