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 |
| 18 // Additions to the NSView interface for compositor frames. |
| 19 @interface NSView (BrowserCompositorView) |
| 20 - (void)gotAcceleratedIOSurfaceFrame:(IOSurfaceID)surface_handle |
| 21 withOutputSurfaceID:(int)surface_id |
| 22 withLatencyInfo:(std::vector<ui::LatencyInfo>) latency_info |
| 23 withPixelSize:(gfx::Size)pixel_size |
| 24 withScaleFactor:(float)scale_factor; |
| 25 |
| 26 - (void)gotSoftwareFrame:(cc::SoftwareFrameData*)frame_data |
| 27 withScaleFactor:(float)scale_factor |
| 28 withCanvas:(SkCanvas*)canvas; |
| 29 @end // NSView (BrowserCompositorView) |
| 30 |
16 namespace content { | 31 namespace content { |
17 | 32 |
18 class BrowserCompositorViewMacInternal; | 33 class BrowserCompositorViewMacInternal; |
19 | 34 |
20 // The interface through which BrowserCompositorViewMac calls back into | 35 // The interface through which BrowserCompositorViewMac calls back into |
21 // RenderWidgetHostViewMac (or any other structure that wishes to draw a | 36 // RenderWidgetHostViewMac (or any other structure that wishes to draw a |
22 // NSView backed by a ui::Compositor). | 37 // NSView backed by a ui::Compositor). |
23 class BrowserCompositorViewMacClient { | 38 class CONTENT_EXPORT BrowserCompositorViewMacClient { |
24 public: | 39 public: |
25 // Drawing is usually throttled by the rate at which CoreAnimation draws | 40 // Drawing is usually throttled by the rate at which CoreAnimation draws |
26 // frames to the screen. This can be used to disable throttling. | 41 // frames to the screen. This can be used to disable throttling. |
27 virtual bool BrowserCompositorViewShouldAckImmediately() const = 0; | 42 virtual bool BrowserCompositorViewShouldAckImmediately() const = 0; |
28 | 43 |
29 // Called when a frame is drawn, and used to pass latency info back to the | 44 // Called when a frame is drawn, and used to pass latency info back to the |
30 // renderer (if any). | 45 // renderer (if any). |
31 virtual void BrowserCompositorViewFrameSwapped( | 46 virtual void BrowserCompositorViewFrameSwapped( |
32 const std::vector<ui::LatencyInfo>& latency_info) = 0; | 47 const std::vector<ui::LatencyInfo>& latency_info) = 0; |
33 | 48 |
34 // 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 |
35 // view. | 50 // view. |
36 virtual NSView* BrowserCompositorSuperview() = 0; | 51 virtual NSView* BrowserCompositorSuperview() = 0; |
37 | 52 |
38 // Used to install the root ui::Layer into the ui::Compositor. | 53 // Used to install the root ui::Layer into the ui::Compositor. |
39 virtual ui::Layer* BrowserCompositorRootLayer() = 0; | 54 virtual ui::Layer* BrowserCompositorRootLayer() = 0; |
40 }; | 55 }; |
41 | 56 |
42 // 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 |
43 // 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 |
44 // 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 |
45 // instances of BrowserCompositorViewCocoa, which actually is a NSView and | 60 // instances of BrowserCompositorViewCocoa, which actually is a NSView and |
46 // has a ui::Compositor instance. | 61 // has a ui::Compositor instance. |
47 class BrowserCompositorViewMac { | 62 class CONTENT_EXPORT BrowserCompositorViewMac { |
48 public: | 63 public: |
49 // 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 |
50 // the NSView provided by the client. | 65 // the NSView provided by the client. |
51 explicit BrowserCompositorViewMac(BrowserCompositorViewMacClient* client); | 66 explicit BrowserCompositorViewMac(BrowserCompositorViewMacClient* client); |
52 ~BrowserCompositorViewMac(); | 67 ~BrowserCompositorViewMac(); |
53 | 68 |
54 // The ui::Compositor being used to render the NSView. | 69 // The ui::Compositor being used to render the NSView. |
55 ui::Compositor* GetCompositor() const; | 70 ui::Compositor* GetCompositor() const; |
56 | 71 |
57 // The client (used by the BrowserCompositorViewCocoa to access the client). | 72 // The client (used by the BrowserCompositorViewCocoa to access the client). |
(...skipping 21 matching lines...) Expand all Loading... |
79 | 94 |
80 private: | 95 private: |
81 BrowserCompositorViewMacClient* client_; | 96 BrowserCompositorViewMacClient* client_; |
82 scoped_ptr<BrowserCompositorViewMacInternal> internal_view_; | 97 scoped_ptr<BrowserCompositorViewMacInternal> internal_view_; |
83 }; | 98 }; |
84 | 99 |
85 // A class to keep around whenever a BrowserCompositorViewMac may be created. | 100 // A class to keep around whenever a BrowserCompositorViewMac may be created. |
86 // While at least one instance of this class exists, a spare | 101 // While at least one instance of this class exists, a spare |
87 // BrowserCompositorViewCocoa will be kept around to be recycled so that the | 102 // BrowserCompositorViewCocoa will be kept around to be recycled so that the |
88 // next BrowserCompositorViewMac to be created will be be created quickly. | 103 // next BrowserCompositorViewMac to be created will be be created quickly. |
89 class BrowserCompositorViewPlaceholderMac { | 104 class CONTENT_EXPORT BrowserCompositorViewPlaceholderMac { |
90 public: | 105 public: |
91 BrowserCompositorViewPlaceholderMac(); | 106 BrowserCompositorViewPlaceholderMac(); |
92 ~BrowserCompositorViewPlaceholderMac(); | 107 ~BrowserCompositorViewPlaceholderMac(); |
93 }; | 108 }; |
94 | 109 |
95 } // namespace content | 110 } // namespace content |
96 | 111 |
97 #endif // CONTENT_BROWSER_COMPOSITOR_BROWSER_COMPOSITOR_VIEW_MAC_H_ | 112 #endif // CONTENT_BROWSER_COMPOSITOR_BROWSER_COMPOSITOR_VIEW_MAC_H_ |
OLD | NEW |