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 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
9 #include <IOSurface/IOSurfaceAPI.h> | 9 #include <IOSurface/IOSurfaceAPI.h> |
10 #include <vector> | 10 #include <vector> |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 // renderer (if any). | 45 // renderer (if any). |
46 virtual void BrowserCompositorViewFrameSwapped( | 46 virtual void BrowserCompositorViewFrameSwapped( |
47 const std::vector<ui::LatencyInfo>& latency_info) = 0; | 47 const std::vector<ui::LatencyInfo>& latency_info) = 0; |
48 | 48 |
49 // Used to install the ui::Compositor-backed NSView as a child of its parent | 49 // Used to install the ui::Compositor-backed NSView as a child of its parent |
50 // view. | 50 // view. |
51 virtual NSView* BrowserCompositorSuperview() = 0; | 51 virtual NSView* BrowserCompositorSuperview() = 0; |
52 | 52 |
53 // Used to install the root ui::Layer into the ui::Compositor. | 53 // Used to install the root ui::Layer into the ui::Compositor. |
54 virtual ui::Layer* BrowserCompositorRootLayer() = 0; | 54 virtual ui::Layer* BrowserCompositorRootLayer() = 0; |
55 | |
56 // If this returns true, then frames will be drawn immediately when they are | |
57 // received, instead of waiting for the CAOpenGLLayer's callback. This helps | |
58 // de-jank resize, because said callback can't come through while pumping for | |
59 // resized frames. | |
60 virtual bool BrowserCompositorShouldDrawImmediately() = 0; | |
61 }; | 55 }; |
62 | 56 |
63 // The class to hold a ui::Compositor-backed NSView. Because a ui::Compositor | 57 // The class to hold a ui::Compositor-backed NSView. Because a ui::Compositor |
64 // is expensive in terms of resources and re-allocating a ui::Compositor is | 58 // is expensive in terms of resources and re-allocating a ui::Compositor is |
65 // expensive in terms of work, this class is largely used to manage recycled | 59 // expensive in terms of work, this class is largely used to manage recycled |
66 // instances of BrowserCompositorViewCocoa, which actually is a NSView and | 60 // instances of BrowserCompositorViewCocoa, which actually is a NSView and |
67 // has a ui::Compositor instance. | 61 // has a ui::Compositor instance. |
68 class BrowserCompositorViewMac { | 62 class BrowserCompositorViewMac { |
69 public: | 63 public: |
70 // This will install the NSView which is drawn by the ui::Compositor into | 64 // This will install the NSView which is drawn by the ui::Compositor into |
71 // the NSView provided by the client. | 65 // the NSView provided by the client. |
72 explicit BrowserCompositorViewMac(BrowserCompositorViewMacClient* client); | 66 explicit BrowserCompositorViewMac(BrowserCompositorViewMacClient* client); |
73 ~BrowserCompositorViewMac(); | 67 ~BrowserCompositorViewMac(); |
74 | 68 |
75 // The NSView set at the sub-view for this view. | |
76 NSView* GetView() const; | |
77 | |
78 // The ui::Compositor being used to render the NSView. | 69 // The ui::Compositor being used to render the NSView. |
79 ui::Compositor* GetCompositor() const; | 70 ui::Compositor* GetCompositor() const; |
80 | 71 |
81 // Check if a frame of the correct size is currently being displayed. | |
82 bool HasFrameWithSizeInDIP(const gfx::Size& desired_size_in_dip) const; | |
83 | |
84 // The client (used by the BrowserCompositorViewCocoa to access the client). | 72 // The client (used by the BrowserCompositorViewCocoa to access the client). |
85 BrowserCompositorViewMacClient* GetClient() const { return client_; } | 73 BrowserCompositorViewMacClient* GetClient() const { return client_; } |
86 | 74 |
87 private: | 75 private: |
88 BrowserCompositorViewMacClient* client_; | 76 BrowserCompositorViewMacClient* client_; |
89 base::scoped_nsobject<BrowserCompositorViewCocoa> cocoa_view_; | 77 base::scoped_nsobject<BrowserCompositorViewCocoa> cocoa_view_; |
90 }; | 78 }; |
91 | 79 |
92 // A class to keep around whenever a BrowserCompositorViewMac may be created. | 80 // A class to keep around whenever a BrowserCompositorViewMac may be created. |
93 // While at least one instance of this class exists, a spare | 81 // While at least one instance of this class exists, a spare |
94 // BrowserCompositorViewCocoa will be kept around to be recycled so that the | 82 // BrowserCompositorViewCocoa will be kept around to be recycled so that the |
95 // next BrowserCompositorViewMac to be created will be be created quickly. | 83 // next BrowserCompositorViewMac to be created will be be created quickly. |
96 class BrowserCompositorViewPlaceholderMac { | 84 class BrowserCompositorViewPlaceholderMac { |
97 public: | 85 public: |
98 BrowserCompositorViewPlaceholderMac(); | 86 BrowserCompositorViewPlaceholderMac(); |
99 ~BrowserCompositorViewPlaceholderMac(); | 87 ~BrowserCompositorViewPlaceholderMac(); |
100 }; | 88 }; |
101 | 89 |
102 } // namespace content | 90 } // namespace content |
103 | 91 |
104 #endif // CONTENT_BROWSER_COMPOSITOR_BROWSER_COMPOSITOR_VIEW_MAC_H_ | 92 #endif // CONTENT_BROWSER_COMPOSITOR_BROWSER_COMPOSITOR_VIEW_MAC_H_ |
OLD | NEW |