Commit e84d14b4 authored by Christopher Cameron's avatar Christopher Cameron Committed by Commit Bot

mac: Take previous RWHVMac contents at navigation

When navigating, make the old RHWVMac dump its ui::Compositor in
TakeFallbackContentFrom, and have the new RWHVMac pick it up.

Ensure that the ui::AcceleratedWidgetMac preserve its contents through
this transition.

This is not enough to completely eliminate all flashes, because the
NSViews in play aren't being atomically swapped.

Bug: 829523
Change-Id: Ica6eab8dcea7a7987e8b7f83dbfd24acb2c6f7c4
Reviewed-on: https://chromium-review.googlesource.com/1023653
Commit-Queue: ccameron <ccameron@chromium.org>
Reviewed-by: default avatarSaman Sami <samans@chromium.org>
Cr-Commit-Position: refs/heads/master@{#552954}
parent 219322f1
......@@ -70,6 +70,7 @@ class CONTENT_EXPORT BrowserCompositorMac : public DelegatedFrameHostClient {
const base::TimeDelta& interval);
void SetNeedsBeginFrames(bool needs_begin_frames);
void SetWantsAnimateOnlyBeginFrames();
void TakeFallbackContentFrom(BrowserCompositorMac* other);
// Update the renderer's SurfaceId to reflect the current dimensions of the
// NSView. This will allocate a new SurfaceId if needed. This will return
......
......@@ -423,6 +423,21 @@ void BrowserCompositorMac::SetWantsAnimateOnlyBeginFrames() {
delegated_frame_host_->SetWantsAnimateOnlyBeginFrames();
}
void BrowserCompositorMac::TakeFallbackContentFrom(
BrowserCompositorMac* other) {
// We will have a flash if we can't recycle the compositor from |other|.
if (other->state_ != HasDetachedCompositor || state_ != HasNoCompositor) {
return;
}
delegated_frame_host_->TakeFallbackContentFrom(
other->delegated_frame_host_.get());
other->recyclable_compositor_->accelerated_widget_mac()
->ResetNSViewPreservingContents();
other->TransitionToState(HasNoCompositor);
TransitionToState(HasAttachedCompositor);
}
////////////////////////////////////////////////////////////////////////////////
// DelegatedFrameHost, public:
......
......@@ -6,7 +6,31 @@
#define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_NS_VIEW_CLIENT_H_
#include "base/macros.h"
#include "base/strings/string16.h"
#include "content/common/edit_command.h"
#include "content/common/mac/attributed_string_coder.h"
#include "ui/base/ime/ime_text_span.h"
#include "ui/base/ime/text_input_type.h"
namespace blink {
class WebGestureEvent;
class WebMouseEvent;
class WebMouseWheelEvent;
} // namespace blink
namespace display {
class Display;
} // namespace display
namespace gfx {
class PointF;
class Range;
class Rect;
} // namespace gfx
namespace ui {
class LatencyInfo;
} // namespace ui
namespace content {
......
......@@ -711,8 +711,16 @@ void RenderWidgetHostViewMac::SetWantsAnimateOnlyBeginFrames() {
void RenderWidgetHostViewMac::TakeFallbackContentFrom(
RenderWidgetHostView* view) {
SetBackgroundColor(view->background_color());
// TODO(crbug.com/829523): Implement this.
DCHECK(!static_cast<RenderWidgetHostViewBase*>(view)
->IsRenderWidgetHostViewChildFrame());
DCHECK(!static_cast<RenderWidgetHostViewBase*>(view)
->IsRenderWidgetHostViewGuest());
RenderWidgetHostViewMac* view_mac =
static_cast<RenderWidgetHostViewMac*>(view);
ScopedCAActionDisabler disabler;
SetBackgroundColor(view_mac->background_color());
browser_compositor_->TakeFallbackContentFrom(
view_mac->browser_compositor_.get());
}
bool RenderWidgetHostViewMac::GetLineBreakIndex(
......
......@@ -58,6 +58,7 @@ class ACCELERATED_WIDGET_MAC_EXPORT AcceleratedWidgetMac
void SetNSView(AcceleratedWidgetMacNSView* view);
void ResetNSView();
void ResetNSViewPreservingContents();
// Return true if the last frame swapped has a size in DIP of |dip_size|.
bool HasFrameOfSize(const gfx::Size& dip_size) const;
......
......@@ -94,6 +94,15 @@ void AcceleratedWidgetMac::ResetNSView() {
view_ = NULL;
}
void AcceleratedWidgetMac::ResetNSViewPreservingContents() {
if (!view_)
return;
ScopedCAActionDisabler disabler;
[flipped_layer_ removeFromSuperlayer];
view_ = NULL;
}
bool AcceleratedWidgetMac::HasFrameOfSize(
const gfx::Size& dip_size) const {
return last_swap_size_dip_ == dip_size;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment