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

Unified Diff: content/browser/renderer_host/render_widget_host_view_mac.mm

Issue 188873005: Do not dynamically call setLayer on RenderWidgetHostViewCocoa (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clean up Created 6 years, 9 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
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_mac.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/render_widget_host_view_mac.mm
diff --git a/content/browser/renderer_host/render_widget_host_view_mac.mm b/content/browser/renderer_host/render_widget_host_view_mac.mm
index e3940a096ca87518f486172675838a1bfe5415b7..4e4fbc15ada33496c1e6299c09d9b44dd082ee85 100644
--- a/content/browser/renderer_host/render_widget_host_view_mac.mm
+++ b/content/browser/renderer_host/render_widget_host_view_mac.mm
@@ -520,11 +520,8 @@ bool RenderWidgetHostViewMac::CreateCompositedIOSurface() {
return true;
}
-void RenderWidgetHostViewMac::CreateSoftwareLayerAndDestroyCompositedLayer() {
- TRACE_EVENT0(
- "browser",
- "RenderWidgetHostViewMac::CreateSoftwareLayerAndDestroyCompositedLayer");
-
+void RenderWidgetHostViewMac::CreateSoftwareLayer() {
+ TRACE_EVENT0("browser", "RenderWidgetHostViewMac::CreateSoftwareLayer");
if (software_layer_ || !use_core_animation_)
return;
@@ -538,9 +535,8 @@ void RenderWidgetHostViewMac::CreateSoftwareLayerAndDestroyCompositedLayer() {
return;
}
- // Make the layer current and get rid of the old layer, if there is one.
- [cocoa_view_ setLayer:software_layer_];
- DestroyCompositedIOSurfaceAndLayer(kDestroyContext);
+ // Make the layer visible.
+ [background_layer_ addSublayer:software_layer_];
}
void RenderWidgetHostViewMac::DestroySoftwareLayer() {
@@ -548,19 +544,14 @@ void RenderWidgetHostViewMac::DestroySoftwareLayer() {
return;
ScopedCAActionDisabler disabler;
-
- if ([cocoa_view_ layer] == software_layer_.get())
- [cocoa_view_ setLayer:background_layer_];
[software_layer_ removeFromSuperlayer];
[software_layer_ disableRendering];
software_layer_.reset();
}
-bool RenderWidgetHostViewMac::CreateCompositedLayerAndDestroySoftwareLayer() {
- TRACE_EVENT0(
- "browser",
- "RenderWidgetHostViewMac::CreateCompositedLayerAndDestroySoftwareLayer");
-
+bool RenderWidgetHostViewMac::CreateCompositedIOSurfaceLayer() {
+ TRACE_EVENT0("browser",
+ "RenderWidgetHostViewMac::CreateCompositedIOSurfaceLayer");
if (compositing_iosurface_layer_ || !use_core_animation_)
return true;
@@ -574,31 +565,33 @@ bool RenderWidgetHostViewMac::CreateCompositedLayerAndDestroySoftwareLayer() {
return false;
}
- // Make the layer current and get rid of the old layer, if there is one.
- [cocoa_view_ setLayer:compositing_iosurface_layer_];
- DestroySoftwareLayer();
+ // Make the layer visible.
+ [background_layer_ addSublayer:compositing_iosurface_layer_];
- // Creating the CompositingIOSurfaceLayer may attempt to draw in setLayer,
- // which, if it fails, will promptly tear down everything that was just
- // created. If that happened, return failure.
+ // Creating the CompositingIOSurfaceLayer may attempt to draw inside
+ // addSublayer, which, if it fails, will promptly tear down everything that
+ // was just created. If that happened, return failure.
return compositing_iosurface_layer_;
}
+void RenderWidgetHostViewMac::DestroyCompositedIOSurfaceLayer() {
+ if (!compositing_iosurface_layer_)
+ return;
+
+ ScopedCAActionDisabler disabler;
+ [compositing_iosurface_layer_ removeFromSuperlayer];
+ [compositing_iosurface_layer_ disableCompositing];
+ compositing_iosurface_layer_.reset();
+}
+
void RenderWidgetHostViewMac::DestroyCompositedIOSurfaceAndLayer(
DestroyContextBehavior destroy_context_behavior) {
// Any pending frames will not be displayed, so ack them now.
SendPendingSwapAck();
- ScopedCAActionDisabler disabler;
-
+ DestroyCompositedIOSurfaceLayer();
compositing_iosurface_.reset();
- if (compositing_iosurface_layer_) {
- if ([cocoa_view_ layer] == compositing_iosurface_layer_.get())
- [cocoa_view_ setLayer:background_layer_];
- [compositing_iosurface_layer_ removeFromSuperlayer];
- [compositing_iosurface_layer_ disableCompositing];
- compositing_iosurface_layer_.reset();
- }
+
switch (destroy_context_behavior) {
case kLeaveContextBoundToView:
break;
@@ -786,9 +779,8 @@ void RenderWidgetHostViewMac::UpdateBackingStoreScaleFactor() {
ScopedCAActionDisabler disabler;
if (software_layer_) {
- [software_layer_ disableRendering];
- software_layer_.reset();
- CreateSoftwareLayerAndDestroyCompositedLayer();
+ DestroySoftwareLayer();
+ CreateSoftwareLayer();
}
// Dynamically calling setContentsScale on a CAOpenGLLayer for which
@@ -796,9 +788,8 @@ void RenderWidgetHostViewMac::UpdateBackingStoreScaleFactor() {
// content. Work around this by replacing the entire layer when the scale
// factor changes.
if (compositing_iosurface_layer_) {
- [compositing_iosurface_layer_ disableCompositing];
- compositing_iosurface_layer_.reset();
- CreateCompositedLayerAndDestroySoftwareLayer();
+ DestroyCompositedIOSurfaceLayer();
+ CreateCompositedIOSurfaceLayer();
}
render_widget_host_->NotifyScreenInfoChanged();
@@ -1487,7 +1478,7 @@ void RenderWidgetHostViewMac::CompositorSwapBuffers(
// Create the layer for the composited content only after the IOSurface has
// been initialized.
- if (!CreateCompositedLayerAndDestroySoftwareLayer()) {
+ if (!CreateCompositedIOSurfaceLayer()) {
Ken Russell (switch to Gerrit) 2014/03/07 00:29:56 Who takes care of deleting the software layer in t
ccameron 2014/03/07 07:30:01 I moved this to where the software frame and backi
LOG(ERROR) << "Failed to create CompositingIOSurface layer";
GotAcceleratedCompositingError();
return;
@@ -1985,14 +1976,15 @@ void RenderWidgetHostViewMac::GotAcceleratedFrame() {
[cocoa_view_ setNeedsDisplay:YES];
}
- // Delete software backingstore.
+ // Delete software backingstore and layer.
BackingStoreManager::RemoveBackingStore(render_widget_host_);
software_frame_manager_->DiscardCurrentFrame();
+ DestroySoftwareLayer();
ccameron 2014/03/07 07:30:01 [1] from above.
}
}
void RenderWidgetHostViewMac::GotSoftwareFrame() {
- CreateSoftwareLayerAndDestroyCompositedLayer();
+ CreateSoftwareLayer();
Ken Russell (switch to Gerrit) 2014/03/07 00:29:56 Who takes care of deleting the composited IOSurfac
ccameron 2014/03/07 07:30:01 This is done further down in the if (last_frame_wa
[software_layer_ setNeedsDisplay];
SendVSyncParametersToRenderer();
@@ -2945,8 +2937,10 @@ void RenderWidgetHostViewMac::SendPendingSwapAck() {
// this is not sufficient.
ScopedCAActionDisabler disabler;
CGRect frame = NSRectToCGRect([renderWidgetHostView_->cocoa_view() bounds]);
- [[self layer] setFrame:frame];
- [[self layer] setNeedsDisplay];
+ [renderWidgetHostView_->software_layer_ setFrame:frame];
+ [renderWidgetHostView_->software_layer_ setNeedsDisplay];
+ [renderWidgetHostView_->compositing_iosurface_layer_ setFrame:frame];
+ [renderWidgetHostView_->compositing_iosurface_layer_ setNeedsDisplay];
}
- (void)callSetNeedsDisplayInRect {
@@ -2956,7 +2950,8 @@ void RenderWidgetHostViewMac::SendPendingSwapAck() {
renderWidgetHostView_->call_set_needs_display_in_rect_pending_ = false;
renderWidgetHostView_->invalid_rect_ = NSZeroRect;
- [[self layer] setNeedsDisplay];
+ [renderWidgetHostView_->software_layer_ setNeedsDisplay];
+ [renderWidgetHostView_->compositing_iosurface_layer_ setNeedsDisplay];
}
// Fills with white the parts of the area to the right and bottom for |rect|
@@ -3949,7 +3944,10 @@ extern NSString *NSTextInputReplacementRangeAttributeName;
// Resize the view's layers to match the new window size.
ScopedCAActionDisabler disabler;
- [[self layer] setFrame:NSRectToCGRect([self bounds])];
+ [renderWidgetHostView_->software_layer_
+ setFrame:NSRectToCGRect([self bounds])];
+ [renderWidgetHostView_->compositing_iosurface_layer_
+ setFrame:NSRectToCGRect([self bounds])];
}
- (void)undo:(id)sender {
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_mac.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698