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

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

Issue 2893083002: cc: Move SkShader construction to a single spot in PaintShader (Closed)
Patch Set: update Created 3 years, 6 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
OLDNEW
1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. 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 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_PAINT_UTIL_H_ 5 #ifndef UI_GFX_SKIA_PAINT_UTIL_H_
6 #define UI_GFX_SKIA_PAINT_UTIL_H_ 6 #define UI_GFX_SKIA_PAINT_UTIL_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "cc/paint/paint_shader.h" 10 #include "cc/paint/paint_shader.h"
11 #include "ui/gfx/gfx_export.h" 11 #include "ui/gfx/gfx_export.h"
12 #include "ui/gfx/shadow_value.h" 12 #include "ui/gfx/shadow_value.h"
13 13
14 class SkDrawLooper; 14 class SkDrawLooper;
15 class SkMatrix; 15 class SkMatrix;
16 16
17 namespace gfx { 17 namespace gfx {
18 18
19 class ImageSkiaRep; 19 class ImageSkiaRep;
20 20
21 // Creates a bitmap shader for the image rep with the image rep's scale factor. 21 // Creates a bitmap shader for the image rep with the image rep's scale factor.
22 // Sets the created shader's local matrix such that it displays the image rep at 22 // Sets the created shader's local matrix such that it displays the image rep at
23 // the correct scale factor. 23 // the correct scale factor.
24 // The shader's local matrix should not be changed after the shader is created. 24 // The shader's local matrix should not be changed after the shader is created.
25 // TODO(pkotwicz): Allow shader's local matrix to be changed after the shader 25 // TODO(pkotwicz): Allow shader's local matrix to be changed after the shader
26 // is created. 26 // is created.
27 // 27 //
28 GFX_EXPORT sk_sp<cc::PaintShader> CreateImageRepShader( 28 GFX_EXPORT std::unique_ptr<cc::PaintShader> CreateImageRepShader(
sky 2017/06/02 22:51:05 Include <memory>?
vmpstr 2017/06/05 21:02:07 Done.
29 const gfx::ImageSkiaRep& image_rep, 29 const gfx::ImageSkiaRep& image_rep,
30 cc::PaintShader::TileMode tile_mode, 30 SkShader::TileMode tile_mode,
31 const SkMatrix& local_matrix); 31 const SkMatrix& local_matrix);
32 32
33 // Creates a bitmap shader for the image rep with the passed in scale factor. 33 // Creates a bitmap shader for the image rep with the passed in scale factor.
34 GFX_EXPORT sk_sp<cc::PaintShader> CreateImageRepShaderForScale( 34 GFX_EXPORT std::unique_ptr<cc::PaintShader> CreateImageRepShaderForScale(
35 const gfx::ImageSkiaRep& image_rep, 35 const gfx::ImageSkiaRep& image_rep,
36 cc::PaintShader::TileMode tile_mode, 36 SkShader::TileMode tile_mode,
37 const SkMatrix& local_matrix, 37 const SkMatrix& local_matrix,
38 SkScalar scale); 38 SkScalar scale);
39 39
40 // Creates a vertical gradient shader. The caller owns the shader. 40 // Creates a vertical gradient shader. The caller owns the shader.
41 // Example usage to avoid leaks: 41 // Example usage to avoid leaks:
42 GFX_EXPORT sk_sp<cc::PaintShader> CreateGradientShader(int start_point, 42 GFX_EXPORT std::unique_ptr<cc::PaintShader> CreateGradientShader(
43 int end_point, 43 int start_point,
44 SkColor start_color, 44 int end_point,
45 SkColor end_color); 45 SkColor start_color,
46 SkColor end_color);
46 47
47 // Creates a draw looper to generate |shadows|. The caller owns the draw looper. 48 // Creates a draw looper to generate |shadows|. The caller owns the draw looper.
48 // NULL is returned if |shadows| is empty since no draw looper is needed in 49 // NULL is returned if |shadows| is empty since no draw looper is needed in
49 // this case. 50 // this case.
50 GFX_EXPORT sk_sp<SkDrawLooper> CreateShadowDrawLooper( 51 GFX_EXPORT sk_sp<SkDrawLooper> CreateShadowDrawLooper(
51 const std::vector<ShadowValue>& shadows); 52 const std::vector<ShadowValue>& shadows);
52 53
53 } // namespace gfx 54 } // namespace gfx
54 55
55 #endif // UI_GFX_SKIA_UTIL_H_ 56 #endif // UI_GFX_SKIA_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698