summaryrefslogtreecommitdiffstats
path: root/content/browser
diff options
context:
space:
mode:
authorccameron@chromium.org <ccameron@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-02 12:05:35 +0000
committerccameron@chromium.org <ccameron@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-02 12:05:35 +0000
commit1c08fa7168a6d702a4f7c7e347bf126770fc26ea (patch)
treef7484040fb9c58cba634ae7a27cea5a64aabf201 /content/browser
parent4957d847f492e76cdc3200ab472d9dd08e0b3fcc (diff)
downloadchromium_src-1c08fa7168a6d702a4f7c7e347bf126770fc26ea.zip
chromium_src-1c08fa7168a6d702a4f7c7e347bf126770fc26ea.tar.gz
chromium_src-1c08fa7168a6d702a4f7c7e347bf126770fc26ea.tar.bz2
Make window resize using CoreAnimation behave the same as without.
Change the NSView to update the layer when setNeedsDisplay is called and add a call to the layer's setNeedsDisplay in the NSView's setFrameSize. This has the consequnece that drawLayer will be called inside the call to setNeedsDisplay. Make the call to drawLayer (for the composited path) block until a frame of the new window size is received. Add all of this together, and the setFrameSize call will block until a frame of the right size is received. This may not be the best thing, as it blocks the browser's main thread (which will jank any animations in other windows), but it matches the non-CoreAnimation behavior. Of note is that setting the NSView to have the redraw policy of NSViewLayerContentsRedrawDuringViewResize and not adding the setNeedsDisplay call in setFrameSize does not result in the setFrameSize call blocking in time, and so the window contents lag during resize. BUG=254629 Review URL: https://chromiumcodereview.appspot.com/18029025 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@209678 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser')
-rw-r--r--content/browser/renderer_host/compositing_iosurface_layer_mac.mm14
-rw-r--r--content/browser/renderer_host/render_widget_host_view_mac.mm11
2 files changed, 25 insertions, 0 deletions
diff --git a/content/browser/renderer_host/compositing_iosurface_layer_mac.mm b/content/browser/renderer_host/compositing_iosurface_layer_mac.mm
index 10b0727..47878a0 100644
--- a/content/browser/renderer_host/compositing_iosurface_layer_mac.mm
+++ b/content/browser/renderer_host/compositing_iosurface_layer_mac.mm
@@ -8,6 +8,7 @@
#include <OpenGL/gl.h>
#include "base/mac/sdk_forward_declarations.h"
+#include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/browser/renderer_host/render_widget_host_view_mac.h"
#include "content/browser/renderer_host/compositing_iosurface_context_mac.h"
#include "content/browser/renderer_host/compositing_iosurface_mac.h"
@@ -100,6 +101,8 @@
pixelFormat:(CGLPixelFormatObj)pixelFormat
forLayerTime:(CFTimeInterval)timeInterval
displayTime:(const CVTimeStamp*)timeStamp {
+ TRACE_EVENT0("browser", "CompositingIOSurfaceLayer::drawInCGLContext");
+
if (!context_.get() || !renderWidgetHostView_ ||
!renderWidgetHostView_->compositing_iosurface_) {
glClearColor(1, 1, 1, 1);
@@ -109,6 +112,17 @@
DCHECK(glContext == context_->cgl_context());
+ // If a resize is in progress then GetBackingStore request a frame of the
+ // current window size and block until a frame of the right size comes in.
+ // This makes the window content not lag behind the resize (at the cost of
+ // blocking on the browser's main thread).
+ if (renderWidgetHostView_->render_widget_host_) {
+ renderWidgetHostView_->about_to_validate_and_paint_ = true;
+ (void)renderWidgetHostView_->render_widget_host_->GetBackingStore(true);
+ renderWidgetHostView_->about_to_validate_and_paint_ = false;
+ CGLSetCurrentContext(glContext);
+ }
+
gfx::Size window_size([self frame].size);
float window_scale_factor = 1.f;
if ([self respondsToSelector:(@selector(contentsScale))])
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 4349775..47d617c 100644
--- a/content/browser/renderer_host/render_widget_host_view_mac.mm
+++ b/content/browser/renderer_host/render_widget_host_view_mac.mm
@@ -2465,6 +2465,8 @@ void RenderWidgetHostViewMac::FrameSwapped() {
}
- (void)setFrameSize:(NSSize)newSize {
+ TRACE_EVENT0("browser", "RenderWidgetHostViewCocoa::setFrameSize");
+
// NB: -[NSView setFrame:] calls through -setFrameSize:, so overriding
// -setFrame: isn't neccessary.
[super setFrameSize:newSize];
@@ -2472,6 +2474,13 @@ void RenderWidgetHostViewMac::FrameSwapped() {
renderWidgetHostView_->render_widget_host_->SendScreenRects();
renderWidgetHostView_->render_widget_host_->WasResized();
}
+
+ // This call is necessary to make the window wait for a new frame at the new
+ // size to be available before the resize completes. Calling only
+ // setLayerContentsRedrawPolicy:NSViewLayerContentsRedrawOnSetNeedsDisplay on
+ // this is not sufficient.
+ [renderWidgetHostView_->software_layer_ setNeedsDisplay];
+ [renderWidgetHostView_->compositing_iosurface_layer_ setNeedsDisplay];
}
- (void)callSetNeedsDisplayInRect {
@@ -3649,6 +3658,8 @@ extern NSString *NSTextInputReplacementRangeAttributeName;
// Delegate methods for the software CALayer
- (void)drawLayer:(CALayer*)layer
inContext:(CGContextRef)context {
+ TRACE_EVENT0("browser", "CompositingIOSurfaceLayer::drawLayer");
+
DCHECK(renderWidgetHostView_->use_core_animation_);
DCHECK([layer isEqual:renderWidgetHostView_->software_layer_]);