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

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

Issue 490393002: Simplify IOSurface CoreAnimation code: Part 2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Lower similarity Created 6 years, 4 months 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_PRIVATE_MAC_H_ 5 #ifndef CONTENT_BROWSER_COMPOSITOR_BROWSER_COMPOSITOR_VIEW_PRIVATE_MAC_H_
6 #define CONTENT_BROWSER_COMPOSITOR_BROWSER_COMPOSITOR_VIEW_PRIVATE_MAC_H_ 6 #define CONTENT_BROWSER_COMPOSITOR_BROWSER_COMPOSITOR_VIEW_PRIVATE_MAC_H_
7 7
8 #include <IOSurface/IOSurfaceAPI.h> 8 #include <IOSurface/IOSurfaceAPI.h>
9 9
10 #include "base/mac/scoped_nsobject.h" 10 #include "base/mac/scoped_nsobject.h"
11 #include "base/memory/weak_ptr.h"
11 #include "content/browser/compositor/browser_compositor_view_mac.h" 12 #include "content/browser/compositor/browser_compositor_view_mac.h"
12 #include "content/browser/renderer_host/compositing_iosurface_layer_mac.h" 13 #include "content/browser/compositor/io_surface_layer_mac.h"
13 #include "content/browser/renderer_host/software_layer_mac.h" 14 #include "content/browser/compositor/software_layer_mac.h"
14 #include "ui/base/cocoa/remote_layer_api.h" 15 #include "ui/base/cocoa/remote_layer_api.h"
15 16
16 namespace content { 17 namespace content {
17 18
18 // BrowserCompositorViewMacInternal owns a NSView and a ui::Compositor that 19 // BrowserCompositorViewMacInternal owns a NSView and a ui::Compositor that
19 // draws that view. 20 // draws that view.
20 class BrowserCompositorViewMacInternal 21 class BrowserCompositorViewMacInternal
21 : public CompositingIOSurfaceLayerClient { 22 : public IOSurfaceLayerClient {
22 public: 23 public:
23 BrowserCompositorViewMacInternal(); 24 BrowserCompositorViewMacInternal();
24 virtual ~BrowserCompositorViewMacInternal(); 25 virtual ~BrowserCompositorViewMacInternal();
25 static BrowserCompositorViewMacInternal* FromAcceleratedWidget( 26 static BrowserCompositorViewMacInternal* FromAcceleratedWidget(
26 gfx::AcceleratedWidget widget); 27 gfx::AcceleratedWidget widget);
27 28
28 void SetClient(BrowserCompositorViewMacClient* client); 29 void SetClient(BrowserCompositorViewMacClient* client);
29 void ResetClient(); 30 void ResetClient();
30 31
31 ui::Compositor* compositor() const { return compositor_.get(); } 32 ui::Compositor* compositor() const { return compositor_.get(); }
(...skipping 11 matching lines...) Expand all
43 44
44 void GotAcceleratedFrame( 45 void GotAcceleratedFrame(
45 uint64 surface_handle, int output_surface_id, 46 uint64 surface_handle, int output_surface_id,
46 const std::vector<ui::LatencyInfo>& latency_info, 47 const std::vector<ui::LatencyInfo>& latency_info,
47 gfx::Size pixel_size, float scale_factor); 48 gfx::Size pixel_size, float scale_factor);
48 49
49 void GotSoftwareFrame( 50 void GotSoftwareFrame(
50 cc::SoftwareFrameData* frame_data, float scale_factor, SkCanvas* canvas); 51 cc::SoftwareFrameData* frame_data, float scale_factor, SkCanvas* canvas);
51 52
52 private: 53 private:
53 // CompositingIOSurfaceLayerClient implementation: 54 // IOSurfaceLayerClient implementation:
54 virtual bool AcceleratedLayerShouldAckImmediately() const OVERRIDE; 55 virtual bool IOSurfaceLayerShouldAckImmediately() const OVERRIDE;
55 virtual void AcceleratedLayerDidDrawFrame() OVERRIDE; 56 virtual void IOSurfaceLayerDidDrawFrame() OVERRIDE;
56 virtual void AcceleratedLayerHitError() OVERRIDE; 57 virtual void IOSurfaceLayerHitError() OVERRIDE;
58
59 void HandleIOSurfaceLayerError();
57 60
58 void GotAcceleratedCAContextFrame( 61 void GotAcceleratedCAContextFrame(
59 CAContextID ca_context_id, gfx::Size pixel_size, float scale_factor); 62 CAContextID ca_context_id, gfx::Size pixel_size, float scale_factor);
60 63
61 void GotAcceleratedIOSurfaceFrame( 64 void GotAcceleratedIOSurfaceFrame(
62 IOSurfaceID io_surface_id, gfx::Size pixel_size, float scale_factor); 65 IOSurfaceID io_surface_id, gfx::Size pixel_size, float scale_factor);
63 66
64 // Remove a layer from the heirarchy and destroy it. Because the accelerated 67 // Remove a layer from the heirarchy and destroy it. Because the accelerated
65 // layer types may be replaced by a layer of the same type, the layer to 68 // layer types may be replaced by a layer of the same type, the layer to
66 // destroy is parameterized, and, if it is the current layer, the current 69 // destroy is parameterized, and, if it is the current layer, the current
67 // layer is reset. 70 // layer is reset.
68 void DestroyCAContextLayer( 71 void DestroyCAContextLayer(
69 base::scoped_nsobject<CALayerHost> ca_context_layer); 72 base::scoped_nsobject<CALayerHost> ca_context_layer);
70 void DestroyIOSurfaceLayer( 73 void DestroyIOSurfaceLayer(
71 base::scoped_nsobject<CompositingIOSurfaceLayer> io_surface_layer); 74 base::scoped_nsobject<IOSurfaceLayer> io_surface_layer);
72 void DestroySoftwareLayer(); 75 void DestroySoftwareLayer();
73 76
74 // The client of the BrowserCompositorViewMac that is using this as its 77 // The client of the BrowserCompositorViewMac that is using this as its
75 // internals. 78 // internals.
76 BrowserCompositorViewMacClient* client_; 79 BrowserCompositorViewMacClient* client_;
77 80
78 // A phony NSView handle used to identify this. 81 // A phony NSView handle used to identify this.
79 gfx::AcceleratedWidget native_widget_; 82 gfx::AcceleratedWidget native_widget_;
80 83
81 // The compositor drawing the contents of this view. 84 // The compositor drawing the contents of this view.
82 scoped_ptr<ui::Compositor> compositor_; 85 scoped_ptr<ui::Compositor> compositor_;
83 86
84 // A flipped layer, which acts as the parent of the compositing and software 87 // A flipped layer, which acts as the parent of the compositing and software
85 // layers. This layer is flipped so that the we don't need to recompute the 88 // layers. This layer is flipped so that the we don't need to recompute the
86 // origin for sub-layers when their position changes (this is impossible when 89 // origin for sub-layers when their position changes (this is impossible when
87 // using remote layers, as their size change cannot be synchronized with the 90 // using remote layers, as their size change cannot be synchronized with the
88 // window). This indirection is needed because flipping hosted layers (like 91 // window). This indirection is needed because flipping hosted layers (like
89 // |background_layer_| of RenderWidgetHostViewCocoa) leads to unpredictable 92 // |background_layer_| of RenderWidgetHostViewCocoa) leads to unpredictable
90 // behavior. 93 // behavior.
91 base::scoped_nsobject<CALayer> flipped_layer_; 94 base::scoped_nsobject<CALayer> flipped_layer_;
92 95
93 // The accelerated CoreAnimation layer hosted by the GPU process. 96 // The accelerated CoreAnimation layer hosted by the GPU process.
94 base::scoped_nsobject<CALayerHost> ca_context_layer_; 97 base::scoped_nsobject<CALayerHost> ca_context_layer_;
95 98
96 // The locally drawn accelerated CoreAnimation layer. 99 // The locally drawn accelerated CoreAnimation layer.
97 base::scoped_nsobject<CompositingIOSurfaceLayer> io_surface_layer_; 100 base::scoped_nsobject<IOSurfaceLayer> io_surface_layer_;
98 101
99 // The locally drawn software layer. 102 // The locally drawn software layer.
100 base::scoped_nsobject<SoftwareLayer> software_layer_; 103 base::scoped_nsobject<SoftwareLayer> software_layer_;
101 104
102 // The output surface and latency info of the last accelerated surface that 105 // The output surface and latency info of the last accelerated surface that
103 // was swapped. Sent back to the renderer when the accelerated surface is 106 // was swapped. Sent back to the renderer when the accelerated surface is
104 // drawn. 107 // drawn.
105 int accelerated_output_surface_id_; 108 int accelerated_output_surface_id_;
106 std::vector<ui::LatencyInfo> accelerated_latency_info_; 109 std::vector<ui::LatencyInfo> accelerated_latency_info_;
107 110
108 // The size in DIP of the last swap received from |compositor_|. 111 // The size in DIP of the last swap received from |compositor_|.
109 gfx::Size last_swap_size_dip_; 112 gfx::Size last_swap_size_dip_;
113
114 base::WeakPtrFactory<BrowserCompositorViewMacInternal> weak_factory_;
110 }; 115 };
111 116
112 } // namespace content 117 } // namespace content
113 118
114 #endif // CONTENT_BROWSER_COMPOSITOR_BROWSER_COMPOSITOR_VIEW_PRIVATE_MAC_H_ 119 #endif // CONTENT_BROWSER_COMPOSITOR_BROWSER_COMPOSITOR_VIEW_PRIVATE_MAC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698