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 <vector> | 8 #include <vector> |
9 | 9 |
10 #include "cc/output/software_frame_data.h" | 10 #include "cc/output/software_frame_data.h" |
11 #include "skia/ext/platform_canvas.h" | 11 #include "skia/ext/platform_canvas.h" |
12 #include "ui/compositor/compositor.h" | 12 #include "ui/compositor/compositor.h" |
13 #include "ui/events/latency_info.h" | 13 #include "ui/events/latency_info.h" |
14 #include "ui/gfx/geometry/size.h" | 14 #include "ui/gfx/geometry/size.h" |
15 | 15 |
| 16 #include "content/common/content_export.h" |
| 17 |
16 namespace content { | 18 namespace content { |
17 | 19 |
18 class BrowserCompositorCALayerTreeMac; | 20 class BrowserCompositorCALayerTreeMac; |
19 | 21 |
20 // The interface through which BrowserCompositorViewMac calls back into | 22 // The interface through which BrowserCompositorViewMac calls back into |
21 // RenderWidgetHostViewMac (or any other structure that wishes to draw a | 23 // RenderWidgetHostViewMac (or any other structure that wishes to draw a |
22 // NSView backed by a ui::Compositor). | 24 // NSView backed by a ui::Compositor). |
23 class BrowserCompositorViewMacClient { | 25 class CONTENT_EXPORT 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 | 35 |
34 // Used to install the ui::Compositor-backed NSView as a child of its parent | 36 // Used to install the ui::Compositor-backed NSView as a child of its parent |
35 // view. | 37 // view. |
36 virtual NSView* BrowserCompositorSuperview() = 0; | 38 virtual NSView* BrowserCompositorSuperview() = 0; |
37 | 39 |
38 // Used to install the root ui::Layer into the ui::Compositor. | 40 // Used to install the root ui::Layer into the ui::Compositor. |
39 virtual ui::Layer* BrowserCompositorRootLayer() = 0; | 41 virtual ui::Layer* BrowserCompositorRootLayer() = 0; |
40 }; | 42 }; |
41 | 43 |
42 // The class to hold a ui::Compositor-backed NSView. Because a ui::Compositor | 44 // 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 | 45 // 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 | 46 // expensive in terms of work, this class is largely used to manage recycled |
45 // instances of BrowserCompositorViewCocoa, which actually is a NSView and | 47 // instances of BrowserCompositorViewCocoa, which actually is a NSView and |
46 // has a ui::Compositor instance. | 48 // has a ui::Compositor instance. |
47 class BrowserCompositorViewMac { | 49 class CONTENT_EXPORT BrowserCompositorViewMac { |
48 public: | 50 public: |
49 // This will install the NSView which is drawn by the ui::Compositor into | 51 // This will install the NSView which is drawn by the ui::Compositor into |
50 // the NSView provided by the client. | 52 // the NSView provided by the client. |
51 explicit BrowserCompositorViewMac(BrowserCompositorViewMacClient* client); | 53 explicit BrowserCompositorViewMac(BrowserCompositorViewMacClient* client); |
52 ~BrowserCompositorViewMac(); | 54 ~BrowserCompositorViewMac(); |
53 | 55 |
54 // The ui::Compositor being used to render the NSView. | 56 // The ui::Compositor being used to render the NSView. |
55 ui::Compositor* GetCompositor() const; | 57 ui::Compositor* GetCompositor() const; |
56 | 58 |
57 // The client (used by the BrowserCompositorViewCocoa to access the client). | 59 // The client (used by the BrowserCompositorViewCocoa to access the client). |
(...skipping 21 matching lines...) Expand all Loading... |
79 | 81 |
80 private: | 82 private: |
81 BrowserCompositorViewMacClient* client_; | 83 BrowserCompositorViewMacClient* client_; |
82 scoped_ptr<BrowserCompositorCALayerTreeMac> ca_layer_tree_; | 84 scoped_ptr<BrowserCompositorCALayerTreeMac> ca_layer_tree_; |
83 }; | 85 }; |
84 | 86 |
85 // A class to keep around whenever a BrowserCompositorViewMac may be created. | 87 // A class to keep around whenever a BrowserCompositorViewMac may be created. |
86 // While at least one instance of this class exists, a spare | 88 // While at least one instance of this class exists, a spare |
87 // BrowserCompositorViewCocoa will be kept around to be recycled so that the | 89 // BrowserCompositorViewCocoa will be kept around to be recycled so that the |
88 // next BrowserCompositorViewMac to be created will be be created quickly. | 90 // next BrowserCompositorViewMac to be created will be be created quickly. |
89 class BrowserCompositorViewPlaceholderMac { | 91 class CONTENT_EXPORT BrowserCompositorViewPlaceholderMac { |
90 public: | 92 public: |
91 BrowserCompositorViewPlaceholderMac(); | 93 BrowserCompositorViewPlaceholderMac(); |
92 ~BrowserCompositorViewPlaceholderMac(); | 94 ~BrowserCompositorViewPlaceholderMac(); |
93 }; | 95 }; |
94 | 96 |
95 } // namespace content | 97 } // namespace content |
96 | 98 |
97 #endif // CONTENT_BROWSER_COMPOSITOR_BROWSER_COMPOSITOR_VIEW_MAC_H_ | 99 #endif // CONTENT_BROWSER_COMPOSITOR_BROWSER_COMPOSITOR_VIEW_MAC_H_ |
OLD | NEW |