Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(161)

Side by Side Diff: ui/gfx/skia_util.h

Issue 1831883002: Use sk_sp-based shader creation APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/gfx/render_text.cc ('k') | ui/gfx/skia_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 GFX_EXPORT void TransformToFlattenedSkMatrix(const gfx::Transform& transform, 47 GFX_EXPORT void TransformToFlattenedSkMatrix(const gfx::Transform& transform,
48 SkMatrix* flattened); 48 SkMatrix* flattened);
49 49
50 // Creates a bitmap shader for the image rep with the image rep's scale factor. 50 // Creates a bitmap shader for the image rep with the image rep's scale factor.
51 // Sets the created shader's local matrix such that it displays the image rep at 51 // Sets the created shader's local matrix such that it displays the image rep at
52 // the correct scale factor. 52 // the correct scale factor.
53 // The shader's local matrix should not be changed after the shader is created. 53 // The shader's local matrix should not be changed after the shader is created.
54 // TODO(pkotwicz): Allow shader's local matrix to be changed after the shader 54 // TODO(pkotwicz): Allow shader's local matrix to be changed after the shader
55 // is created. 55 // is created.
56 // 56 //
57 GFX_EXPORT skia::RefPtr<SkShader> CreateImageRepShader( 57 GFX_EXPORT sk_sp<SkShader> CreateImageRepShader(
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 61
62 // Creates a bitmap shader for the image rep with the passed in scale factor. 62 // Creates a bitmap shader for the image rep with the passed in scale factor.
63 GFX_EXPORT skia::RefPtr<SkShader> CreateImageRepShaderForScale( 63 GFX_EXPORT sk_sp<SkShader> CreateImageRepShaderForScale(
64 const gfx::ImageSkiaRep& image_rep, 64 const gfx::ImageSkiaRep& image_rep,
65 SkShader::TileMode tile_mode, 65 SkShader::TileMode tile_mode,
66 const SkMatrix& local_matrix, 66 const SkMatrix& local_matrix,
67 SkScalar scale); 67 SkScalar scale);
68 68
69 // Creates a vertical gradient shader. The caller owns the shader. 69 // Creates a vertical gradient shader. The caller owns the shader.
70 // Example usage to avoid leaks: 70 // Example usage to avoid leaks:
71 GFX_EXPORT skia::RefPtr<SkShader> CreateGradientShader(int start_point, 71 GFX_EXPORT sk_sp<SkShader> CreateGradientShader(int start_point,
72 int end_point, 72 int end_point,
73 SkColor start_color, 73 SkColor start_color,
74 SkColor end_color); 74 SkColor end_color);
75 75
76 // Creates a draw looper to generate |shadows|. The caller owns the draw looper. 76 // Creates a draw looper to generate |shadows|. The caller owns the draw looper.
77 // NULL is returned if |shadows| is empty since no draw looper is needed in 77 // NULL is returned if |shadows| is empty since no draw looper is needed in
78 // this case. 78 // this case.
79 GFX_EXPORT skia::RefPtr<SkDrawLooper> CreateShadowDrawLooper( 79 GFX_EXPORT skia::RefPtr<SkDrawLooper> CreateShadowDrawLooper(
80 const std::vector<ShadowValue>& shadows); 80 const std::vector<ShadowValue>& shadows);
81 81
82 // Returns true if the two bitmaps contain the same pixels. 82 // Returns true if the two bitmaps contain the same pixels.
83 GFX_EXPORT bool BitmapsAreEqual(const SkBitmap& bitmap1, 83 GFX_EXPORT bool BitmapsAreEqual(const SkBitmap& bitmap1,
84 const SkBitmap& bitmap2); 84 const SkBitmap& bitmap2);
85 85
86 // Converts Skia ARGB format pixels in |skia| to RGBA. 86 // Converts Skia ARGB format pixels in |skia| to RGBA.
87 GFX_EXPORT void ConvertSkiaToRGBA(const unsigned char* skia, 87 GFX_EXPORT void ConvertSkiaToRGBA(const unsigned char* skia,
88 int pixel_width, 88 int pixel_width,
89 unsigned char* rgba); 89 unsigned char* rgba);
90 90
91 // Converts a Skia floating-point value to an int appropriate for hb_position_t. 91 // Converts a Skia floating-point value to an int appropriate for hb_position_t.
92 GFX_EXPORT int SkiaScalarToHarfBuzzUnits(SkScalar value); 92 GFX_EXPORT int SkiaScalarToHarfBuzzUnits(SkScalar value);
93 93
94 // Converts an hb_position_t to a Skia floating-point value. 94 // Converts an hb_position_t to a Skia floating-point value.
95 GFX_EXPORT SkScalar HarfBuzzUnitsToSkiaScalar(int value); 95 GFX_EXPORT SkScalar HarfBuzzUnitsToSkiaScalar(int value);
96 96
97 // Converts an hb_position_t to a float. 97 // Converts an hb_position_t to a float.
98 GFX_EXPORT float HarfBuzzUnitsToFloat(int value); 98 GFX_EXPORT float HarfBuzzUnitsToFloat(int value);
99 99
100 } // namespace gfx 100 } // namespace gfx
101 101
102 #endif // UI_GFX_SKIA_UTIL_H_ 102 #endif // UI_GFX_SKIA_UTIL_H_
OLDNEW
« no previous file with comments | « ui/gfx/render_text.cc ('k') | ui/gfx/skia_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698