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

Side by Side Diff: skia/ext/benchmarking_canvas.cc

Issue 2516363005: Inline StringValue into base::Value (Closed)
Patch Set: Rebase and Nits. Created 3 years, 10 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "skia/ext/benchmarking_canvas.h" 5 #include "skia/ext/benchmarking_canvas.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 val->SetInteger("g", SkColorGetG(color)); 114 val->SetInteger("g", SkColorGetG(color));
115 val->SetInteger("b", SkColorGetB(color)); 115 val->SetInteger("b", SkColorGetB(color));
116 116
117 return std::move(val); 117 return std::move(val);
118 } 118 }
119 119
120 std::unique_ptr<base::Value> AsValue(SkBlendMode mode) { 120 std::unique_ptr<base::Value> AsValue(SkBlendMode mode) {
121 std::unique_ptr<base::StringValue> val( 121 std::unique_ptr<base::StringValue> val(
122 new base::StringValue(SkBlendMode_Name(mode))); 122 new base::StringValue(SkBlendMode_Name(mode)));
123 123
124 return std::move(val); 124 return val;
125 } 125 }
126 126
127 std::unique_ptr<base::Value> AsValue(SkCanvas::PointMode mode) { 127 std::unique_ptr<base::Value> AsValue(SkCanvas::PointMode mode) {
128 static const char* gModeStrings[] = { "Points", "Lines", "Polygon" }; 128 static const char* gModeStrings[] = { "Points", "Lines", "Polygon" };
129 DCHECK_LT(static_cast<size_t>(mode), SK_ARRAY_COUNT(gModeStrings)); 129 DCHECK_LT(static_cast<size_t>(mode), SK_ARRAY_COUNT(gModeStrings));
130 130
131 std::unique_ptr<base::StringValue> val( 131 std::unique_ptr<base::StringValue> val(
132 new base::StringValue(gModeStrings[mode])); 132 new base::StringValue(gModeStrings[mode]));
133 133
134 return std::move(val); 134 return val;
135 } 135 }
136 136
137 std::unique_ptr<base::Value> AsValue(const SkColorFilter& filter) { 137 std::unique_ptr<base::Value> AsValue(const SkColorFilter& filter) {
138 std::unique_ptr<base::DictionaryValue> val(new base::DictionaryValue()); 138 std::unique_ptr<base::DictionaryValue> val(new base::DictionaryValue());
139 139
140 if (unsigned flags = filter.getFlags()) { 140 if (unsigned flags = filter.getFlags()) {
141 FlagsBuilder builder('|'); 141 FlagsBuilder builder('|');
142 builder.addFlag(flags & SkColorFilter::kAlphaUnchanged_Flag, 142 builder.addFlag(flags & SkColorFilter::kAlphaUnchanged_Flag,
143 "kAlphaUnchanged_Flag"); 143 "kAlphaUnchanged_Flag");
144 144
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 std::unique_ptr<base::Value> SaveLayerFlagsAsValue( 254 std::unique_ptr<base::Value> SaveLayerFlagsAsValue(
255 SkCanvas::SaveLayerFlags flags) { 255 SkCanvas::SaveLayerFlags flags) {
256 FlagsBuilder builder('|'); 256 FlagsBuilder builder('|');
257 builder.addFlag(flags & SkCanvas::kIsOpaque_SaveLayerFlag, 257 builder.addFlag(flags & SkCanvas::kIsOpaque_SaveLayerFlag,
258 "kIsOpaque"); 258 "kIsOpaque");
259 builder.addFlag(flags & SkCanvas::kPreserveLCDText_SaveLayerFlag, 259 builder.addFlag(flags & SkCanvas::kPreserveLCDText_SaveLayerFlag,
260 "kPreserveLCDText"); 260 "kPreserveLCDText");
261 261
262 std::unique_ptr<base::StringValue> val(new base::StringValue(builder.str())); 262 std::unique_ptr<base::StringValue> val(new base::StringValue(builder.str()));
263 263
264 return std::move(val); 264 return val;
265 } 265 }
266 266
267 std::unique_ptr<base::Value> AsValue(SkClipOp op) { 267 std::unique_ptr<base::Value> AsValue(SkClipOp op) {
268 static const char* gOpStrings[] = { "Difference", 268 static const char* gOpStrings[] = { "Difference",
269 "Intersect", 269 "Intersect",
270 "Union", 270 "Union",
271 "XOR", 271 "XOR",
272 "ReverseDifference", 272 "ReverseDifference",
273 "Replace" 273 "Replace"
274 }; 274 };
275 size_t index = static_cast<size_t>(op); 275 size_t index = static_cast<size_t>(op);
276 DCHECK_LT(index, SK_ARRAY_COUNT(gOpStrings)); 276 DCHECK_LT(index, SK_ARRAY_COUNT(gOpStrings));
277 std::unique_ptr<base::StringValue> val( 277 std::unique_ptr<base::StringValue> val(
278 new base::StringValue(gOpStrings[index])); 278 new base::StringValue(gOpStrings[index]));
279 return std::move(val); 279 return val;
280 } 280 }
281 281
282 std::unique_ptr<base::Value> AsValue(const SkRegion& region) { 282 std::unique_ptr<base::Value> AsValue(const SkRegion& region) {
283 std::unique_ptr<base::DictionaryValue> val(new base::DictionaryValue()); 283 std::unique_ptr<base::DictionaryValue> val(new base::DictionaryValue());
284 val->Set("bounds", AsValue(SkRect::Make(region.getBounds()))); 284 val->Set("bounds", AsValue(SkRect::Make(region.getBounds())));
285 285
286 return std::move(val); 286 return std::move(val);
287 } 287 }
288 288
289 std::unique_ptr<base::Value> AsValue(const SkBitmap& bitmap) { 289 std::unique_ptr<base::Value> AsValue(const SkBitmap& bitmap) {
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 DCHECK(blob); 716 DCHECK(blob);
717 AutoOp op(this, "DrawTextBlob", &paint); 717 AutoOp op(this, "DrawTextBlob", &paint);
718 op.addParam("blob", AsValue(*blob)); 718 op.addParam("blob", AsValue(*blob));
719 op.addParam("x", AsValue(x)); 719 op.addParam("x", AsValue(x));
720 op.addParam("y", AsValue(y)); 720 op.addParam("y", AsValue(y));
721 721
722 INHERITED::onDrawTextBlob(blob, x, y, *op.paint()); 722 INHERITED::onDrawTextBlob(blob, x, y, *op.paint());
723 } 723 }
724 724
725 } // namespace skia 725 } // namespace skia
OLDNEW
« no previous file with comments | « extensions/browser/api/idle/idle_manager.h ('k') | third_party/libaddressinput/chromium/chrome_storage_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698