| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef UI_GFX_SKIA_UTIL_H_ | 5 #ifndef UI_GFX_SKIA_UTIL_H_ |
| 6 #define UI_GFX_SKIA_UTIL_H_ | 6 #define UI_GFX_SKIA_UTIL_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "cc/paint/paint_shader.h" |
| 11 #include "third_party/skia/include/core/SkColor.h" | 12 #include "third_party/skia/include/core/SkColor.h" |
| 12 #include "third_party/skia/include/core/SkRect.h" | 13 #include "third_party/skia/include/core/SkRect.h" |
| 13 #include "third_party/skia/include/core/SkShader.h" | |
| 14 #include "ui/gfx/geometry/quad_f.h" | 14 #include "ui/gfx/geometry/quad_f.h" |
| 15 #include "ui/gfx/geometry/size.h" | 15 #include "ui/gfx/geometry/size.h" |
| 16 #include "ui/gfx/gfx_export.h" | 16 #include "ui/gfx/gfx_export.h" |
| 17 | 17 |
| 18 class SkBitmap; | 18 class SkBitmap; |
| 19 class SkDrawLooper; | 19 class SkDrawLooper; |
| 20 | 20 |
| 21 namespace gfx { | 21 namespace gfx { |
| 22 | 22 |
| 23 class ImageSkiaRep; | 23 class ImageSkiaRep; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 46 GFX_EXPORT void TransformToFlattenedSkMatrix(const gfx::Transform& transform, | 46 GFX_EXPORT void TransformToFlattenedSkMatrix(const gfx::Transform& transform, |
| 47 SkMatrix* flattened); | 47 SkMatrix* flattened); |
| 48 | 48 |
| 49 // Creates a bitmap shader for the image rep with the image rep's scale factor. | 49 // Creates a bitmap shader for the image rep with the image rep's scale factor. |
| 50 // Sets the created shader's local matrix such that it displays the image rep at | 50 // Sets the created shader's local matrix such that it displays the image rep at |
| 51 // the correct scale factor. | 51 // the correct scale factor. |
| 52 // The shader's local matrix should not be changed after the shader is created. | 52 // The shader's local matrix should not be changed after the shader is created. |
| 53 // TODO(pkotwicz): Allow shader's local matrix to be changed after the shader | 53 // TODO(pkotwicz): Allow shader's local matrix to be changed after the shader |
| 54 // is created. | 54 // is created. |
| 55 // | 55 // |
| 56 GFX_EXPORT sk_sp<SkShader> CreateImageRepShader( | 56 GFX_EXPORT sk_sp<cc::PaintShader> CreateImageRepShader( |
| 57 const gfx::ImageSkiaRep& image_rep, | 57 const gfx::ImageSkiaRep& image_rep, |
| 58 SkShader::TileMode tile_mode, | 58 cc::PaintShader::TileMode tile_mode, |
| 59 const SkMatrix& local_matrix); | 59 const SkMatrix& local_matrix); |
| 60 | 60 |
| 61 // Creates a bitmap shader for the image rep with the passed in scale factor. | 61 // Creates a bitmap shader for the image rep with the passed in scale factor. |
| 62 GFX_EXPORT sk_sp<SkShader> CreateImageRepShaderForScale( | 62 GFX_EXPORT sk_sp<cc::PaintShader> CreateImageRepShaderForScale( |
| 63 const gfx::ImageSkiaRep& image_rep, | 63 const gfx::ImageSkiaRep& image_rep, |
| 64 SkShader::TileMode tile_mode, | 64 cc::PaintShader::TileMode tile_mode, |
| 65 const SkMatrix& local_matrix, | 65 const SkMatrix& local_matrix, |
| 66 SkScalar scale); | 66 SkScalar scale); |
| 67 | 67 |
| 68 // Creates a vertical gradient shader. The caller owns the shader. | 68 // Creates a vertical gradient shader. The caller owns the shader. |
| 69 // Example usage to avoid leaks: | 69 // Example usage to avoid leaks: |
| 70 GFX_EXPORT sk_sp<SkShader> CreateGradientShader(int start_point, | 70 GFX_EXPORT sk_sp<cc::PaintShader> CreateGradientShader(int start_point, |
| 71 int end_point, | 71 int end_point, |
| 72 SkColor start_color, | 72 SkColor start_color, |
| 73 SkColor end_color); | 73 SkColor end_color); |
| 74 | 74 |
| 75 // Creates a draw looper to generate |shadows|. The caller owns the draw looper. | 75 // Creates a draw looper to generate |shadows|. The caller owns the draw looper. |
| 76 // NULL is returned if |shadows| is empty since no draw looper is needed in | 76 // NULL is returned if |shadows| is empty since no draw looper is needed in |
| 77 // this case. | 77 // this case. |
| 78 // DEPRECATED: See below. TODO(estade): remove this: crbug.com/624175 | 78 // DEPRECATED: See below. TODO(estade): remove this: crbug.com/624175 |
| 79 GFX_EXPORT sk_sp<SkDrawLooper> CreateShadowDrawLooper( | 79 GFX_EXPORT sk_sp<SkDrawLooper> CreateShadowDrawLooper( |
| 80 const std::vector<ShadowValue>& shadows); | 80 const std::vector<ShadowValue>& shadows); |
| 81 | 81 |
| 82 // Creates a draw looper to generate |shadows|. This creates a looper with the | 82 // Creates a draw looper to generate |shadows|. This creates a looper with the |
| 83 // correct amount of blur. Callers of the existing CreateShadowDrawLooper may | 83 // correct amount of blur. Callers of the existing CreateShadowDrawLooper may |
| (...skipping 16 matching lines...) Expand all Loading... |
| 100 | 100 |
| 101 // Converts an hb_position_t to a Skia floating-point value. | 101 // Converts an hb_position_t to a Skia floating-point value. |
| 102 GFX_EXPORT SkScalar HarfBuzzUnitsToSkiaScalar(int value); | 102 GFX_EXPORT SkScalar HarfBuzzUnitsToSkiaScalar(int value); |
| 103 | 103 |
| 104 // Converts an hb_position_t to a float. | 104 // Converts an hb_position_t to a float. |
| 105 GFX_EXPORT float HarfBuzzUnitsToFloat(int value); | 105 GFX_EXPORT float HarfBuzzUnitsToFloat(int value); |
| 106 | 106 |
| 107 } // namespace gfx | 107 } // namespace gfx |
| 108 | 108 |
| 109 #endif // UI_GFX_SKIA_UTIL_H_ | 109 #endif // UI_GFX_SKIA_UTIL_H_ |
| OLD | NEW |