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

Side by Side Diff: cc/paint/paint_shader.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
« no previous file with comments | « cc/paint/paint_op_buffer_unittest.cc ('k') | cc/paint/paint_shader.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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 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 CC_PAINT_PAINT_SHADER_H_ 5 #ifndef CC_PAINT_PAINT_SHADER_H_
6 #define CC_PAINT_PAINT_SHADER_H_ 6 #define CC_PAINT_PAINT_SHADER_H_
7 7
8 #include "cc/paint/paint_record.h" 8 #include <memory>
9
10 #include "cc/paint/paint_export.h"
9 #include "third_party/skia/include/core/SkImage.h" 11 #include "third_party/skia/include/core/SkImage.h"
12 #include "third_party/skia/include/core/SkScalar.h"
10 #include "third_party/skia/include/core/SkShader.h" 13 #include "third_party/skia/include/core/SkShader.h"
11 14
12 namespace cc { 15 namespace cc {
13 using PaintShader = SkShader;
14 16
15 inline sk_sp<PaintShader> WrapSkShader(sk_sp<SkShader> shader) { 17 class PaintOpBuffer;
16 return shader; 18 using PaintRecord = PaintOpBuffer;
17 }
18 19
19 inline sk_sp<PaintShader> MakePaintShaderImage(sk_sp<const SkImage> image, 20 class CC_PAINT_EXPORT PaintShader {
20 SkShader::TileMode tx, 21 public:
21 SkShader::TileMode ty, 22 static std::unique_ptr<PaintShader> MakeColor(SkColor color);
22 const SkMatrix* local_matrix) {
23 return image->makeShader(tx, ty, local_matrix);
24 }
25 23
26 inline sk_sp<PaintShader> MakePaintShaderRecord(sk_sp<PaintRecord> record, 24 static std::unique_ptr<PaintShader> MakeLinearGradient(
27 const SkRect& tile, 25 const SkPoint points[],
26 const SkColor colors[],
27 const SkScalar pos[],
28 int count,
29 SkShader::TileMode mode,
30 uint32_t flags = 0,
31 const SkMatrix* local_matrix = nullptr,
32 SkColor fallback_color = SK_ColorTRANSPARENT);
33
34 static std::unique_ptr<PaintShader> MakeRadialGradient(
35 const SkPoint& center,
36 SkScalar radius,
37 const SkColor colors[],
38 const SkScalar pos[],
39 int color_count,
40 SkShader::TileMode mode,
41 uint32_t flags = 0,
42 const SkMatrix* local_matrix = nullptr,
43 SkColor fallback_color = SK_ColorTRANSPARENT);
44
45 static std::unique_ptr<PaintShader> MakeTwoPointConicalGradient(
46 const SkPoint& start,
47 SkScalar start_radius,
48 const SkPoint& end,
49 SkScalar end_radius,
50 const SkColor colors[],
51 const SkScalar pos[],
52 int color_count,
53 SkShader::TileMode mode,
54 uint32_t flags = 0,
55 const SkMatrix* local_matrix = nullptr,
56 SkColor fallback_color = SK_ColorTRANSPARENT);
57
58 static std::unique_ptr<PaintShader> MakeSweepGradient(
59 SkScalar cx,
60 SkScalar cy,
61 const SkColor colors[],
62 const SkScalar pos[],
63 int color_count,
64 uint32_t flags = 0,
65 const SkMatrix* local_matrix = nullptr,
66 SkColor fallback_color = SK_ColorTRANSPARENT);
67
68 static std::unique_ptr<PaintShader> MakeImage(sk_sp<const SkImage> image,
28 SkShader::TileMode tx, 69 SkShader::TileMode tx,
29 SkShader::TileMode ty, 70 SkShader::TileMode ty,
30 const SkMatrix* local_matrix) { 71 const SkMatrix* local_matrix);
31 return SkShader::MakePictureShader(ToSkPicture(record, tile), tx, ty, 72
32 local_matrix, nullptr); 73 static std::unique_ptr<PaintShader> MakePaintRecord(
33 } 74 sk_sp<PaintRecord> record,
75 const SkRect& tile,
76 SkShader::TileMode tx,
77 SkShader::TileMode ty,
78 const SkMatrix* local_matrix);
79
80 PaintShader(const PaintShader& other);
81 PaintShader(PaintShader&& other);
82 ~PaintShader();
83
84 PaintShader& operator=(const PaintShader& other);
85 PaintShader& operator=(PaintShader&& other);
86
87 const sk_sp<SkShader>& sk_shader() const { return sk_shader_; }
88
89 private:
90 PaintShader(sk_sp<SkShader> shader, SkColor fallback_color);
91
92 sk_sp<SkShader> sk_shader_;
93 };
34 94
35 } // namespace cc 95 } // namespace cc
36 96
37 #endif // CC_PAINT_PAINT_SHADER_H_ 97 #endif // CC_PAINT_PAINT_SHADER_H_
OLDNEW
« no previous file with comments | « cc/paint/paint_op_buffer_unittest.cc ('k') | cc/paint/paint_shader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698