| 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 "content/renderer/skia_benchmarking_extension.h" | 5 #include "content/renderer/skia_benchmarking_extension.h" |
| 6 | 6 |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "third_party/skia/include/core/SkCanvas.h" | 8 #include "third_party/skia/include/core/SkCanvas.h" |
| 9 #include "third_party/skia/include/core/SkGraphics.h" | 9 #include "third_party/skia/include/core/SkGraphics.h" |
| 10 #include "third_party/skia/src/utils/debugger/SkDebugCanvas.h" | 10 #include "third_party/skia/src/utils/debugger/SkDebugCanvas.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 // Prepare canvas and resources. | 44 // Prepare canvas and resources. |
| 45 SkDebugCanvas canvas(100, 100); | 45 SkDebugCanvas canvas(100, 100); |
| 46 SkPaint red_paint; | 46 SkPaint red_paint; |
| 47 red_paint.setColor(SkColorSetARGB(255, 255, 0, 0)); | 47 red_paint.setColor(SkColorSetARGB(255, 255, 0, 0)); |
| 48 SkRect fullRect = SkRect::MakeWH(SkIntToScalar(100), SkIntToScalar(100)); | 48 SkRect fullRect = SkRect::MakeWH(SkIntToScalar(100), SkIntToScalar(100)); |
| 49 SkRect fillRect = SkRect::MakeXYWH(SkIntToScalar(25), SkIntToScalar(25), | 49 SkRect fillRect = SkRect::MakeXYWH(SkIntToScalar(25), SkIntToScalar(25), |
| 50 SkIntToScalar(50), SkIntToScalar(50)); | 50 SkIntToScalar(50), SkIntToScalar(50)); |
| 51 | 51 |
| 52 // Draw a trivial scene. | 52 // Draw a trivial scene. |
| 53 canvas.save(); | 53 canvas.save(); |
| 54 canvas.clipRect(fullRect, SkRegion::kIntersect_Op, false); | 54 canvas.clipRect(fullRect); |
| 55 canvas.translate(SkIntToScalar(10), SkIntToScalar(10)); | 55 canvas.translate(SkIntToScalar(10), SkIntToScalar(10)); |
| 56 canvas.scale(SkIntToScalar(2), SkIntToScalar(2)); | 56 canvas.scale(SkIntToScalar(2), SkIntToScalar(2)); |
| 57 canvas.drawRect(fillRect, red_paint); | 57 canvas.drawRect(fillRect, red_paint); |
| 58 canvas.restore(); | 58 canvas.restore(); |
| 59 | 59 |
| 60 // Verify the recorded commands. | 60 // Verify the recorded commands. |
| 61 DrawType cmd; | 61 DrawType cmd; |
| 62 int idx = 0; | 62 int idx = 0; |
| 63 ASSERT_EQ(canvas.getSize(), 6); | 63 ASSERT_EQ(canvas.getSize(), 6); |
| 64 | 64 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 95 EXPECT_STREQ(SkDrawCommand::GetCommandString(cmd), "Draw Rect"); | 95 EXPECT_STREQ(SkDrawCommand::GetCommandString(cmd), "Draw Rect"); |
| 96 EXPECT_TRUE(HasInfoField(canvas, idx, "SkRect")); | 96 EXPECT_TRUE(HasInfoField(canvas, idx, "SkRect")); |
| 97 | 97 |
| 98 ASSERT_TRUE(canvas.getDrawCommandAt(++idx) != NULL); | 98 ASSERT_TRUE(canvas.getDrawCommandAt(++idx) != NULL); |
| 99 cmd = canvas.getDrawCommandAt(idx)->getType(); | 99 cmd = canvas.getDrawCommandAt(idx)->getType(); |
| 100 EXPECT_EQ(cmd, RESTORE); | 100 EXPECT_EQ(cmd, RESTORE); |
| 101 EXPECT_STREQ(SkDrawCommand::GetCommandString(cmd), "Restore"); | 101 EXPECT_STREQ(SkDrawCommand::GetCommandString(cmd), "Restore"); |
| 102 } | 102 } |
| 103 | 103 |
| 104 } // namespace content | 104 } // namespace content |
| OLD | NEW |