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; |
55 }; | 61 }; |
56 | 62 |
57 // The class to hold a ui::Compositor-backed NSView. Because a ui::Compositor | 63 // The class to hold a ui::Compositor-backed NSView. Because a ui::Compositor |
58 // is expensive in terms of resources and re-allocating a ui::Compositor is | 64 // is expensive in terms of resources and re-allocating a ui::Compositor is |
59 // expensive in terms of work, this class is largely used to manage recycled | 65 // expensive in terms of work, this class is largely used to manage recycled |
60 // instances of BrowserCompositorViewCocoa, which actually is a NSView and | 66 // instances of BrowserCompositorViewCocoa, which actually is a NSView and |
61 // has a ui::Compositor instance. | 67 // has a ui::Compositor instance. |
62 class BrowserCompositorViewMac { | 68 class BrowserCompositorViewMac { |
63 public: | 69 public: |
64 // This will install the NSView which is drawn by the ui::Compositor into | 70 // This will install the NSView which is drawn by the ui::Compositor into |
65 // the NSView provided by the client. | 71 // the NSView provided by the client. |
66 explicit BrowserCompositorViewMac(BrowserCompositorViewMacClient* client); | 72 explicit BrowserCompositorViewMac(BrowserCompositorViewMacClient* client); |
67 ~BrowserCompositorViewMac(); | 73 ~BrowserCompositorViewMac(); |
68 | 74 |
| 75 // The NSView set at the sub-view for this view. |
| 76 NSView* GetView() const; |
| 77 |
69 // The ui::Compositor being used to render the NSView. | 78 // The ui::Compositor being used to render the NSView. |
70 ui::Compositor* GetCompositor() const; | 79 ui::Compositor* GetCompositor() const; |
71 | 80 |
| 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 |
72 // The client (used by the BrowserCompositorViewCocoa to access the client). | 84 // The client (used by the BrowserCompositorViewCocoa to access the client). |
73 BrowserCompositorViewMacClient* GetClient() const { return client_; } | 85 BrowserCompositorViewMacClient* GetClient() const { return client_; } |
74 | 86 |
75 private: | 87 private: |
76 BrowserCompositorViewMacClient* client_; | 88 BrowserCompositorViewMacClient* client_; |
77 base::scoped_nsobject<BrowserCompositorViewCocoa> cocoa_view_; | 89 base::scoped_nsobject<BrowserCompositorViewCocoa> cocoa_view_; |
78 }; | 90 }; |
79 | 91 |
80 // A class to keep around whenever a BrowserCompositorViewMac may be created. | 92 // A class to keep around whenever a BrowserCompositorViewMac may be created. |
81 // While at least one instance of this class exists, a spare | 93 // While at least one instance of this class exists, a spare |
82 // BrowserCompositorViewCocoa will be kept around to be recycled so that the | 94 // BrowserCompositorViewCocoa will be kept around to be recycled so that the |
83 // next BrowserCompositorViewMac to be created will be be created quickly. | 95 // next BrowserCompositorViewMac to be created will be be created quickly. |
84 class BrowserCompositorViewPlaceholderMac { | 96 class BrowserCompositorViewPlaceholderMac { |
85 public: | 97 public: |
86 BrowserCompositorViewPlaceholderMac(); | 98 BrowserCompositorViewPlaceholderMac(); |
87 ~BrowserCompositorViewPlaceholderMac(); | 99 ~BrowserCompositorViewPlaceholderMac(); |
88 }; | 100 }; |
89 | 101 |
90 } // namespace content | 102 } // namespace content |
91 | 103 |
92 #endif // CONTENT_BROWSER_COMPOSITOR_BROWSER_COMPOSITOR_VIEW_MAC_H_ | 104 #endif // CONTENT_BROWSER_COMPOSITOR_BROWSER_COMPOSITOR_VIEW_MAC_H_ |
OLD | NEW |