| 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_CA_LAYER_TREE_MAC_H_ | 5 #ifndef CONTENT_BROWSER_COMPOSITOR_BROWSER_COMPOSITOR_CA_LAYER_TREE_MAC_H_ |
| 6 #define CONTENT_BROWSER_COMPOSITOR_BROWSER_COMPOSITOR_CA_LAYER_TREE_MAC_H_ | 6 #define CONTENT_BROWSER_COMPOSITOR_BROWSER_COMPOSITOR_CA_LAYER_TREE_MAC_H_ |
| 7 | 7 |
| 8 #include <Cocoa/Cocoa.h> |
| 8 #include <IOSurface/IOSurfaceAPI.h> | 9 #include <IOSurface/IOSurfaceAPI.h> |
| 9 | 10 |
| 10 #include "base/mac/scoped_nsobject.h" | 11 #include "base/mac/scoped_nsobject.h" |
| 11 #include "content/browser/compositor/browser_compositor_view_mac.h" | 12 #include "content/browser/compositor/browser_compositor_view_mac.h" |
| 12 #include "content/browser/compositor/io_surface_layer_mac.h" | 13 #include "content/browser/compositor/io_surface_layer_mac.h" |
| 13 #include "content/browser/compositor/software_layer_mac.h" | 14 #include "content/browser/compositor/software_layer_mac.h" |
| 14 #include "ui/base/cocoa/remote_layer_api.h" | 15 #include "ui/base/cocoa/remote_layer_api.h" |
| 15 | 16 |
| 16 namespace content { | 17 namespace content { |
| 17 | 18 |
| 18 // BrowserCompositorCALayerTreeMac owns tree of CALayer and a ui::Compositor | 19 // BrowserCompositorCALayerTreeMac owns tree of CALayer and a ui::Compositor |
| 19 // that is used to draw the layers. The CALayer tree can be attached to the | 20 // that is used to draw the layers. The CALayer tree can be attached to the |
| 20 // NSView of a BrowserCompositorViewMac | 21 // NSView of a BrowserCompositorViewMac |
| 21 class BrowserCompositorCALayerTreeMac | 22 class BrowserCompositorCALayerTreeMac |
| 22 : public IOSurfaceLayerClient { | 23 : public IOSurfaceLayerClient { |
| 23 public: | 24 public: |
| 24 BrowserCompositorCALayerTreeMac(); | 25 BrowserCompositorCALayerTreeMac(); |
| 25 virtual ~BrowserCompositorCALayerTreeMac(); | 26 virtual ~BrowserCompositorCALayerTreeMac(); |
| 26 static BrowserCompositorCALayerTreeMac* FromAcceleratedWidget( | 27 static BrowserCompositorCALayerTreeMac* FromAcceleratedWidget( |
| 27 gfx::AcceleratedWidget widget); | 28 gfx::AcceleratedWidget widget); |
| 28 | 29 |
| 29 void SetClient(BrowserCompositorViewMacClient* client); | 30 void SetView(BrowserCompositorViewMac* view); |
| 30 void ResetClient(); | 31 void ResetView(); |
| 31 | 32 |
| 32 ui::Compositor* compositor() const { return compositor_.get(); } | 33 ui::Compositor* compositor() const { return compositor_.get(); } |
| 33 | 34 |
| 34 // Return true if the last frame swapped has a size in DIP of |dip_size|. | 35 // Return true if the last frame swapped has a size in DIP of |dip_size|. |
| 35 bool HasFrameOfSize(const gfx::Size& dip_size) const; | 36 bool HasFrameOfSize(const gfx::Size& dip_size) const; |
| 36 | 37 |
| 37 // Return the CGL renderer ID for the surface, if one is available. | 38 // Return the CGL renderer ID for the surface, if one is available. |
| 38 int GetRendererID() const; | 39 int GetRendererID() const; |
| 39 | 40 |
| 40 // Return true if the renderer should not be throttled by GPU back-pressure. | 41 // Return true if the renderer should not be throttled by GPU back-pressure. |
| 41 bool IsRendererThrottlingDisabled() const; | 42 bool IsRendererThrottlingDisabled() const; |
| 42 | 43 |
| 43 // Mark a bracket in which new frames are being pumped in a restricted nested | 44 // Mark a bracket in which new frames are being pumped in a restricted nested |
| 44 // run loop. | 45 // run loop. |
| 45 void BeginPumpingFrames(); | 46 void BeginPumpingFrames(); |
| 46 void EndPumpingFrames(); | 47 void EndPumpingFrames(); |
| 47 | 48 |
| 48 void GotAcceleratedFrame( | 49 static void GotAcceleratedFrame( |
| 49 uint64 surface_handle, int output_surface_id, | 50 gfx::AcceleratedWidget widget, |
| 51 uint64 surface_handle, int surface_id, |
| 50 const std::vector<ui::LatencyInfo>& latency_info, | 52 const std::vector<ui::LatencyInfo>& latency_info, |
| 51 gfx::Size pixel_size, float scale_factor); | 53 gfx::Size pixel_size, float scale_factor, |
| 54 bool* disable_throttling, int* renderer_id); |
| 52 | 55 |
| 53 void GotSoftwareFrame( | 56 static void GotSoftwareFrame( |
| 57 gfx::AcceleratedWidget widget, |
| 54 cc::SoftwareFrameData* frame_data, float scale_factor, SkCanvas* canvas); | 58 cc::SoftwareFrameData* frame_data, float scale_factor, SkCanvas* canvas); |
| 55 | 59 |
| 56 private: | 60 private: |
| 57 // IOSurfaceLayerClient implementation: | 61 // IOSurfaceLayerClient implementation: |
| 58 virtual bool IOSurfaceLayerShouldAckImmediately() const override; | 62 virtual bool IOSurfaceLayerShouldAckImmediately() const override; |
| 59 virtual void IOSurfaceLayerDidDrawFrame() override; | 63 virtual void IOSurfaceLayerDidDrawFrame() override; |
| 60 virtual void IOSurfaceLayerHitError() override; | 64 virtual void IOSurfaceLayerHitError() override; |
| 61 | 65 |
| 66 void GotAcceleratedFrame( |
| 67 uint64 surface_handle, int output_surface_id, |
| 68 const std::vector<ui::LatencyInfo>& latency_info, |
| 69 gfx::Size pixel_size, float scale_factor); |
| 70 |
| 62 void GotAcceleratedCAContextFrame( | 71 void GotAcceleratedCAContextFrame( |
| 63 CAContextID ca_context_id, gfx::Size pixel_size, float scale_factor); | 72 CAContextID ca_context_id, gfx::Size pixel_size, float scale_factor); |
| 64 | 73 |
| 65 void GotAcceleratedIOSurfaceFrame( | 74 void GotAcceleratedIOSurfaceFrame( |
| 66 IOSurfaceID io_surface_id, gfx::Size pixel_size, float scale_factor); | 75 IOSurfaceID io_surface_id, gfx::Size pixel_size, float scale_factor); |
| 67 | 76 |
| 77 void GotSoftwareFrame( |
| 78 cc::SoftwareFrameData* frame_data, float scale_factor, SkCanvas* canvas); |
| 79 |
| 68 // Remove a layer from the heirarchy and destroy it. Because the accelerated | 80 // Remove a layer from the heirarchy and destroy it. Because the accelerated |
| 69 // layer types may be replaced by a layer of the same type, the layer to | 81 // layer types may be replaced by a layer of the same type, the layer to |
| 70 // destroy is parameterized, and, if it is the current layer, the current | 82 // destroy is parameterized, and, if it is the current layer, the current |
| 71 // layer is reset. | 83 // layer is reset. |
| 72 void DestroyCAContextLayer( | 84 void DestroyCAContextLayer( |
| 73 base::scoped_nsobject<CALayerHost> ca_context_layer); | 85 base::scoped_nsobject<CALayerHost> ca_context_layer); |
| 74 void DestroyIOSurfaceLayer( | 86 void DestroyIOSurfaceLayer( |
| 75 base::scoped_nsobject<IOSurfaceLayer> io_surface_layer); | 87 base::scoped_nsobject<IOSurfaceLayer> io_surface_layer); |
| 76 void DestroySoftwareLayer(); | 88 void DestroySoftwareLayer(); |
| 77 | 89 |
| 78 // The client of the BrowserCompositorViewMac that is using this as its | 90 // The BrowserCompositorViewMac that is using this as its internals. |
| 79 // internals. | 91 BrowserCompositorViewMac* view_; |
| 80 BrowserCompositorViewMacClient* client_; | |
| 81 | 92 |
| 82 // A phony NSView handle used to identify this. | 93 // A phony NSView handle used to identify this. |
| 83 gfx::AcceleratedWidget native_widget_; | 94 gfx::AcceleratedWidget native_widget_; |
| 84 | 95 |
| 85 // The compositor drawing the contents of this view. | 96 // The compositor drawing the contents of this view. |
| 86 scoped_ptr<ui::Compositor> compositor_; | 97 scoped_ptr<ui::Compositor> compositor_; |
| 87 | 98 |
| 88 // A flipped layer, which acts as the parent of the compositing and software | 99 // A flipped layer, which acts as the parent of the compositing and software |
| 89 // layers. This layer is flipped so that the we don't need to recompute the | 100 // layers. This layer is flipped so that the we don't need to recompute the |
| 90 // origin for sub-layers when their position changes (this is impossible when | 101 // origin for sub-layers when their position changes (this is impossible when |
| (...skipping 18 matching lines...) Expand all Loading... |
| 109 int accelerated_output_surface_id_; | 120 int accelerated_output_surface_id_; |
| 110 std::vector<ui::LatencyInfo> accelerated_latency_info_; | 121 std::vector<ui::LatencyInfo> accelerated_latency_info_; |
| 111 | 122 |
| 112 // The size in DIP of the last swap received from |compositor_|. | 123 // The size in DIP of the last swap received from |compositor_|. |
| 113 gfx::Size last_swap_size_dip_; | 124 gfx::Size last_swap_size_dip_; |
| 114 }; | 125 }; |
| 115 | 126 |
| 116 } // namespace content | 127 } // namespace content |
| 117 | 128 |
| 118 #endif // CONTENT_BROWSER_COMPOSITOR_BROWSER_COMPOSITOR_CA_LAYER_TREE_MAC_H_ | 129 #endif // CONTENT_BROWSER_COMPOSITOR_BROWSER_COMPOSITOR_CA_LAYER_TREE_MAC_H_ |
| OLD | NEW |