| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_BROWSER_COMPOSITOR_BROWSER_COMPOSITOR_VIEW_PRIVATE_MAC_H_ | 5 #ifndef CONTENT_BROWSER_COMPOSITOR_BROWSER_COMPOSITOR_VIEW_PRIVATE_MAC_H_ |
| 6 #define CONTENT_BROWSER_COMPOSITOR_BROWSER_COMPOSITOR_VIEW_PRIVATE_MAC_H_ | 6 #define CONTENT_BROWSER_COMPOSITOR_BROWSER_COMPOSITOR_VIEW_PRIVATE_MAC_H_ |
| 7 | 7 |
| 8 #include <IOSurface/IOSurfaceAPI.h> | 8 #include <IOSurface/IOSurfaceAPI.h> |
| 9 | 9 |
| 10 #include "base/mac/scoped_nsobject.h" | 10 #include "base/mac/scoped_nsobject.h" |
| 11 #include "content/browser/compositor/browser_compositor_view_mac.h" | 11 #include "content/browser/compositor/browser_compositor_view_mac.h" |
| 12 #include "content/browser/renderer_host/compositing_iosurface_layer_mac.h" | 12 #include "content/browser/renderer_host/compositing_iosurface_layer_mac.h" |
| 13 #include "content/browser/renderer_host/software_layer_mac.h" | 13 #include "content/browser/renderer_host/software_layer_mac.h" |
| 14 #include "ui/base/cocoa/remote_layer_api.h" |
| 14 | 15 |
| 15 namespace content { | 16 namespace content { |
| 16 | 17 |
| 17 // BrowserCompositorViewMacInternal owns a NSView and a ui::Compositor that | 18 // BrowserCompositorViewMacInternal owns a NSView and a ui::Compositor that |
| 18 // draws that view. | 19 // draws that view. |
| 19 class BrowserCompositorViewMacInternal | 20 class BrowserCompositorViewMacInternal |
| 20 : public CompositingIOSurfaceLayerClient { | 21 : public CompositingIOSurfaceLayerClient { |
| 21 public: | 22 public: |
| 22 BrowserCompositorViewMacInternal(); | 23 BrowserCompositorViewMacInternal(); |
| 23 virtual ~BrowserCompositorViewMacInternal(); | 24 virtual ~BrowserCompositorViewMacInternal(); |
| 24 static BrowserCompositorViewMacInternal* FromAcceleratedWidget( | 25 static BrowserCompositorViewMacInternal* FromAcceleratedWidget( |
| 25 gfx::AcceleratedWidget widget); | 26 gfx::AcceleratedWidget widget); |
| 26 | 27 |
| 27 void SetClient(BrowserCompositorViewMacClient* client); | 28 void SetClient(BrowserCompositorViewMacClient* client); |
| 28 void ResetClient(); | 29 void ResetClient(); |
| 29 | 30 |
| 30 ui::Compositor* compositor() const { return compositor_.get(); } | 31 ui::Compositor* compositor() const { return compositor_.get(); } |
| 31 | 32 |
| 32 // Return true if the last frame swapped has a size in DIP of |dip_size|. | 33 // Return true if the last frame swapped has a size in DIP of |dip_size|. |
| 33 bool HasFrameOfSize(const gfx::Size& dip_size) const; | 34 bool HasFrameOfSize(const gfx::Size& dip_size) const; |
| 34 | 35 |
| 35 // Mark a bracket in which new frames are being pumped in a restricted nested | 36 // Mark a bracket in which new frames are being pumped in a restricted nested |
| 36 // run loop. | 37 // run loop. |
| 37 void BeginPumpingFrames(); | 38 void BeginPumpingFrames(); |
| 38 void EndPumpingFrames(); | 39 void EndPumpingFrames(); |
| 39 | 40 |
| 40 void GotAcceleratedIOSurfaceFrame( | 41 void GotAcceleratedFrame( |
| 41 IOSurfaceID io_surface_id, int output_surface_id, | 42 uint64 surface_handle, int output_surface_id, |
| 42 const std::vector<ui::LatencyInfo>& latency_info, | 43 const std::vector<ui::LatencyInfo>& latency_info, |
| 43 gfx::Size pixel_size, float scale_factor); | 44 gfx::Size pixel_size, float scale_factor); |
| 44 | 45 |
| 45 void GotSoftwareFrame( | 46 void GotSoftwareFrame( |
| 46 cc::SoftwareFrameData* frame_data, float scale_factor, SkCanvas* canvas); | 47 cc::SoftwareFrameData* frame_data, float scale_factor, SkCanvas* canvas); |
| 47 | 48 |
| 48 private: | 49 private: |
| 49 // CompositingIOSurfaceLayerClient implementation: | 50 // CompositingIOSurfaceLayerClient implementation: |
| 50 virtual bool AcceleratedLayerShouldAckImmediately() const OVERRIDE; | 51 virtual bool AcceleratedLayerShouldAckImmediately() const OVERRIDE; |
| 51 virtual void AcceleratedLayerDidDrawFrame(bool succeeded) OVERRIDE; | 52 virtual void AcceleratedLayerDidDrawFrame(bool succeeded) OVERRIDE; |
| 52 | 53 |
| 54 void GotAcceleratedCAContextFrame( |
| 55 CAContextID ca_context_id, gfx::Size pixel_size, float scale_factor); |
| 56 |
| 57 void GotAcceleratedIOSurfaceFrame( |
| 58 IOSurfaceID io_surface_id, gfx::Size pixel_size, float scale_factor); |
| 59 |
| 53 // The client of the BrowserCompositorViewMac that is using this as its | 60 // The client of the BrowserCompositorViewMac that is using this as its |
| 54 // internals. | 61 // internals. |
| 55 BrowserCompositorViewMacClient* client_; | 62 BrowserCompositorViewMacClient* client_; |
| 56 | 63 |
| 57 // A phony NSView handle used to identify this. | 64 // A phony NSView handle used to identify this. |
| 58 gfx::AcceleratedWidget native_widget_; | 65 gfx::AcceleratedWidget native_widget_; |
| 59 | 66 |
| 60 // The compositor drawing the contents of this view. | 67 // The compositor drawing the contents of this view. |
| 61 scoped_ptr<ui::Compositor> compositor_; | 68 scoped_ptr<ui::Compositor> compositor_; |
| 62 | 69 |
| 63 // A flipped layer, which acts as the parent of the compositing and software | 70 // A flipped layer, which acts as the parent of the compositing and software |
| 64 // layers. This layer is flipped so that the we don't need to recompute the | 71 // layers. This layer is flipped so that the we don't need to recompute the |
| 65 // origin for sub-layers when their position changes (this is impossible when | 72 // origin for sub-layers when their position changes (this is impossible when |
| 66 // using remote layers, as their size change cannot be synchronized with the | 73 // using remote layers, as their size change cannot be synchronized with the |
| 67 // window). This indirection is needed because flipping hosted layers (like | 74 // window). This indirection is needed because flipping hosted layers (like |
| 68 // |background_layer_| of RenderWidgetHostViewCocoa) leads to unpredictable | 75 // |background_layer_| of RenderWidgetHostViewCocoa) leads to unpredictable |
| 69 // behavior. | 76 // behavior. |
| 70 base::scoped_nsobject<CALayer> flipped_layer_; | 77 base::scoped_nsobject<CALayer> flipped_layer_; |
| 71 | 78 |
| 72 base::scoped_nsobject<CompositingIOSurfaceLayer> accelerated_layer_; | 79 // The accelerated CoreAnimation layer hosted by the GPU process. |
| 73 int accelerated_layer_output_surface_id_; | 80 base::scoped_nsobject<CALayerHost> ca_context_layer_; |
| 81 |
| 82 // The locally drawn accelerated CoreAnimation layer. |
| 83 base::scoped_nsobject<CompositingIOSurfaceLayer> io_surface_layer_; |
| 84 |
| 85 // The locally drawn software layer. |
| 86 base::scoped_nsobject<SoftwareLayer> software_layer_; |
| 87 |
| 88 // The output surface and latency info of the last accelerated surface that |
| 89 // was swapped. Sent back to the renderer when the accelerated surface is |
| 90 // drawn. |
| 91 int accelerated_output_surface_id_; |
| 74 std::vector<ui::LatencyInfo> accelerated_latency_info_; | 92 std::vector<ui::LatencyInfo> accelerated_latency_info_; |
| 75 | 93 |
| 76 base::scoped_nsobject<SoftwareLayer> software_layer_; | |
| 77 | |
| 78 // The size in DIP of the last swap received from |compositor_|. | 94 // The size in DIP of the last swap received from |compositor_|. |
| 79 gfx::Size last_swap_size_dip_; | 95 gfx::Size last_swap_size_dip_; |
| 80 }; | 96 }; |
| 81 | 97 |
| 82 } // namespace content | 98 } // namespace content |
| 83 | 99 |
| 84 #endif // CONTENT_BROWSER_COMPOSITOR_BROWSER_COMPOSITOR_VIEW_PRIVATE_MAC_H_ | 100 #endif // CONTENT_BROWSER_COMPOSITOR_BROWSER_COMPOSITOR_VIEW_PRIVATE_MAC_H_ |
| OLD | NEW |