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

Side by Side Diff: ui/gfx/paint_vector_icon.cc

Issue 2523673004: [NOT FOR COMMIT] Fully replace SkCanvas uses.
Patch Set: Support Android build. Created 4 years 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/paint_throbber.cc ('k') | ui/gfx/render_text.h » ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #include "ui/gfx/paint_vector_icon.h" 5 #include "ui/gfx/paint_vector_icon.h"
6 6
7 #include <map> 7 #include <map>
8 #include <tuple> 8 #include <tuple>
9 9
10 #include "base/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
11 #include "base/lazy_instance.h" 11 #include "base/lazy_instance.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
15 #include "base/strings/string_split.h" 15 #include "base/strings/string_split.h"
16 #include "skia/ext/cdl_canvas.h"
17 #include "skia/ext/cdl_paint.h"
16 #include "third_party/skia/include/core/SkPaint.h" 18 #include "third_party/skia/include/core/SkPaint.h"
17 #include "third_party/skia/include/core/SkPath.h" 19 #include "third_party/skia/include/core/SkPath.h"
18 #include "ui/gfx/canvas.h" 20 #include "ui/gfx/canvas.h"
19 #include "ui/gfx/image/canvas_image_source.h" 21 #include "ui/gfx/image/canvas_image_source.h"
20 #include "ui/gfx/scoped_canvas.h" 22 #include "ui/gfx/scoped_canvas.h"
21 #include "ui/gfx/vector_icon_types.h" 23 #include "ui/gfx/vector_icon_types.h"
22 #include "ui/gfx/vector_icons_public.h" 24 #include "ui/gfx/vector_icons_public.h"
23 25
24 namespace gfx { 26 namespace gfx {
25 27
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 84
83 void PaintPath(Canvas* canvas, 85 void PaintPath(Canvas* canvas,
84 const PathElement* path_elements, 86 const PathElement* path_elements,
85 int dip_size, 87 int dip_size,
86 SkColor color) { 88 SkColor color) {
87 SkPath path; 89 SkPath path;
88 path.setFillType(SkPath::kEvenOdd_FillType); 90 path.setFillType(SkPath::kEvenOdd_FillType);
89 91
90 int canvas_size = kReferenceSizeDip; 92 int canvas_size = kReferenceSizeDip;
91 std::vector<SkPath> paths; 93 std::vector<SkPath> paths;
92 std::vector<SkPaint> paints; 94 std::vector<CdlPaint> paints;
93 SkRect clip_rect = SkRect::MakeEmpty(); 95 SkRect clip_rect = SkRect::MakeEmpty();
94 bool flips_in_rtl = false; 96 bool flips_in_rtl = false;
95 CommandType previous_command_type = NEW_PATH; 97 CommandType previous_command_type = NEW_PATH;
96 98
97 for (size_t i = 0; path_elements[i].type != END; i++) { 99 for (size_t i = 0; path_elements[i].type != END; i++) {
98 if (paths.empty() || path_elements[i].type == NEW_PATH) { 100 if (paths.empty() || path_elements[i].type == NEW_PATH) {
99 paths.push_back(SkPath()); 101 paths.push_back(SkPath());
100 paths.back().setFillType(SkPath::kEvenOdd_FillType); 102 paths.back().setFillType(SkPath::kEvenOdd_FillType);
101 103
102 paints.push_back(SkPaint()); 104 paints.push_back(CdlPaint());
103 paints.back().setColor(color); 105 paints.back().setColor(color);
104 paints.back().setAntiAlias(true); 106 paints.back().setAntiAlias(true);
105 paints.back().setStrokeCap(SkPaint::kRound_Cap); 107 paints.back().setStrokeCap(CdlPaint::kRound_Cap);
106 } 108 }
107 109
108 SkPath& path = paths.back(); 110 SkPath& path = paths.back();
109 SkPaint& paint = paints.back(); 111 CdlPaint& paint = paints.back();
110 CommandType command_type = path_elements[i].type; 112 CommandType command_type = path_elements[i].type;
111 switch (command_type) { 113 switch (command_type) {
112 // Handled above. 114 // Handled above.
113 case NEW_PATH: 115 case NEW_PATH:
114 continue; 116 continue;
115 117
116 case PATH_COLOR_ARGB: { 118 case PATH_COLOR_ARGB: {
117 int a = SkScalarFloorToInt(path_elements[++i].arg); 119 int a = SkScalarFloorToInt(path_elements[++i].arg);
118 int r = SkScalarFloorToInt(path_elements[++i].arg); 120 int r = SkScalarFloorToInt(path_elements[++i].arg);
119 int g = SkScalarFloorToInt(path_elements[++i].arg); 121 int g = SkScalarFloorToInt(path_elements[++i].arg);
120 int b = SkScalarFloorToInt(path_elements[++i].arg); 122 int b = SkScalarFloorToInt(path_elements[++i].arg);
121 paint.setColor(SkColorSetARGB(a, r, g, b)); 123 paint.setColor(SkColorSetARGB(a, r, g, b));
122 break; 124 break;
123 } 125 }
124 126
125 case PATH_MODE_CLEAR: { 127 case PATH_MODE_CLEAR: {
126 paint.setBlendMode(SkBlendMode::kClear); 128 paint.setBlendMode(SkBlendMode::kClear);
127 break; 129 break;
128 }; 130 };
129 131
130 case STROKE: { 132 case STROKE: {
131 paint.setStyle(SkPaint::kStroke_Style); 133 paint.setStyle(CdlPaint::kStroke_Style);
132 SkScalar width = path_elements[++i].arg; 134 SkScalar width = path_elements[++i].arg;
133 paint.setStrokeWidth(width); 135 paint.setStrokeWidth(width);
134 break; 136 break;
135 } 137 }
136 138
137 case CAP_SQUARE: { 139 case CAP_SQUARE: {
138 paint.setStrokeCap(SkPaint::kSquare_Cap); 140 paint.setStrokeCap(CdlPaint::kSquare_Cap);
139 break; 141 break;
140 } 142 }
141 143
142 case MOVE_TO: { 144 case MOVE_TO: {
143 SkScalar x = path_elements[++i].arg; 145 SkScalar x = path_elements[++i].arg;
144 SkScalar y = path_elements[++i].arg; 146 SkScalar y = path_elements[++i].arg;
145 path.moveTo(x, y); 147 path.moveTo(x, y);
146 break; 148 break;
147 } 149 }
148 150
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 } 596 }
595 597
596 ImageSkia CreateVectorIconFromSource(const std::string& source, 598 ImageSkia CreateVectorIconFromSource(const std::string& source,
597 int dip_size, 599 int dip_size,
598 SkColor color) { 600 SkColor color) {
599 return CanvasImageSource::MakeImageSkia<VectorIconSourceLegacy>( 601 return CanvasImageSource::MakeImageSkia<VectorIconSourceLegacy>(
600 source, dip_size, color); 602 source, dip_size, color);
601 } 603 }
602 604
603 } // namespace gfx 605 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/paint_throbber.cc ('k') | ui/gfx/render_text.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698