| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "config.h" | 5 #include "config.h" |
| 6 #include "core/paint/RenderDrawingRecorder.h" | 6 #include "core/paint/RenderDrawingRecorder.h" |
| 7 | 7 |
| 8 #include "core/rendering/RenderLayer.h" | 8 #include "core/rendering/RenderLayer.h" |
| 9 #include "core/rendering/RenderView.h" | 9 #include "core/rendering/RenderView.h" |
| 10 #include "core/rendering/RenderingTestHelper.h" | 10 #include "core/rendering/RenderingTestHelper.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 context->drawRect(rect); | 53 context->drawRect(rect); |
| 54 } | 54 } |
| 55 | 55 |
| 56 | 56 |
| 57 TEST_F(DrawingRecorderTest, DrawingRecorderTest_Nothing) | 57 TEST_F(DrawingRecorderTest, DrawingRecorderTest_Nothing) |
| 58 { | 58 { |
| 59 GraphicsContext context(nullptr, &rootDisplayItemList()); | 59 GraphicsContext context(nullptr, &rootDisplayItemList()); |
| 60 FloatRect bound = renderView()->viewRect(); | 60 FloatRect bound = renderView()->viewRect(); |
| 61 EXPECT_EQ((size_t)0, rootDisplayItemList().paintList().size()); | 61 EXPECT_EQ((size_t)0, rootDisplayItemList().paintList().size()); |
| 62 | 62 |
| 63 rootDisplayItemList().beginNewPaints(); |
| 63 drawNothing(&context, renderView(), PaintPhaseForeground, bound); | 64 drawNothing(&context, renderView(), PaintPhaseForeground, bound); |
| 65 rootDisplayItemList().endNewPaints(); |
| 64 EXPECT_EQ((size_t)1, rootDisplayItemList().paintList().size()); | 66 EXPECT_EQ((size_t)1, rootDisplayItemList().paintList().size()); |
| 65 #ifndef NDEBUG | 67 #ifndef NDEBUG |
| 66 EXPECT_STREQ("Dummy", rootDisplayItemList().paintList()[0]->name()); | 68 EXPECT_STREQ("Dummy", rootDisplayItemList().paintList()[0]->name()); |
| 67 #endif | 69 #endif |
| 68 } | 70 } |
| 69 | 71 |
| 70 TEST_F(DrawingRecorderTest, DrawingRecorderTest_Rect) | 72 TEST_F(DrawingRecorderTest, DrawingRecorderTest_Rect) |
| 71 { | 73 { |
| 72 GraphicsContext context(nullptr, &rootDisplayItemList()); | 74 GraphicsContext context(nullptr, &rootDisplayItemList()); |
| 73 FloatRect bound = renderView()->viewRect(); | 75 FloatRect bound = renderView()->viewRect(); |
| 76 rootDisplayItemList().beginNewPaints(); |
| 74 drawRect(&context, renderView(), PaintPhaseForeground, bound); | 77 drawRect(&context, renderView(), PaintPhaseForeground, bound); |
| 78 rootDisplayItemList().endNewPaints(); |
| 75 EXPECT_EQ((size_t)1, rootDisplayItemList().paintList().size()); | 79 EXPECT_EQ((size_t)1, rootDisplayItemList().paintList().size()); |
| 76 #ifndef NDEBUG | 80 #ifndef NDEBUG |
| 77 EXPECT_STREQ("Drawing", rootDisplayItemList().paintList()[0]->name()); | 81 EXPECT_STREQ("Drawing", rootDisplayItemList().paintList()[0]->name()); |
| 78 #endif | 82 #endif |
| 79 } | 83 } |
| 80 | 84 |
| 81 TEST_F(DrawingRecorderTest, DrawingRecorderTest_Cached) | 85 TEST_F(DrawingRecorderTest, DrawingRecorderTest_Cached) |
| 82 { | 86 { |
| 83 GraphicsContext context(nullptr, &rootDisplayItemList()); | 87 GraphicsContext context(nullptr, &rootDisplayItemList()); |
| 84 FloatRect bound = renderView()->viewRect(); | 88 FloatRect bound = renderView()->viewRect(); |
| 89 rootDisplayItemList().beginNewPaints(); |
| 85 drawNothing(&context, renderView(), PaintPhaseBlockBackground, bound); | 90 drawNothing(&context, renderView(), PaintPhaseBlockBackground, bound); |
| 86 drawRect(&context, renderView(), PaintPhaseForeground, bound); | 91 drawRect(&context, renderView(), PaintPhaseForeground, bound); |
| 92 rootDisplayItemList().endNewPaints(); |
| 87 EXPECT_EQ((size_t)2, rootDisplayItemList().paintList().size()); | 93 EXPECT_EQ((size_t)2, rootDisplayItemList().paintList().size()); |
| 88 #ifndef NDEBUG | 94 #ifndef NDEBUG |
| 89 EXPECT_STREQ("Dummy", rootDisplayItemList().paintList()[0]->name()); | 95 EXPECT_STREQ("Dummy", rootDisplayItemList().paintList()[0]->name()); |
| 90 EXPECT_STREQ("Drawing", rootDisplayItemList().paintList()[1]->name()); | 96 EXPECT_STREQ("Drawing", rootDisplayItemList().paintList()[1]->name()); |
| 91 #endif | 97 #endif |
| 92 | 98 |
| 99 rootDisplayItemList().beginNewPaints(); |
| 93 drawNothing(&context, renderView(), PaintPhaseBlockBackground, bound); | 100 drawNothing(&context, renderView(), PaintPhaseBlockBackground, bound); |
| 94 drawRect(&context, renderView(), PaintPhaseForeground, bound); | 101 drawRect(&context, renderView(), PaintPhaseForeground, bound); |
| 102 rootDisplayItemList().endNewPaints(); |
| 95 EXPECT_EQ((size_t)2, rootDisplayItemList().paintList().size()); | 103 EXPECT_EQ((size_t)2, rootDisplayItemList().paintList().size()); |
| 96 #ifndef NDEBUG | 104 #ifndef NDEBUG |
| 97 EXPECT_STREQ("Dummy", rootDisplayItemList().paintList()[0]->name()); | 105 EXPECT_STREQ("Dummy", rootDisplayItemList().paintList()[0]->name()); |
| 98 EXPECT_STREQ("Drawing", rootDisplayItemList().paintList()[1]->name()); | 106 EXPECT_STREQ("Drawing", rootDisplayItemList().paintList()[1]->name()); |
| 99 #endif | 107 #endif |
| 100 } | 108 } |
| 101 | 109 |
| 102 } | 110 } |
| 103 } | 111 } |
| OLD | NEW |