Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(526)

Side by Side Diff: content/browser/compositor/browser_compositor_view_mac.h

Issue 745453002: Create an AcceleratedWidgetMac (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <vector> 8 #include "content/browser/compositor/browser_compositor_ca_layer_tree_mac.h"
9
10 #include "cc/output/software_frame_data.h"
11 #include "skia/ext/platform_canvas.h"
12 #include "ui/compositor/compositor.h" 9 #include "ui/compositor/compositor.h"
13 #include "ui/events/latency_info.h"
14 #include "ui/gfx/geometry/size.h"
15 10
16 namespace content { 11 namespace content {
17 12
18 class BrowserCompositorCALayerTreeMac; 13 // A ui::Compositor and a gfx::AcceleratedWidget (and helper) that it draws
14 // into. This structure is used to efficiently recycle these structures across
15 // tabs (because creating a new ui::Compositor for each tab would be expensive
16 // in terms of time and resources).
17 class BrowserCompositorMac {
18 public:
19 // Create a compositor, or recycle a preexisting one.
20 static void AcquireCompositor(BrowserCompositorMac** compositor);
19 21
20 // The interface through which BrowserCompositorViewMac calls back into 22 // Delete a compositor, or allow it to be recycled.
21 // RenderWidgetHostViewMac (or any other structure that wishes to draw a 23 static void ReleaseCompositor(BrowserCompositorMac** compositor);
22 // NSView backed by a ui::Compositor).
23 // TODO(ccameron): This interface should be in the ui namespace.
24 class BrowserCompositorViewMacClient {
25 public:
26 // Drawing is usually throttled by the rate at which CoreAnimation draws
27 // frames to the screen. This can be used to disable throttling.
28 virtual bool BrowserCompositorViewShouldAckImmediately() const = 0;
29 24
30 // Called when a frame is drawn, and used to pass latency info back to the 25 ui::Compositor* compositor();
31 // renderer (if any). 26 AcceleratedWidgetMac* accelerated_widget_mac();
32 virtual void BrowserCompositorViewFrameSwapped( 27
33 const std::vector<ui::LatencyInfo>& latency_info) = 0; 28 private:
29 BrowserCompositorMac();
30
31 AcceleratedWidgetMac accelerated_widget_mac_;
32 ui::Compositor compositor_;
34 }; 33 };
35 34
36 // The class to hold the ui::Compositor which is used to draw a NSView. 35 // A class to keep around whenever a BrowserCompositorMac may be created.
37 // TODO(ccameron): This should implement an interface in the ui namespace.
38 class BrowserCompositorViewMac {
39 public:
40 // This will install the NSView which is drawn by the ui::Compositor into
41 // the NSView provided by the client. Note that |client|, |native_view|, and
42 // |ui_root_layer| outlive their BrowserCompositorViewMac object.
43 BrowserCompositorViewMac(
44 BrowserCompositorViewMacClient* client,
45 NSView* native_view,
46 ui::Layer* ui_root_layer);
47 ~BrowserCompositorViewMac();
48
49 BrowserCompositorViewMacClient* client() const { return client_; }
50 NSView* native_view() const { return native_view_; }
51 ui::Layer* ui_root_layer() const { return ui_root_layer_; }
52
53 // The ui::Compositor being used to render the NSView.
54 // TODO(ccameron): This should be in the ui namespace interface.
55 ui::Compositor* GetCompositor() const;
56
57 // Return true if the last frame swapped has a size in DIP of |dip_size|.
58 bool HasFrameOfSize(const gfx::Size& dip_size) const;
59
60 // Mark a bracket in which new frames are pumped in a restricted nested run
61 // loop because the the target window is resizing or because the view is being
62 // shown after previously being hidden.
63 void BeginPumpingFrames();
64 void EndPumpingFrames();
65
66 private:
67 BrowserCompositorViewMacClient* client_;
68 NSView* native_view_;
69 ui::Layer* ui_root_layer_;
70
71 // Because a ui::Compositor is expensive in terms of resources and
72 // re-allocating a ui::Compositor is expensive in terms of work, this class
73 // is largely used to manage recycled instances of
74 // BrowserCompositorCALayerTreeMac, which actually has a ui::Compositor
75 // instance and modifies the CALayers used to draw the NSView.
76 scoped_ptr<BrowserCompositorCALayerTreeMac> ca_layer_tree_;
77 };
78
79 // A class to keep around whenever a BrowserCompositorViewMac may be created.
80 // While at least one instance of this class exists, a spare 36 // While at least one instance of this class exists, a spare
81 // BrowserCompositorViewCocoa will be kept around to be recycled so that the 37 // BrowserCompositorViewCocoa will be kept around to be recycled so that the
82 // next BrowserCompositorViewMac to be created will be be created quickly. 38 // next BrowserCompositorMac to be created will be be created quickly.
83 class BrowserCompositorViewPlaceholderMac { 39 class BrowserCompositorMacPlaceholder {
84 public: 40 public:
85 BrowserCompositorViewPlaceholderMac(); 41 BrowserCompositorMacPlaceholder();
86 ~BrowserCompositorViewPlaceholderMac(); 42 ~BrowserCompositorMacPlaceholder();
87 }; 43 };
88 44
89 } // namespace content 45 } // namespace content
90 46
91 #endif // CONTENT_BROWSER_COMPOSITOR_BROWSER_COMPOSITOR_VIEW_MAC_H_ 47 #endif // CONTENT_BROWSER_COMPOSITOR_BROWSER_COMPOSITOR_VIEW_MAC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698