OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "base/compiler_specific.h" | 5 #include "base/compiler_specific.h" |
6 #include "base/macros.h" | 6 #include "base/macros.h" |
7 #include "skia/ext/analysis_canvas.h" | 7 #include "skia/ext/analysis_canvas.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 #include "third_party/skia/include/core/SkPicture.h" | 9 #include "third_party/skia/include/core/SkPicture.h" |
10 #include "third_party/skia/include/core/SkPictureRecorder.h" | 10 #include "third_party/skia/include/core/SkPictureRecorder.h" |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 SolidColorFill(canvas); | 322 SolidColorFill(canvas); |
323 EXPECT_TRUE(canvas.GetColorIfSolid(&outputColor)); | 323 EXPECT_TRUE(canvas.GetColorIfSolid(&outputColor)); |
324 EXPECT_NE(static_cast<SkColor>(SK_ColorTRANSPARENT), outputColor); | 324 EXPECT_NE(static_cast<SkColor>(SK_ColorTRANSPARENT), outputColor); |
325 } | 325 } |
326 | 326 |
327 TEST(AnalysisCanvasTest, EarlyOutNotSolid) { | 327 TEST(AnalysisCanvasTest, EarlyOutNotSolid) { |
328 SkRTreeFactory factory; | 328 SkRTreeFactory factory; |
329 SkPictureRecorder recorder; | 329 SkPictureRecorder recorder; |
330 | 330 |
331 // Create a picture with 3 commands, last of which is non-solid. | 331 // Create a picture with 3 commands, last of which is non-solid. |
332 sk_sp<SkCanvas> record_canvas = sk_ref_sp(recorder.beginRecording(256, 256, &f
actory)); | 332 SkCanvas* record_canvas = recorder.beginRecording(256, 256, &factory); |
333 | 333 |
334 std::string text = "text"; | 334 std::string text = "text"; |
335 SkPoint point = SkPoint::Make(SkIntToScalar(25), SkIntToScalar(25)); | 335 SkPoint point = SkPoint::Make(SkIntToScalar(25), SkIntToScalar(25)); |
336 | 336 |
337 SkPaint paint; | 337 SkPaint paint; |
338 paint.setColor(SkColorSetARGB(255, 255, 255, 255)); | 338 paint.setColor(SkColorSetARGB(255, 255, 255, 255)); |
339 paint.setBlendMode(SkBlendMode::kSrcOver); | 339 paint.setBlendMode(SkBlendMode::kSrcOver); |
340 | 340 |
341 record_canvas->drawRect(SkRect::MakeWH(256, 256), paint); | 341 record_canvas->drawRect(SkRect::MakeWH(256, 256), paint); |
342 record_canvas->drawRect(SkRect::MakeWH(256, 256), paint); | 342 record_canvas->drawRect(SkRect::MakeWH(256, 256), paint); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 | 446 |
447 SkRRect rr; | 447 SkRRect rr; |
448 rr.setRectRadii(bounding_rect, radii); | 448 rr.setRectRadii(bounding_rect, radii); |
449 | 449 |
450 canvas.clipRRect(rr); | 450 canvas.clipRRect(rr); |
451 EXPECT_EQ(cases[i].expected, canvas.GetColorIfSolid(&outputColor)) << i; | 451 EXPECT_EQ(cases[i].expected, canvas.GetColorIfSolid(&outputColor)) << i; |
452 } | 452 } |
453 } | 453 } |
454 | 454 |
455 } // namespace skia | 455 } // namespace skia |
OLD | NEW |