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 | 6 |
7 #include "core/layout/compositing/RenderLayerCompositor.h" | 7 #include "core/layout/compositing/LayerCompositor.h" |
8 #include "core/paint/LayerClipRecorder.h" | 8 #include "core/paint/LayerClipRecorder.h" |
9 #include "core/paint/LayerPainter.h" | 9 #include "core/paint/LayerPainter.h" |
10 #include "core/paint/RenderDrawingRecorder.h" | 10 #include "core/paint/RenderDrawingRecorder.h" |
11 #include "core/rendering/InlineTextBox.h" | 11 #include "core/rendering/InlineTextBox.h" |
12 #include "core/rendering/RenderText.h" | 12 #include "core/rendering/RenderText.h" |
13 #include "core/rendering/RenderView.h" | 13 #include "core/rendering/RenderView.h" |
14 #include "core/rendering/RenderingTestHelper.h" | 14 #include "core/rendering/RenderingTestHelper.h" |
15 #include "platform/graphics/GraphicsContext.h" | 15 #include "platform/graphics/GraphicsContext.h" |
16 #include "platform/graphics/GraphicsLayer.h" | 16 #include "platform/graphics/GraphicsLayer.h" |
17 #include "platform/graphics/paint/DisplayItemList.h" | 17 #include "platform/graphics/paint/DisplayItemList.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 | 79 |
80 void drawRect(GraphicsContext* context, RenderObject* renderer, PaintPhase phase
, const FloatRect& bound) | 80 void drawRect(GraphicsContext* context, RenderObject* renderer, PaintPhase phase
, const FloatRect& bound) |
81 { | 81 { |
82 RenderDrawingRecorder drawingRecorder(context, *renderer, phase, bound); | 82 RenderDrawingRecorder drawingRecorder(context, *renderer, phase, bound); |
83 if (drawingRecorder.canUseCachedDrawing()) | 83 if (drawingRecorder.canUseCachedDrawing()) |
84 return; | 84 return; |
85 IntRect rect(0, 0, 10, 10); | 85 IntRect rect(0, 0, 10, 10); |
86 context->drawRect(rect); | 86 context->drawRect(rect); |
87 } | 87 } |
88 | 88 |
89 void drawClippedRect(GraphicsContext* context, RenderLayerModelObject* renderer,
PaintPhase phase, const FloatRect& bound) | 89 void drawClippedRect(GraphicsContext* context, LayoutLayerModelObject* renderer,
PaintPhase phase, const FloatRect& bound) |
90 { | 90 { |
91 IntRect rect(1, 1, 9, 9); | 91 IntRect rect(1, 1, 9, 9); |
92 ClipRect clipRect(rect); | 92 ClipRect clipRect(rect); |
93 LayerClipRecorder layerClipRecorder(renderer, context, DisplayItem::ClipLaye
rForeground, clipRect, 0, LayoutPoint(), PaintLayerFlags()); | 93 LayerClipRecorder layerClipRecorder(renderer, context, DisplayItem::ClipLaye
rForeground, clipRect, 0, LayoutPoint(), PaintLayerFlags()); |
94 drawRect(context, renderer, phase, bound); | 94 drawRect(context, renderer, phase, bound); |
95 } | 95 } |
96 | 96 |
97 TEST_F(ViewDisplayListTest, ViewDisplayListTest_NestedRecorders) | 97 TEST_F(ViewDisplayListTest, ViewDisplayListTest_NestedRecorders) |
98 { | 98 { |
99 GraphicsContext context(nullptr, &rootDisplayItemList()); | 99 GraphicsContext context(nullptr, &rootDisplayItemList()); |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150)); | 395 drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 150, 150)); |
396 | 396 |
397 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, | 397 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, |
398 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl
ockBackground)), | 398 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseBl
ockBackground)), |
399 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseOu
tline))); | 399 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseOu
tline))); |
400 } | 400 } |
401 | 401 |
402 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateClip) | 402 TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateClip) |
403 { | 403 { |
404 setBodyInnerHTML("<div id='first'><div id='second'></div></div>"); | 404 setBodyInnerHTML("<div id='first'><div id='second'></div></div>"); |
405 RenderLayerModelObject* firstRenderer = toRenderLayerModelObject(document().
body()->firstChild()->renderer()); | 405 LayoutLayerModelObject* firstRenderer = toLayoutLayerModelObject(document().
body()->firstChild()->renderer()); |
406 RenderLayerModelObject* secondRenderer = toRenderLayerModelObject(document()
.body()->firstChild()->firstChild()->renderer()); | 406 LayoutLayerModelObject* secondRenderer = toLayoutLayerModelObject(document()
.body()->firstChild()->firstChild()->renderer()); |
407 GraphicsContext context(nullptr, &rootDisplayItemList()); | 407 GraphicsContext context(nullptr, &rootDisplayItemList()); |
408 | 408 |
409 ClipRect firstClipRect(IntRect(1, 1, 2, 2)); | 409 ClipRect firstClipRect(IntRect(1, 1, 2, 2)); |
410 { | 410 { |
411 LayerClipRecorder layerClipRecorder(firstRenderer, &context, DisplayItem
::ClipLayerForeground, firstClipRect, 0, LayoutPoint(), PaintLayerFlags()); | 411 LayerClipRecorder layerClipRecorder(firstRenderer, &context, DisplayItem
::ClipLayerForeground, firstClipRect, 0, LayoutPoint(), PaintLayerFlags()); |
412 drawRect(&context, firstRenderer, PaintPhaseBlockBackground, FloatRect(1
00, 100, 150, 150)); | 412 drawRect(&context, firstRenderer, PaintPhaseBlockBackground, FloatRect(1
00, 100, 150, 150)); |
413 drawRect(&context, secondRenderer, PaintPhaseBlockBackground, FloatRect(
100, 100, 150, 150)); | 413 drawRect(&context, secondRenderer, PaintPhaseBlockBackground, FloatRect(
100, 100, 150, 150)); |
414 } | 414 } |
415 rootDisplayItemList().endNewPaints(); | 415 rootDisplayItemList().endNewPaints(); |
416 | 416 |
(...skipping 26 matching lines...) Expand all Loading... |
443 TestDisplayItem(secondRenderer, DisplayItem::ClipLayerForeground), | 443 TestDisplayItem(secondRenderer, DisplayItem::ClipLayerForeground), |
444 TestDisplayItem(secondRenderer, DisplayItem::paintPhaseToDrawingType(Pai
ntPhaseBlockBackground)), | 444 TestDisplayItem(secondRenderer, DisplayItem::paintPhaseToDrawingType(Pai
ntPhaseBlockBackground)), |
445 TestDisplayItem(secondRenderer, DisplayItem::clipTypeToEndClipType(Displ
ayItem::ClipLayerForeground))); | 445 TestDisplayItem(secondRenderer, DisplayItem::clipTypeToEndClipType(Displ
ayItem::ClipLayerForeground))); |
446 } | 446 } |
447 | 447 |
448 TEST_F(ViewDisplayListTest, CachedDisplayItems) | 448 TEST_F(ViewDisplayListTest, CachedDisplayItems) |
449 { | 449 { |
450 RuntimeEnabledFeatures::setSlimmingPaintDisplayItemCacheEnabled(true); | 450 RuntimeEnabledFeatures::setSlimmingPaintDisplayItemCacheEnabled(true); |
451 | 451 |
452 setBodyInnerHTML("<div id='first'><div id='second'></div></div>"); | 452 setBodyInnerHTML("<div id='first'><div id='second'></div></div>"); |
453 RenderLayerModelObject* firstRenderer = toRenderLayerModelObject(document().
body()->firstChild()->renderer()); | 453 LayoutLayerModelObject* firstRenderer = toLayoutLayerModelObject(document().
body()->firstChild()->renderer()); |
454 RenderLayerModelObject* secondRenderer = toRenderLayerModelObject(document()
.body()->firstChild()->firstChild()->renderer()); | 454 LayoutLayerModelObject* secondRenderer = toLayoutLayerModelObject(document()
.body()->firstChild()->firstChild()->renderer()); |
455 GraphicsContext context(nullptr, &rootDisplayItemList()); | 455 GraphicsContext context(nullptr, &rootDisplayItemList()); |
456 | 456 |
457 drawRect(&context, firstRenderer, PaintPhaseBlockBackground, FloatRect(100,
100, 150, 150)); | 457 drawRect(&context, firstRenderer, PaintPhaseBlockBackground, FloatRect(100,
100, 150, 150)); |
458 drawRect(&context, secondRenderer, PaintPhaseBlockBackground, FloatRect(100,
100, 150, 150)); | 458 drawRect(&context, secondRenderer, PaintPhaseBlockBackground, FloatRect(100,
100, 150, 150)); |
459 rootDisplayItemList().endNewPaints(); | 459 rootDisplayItemList().endNewPaints(); |
460 | 460 |
461 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, | 461 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, |
462 TestDisplayItem(firstRenderer, DisplayItem::paintPhaseToDrawingType(Pain
tPhaseBlockBackground)), | 462 TestDisplayItem(firstRenderer, DisplayItem::paintPhaseToDrawingType(Pain
tPhaseBlockBackground)), |
463 TestDisplayItem(secondRenderer, DisplayItem::paintPhaseToDrawingType(Pai
ntPhaseBlockBackground))); | 463 TestDisplayItem(secondRenderer, DisplayItem::paintPhaseToDrawingType(Pai
ntPhaseBlockBackground))); |
464 EXPECT_TRUE(rootDisplayItemList().clientCacheIsValid(firstRenderer->displayI
temClient())); | 464 EXPECT_TRUE(rootDisplayItemList().clientCacheIsValid(firstRenderer->displayI
temClient())); |
(...skipping 21 matching lines...) Expand all Loading... |
486 | 486 |
487 rootDisplayItemList().invalidateAll(); | 487 rootDisplayItemList().invalidateAll(); |
488 EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(firstRenderer->display
ItemClient())); | 488 EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(firstRenderer->display
ItemClient())); |
489 EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(secondRenderer->displa
yItemClient())); | 489 EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(secondRenderer->displa
yItemClient())); |
490 } | 490 } |
491 | 491 |
492 TEST_F(ViewDisplayListTest, FullDocumentPaintingWithCaret) | 492 TEST_F(ViewDisplayListTest, FullDocumentPaintingWithCaret) |
493 { | 493 { |
494 setBodyInnerHTML("<div id='div' contentEditable='true'>XYZ</div>"); | 494 setBodyInnerHTML("<div id='div' contentEditable='true'>XYZ</div>"); |
495 RenderView* renderView = document().renderView(); | 495 RenderView* renderView = document().renderView(); |
496 RenderLayer* rootLayer = renderView->layer(); | 496 Layer* rootLayer = renderView->layer(); |
497 RenderObject* htmlRenderer = document().documentElement()->renderer(); | 497 RenderObject* htmlRenderer = document().documentElement()->renderer(); |
498 Element* div = toElement(document().body()->firstChild()); | 498 Element* div = toElement(document().body()->firstChild()); |
499 RenderObject* divRenderer = document().body()->firstChild()->renderer(); | 499 RenderObject* divRenderer = document().body()->firstChild()->renderer(); |
500 InlineTextBox* textInlineBox = toRenderText(div->firstChild()->renderer())->
firstTextBox(); | 500 InlineTextBox* textInlineBox = toRenderText(div->firstChild()->renderer())->
firstTextBox(); |
501 | 501 |
502 SkCanvas canvas(800, 600); | 502 SkCanvas canvas(800, 600); |
503 GraphicsContext context(&canvas, &rootDisplayItemList()); | 503 GraphicsContext context(&canvas, &rootDisplayItemList()); |
504 LayerPaintingInfo paintingInfo(rootLayer, LayoutRect(0, 0, 800, 600), PaintB
ehaviorNormal, LayoutSize()); | 504 LayerPaintingInfo paintingInfo(rootLayer, LayoutRect(0, 0, 800, 600), PaintB
ehaviorNormal, LayoutSize()); |
505 LayerPainter(*rootLayer).paintLayerContents(&context, paintingInfo, PaintLay
erPaintingCompositingAllPhases); | 505 LayerPainter(*rootLayer).paintLayerContents(&context, paintingInfo, PaintLay
erPaintingCompositingAllPhases); |
506 rootDisplayItemList().endNewPaints(); | 506 rootDisplayItemList().endNewPaints(); |
507 | 507 |
508 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, | 508 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, |
509 TestDisplayItem(htmlRenderer, DisplayItem::BoxDecorationBackground), | 509 TestDisplayItem(htmlRenderer, DisplayItem::BoxDecorationBackground), |
510 TestDisplayItem(textInlineBox->displayItemClient(), DisplayItem::paintPh
aseToDrawingType(PaintPhaseForeground))); | 510 TestDisplayItem(textInlineBox->displayItemClient(), DisplayItem::paintPh
aseToDrawingType(PaintPhaseForeground))); |
511 | 511 |
512 div->focus(); | 512 div->focus(); |
513 document().view()->updateLayoutAndStyleForPainting(); | 513 document().view()->updateLayoutAndStyleForPainting(); |
514 LayerPainter(*rootLayer).paintLayerContents(&context, paintingInfo, PaintLay
erPaintingCompositingAllPhases); | 514 LayerPainter(*rootLayer).paintLayerContents(&context, paintingInfo, PaintLay
erPaintingCompositingAllPhases); |
515 rootDisplayItemList().endNewPaints(); | 515 rootDisplayItemList().endNewPaints(); |
516 | 516 |
517 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3, | 517 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3, |
518 TestDisplayItem(htmlRenderer, DisplayItem::BoxDecorationBackground), | 518 TestDisplayItem(htmlRenderer, DisplayItem::BoxDecorationBackground), |
519 TestDisplayItem(textInlineBox->displayItemClient(), DisplayItem::paintPh
aseToDrawingType(PaintPhaseForeground)), | 519 TestDisplayItem(textInlineBox->displayItemClient(), DisplayItem::paintPh
aseToDrawingType(PaintPhaseForeground)), |
520 TestDisplayItem(divRenderer, DisplayItem::paintPhaseToDrawingType(PaintP
haseCaret))); | 520 TestDisplayItem(divRenderer, DisplayItem::paintPhaseToDrawingType(PaintP
haseCaret))); |
521 } | 521 } |
522 | 522 |
523 } // anonymous namespace | 523 } // anonymous namespace |
524 } // namespace blink | 524 } // namespace blink |
OLD | NEW |