| 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. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 68 // Remove a layer from the heirarchy and destroy it. Because the accelerated | 69 // 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 | 70 // 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 | 71 // destroy is parameterized, and, if it is the current layer, the current |
| 71 // layer is reset. | 72 // layer is reset. |
| 72 void DestroyCAContextLayer( | 73 void DestroyCAContextLayer( |
| 73 base::scoped_nsobject<CALayerHost> ca_context_layer); | 74 base::scoped_nsobject<CALayerHost> ca_context_layer); |
| 74 void DestroyIOSurfaceLayer( | 75 void DestroyIOSurfaceLayer( |
| 75 base::scoped_nsobject<IOSurfaceLayer> io_surface_layer); | 76 base::scoped_nsobject<IOSurfaceLayer> io_surface_layer); |
| 76 void DestroySoftwareLayer(); | 77 void DestroySoftwareLayer(); |
| 77 | 78 |
| 78 // The client of the BrowserCompositorViewMac that is using this as its | 79 // The BrowserCompositorViewMac that is using this as its internals. |
| 79 // internals. | 80 BrowserCompositorViewMac* view_; |
| 80 BrowserCompositorViewMacClient* client_; | |
| 81 | 81 |
| 82 // A phony NSView handle used to identify this. | 82 // A phony NSView handle used to identify this. |
| 83 gfx::AcceleratedWidget native_widget_; | 83 gfx::AcceleratedWidget native_widget_; |
| 84 | 84 |
| 85 // The compositor drawing the contents of this view. | 85 // The compositor drawing the contents of this view. |
| 86 scoped_ptr<ui::Compositor> compositor_; | 86 scoped_ptr<ui::Compositor> compositor_; |
| 87 | 87 |
| 88 // A flipped layer, which acts as the parent of the compositing and software | 88 // 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 | 89 // 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 | 90 // origin for sub-layers when their position changes (this is impossible when |
| (...skipping 15 matching lines...) Expand all Loading... |
| 106 // The output surface and latency info of the last accelerated surface that | 106 // The output surface and latency info of the last accelerated surface that |
| 107 // was swapped. Sent back to the renderer when the accelerated surface is | 107 // was swapped. Sent back to the renderer when the accelerated surface is |
| 108 // drawn. | 108 // drawn. |
| 109 int accelerated_output_surface_id_; | 109 int accelerated_output_surface_id_; |
| 110 std::vector<ui::LatencyInfo> accelerated_latency_info_; | 110 std::vector<ui::LatencyInfo> accelerated_latency_info_; |
| 111 | 111 |
| 112 // The size in DIP of the last swap received from |compositor_|. | 112 // The size in DIP of the last swap received from |compositor_|. |
| 113 gfx::Size last_swap_size_dip_; | 113 gfx::Size last_swap_size_dip_; |
| 114 }; | 114 }; |
| 115 | 115 |
| 116 void BrowserCompositorCALayerTreeMacGotAcceleratedFrame( |
| 117 gfx::AcceleratedWidget widget, |
| 118 uint64 surface_handle, int surface_id, |
| 119 const std::vector<ui::LatencyInfo>& latency_info, |
| 120 gfx::Size pixel_size, float scale_factor, |
| 121 bool* disable_throttling, int* renderer_id); |
| 122 |
| 123 void BrowserCompositorCALayerTreeMacGotSoftwareFrame( |
| 124 gfx::AcceleratedWidget widget, |
| 125 cc::SoftwareFrameData* frame_data, float scale_factor, SkCanvas* canvas); |
| 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 |