Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(782)

Unified Diff: third_party/WebKit/Source/core/paint/FramePainter.cpp

Issue 2872793002: Notify paint for each frame (Closed)
Patch Set: review fix Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/paint/FramePainter.cpp
diff --git a/third_party/WebKit/Source/core/paint/FramePainter.cpp b/third_party/WebKit/Source/core/paint/FramePainter.cpp
index dad69700113834beb63a0f3a560e64801972239d..c54ddb283876a791ed10fef4789b5a239b0acecf 100644
--- a/third_party/WebKit/Source/core/paint/FramePainter.cpp
+++ b/third_party/WebKit/Source/core/paint/FramePainter.cpp
@@ -13,12 +13,14 @@
#include "core/paint/PaintInfo.h"
#include "core/paint/PaintLayer.h"
#include "core/paint/PaintLayerPainter.h"
+#include "core/paint/PaintTiming.h"
#include "core/paint/ScrollbarPainter.h"
#include "core/paint/TransformRecorder.h"
#include "core/probe/CoreProbes.h"
#include "platform/fonts/FontCache.h"
#include "platform/graphics/GraphicsContext.h"
#include "platform/graphics/paint/ClipRecorder.h"
+#include "platform/graphics/paint/PaintController.h"
#include "platform/graphics/paint/ScopedPaintChunkProperties.h"
#include "platform/loader/fetch/MemoryCache.h"
#include "platform/scroll/ScrollbarTheme.h"
@@ -27,8 +29,19 @@ namespace blink {
bool FramePainter::in_paint_contents_ = false;
-void FramePainter::Paint(GraphicsContext& context,
- const GlobalPaintFlags global_paint_flags,
+FramePainter::FramePainter(GraphicsContext& context,
+ const FrameView& frame_view)
+ : context_(context), frame_view_(&frame_view) {
+ context_.GetPaintController().BeginFrame(&GetFrameView().GetFrame());
+}
+
+FramePainter::~FramePainter() {
+ FrameFirstPaint result =
+ context_.GetPaintController().EndFrame(&GetFrameView().GetFrame());
+ NotifyPaint(result);
+}
+
+void FramePainter::Paint(const GlobalPaintFlags global_paint_flags,
const CullRect& rect) {
GetFrameView().NotifyPageThatContentAreaWillPaint();
@@ -56,28 +69,28 @@ void FramePainter::Paint(GraphicsContext& context,
if (const PropertyTreeState* contents_state =
frame_view_->TotalPropertyTreeStateForContents()) {
PaintChunkProperties properties(
- context.GetPaintController().CurrentPaintChunkProperties());
+ context_.GetPaintController().CurrentPaintChunkProperties());
properties.property_tree_state = *contents_state;
- scoped_paint_chunk_properties.emplace(context.GetPaintController(),
+ scoped_paint_chunk_properties.emplace(context_.GetPaintController(),
*GetFrameView().GetLayoutView(),
properties);
}
}
TransformRecorder transform_recorder(
- context, *GetFrameView().GetLayoutView(),
+ context_, *GetFrameView().GetLayoutView(),
AffineTransform::Translation(
GetFrameView().X() - GetFrameView().ScrollX(),
GetFrameView().Y() - GetFrameView().ScrollY()));
if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) {
- PaintContents(context, global_paint_flags, document_dirty_rect);
+ PaintContents(global_paint_flags, document_dirty_rect);
} else {
- ClipRecorder clip_recorder(context, *GetFrameView().GetLayoutView(),
+ ClipRecorder clip_recorder(context_, *GetFrameView().GetLayoutView(),
DisplayItem::kClipFrameToVisibleContentRect,
GetFrameView().VisibleContentRect());
- PaintContents(context, global_paint_flags, document_dirty_rect);
+ PaintContents(global_paint_flags, document_dirty_rect);
}
}
@@ -98,33 +111,32 @@ void FramePainter::Paint(GraphicsContext& context,
// contents state but we want to exclude the content-specific
// properties. This prevents the scrollbars from scrolling, for example.
PaintChunkProperties properties(
- context.GetPaintController().CurrentPaintChunkProperties());
+ context_.GetPaintController().CurrentPaintChunkProperties());
properties.property_tree_state.SetTransform(
frame_view_->PreTranslation());
properties.property_tree_state.SetClip(
frame_view_->ContentClip()->Parent());
properties.property_tree_state.SetEffect(contents_state->Effect());
- scoped_paint_chunk_properties.emplace(context.GetPaintController(),
+ scoped_paint_chunk_properties.emplace(context_.GetPaintController(),
*GetFrameView().GetLayoutView(),
properties);
}
}
TransformRecorder transform_recorder(
- context, *GetFrameView().GetLayoutView(),
+ context_, *GetFrameView().GetLayoutView(),
AffineTransform::Translation(GetFrameView().X(), GetFrameView().Y()));
ClipRecorder recorder(
- context, *GetFrameView().GetLayoutView(),
+ context_, *GetFrameView().GetLayoutView(),
DisplayItem::kClipFrameScrollbars,
IntRect(IntPoint(), visible_area_with_scrollbars.Size()));
- PaintScrollbars(context, scroll_view_dirty_rect);
+ PaintScrollbars(scroll_view_dirty_rect);
}
}
-void FramePainter::PaintContents(GraphicsContext& context,
- const GlobalPaintFlags global_paint_flags,
+void FramePainter::PaintContents(const GlobalPaintFlags global_paint_flags,
const IntRect& rect) {
Document* document = GetFrameView().GetFrame().GetDocument();
@@ -174,12 +186,12 @@ void FramePainter::PaintContents(GraphicsContext& context,
float device_scale_factor = blink::DeviceScaleFactorDeprecated(
root_layer->GetLayoutObject().GetFrame());
- context.SetDeviceScaleFactor(device_scale_factor);
+ context_.SetDeviceScaleFactor(device_scale_factor);
- layer_painter.Paint(context, LayoutRect(rect), local_paint_flags);
+ layer_painter.Paint(context_, LayoutRect(rect), local_paint_flags);
if (root_layer->ContainsDirtyOverlayScrollbars())
- layer_painter.PaintOverlayScrollbars(context, LayoutRect(rect),
+ layer_painter.PaintOverlayScrollbars(context_, LayoutRect(rect),
local_paint_flags);
// Regions may have changed as a result of the visibility/z-index of element
@@ -194,40 +206,38 @@ void FramePainter::PaintContents(GraphicsContext& context,
in_paint_contents_ = false;
}
- probe::didPaint(layout_view->GetFrame(), 0, context, LayoutRect(rect));
+ probe::didPaint(layout_view->GetFrame(), 0, context_, LayoutRect(rect));
}
-void FramePainter::PaintScrollbars(GraphicsContext& context,
- const IntRect& rect) {
+void FramePainter::PaintScrollbars(const IntRect& rect) {
if (GetFrameView().HorizontalScrollbar() &&
!GetFrameView().LayerForHorizontalScrollbar())
- PaintScrollbar(context, *GetFrameView().HorizontalScrollbar(), rect);
+ PaintScrollbar(*GetFrameView().HorizontalScrollbar(), rect);
if (GetFrameView().VerticalScrollbar() &&
!GetFrameView().LayerForVerticalScrollbar())
- PaintScrollbar(context, *GetFrameView().VerticalScrollbar(), rect);
+ PaintScrollbar(*GetFrameView().VerticalScrollbar(), rect);
if (GetFrameView().LayerForScrollCorner() ||
!GetFrameView().IsScrollCornerVisible()) {
return;
}
- PaintScrollCorner(context, GetFrameView().ScrollCornerRect());
+ PaintScrollCorner(GetFrameView().ScrollCornerRect());
}
-void FramePainter::PaintScrollCorner(GraphicsContext& context,
- const IntRect& corner_rect) {
+void FramePainter::PaintScrollCorner(const IntRect& corner_rect) {
if (GetFrameView().ScrollCorner()) {
bool needs_background = GetFrameView().GetFrame().IsMainFrame();
if (needs_background &&
!LayoutObjectDrawingRecorder::UseCachedDrawingIfPossible(
- context, *GetFrameView().GetLayoutView(),
+ context_, *GetFrameView().GetLayoutView(),
DisplayItem::kScrollbarCorner)) {
LayoutObjectDrawingRecorder drawing_recorder(
- context, *GetFrameView().GetLayoutView(),
+ context_, *GetFrameView().GetLayoutView(),
DisplayItem::kScrollbarCorner, FloatRect(corner_rect));
- context.FillRect(corner_rect, GetFrameView().BaseBackgroundColor());
+ context_.FillRect(corner_rect, GetFrameView().BaseBackgroundColor());
}
- ScrollbarPainter::PaintIntoRect(*GetFrameView().ScrollCorner(), context,
+ ScrollbarPainter::PaintIntoRect(*GetFrameView().ScrollCorner(), context_,
corner_rect.Location(),
LayoutRect(corner_rect));
return;
@@ -243,27 +253,35 @@ void FramePainter::PaintScrollCorner(GraphicsContext& context,
NOTREACHED();
}
- theme->PaintScrollCorner(context, *GetFrameView().GetLayoutView(),
+ theme->PaintScrollCorner(context_, *GetFrameView().GetLayoutView(),
corner_rect);
}
-void FramePainter::PaintScrollbar(GraphicsContext& context,
- Scrollbar& bar,
- const IntRect& rect) {
+void FramePainter::PaintScrollbar(Scrollbar& bar, const IntRect& rect) {
bool needs_background =
bar.IsCustomScrollbar() && GetFrameView().GetFrame().IsMainFrame();
if (needs_background) {
IntRect to_fill = bar.FrameRect();
to_fill.Intersect(rect);
- context.FillRect(to_fill, GetFrameView().BaseBackgroundColor());
+ context_.FillRect(to_fill, GetFrameView().BaseBackgroundColor());
}
- bar.Paint(context, CullRect(rect));
+ bar.Paint(context_, CullRect(rect));
}
-const FrameView& FramePainter::GetFrameView() {
+const FrameView& FramePainter::GetFrameView() const {
DCHECK(frame_view_);
return *frame_view_;
}
+void FramePainter::NotifyPaint(const FrameFirstPaint& frame_first_paint) const {
+ const LocalFrame& frame = GetFrameView().GetFrame();
+ DCHECK(frame.GetDocument());
+
+ PaintTiming::From(*frame.GetDocument())
+ .NotifyPaint(frame_first_paint.first_painted,
+ frame_first_paint.text_painted,
+ frame_first_paint.image_painted);
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698