diff options
author | ccameron <ccameron@chromium.org> | 2015-04-10 10:43:56 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-04-10 17:44:20 +0000 |
commit | c85aba5fa461901d8b76c4fe26719ec6056abd20 (patch) | |
tree | a96576440a47edd6aa6880ac79c314c4d67ad11c | |
parent | db4f05ad8220e94b82976196cdb307fd4be9047d (diff) | |
download | chromium_src-c85aba5fa461901d8b76c4fe26719ec6056abd20.zip chromium_src-c85aba5fa461901d8b76c4fe26719ec6056abd20.tar.gz chromium_src-c85aba5fa461901d8b76c4fe26719ec6056abd20.tar.bz2 |
Mac: Partially enable partial swap
We draw all contents in the IOSurface and remote CALayer paths into a
buffer, which we then draw to the screen. A partial swap here means that
we partially re-drew the buffer.
This isn't a complete partial swap, because, in both of these cases, we
still re-draw the full buffer to the screen.
While I'm in the neighborhood, clean up how we track the size of the
frame, since that is particularly confusing (especially when we have
partial swaps that would, more logically, pass in the damage rect).
BUG=474299
Review URL: https://codereview.chromium.org/1065123002
Cr-Commit-Position: refs/heads/master@{#324658}
6 files changed, 46 insertions, 17 deletions
diff --git a/content/common/gpu/image_transport_surface_calayer_mac.h b/content/common/gpu/image_transport_surface_calayer_mac.h index e341661..43cd2af 100644 --- a/content/common/gpu/image_transport_surface_calayer_mac.h +++ b/content/common/gpu/image_transport_surface_calayer_mac.h @@ -29,7 +29,9 @@ class CALayerStorageProvider CGLContextObj context, const base::Closure& context_dirtied_callback, GLuint texture, gfx::Size pixel_size, float scale_factor) override; void FreeColorBufferStorage() override; - void SwapBuffers(const gfx::Size& size, float scale_factor) override; + void FrameSizeChanged( + const gfx::Size& pixel_size, float scale_factor) override; + void SwapBuffers() override; void WillWriteToBackbuffer() override; void DiscardBackbuffer() override; void SwapBuffersAckedByBrowser(bool disable_throttling) override; diff --git a/content/common/gpu/image_transport_surface_calayer_mac.mm b/content/common/gpu/image_transport_surface_calayer_mac.mm index 3778d48..1aec294 100644 --- a/content/common/gpu/image_transport_surface_calayer_mac.mm +++ b/content/common/gpu/image_transport_surface_calayer_mac.mm @@ -290,8 +290,13 @@ void CALayerStorageProvider::FreeColorBufferStorage() { can_draw_returned_false_count_ = 0; } -void CALayerStorageProvider::SwapBuffers( - const gfx::Size& size, float scale_factor) { +void CALayerStorageProvider::FrameSizeChanged(const gfx::Size& pixel_size, + float scale_factor) { + DCHECK_EQ(fbo_pixel_size_.ToString(), pixel_size.ToString()); + DCHECK_EQ(fbo_scale_factor_, scale_factor); +} + +void CALayerStorageProvider::SwapBuffers() { DCHECK(!has_pending_draw_); // Recreate the CALayer on the new GPU if a GPU switch has occurred. Note diff --git a/content/common/gpu/image_transport_surface_fbo_mac.h b/content/common/gpu/image_transport_surface_fbo_mac.h index 21178b5..d5a0c20 100644 --- a/content/common/gpu/image_transport_surface_fbo_mac.h +++ b/content/common/gpu/image_transport_surface_fbo_mac.h @@ -41,9 +41,13 @@ class ImageTransportSurfaceFBO // GL texture that was bound has already been deleted by the caller. virtual void FreeColorBufferStorage() = 0; - // Swap buffers and return the handle for the surface to send to the browser - // process to display. - virtual void SwapBuffers(const gfx::Size& size, float scale_factor) = 0; + // Called when the frame size has changed (the buffer may not have been + // reallocated, since its size may be rounded). + virtual void FrameSizeChanged( + const gfx::Size& pixel_size, float scale_factor) = 0; + + // Swap buffers, or post sub-buffer. + virtual void SwapBuffers() = 0; // Indicate that the backbuffer will be written to. virtual void WillWriteToBackbuffer() = 0; @@ -103,6 +107,7 @@ class ImageTransportSurfaceFBO void DestroyFramebuffer(); void AllocateOrResizeFramebuffer( const gfx::Size& pixel_size, float scale_factor); + bool SwapBuffersInternal(); scoped_ptr<StorageProvider> storage_provider_; diff --git a/content/common/gpu/image_transport_surface_fbo_mac.mm b/content/common/gpu/image_transport_surface_fbo_mac.mm index 64e3e72..fcb4024 100644 --- a/content/common/gpu/image_transport_surface_fbo_mac.mm +++ b/content/common/gpu/image_transport_surface_fbo_mac.mm @@ -169,6 +169,10 @@ void ImageTransportSurfaceFBO::AdjustBufferAllocation() { } bool ImageTransportSurfaceFBO::SwapBuffers() { + return SwapBuffersInternal(); +} + +bool ImageTransportSurfaceFBO::SwapBuffersInternal() { DCHECK(backbuffer_suggested_allocation_); if (!frontbuffer_suggested_allocation_) return true; @@ -176,7 +180,7 @@ bool ImageTransportSurfaceFBO::SwapBuffers() { // It is the responsibility of the storage provider to send the swap IPC. is_swap_buffers_send_pending_ = true; - storage_provider_->SwapBuffers(pixel_size_, scale_factor_); + storage_provider_->SwapBuffers(); // The call to swapBuffers could potentially result in an immediate draw. // Ensure that any changes made to the context's state are restored. @@ -203,13 +207,11 @@ void ImageTransportSurfaceFBO::SetRendererID(int renderer_id) { bool ImageTransportSurfaceFBO::PostSubBuffer( int x, int y, int width, int height) { - // Mac does not support sub-buffer swaps. - NOTREACHED(); - return false; + return SwapBuffersInternal(); } bool ImageTransportSurfaceFBO::SupportsPostSubBuffer() { - return false; + return true; } gfx::Size ImageTransportSurfaceFBO::GetSize() { @@ -302,8 +304,10 @@ void ImageTransportSurfaceFBO::AllocateOrResizeFramebuffer( rounded_pixel_size_ = new_rounded_pixel_size; scale_factor_ = new_scale_factor; - if (!needs_new_storage) + if (!needs_new_storage) { + storage_provider_->FrameSizeChanged(pixel_size_, scale_factor_); return; + } TRACE_EVENT2("gpu", "ImageTransportSurfaceFBO::AllocateOrResizeFramebuffer", "width", new_rounded_pixel_size.width(), @@ -398,6 +402,7 @@ void ImageTransportSurfaceFBO::AllocateOrResizeFramebuffer( } has_complete_framebuffer_ = true; + storage_provider_->FrameSizeChanged(pixel_size_, scale_factor_); glBindTexture(texture_target, previous_texture_id); // The FBO remains bound for this GL context. diff --git a/content/common/gpu/image_transport_surface_iosurface_mac.cc b/content/common/gpu/image_transport_surface_iosurface_mac.cc index d2c6b57..2b61810 100644 --- a/content/common/gpu/image_transport_surface_iosurface_mac.cc +++ b/content/common/gpu/image_transport_surface_iosurface_mac.cc @@ -42,7 +42,8 @@ void AddIntegerValue(CFMutableDictionaryRef dictionary, IOSurfaceStorageProvider::IOSurfaceStorageProvider( ImageTransportSurfaceFBO* transport_surface) - : transport_surface_(transport_surface) {} + : transport_surface_(transport_surface), + frame_scale_factor_(1) {} IOSurfaceStorageProvider::~IOSurfaceStorageProvider() { DCHECK(!io_surface_); @@ -105,8 +106,13 @@ void IOSurfaceStorageProvider::FreeColorBufferStorage() { io_surface_id_ = 0; } -void IOSurfaceStorageProvider::SwapBuffers( - const gfx::Size& size, float scale_factor) { +void IOSurfaceStorageProvider::FrameSizeChanged(const gfx::Size& pixel_size, + float scale_factor) { + frame_pixel_size_ = pixel_size; + frame_scale_factor_ = scale_factor; +} + +void IOSurfaceStorageProvider::SwapBuffers() { // The browser compositor will throttle itself, so we are free to unblock the // context immediately. Make sure that the browser is doing its throttling // appropriately by ensuring that the previous swap was acknowledged before @@ -115,7 +121,9 @@ void IOSurfaceStorageProvider::SwapBuffers( pending_swapped_surfaces_.push_back(io_surface_); transport_surface_->SendSwapBuffers( - ui::SurfaceHandleFromIOSurfaceID(io_surface_id_), size, scale_factor); + ui::SurfaceHandleFromIOSurfaceID(io_surface_id_), + frame_pixel_size_, + frame_scale_factor_); } void IOSurfaceStorageProvider::WillWriteToBackbuffer() { diff --git a/content/common/gpu/image_transport_surface_iosurface_mac.h b/content/common/gpu/image_transport_surface_iosurface_mac.h index 797c4ec..9062595 100644 --- a/content/common/gpu/image_transport_surface_iosurface_mac.h +++ b/content/common/gpu/image_transport_surface_iosurface_mac.h @@ -27,7 +27,9 @@ class IOSurfaceStorageProvider CGLContextObj context, const base::Closure& context_dirtied_callback, GLuint texture, gfx::Size pixel_size, float scale_factor) override; void FreeColorBufferStorage() override; - void SwapBuffers(const gfx::Size& size, float scale_factor) override; + void FrameSizeChanged( + const gfx::Size& pixel_size, float scale_factor) override; + void SwapBuffers() override; void WillWriteToBackbuffer() override; void DiscardBackbuffer() override; void SwapBuffersAckedByBrowser(bool disable_throttling) override; @@ -36,6 +38,8 @@ class IOSurfaceStorageProvider ImageTransportSurfaceFBO* transport_surface_; base::ScopedCFTypeRef<IOSurfaceRef> io_surface_; + gfx::Size frame_pixel_size_; + float frame_scale_factor_; // The list of IOSurfaces that have been sent to the browser process but have // not been opened in the browser process yet. This list should never have |