OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 23 matching lines...) Expand all Loading... |
34 #include "platform/graphics/GraphicsContext.h" | 34 #include "platform/graphics/GraphicsContext.h" |
35 #include "platform/graphics/paint/PaintArtifactToSkCanvas.h" | 35 #include "platform/graphics/paint/PaintArtifactToSkCanvas.h" |
36 #include "platform/graphics/paint/PaintController.h" | 36 #include "platform/graphics/paint/PaintController.h" |
37 #include "platform/transforms/AffineTransform.h" | 37 #include "platform/transforms/AffineTransform.h" |
38 #include "platform/transforms/TransformationMatrix.h" | 38 #include "platform/transforms/TransformationMatrix.h" |
39 #include "public/platform/WebDisplayItemList.h" | 39 #include "public/platform/WebDisplayItemList.h" |
40 #include "public/platform/WebFloatRect.h" | 40 #include "public/platform/WebFloatRect.h" |
41 #include "public/platform/WebRect.h" | 41 #include "public/platform/WebRect.h" |
42 #include "third_party/skia/include/core/SkCanvas.h" | 42 #include "third_party/skia/include/core/SkCanvas.h" |
43 #include "third_party/skia/include/core/SkPicture.h" | 43 #include "third_party/skia/include/core/SkPicture.h" |
| 44 #include "ui/gfx/geometry/rect.h" |
44 | 45 |
45 namespace blink { | 46 namespace blink { |
46 | 47 |
47 ContentLayerDelegate::ContentLayerDelegate(GraphicsContextPainter* painter) | 48 ContentLayerDelegate::ContentLayerDelegate(GraphicsContextPainter* painter) |
48 : m_painter(painter) | 49 : m_painter(painter) |
49 { | 50 { |
50 } | 51 } |
51 | 52 |
52 ContentLayerDelegate::~ContentLayerDelegate() | 53 ContentLayerDelegate::~ContentLayerDelegate() |
53 { | 54 { |
54 } | 55 } |
55 | 56 |
56 PassRefPtr<TracedValue> toTracedValue(const WebRect& clip) | 57 PassRefPtr<TracedValue> toTracedValue(const gfx::Rect& recordingViewport) |
57 { | 58 { |
58 RefPtr<TracedValue> tracedValue = TracedValue::create(); | 59 RefPtr<TracedValue> tracedValue = TracedValue::create(); |
59 tracedValue->beginArray("clip_rect"); | 60 tracedValue->beginArray("clip_rect"); |
60 tracedValue->pushInteger(clip.x); | 61 tracedValue->pushInteger(recordingViewport.x()); |
61 tracedValue->pushInteger(clip.y); | 62 tracedValue->pushInteger(recordingViewport.y()); |
62 tracedValue->pushInteger(clip.width); | 63 tracedValue->pushInteger(recordingViewport.width()); |
63 tracedValue->pushInteger(clip.height); | 64 tracedValue->pushInteger(recordingViewport.height()); |
64 tracedValue->endArray(); | 65 tracedValue->endArray(); |
65 return tracedValue; | 66 return tracedValue; |
66 } | 67 } |
67 | 68 |
68 static void paintArtifactToWebDisplayItemList(WebDisplayItemList* list, const Pa
intArtifact& artifact, const WebRect& bounds) | 69 static void paintArtifactToWebDisplayItemList(WebDisplayItemList* list, const Pa
intArtifact& artifact, const gfx::Rect& recordingViewport) |
69 { | 70 { |
70 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 71 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
71 // This is a temporary path to paint the artifact using the paint chunk | 72 // This is a temporary path to paint the artifact using the paint chunk |
72 // properties. Ultimately, we should instead split the artifact into | 73 // properties. Ultimately, we should instead split the artifact into |
73 // separate layers and send those to the compositor, instead of sending | 74 // separate layers and send those to the compositor, instead of sending |
74 // one big flat SkPicture. | 75 // one big flat SkPicture. |
75 SkRect skBounds = SkRect::MakeXYWH(bounds.x, bounds.y, bounds.width, bou
nds.height); | 76 SkRect skBounds = SkRect::MakeXYWH(recordingViewport.x(), recordingViewp
ort.y(), recordingViewport.width(), recordingViewport.height()); |
76 RefPtr<SkPicture> picture = paintArtifactToSkPicture(artifact, skBounds)
; | 77 RefPtr<SkPicture> picture = paintArtifactToSkPicture(artifact, skBounds)
; |
77 // TODO(wkorman): Pass actual visual rect with the drawing item. | 78 // TODO(wkorman): Pass actual visual rect with the drawing item. |
78 list->appendDrawingItem(IntRect(), picture.get()); | 79 list->appendDrawingItem(IntRect(), picture.get()); |
79 return; | 80 return; |
80 } | 81 } |
81 artifact.appendToWebDisplayItemList(list); | 82 artifact.appendToWebDisplayItemList(list); |
82 } | 83 } |
83 | 84 |
84 void ContentLayerDelegate::paintContents( | 85 void ContentLayerDelegate::paintContents( |
85 WebDisplayItemList* webDisplayItemList, const WebRect& clip, | 86 WebDisplayItemList* webDisplayItemList, gfx::Rect* recordingViewport, |
86 WebContentLayerClient::PaintingControlSetting paintingControl) | 87 WebContentLayerClient::PaintingControlSetting paintingControl) |
87 { | 88 { |
88 TRACE_EVENT1("blink,benchmark", "ContentLayerDelegate::paintContents", "clip
_rect", toTracedValue(clip)); | 89 TRACE_EVENT1("blink,benchmark", "ContentLayerDelegate::paintContents", "clip
_rect", toTracedValue(*recordingViewport)); |
89 | 90 |
90 // TODO(pdr): Remove when slimming paint v2 is further along. This is only | 91 // TODO(pdr): Remove when slimming paint v2 is further along. This is only |
91 // here so the browser is usable during development and does not crash due | 92 // here so the browser is usable during development and does not crash due |
92 // to committing the new display items twice. | 93 // to committing the new display items twice. |
93 if (RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled()) { | 94 if (RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled()) { |
94 paintArtifactToWebDisplayItemList(webDisplayItemList, m_painter->paintCo
ntroller()->paintArtifact(), clip); | 95 IntRect interestRect = m_painter->interestRect(); |
| 96 *recordingViewport = gfx::Rect(interestRect.x(), interestRect.y(), inter
estRect.width(), interestRect.y()); |
| 97 paintArtifactToWebDisplayItemList(webDisplayItemList, m_painter->paintCo
ntroller()->paintArtifact(), *recordingViewport); |
95 return; | 98 return; |
96 } | 99 } |
97 | 100 |
98 PaintController* paintController = m_painter->paintController(); | 101 PaintController* paintController = m_painter->paintController(); |
99 ASSERT(paintController); | 102 ASSERT(paintController); |
100 paintController->setDisplayItemConstructionIsDisabled( | 103 paintController->setDisplayItemConstructionIsDisabled( |
101 paintingControl == WebContentLayerClient::DisplayListConstructionDisable
d); | 104 paintingControl == WebContentLayerClient::DisplayListConstructionDisable
d); |
102 | 105 |
103 // We also disable caching when Painting or Construction are disabled. In bo
th cases we would like | 106 // We also disable caching when Painting or Construction are disabled. In bo
th cases we would like |
104 // to compare assuming the full cost of recording, not the cost of re-using
cached content. | 107 // to compare assuming the full cost of recording, not the cost of re-using
cached content. |
105 if (paintingControl != WebContentLayerClient::PaintDefaultBehavior) | 108 if (paintingControl != WebContentLayerClient::PaintDefaultBehavior) |
106 paintController->invalidateAll(); | 109 paintController->invalidateAll(); |
107 | 110 |
108 GraphicsContext::DisabledMode disabledMode = GraphicsContext::NothingDisable
d; | 111 GraphicsContext::DisabledMode disabledMode = GraphicsContext::NothingDisable
d; |
109 if (paintingControl == WebContentLayerClient::DisplayListPaintingDisabled | 112 if (paintingControl == WebContentLayerClient::DisplayListPaintingDisabled |
110 || paintingControl == WebContentLayerClient::DisplayListConstructionDisa
bled) | 113 || paintingControl == WebContentLayerClient::DisplayListConstructionDisa
bled) |
111 disabledMode = GraphicsContext::FullyDisabled; | 114 disabledMode = GraphicsContext::FullyDisabled; |
112 GraphicsContext context(*paintController, disabledMode); | 115 GraphicsContext context(*paintController, disabledMode); |
113 | 116 |
114 IntRect interestRect = clip; | 117 IntRect interestRect(recordingViewport->x(), recordingViewport->y(), recordi
ngViewport->width(), recordingViewport->height()); |
115 m_painter->paint(context, &interestRect); | 118 m_painter->paint(context, &interestRect); |
116 | 119 |
117 paintController->commitNewDisplayItems(); | 120 paintController->commitNewDisplayItems(); |
118 paintArtifactToWebDisplayItemList(webDisplayItemList, paintController->paint
Artifact(), clip); | 121 paintArtifactToWebDisplayItemList(webDisplayItemList, paintController->paint
Artifact(), *recordingViewport); |
119 } | 122 } |
120 | 123 |
121 size_t ContentLayerDelegate::approximateUnsharedMemoryUsage() const | 124 size_t ContentLayerDelegate::approximateUnsharedMemoryUsage() const |
122 { | 125 { |
123 return m_painter->paintController()->approximateUnsharedMemoryUsage(); | 126 return m_painter->paintController()->approximateUnsharedMemoryUsage(); |
124 } | 127 } |
125 | 128 |
126 } // namespace blink | 129 } // namespace blink |
OLD | NEW |