Index: content/browser/compositor/browser_compositor_view_mac.h |
diff --git a/content/browser/compositor/browser_compositor_view_mac.h b/content/browser/compositor/browser_compositor_view_mac.h |
index 619aef55eddff458c65bafc4b6e243abac507bf2..3f8cfa7bb93096b360e14297394e5d5f216c123b 100644 |
--- a/content/browser/compositor/browser_compositor_view_mac.h |
+++ b/content/browser/compositor/browser_compositor_view_mac.h |
@@ -5,85 +5,48 @@ |
#ifndef CONTENT_BROWSER_COMPOSITOR_BROWSER_COMPOSITOR_VIEW_MAC_H_ |
#define CONTENT_BROWSER_COMPOSITOR_BROWSER_COMPOSITOR_VIEW_MAC_H_ |
-#include <vector> |
- |
-#include "cc/output/software_frame_data.h" |
-#include "skia/ext/platform_canvas.h" |
+#include "content/browser/compositor/browser_compositor_ca_layer_tree_mac.h" |
#include "ui/compositor/compositor.h" |
-#include "ui/events/latency_info.h" |
-#include "ui/gfx/geometry/size.h" |
namespace content { |
-class BrowserCompositorCALayerTreeMac; |
- |
-// The interface through which BrowserCompositorViewMac calls back into |
-// RenderWidgetHostViewMac (or any other structure that wishes to draw a |
-// NSView backed by a ui::Compositor). |
-// TODO(ccameron): This interface should be in the ui namespace. |
-class BrowserCompositorViewMacClient { |
- public: |
- // Drawing is usually throttled by the rate at which CoreAnimation draws |
- // frames to the screen. This can be used to disable throttling. |
- virtual bool BrowserCompositorViewShouldAckImmediately() const = 0; |
- |
- // Called when a frame is drawn, and used to pass latency info back to the |
- // renderer (if any). |
- virtual void BrowserCompositorViewFrameSwapped( |
- const std::vector<ui::LatencyInfo>& latency_info) = 0; |
-}; |
- |
-// The class to hold the ui::Compositor which is used to draw a NSView. |
-// TODO(ccameron): This should implement an interface in the ui namespace. |
-class BrowserCompositorViewMac { |
+// A ui::Compositor and a gfx::AcceleratedWidget (and helper) that it draws |
+// into. This structure is used to efficiently recycle these structures across |
+// tabs (because creating a new ui::Compositor for each tab would be expensive |
+// in terms of time and resources). |
+class BrowserCompositorMac { |
public: |
- // This will install the NSView which is drawn by the ui::Compositor into |
- // the NSView provided by the client. Note that |client|, |native_view|, and |
- // |ui_root_layer| outlive their BrowserCompositorViewMac object. |
- BrowserCompositorViewMac( |
- BrowserCompositorViewMacClient* client, |
- NSView* native_view, |
- ui::Layer* ui_root_layer); |
- ~BrowserCompositorViewMac(); |
+ // Create a compositor, or recycle a preexisting one. |
+ static BrowserCompositorMac* Create(); |
tapted
2014/11/20 23:18:07
You can enforce the lifetime dealie by returning a
ccameron
2014/11/21 01:32:40
(hides head in shame). Done.
|
- BrowserCompositorViewMacClient* client() const { return client_; } |
- NSView* native_view() const { return native_view_; } |
- ui::Layer* ui_root_layer() const { return ui_root_layer_; } |
+ // Delete a compositor, or allow it to be recycled. |
+ static void Recycle(BrowserCompositorMac* compositor); |
tapted
2014/11/20 23:18:07
and taking a scoped_ptr here (then see below)
ccameron
2014/11/21 01:32:40
(hides head further in shame). Done.
|
- // The ui::Compositor being used to render the NSView. |
- // TODO(ccameron): This should be in the ui namespace interface. |
- ui::Compositor* GetCompositor() const; |
- |
- // Return true if the last frame swapped has a size in DIP of |dip_size|. |
- bool HasFrameOfSize(const gfx::Size& dip_size) const; |
- |
- // Mark a bracket in which new frames are pumped in a restricted nested run |
- // loop because the the target window is resizing or because the view is being |
- // shown after previously being hidden. |
- void BeginPumpingFrames(); |
- void EndPumpingFrames(); |
+ ui::Compositor* compositor() { return &compositor_; } |
+ AcceleratedWidgetMac* accelerated_widget_mac() { |
+ return &accelerated_widget_mac_; |
+ } |
private: |
- BrowserCompositorViewMacClient* client_; |
- NSView* native_view_; |
- ui::Layer* ui_root_layer_; |
+ BrowserCompositorMac(); |
+ |
+ AcceleratedWidgetMac accelerated_widget_mac_; |
+ ui::Compositor compositor_; |
- // Because a ui::Compositor is expensive in terms of resources and |
- // re-allocating a ui::Compositor is expensive in terms of work, this class |
- // is largely used to manage recycled instances of |
- // BrowserCompositorCALayerTreeMac, which actually has a ui::Compositor |
- // instance and modifies the CALayers used to draw the NSView. |
- scoped_ptr<BrowserCompositorCALayerTreeMac> ca_layer_tree_; |
+ DISALLOW_COPY_AND_ASSIGN(BrowserCompositorMac); |
}; |
-// A class to keep around whenever a BrowserCompositorViewMac may be created. |
+// A class to keep around whenever a BrowserCompositorMac may be created. |
// While at least one instance of this class exists, a spare |
// BrowserCompositorViewCocoa will be kept around to be recycled so that the |
-// next BrowserCompositorViewMac to be created will be be created quickly. |
-class BrowserCompositorViewPlaceholderMac { |
+// next BrowserCompositorMac to be created will be be created quickly. |
+class BrowserCompositorMacPlaceholder { |
public: |
- BrowserCompositorViewPlaceholderMac(); |
- ~BrowserCompositorViewPlaceholderMac(); |
+ BrowserCompositorMacPlaceholder(); |
+ ~BrowserCompositorMacPlaceholder(); |
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(BrowserCompositorMacPlaceholder); |
}; |
} // namespace content |