| OLD | NEW |
| 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 std::unique_ptr<base::DictionaryValue> val(new base::DictionaryValue()); | 110 std::unique_ptr<base::DictionaryValue> val(new base::DictionaryValue()); |
| 111 val->SetInteger("a", SkColorGetA(color)); | 111 val->SetInteger("a", SkColorGetA(color)); |
| 112 val->SetInteger("r", SkColorGetR(color)); | 112 val->SetInteger("r", SkColorGetR(color)); |
| 113 val->SetInteger("g", SkColorGetG(color)); | 113 val->SetInteger("g", SkColorGetG(color)); |
| 114 val->SetInteger("b", SkColorGetB(color)); | 114 val->SetInteger("b", SkColorGetB(color)); |
| 115 | 115 |
| 116 return std::move(val); | 116 return std::move(val); |
| 117 } | 117 } |
| 118 | 118 |
| 119 std::unique_ptr<base::Value> AsValue(SkBlendMode mode) { | 119 std::unique_ptr<base::Value> AsValue(SkBlendMode mode) { |
| 120 std::unique_ptr<base::StringValue> val( | 120 std::unique_ptr<base::Value> val(new base::Value(SkBlendMode_Name(mode))); |
| 121 new base::StringValue(SkBlendMode_Name(mode))); | |
| 122 | 121 |
| 123 return val; | 122 return val; |
| 124 } | 123 } |
| 125 | 124 |
| 126 std::unique_ptr<base::Value> AsValue(SkCanvas::PointMode mode) { | 125 std::unique_ptr<base::Value> AsValue(SkCanvas::PointMode mode) { |
| 127 static const char* gModeStrings[] = { "Points", "Lines", "Polygon" }; | 126 static const char* gModeStrings[] = { "Points", "Lines", "Polygon" }; |
| 128 DCHECK_LT(static_cast<size_t>(mode), SK_ARRAY_COUNT(gModeStrings)); | 127 DCHECK_LT(static_cast<size_t>(mode), SK_ARRAY_COUNT(gModeStrings)); |
| 129 | 128 |
| 130 std::unique_ptr<base::StringValue> val( | 129 std::unique_ptr<base::Value> val(new base::Value(gModeStrings[mode])); |
| 131 new base::StringValue(gModeStrings[mode])); | |
| 132 | 130 |
| 133 return val; | 131 return val; |
| 134 } | 132 } |
| 135 | 133 |
| 136 std::unique_ptr<base::Value> AsValue(const SkColorFilter& filter) { | 134 std::unique_ptr<base::Value> AsValue(const SkColorFilter& filter) { |
| 137 std::unique_ptr<base::DictionaryValue> val(new base::DictionaryValue()); | 135 std::unique_ptr<base::DictionaryValue> val(new base::DictionaryValue()); |
| 138 | 136 |
| 139 if (unsigned flags = filter.getFlags()) { | 137 if (unsigned flags = filter.getFlags()) { |
| 140 FlagsBuilder builder('|'); | 138 FlagsBuilder builder('|'); |
| 141 builder.addFlag(flags & SkColorFilter::kAlphaUnchanged_Flag, | 139 builder.addFlag(flags & SkColorFilter::kAlphaUnchanged_Flag, |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 } | 247 } |
| 250 | 248 |
| 251 std::unique_ptr<base::Value> SaveLayerFlagsAsValue( | 249 std::unique_ptr<base::Value> SaveLayerFlagsAsValue( |
| 252 SkCanvas::SaveLayerFlags flags) { | 250 SkCanvas::SaveLayerFlags flags) { |
| 253 FlagsBuilder builder('|'); | 251 FlagsBuilder builder('|'); |
| 254 builder.addFlag(flags & SkCanvas::kIsOpaque_SaveLayerFlag, | 252 builder.addFlag(flags & SkCanvas::kIsOpaque_SaveLayerFlag, |
| 255 "kIsOpaque"); | 253 "kIsOpaque"); |
| 256 builder.addFlag(flags & SkCanvas::kPreserveLCDText_SaveLayerFlag, | 254 builder.addFlag(flags & SkCanvas::kPreserveLCDText_SaveLayerFlag, |
| 257 "kPreserveLCDText"); | 255 "kPreserveLCDText"); |
| 258 | 256 |
| 259 std::unique_ptr<base::StringValue> val(new base::StringValue(builder.str())); | 257 std::unique_ptr<base::Value> val(new base::Value(builder.str())); |
| 260 | 258 |
| 261 return val; | 259 return val; |
| 262 } | 260 } |
| 263 | 261 |
| 264 std::unique_ptr<base::Value> AsValue(SkClipOp op) { | 262 std::unique_ptr<base::Value> AsValue(SkClipOp op) { |
| 265 static const char* gOpStrings[] = { "Difference", | 263 static const char* gOpStrings[] = { "Difference", |
| 266 "Intersect", | 264 "Intersect", |
| 267 "Union", | 265 "Union", |
| 268 "XOR", | 266 "XOR", |
| 269 "ReverseDifference", | 267 "ReverseDifference", |
| 270 "Replace" | 268 "Replace" |
| 271 }; | 269 }; |
| 272 size_t index = static_cast<size_t>(op); | 270 size_t index = static_cast<size_t>(op); |
| 273 DCHECK_LT(index, SK_ARRAY_COUNT(gOpStrings)); | 271 DCHECK_LT(index, SK_ARRAY_COUNT(gOpStrings)); |
| 274 std::unique_ptr<base::StringValue> val( | 272 std::unique_ptr<base::Value> val(new base::Value(gOpStrings[index])); |
| 275 new base::StringValue(gOpStrings[index])); | |
| 276 return val; | 273 return val; |
| 277 } | 274 } |
| 278 | 275 |
| 279 std::unique_ptr<base::Value> AsValue(const SkRegion& region) { | 276 std::unique_ptr<base::Value> AsValue(const SkRegion& region) { |
| 280 std::unique_ptr<base::DictionaryValue> val(new base::DictionaryValue()); | 277 std::unique_ptr<base::DictionaryValue> val(new base::DictionaryValue()); |
| 281 val->Set("bounds", AsValue(SkRect::Make(region.getBounds()))); | 278 val->Set("bounds", AsValue(SkRect::Make(region.getBounds()))); |
| 282 | 279 |
| 283 return std::move(val); | 280 return std::move(val); |
| 284 } | 281 } |
| 285 | 282 |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 713 DCHECK(blob); | 710 DCHECK(blob); |
| 714 AutoOp op(this, "DrawTextBlob", &paint); | 711 AutoOp op(this, "DrawTextBlob", &paint); |
| 715 op.addParam("blob", AsValue(*blob)); | 712 op.addParam("blob", AsValue(*blob)); |
| 716 op.addParam("x", AsValue(x)); | 713 op.addParam("x", AsValue(x)); |
| 717 op.addParam("y", AsValue(y)); | 714 op.addParam("y", AsValue(y)); |
| 718 | 715 |
| 719 INHERITED::onDrawTextBlob(blob, x, y, *op.paint()); | 716 INHERITED::onDrawTextBlob(blob, x, y, *op.paint()); |
| 720 } | 717 } |
| 721 | 718 |
| 722 } // namespace skia | 719 } // namespace skia |
| OLD | NEW |