Chromium Code Reviews| 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_MAC_H_ | 5 #ifndef CONTENT_BROWSER_COMPOSITOR_BROWSER_COMPOSITOR_VIEW_MAC_H_ |
| 6 #define CONTENT_BROWSER_COMPOSITOR_BROWSER_COMPOSITOR_VIEW_MAC_H_ | 6 #define CONTENT_BROWSER_COMPOSITOR_BROWSER_COMPOSITOR_VIEW_MAC_H_ |
| 7 | 7 |
| 8 #include <Cocoa/Cocoa.h> | |
|
tapted
2014/10/17 00:04:35
ui/gfx/native_widget_types.h (and NSView -> gfx::N
ccameron
2014/10/17 00:26:53
Actually, the #include turned out not the be neces
| |
| 8 #include <vector> | 9 #include <vector> |
| 9 | 10 |
| 10 #include "cc/output/software_frame_data.h" | 11 #include "cc/output/software_frame_data.h" |
| 11 #include "skia/ext/platform_canvas.h" | 12 #include "skia/ext/platform_canvas.h" |
| 12 #include "ui/compositor/compositor.h" | 13 #include "ui/compositor/compositor.h" |
| 13 #include "ui/events/latency_info.h" | 14 #include "ui/events/latency_info.h" |
| 14 #include "ui/gfx/geometry/size.h" | 15 #include "ui/gfx/geometry/size.h" |
| 15 | 16 |
| 16 namespace content { | 17 namespace content { |
| 17 | 18 |
| 18 class BrowserCompositorCALayerTreeMac; | 19 class BrowserCompositorCALayerTreeMac; |
| 19 | 20 |
| 20 // The interface through which BrowserCompositorViewMac calls back into | 21 // The interface through which BrowserCompositorViewMac calls back into |
| 21 // RenderWidgetHostViewMac (or any other structure that wishes to draw a | 22 // RenderWidgetHostViewMac (or any other structure that wishes to draw a |
| 22 // NSView backed by a ui::Compositor). | 23 // NSView backed by a ui::Compositor). |
| 24 // TODO(ccameron): This interface should be in the ui namespace. | |
| 23 class BrowserCompositorViewMacClient { | 25 class BrowserCompositorViewMacClient { |
| 24 public: | 26 public: |
| 25 // Drawing is usually throttled by the rate at which CoreAnimation draws | 27 // Drawing is usually throttled by the rate at which CoreAnimation draws |
| 26 // frames to the screen. This can be used to disable throttling. | 28 // frames to the screen. This can be used to disable throttling. |
| 27 virtual bool BrowserCompositorViewShouldAckImmediately() const = 0; | 29 virtual bool BrowserCompositorViewShouldAckImmediately() const = 0; |
| 28 | 30 |
| 29 // Called when a frame is drawn, and used to pass latency info back to the | 31 // Called when a frame is drawn, and used to pass latency info back to the |
| 30 // renderer (if any). | 32 // renderer (if any). |
| 31 virtual void BrowserCompositorViewFrameSwapped( | 33 virtual void BrowserCompositorViewFrameSwapped( |
| 32 const std::vector<ui::LatencyInfo>& latency_info) = 0; | 34 const std::vector<ui::LatencyInfo>& latency_info) = 0; |
| 33 | |
| 34 // Used to install the ui::Compositor-backed NSView as a child of its parent | |
| 35 // view. | |
| 36 virtual NSView* BrowserCompositorSuperview() = 0; | |
| 37 | |
| 38 // Used to install the root ui::Layer into the ui::Compositor. | |
| 39 virtual ui::Layer* BrowserCompositorRootLayer() = 0; | |
| 40 }; | 35 }; |
| 41 | 36 |
| 42 // The class to hold a ui::Compositor-backed NSView. Because a ui::Compositor | 37 // The class to hold a ui::Compositor-backed NSView. Because a ui::Compositor |
| 43 // is expensive in terms of resources and re-allocating a ui::Compositor is | 38 // is expensive in terms of resources and re-allocating a ui::Compositor is |
| 44 // expensive in terms of work, this class is largely used to manage recycled | 39 // expensive in terms of work, this class is largely used to manage recycled |
| 45 // instances of BrowserCompositorViewCocoa, which actually is a NSView and | 40 // instances of BrowserCompositorViewCocoa, which actually is a NSView and |
| 46 // has a ui::Compositor instance. | 41 // has a ui::Compositor instance. |
| 42 // TODO(ccameron): This should implement an interface in the ui namespace. | |
|
danakj
2014/10/16 23:38:56
Can you mark which methods would be that interface
ccameron
2014/10/17 00:02:19
Done.
| |
| 47 class BrowserCompositorViewMac { | 43 class BrowserCompositorViewMac { |
| 48 public: | 44 public: |
| 49 // This will install the NSView which is drawn by the ui::Compositor into | 45 // This will install the NSView which is drawn by the ui::Compositor into |
| 50 // the NSView provided by the client. | 46 // the NSView provided by the client. |
| 51 explicit BrowserCompositorViewMac(BrowserCompositorViewMacClient* client); | 47 explicit BrowserCompositorViewMac( |
|
tapted
2014/10/17 00:04:36
nit: explicit not needed
ccameron
2014/10/17 00:26:53
Done.
| |
| 48 BrowserCompositorViewMacClient* client, | |
| 49 NSView* native_view, | |
| 50 ui::Layer* ui_root_layer); | |
| 52 ~BrowserCompositorViewMac(); | 51 ~BrowserCompositorViewMac(); |
| 53 | 52 |
| 53 BrowserCompositorViewMacClient* client() const { return client_; } | |
| 54 NSView* native_view() const { return native_view_; } | |
| 55 ui::Layer* ui_root_layer() const { return ui_root_layer_; } | |
| 56 | |
| 54 // The ui::Compositor being used to render the NSView. | 57 // The ui::Compositor being used to render the NSView. |
| 55 ui::Compositor* GetCompositor() const; | 58 ui::Compositor* GetCompositor() const; |
| 56 | 59 |
| 57 // The client (used by the BrowserCompositorViewCocoa to access the client). | |
| 58 BrowserCompositorViewMacClient* GetClient() const { return client_; } | |
| 59 | |
| 60 // Return true if the last frame swapped has a size in DIP of |dip_size|. | 60 // Return true if the last frame swapped has a size in DIP of |dip_size|. |
| 61 bool HasFrameOfSize(const gfx::Size& dip_size) const; | 61 bool HasFrameOfSize(const gfx::Size& dip_size) const; |
| 62 | 62 |
| 63 // Mark a bracket in which new frames are pumped in a restricted nested run | 63 // Mark a bracket in which new frames are pumped in a restricted nested run |
| 64 // loop because the the target window is resizing or because the view is being | 64 // loop because the the target window is resizing or because the view is being |
| 65 // shown after previously being hidden. | 65 // shown after previously being hidden. |
| 66 void BeginPumpingFrames(); | 66 void BeginPumpingFrames(); |
| 67 void EndPumpingFrames(); | 67 void EndPumpingFrames(); |
| 68 | 68 |
| 69 static void GotAcceleratedFrame( | |
| 70 gfx::AcceleratedWidget widget, | |
| 71 uint64 surface_handle, int surface_id, | |
| 72 const std::vector<ui::LatencyInfo>& latency_info, | |
| 73 gfx::Size pixel_size, float scale_factor, | |
| 74 int gpu_host_id, int gpu_route_id); | |
| 75 | |
| 76 static void GotSoftwareFrame( | |
| 77 gfx::AcceleratedWidget widget, | |
| 78 cc::SoftwareFrameData* frame_data, float scale_factor, SkCanvas* canvas); | |
| 79 | |
| 80 private: | 69 private: |
| 81 BrowserCompositorViewMacClient* client_; | 70 BrowserCompositorViewMacClient* client_; |
| 71 NSView* native_view_; | |
|
tapted
2014/10/17 00:04:36
Thinking if there might be any lifetime issue arou
ccameron
2014/10/17 00:26:53
Done -- added a comment to the ctor.
| |
| 72 ui::Layer* ui_root_layer_; | |
| 82 scoped_ptr<BrowserCompositorCALayerTreeMac> ca_layer_tree_; | 73 scoped_ptr<BrowserCompositorCALayerTreeMac> ca_layer_tree_; |
|
tapted
2014/10/17 00:04:36
is the plan to move this into a subclass of Browse
ccameron
2014/10/17 00:26:53
Yes, exactly. I may go with something to the effec
| |
| 83 }; | 74 }; |
| 84 | 75 |
| 85 // A class to keep around whenever a BrowserCompositorViewMac may be created. | 76 // A class to keep around whenever a BrowserCompositorViewMac may be created. |
| 86 // While at least one instance of this class exists, a spare | 77 // While at least one instance of this class exists, a spare |
| 87 // BrowserCompositorViewCocoa will be kept around to be recycled so that the | 78 // BrowserCompositorViewCocoa will be kept around to be recycled so that the |
| 88 // next BrowserCompositorViewMac to be created will be be created quickly. | 79 // next BrowserCompositorViewMac to be created will be be created quickly. |
| 89 class BrowserCompositorViewPlaceholderMac { | 80 class BrowserCompositorViewPlaceholderMac { |
| 90 public: | 81 public: |
| 91 BrowserCompositorViewPlaceholderMac(); | 82 BrowserCompositorViewPlaceholderMac(); |
| 92 ~BrowserCompositorViewPlaceholderMac(); | 83 ~BrowserCompositorViewPlaceholderMac(); |
| 93 }; | 84 }; |
| 94 | 85 |
| 95 } // namespace content | 86 } // namespace content |
| 96 | 87 |
| 97 #endif // CONTENT_BROWSER_COMPOSITOR_BROWSER_COMPOSITOR_VIEW_MAC_H_ | 88 #endif // CONTENT_BROWSER_COMPOSITOR_BROWSER_COMPOSITOR_VIEW_MAC_H_ |
| OLD | NEW |