| 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 "skia/ext/refptr.h" | |
| 12 #include "third_party/skia/include/core/SkColor.h" | 11 #include "third_party/skia/include/core/SkColor.h" |
| 13 #include "third_party/skia/include/core/SkRect.h" | 12 #include "third_party/skia/include/core/SkRect.h" |
| 13 #include "third_party/skia/include/core/SkRefCnt.h" |
| 14 #include "third_party/skia/include/core/SkShader.h" | 14 #include "third_party/skia/include/core/SkShader.h" |
| 15 #include "ui/gfx/geometry/quad_f.h" | 15 #include "ui/gfx/geometry/quad_f.h" |
| 16 #include "ui/gfx/geometry/size.h" | 16 #include "ui/gfx/geometry/size.h" |
| 17 #include "ui/gfx/gfx_export.h" | 17 #include "ui/gfx/gfx_export.h" |
| 18 | 18 |
| 19 class SkBitmap; | 19 class SkBitmap; |
| 20 class SkDrawLooper; | 20 class SkDrawLooper; |
| 21 | 21 |
| 22 namespace gfx { | 22 namespace gfx { |
| 23 | 23 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 41 GFX_EXPORT void TransformToFlattenedSkMatrix(const gfx::Transform& transform, | 41 GFX_EXPORT void TransformToFlattenedSkMatrix(const gfx::Transform& transform, |
| 42 SkMatrix* flattened); | 42 SkMatrix* flattened); |
| 43 | 43 |
| 44 // Creates a bitmap shader for the image rep with the image rep's scale factor. | 44 // Creates a bitmap shader for the image rep with the image rep's scale factor. |
| 45 // Sets the created shader's local matrix such that it displays the image rep at | 45 // Sets the created shader's local matrix such that it displays the image rep at |
| 46 // the correct scale factor. | 46 // the correct scale factor. |
| 47 // The shader's local matrix should not be changed after the shader is created. | 47 // The shader's local matrix should not be changed after the shader is created. |
| 48 // TODO(pkotwicz): Allow shader's local matrix to be changed after the shader | 48 // TODO(pkotwicz): Allow shader's local matrix to be changed after the shader |
| 49 // is created. | 49 // is created. |
| 50 // | 50 // |
| 51 GFX_EXPORT skia::RefPtr<SkShader> CreateImageRepShader( | 51 GFX_EXPORT sk_sp<SkShader> CreateImageRepShader( |
| 52 const gfx::ImageSkiaRep& image_rep, | 52 const gfx::ImageSkiaRep& image_rep, |
| 53 SkShader::TileMode tile_mode, | 53 SkShader::TileMode tile_mode, |
| 54 const SkMatrix& local_matrix); | 54 const SkMatrix& local_matrix); |
| 55 | 55 |
| 56 // Creates a bitmap shader for the image rep with the passed in scale factor. | 56 // Creates a bitmap shader for the image rep with the passed in scale factor. |
| 57 GFX_EXPORT skia::RefPtr<SkShader> CreateImageRepShaderForScale( | 57 GFX_EXPORT sk_sp<SkShader> CreateImageRepShaderForScale( |
| 58 const gfx::ImageSkiaRep& image_rep, | 58 const gfx::ImageSkiaRep& image_rep, |
| 59 SkShader::TileMode tile_mode, | 59 SkShader::TileMode tile_mode, |
| 60 const SkMatrix& local_matrix, | 60 const SkMatrix& local_matrix, |
| 61 SkScalar scale); | 61 SkScalar scale); |
| 62 | 62 |
| 63 // Creates a vertical gradient shader. The caller owns the shader. | 63 // Creates a vertical gradient shader. The caller owns the shader. |
| 64 // Example usage to avoid leaks: | 64 // Example usage to avoid leaks: |
| 65 GFX_EXPORT skia::RefPtr<SkShader> CreateGradientShader(int start_point, | 65 GFX_EXPORT sk_sp<SkShader> CreateGradientShader(int start_point, |
| 66 int end_point, | 66 int end_point, |
| 67 SkColor start_color, | 67 SkColor start_color, |
| 68 SkColor end_color); | 68 SkColor end_color); |
| 69 | 69 |
| 70 // Creates a draw looper to generate |shadows|. The caller owns the draw looper. | 70 // Creates a draw looper to generate |shadows|. The caller owns the draw looper. |
| 71 // NULL is returned if |shadows| is empty since no draw looper is needed in | 71 // NULL is returned if |shadows| is empty since no draw looper is needed in |
| 72 // this case. | 72 // this case. |
| 73 GFX_EXPORT skia::RefPtr<SkDrawLooper> CreateShadowDrawLooper( | 73 GFX_EXPORT sk_sp<SkDrawLooper> CreateShadowDrawLooper( |
| 74 const std::vector<ShadowValue>& shadows); | 74 const std::vector<ShadowValue>& shadows); |
| 75 | 75 |
| 76 // Returns true if the two bitmaps contain the same pixels. | 76 // Returns true if the two bitmaps contain the same pixels. |
| 77 GFX_EXPORT bool BitmapsAreEqual(const SkBitmap& bitmap1, | 77 GFX_EXPORT bool BitmapsAreEqual(const SkBitmap& bitmap1, |
| 78 const SkBitmap& bitmap2); | 78 const SkBitmap& bitmap2); |
| 79 | 79 |
| 80 // Converts Skia ARGB format pixels in |skia| to RGBA. | 80 // Converts Skia ARGB format pixels in |skia| to RGBA. |
| 81 GFX_EXPORT void ConvertSkiaToRGBA(const unsigned char* skia, | 81 GFX_EXPORT void ConvertSkiaToRGBA(const unsigned char* skia, |
| 82 int pixel_width, | 82 int pixel_width, |
| 83 unsigned char* rgba); | 83 unsigned char* rgba); |
| 84 | 84 |
| 85 } // namespace gfx | 85 } // namespace gfx |
| 86 | 86 |
| 87 #endif // UI_GFX_SKIA_UTIL_H_ | 87 #endif // UI_GFX_SKIA_UTIL_H_ |
| OLD | NEW |