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

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

Issue 1097223002: Mac: Fix black flashing during tab switch (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Wait for swap to draw frames Created 5 years, 8 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_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 "ui/accelerated_widget_mac/accelerated_widget_mac.h" 8 #include "ui/accelerated_widget_mac/accelerated_widget_mac.h"
9 #include "ui/compositor/compositor.h" 9 #include "ui/compositor/compositor.h"
10 #include "ui/compositor/compositor_observer.h"
10 11
11 namespace content { 12 namespace content {
12 13
13 // A ui::Compositor and a gfx::AcceleratedWidget (and helper) that it draws 14 // A ui::Compositor and a gfx::AcceleratedWidget (and helper) that it draws
14 // into. This structure is used to efficiently recycle these structures across 15 // into. This structure is used to efficiently recycle these structures across
15 // tabs (because creating a new ui::Compositor for each tab would be expensive 16 // tabs (because creating a new ui::Compositor for each tab would be expensive
16 // in terms of time and resources). 17 // in terms of time and resources).
17 class BrowserCompositorMac { 18 class BrowserCompositorMac : public ui::CompositorObserver {
18 public: 19 public:
19 ~BrowserCompositorMac(); 20 virtual ~BrowserCompositorMac();
20 21
21 // Create a compositor, or recycle a preexisting one. 22 // Create a compositor, or recycle a preexisting one.
22 static scoped_ptr<BrowserCompositorMac> Create(); 23 static scoped_ptr<BrowserCompositorMac> Create();
23 24
24 // Delete a compositor, or allow it to be recycled. 25 // Delete a compositor, or allow it to be recycled.
25 static void Recycle(scoped_ptr<BrowserCompositorMac> compositor); 26 static void Recycle(scoped_ptr<BrowserCompositorMac> compositor);
26 27
27 // Indicate that the recyclable compositor should be destroyed, and no future 28 // Indicate that the recyclable compositor should be destroyed, and no future
28 // compositors should be recycled. 29 // compositors should be recycled.
29 static void DisableRecyclingForShutdown(); 30 static void DisableRecyclingForShutdown();
30 31
31 ui::Compositor* compositor() { return &compositor_; } 32 ui::Compositor* compositor() { return &compositor_; }
32 ui::AcceleratedWidgetMac* accelerated_widget_mac() { 33 ui::AcceleratedWidgetMac* accelerated_widget_mac() {
33 return accelerated_widget_mac_.get(); 34 return accelerated_widget_mac_.get();
34 } 35 }
35 36
36 // Suspend will prevent the compositor from producing new frames. This should 37 // Suspend will prevent the compositor from producing new frames. This should
37 // be called to avoid creating spurious frames while changing state. 38 // be called to avoid creating spurious frames while changing state.
38 // Compositors are created as suspended. 39 // Compositors are created as suspended.
39 void Suspend(); 40 void Suspend();
40 void Unsuspend(); 41 void Unsuspend();
41 42
42 private: 43 private:
43 BrowserCompositorMac(); 44 BrowserCompositorMac();
44 45
46 // ui::CompositorObserver implementation:
47 void OnCompositingDidCommit(ui::Compositor* compositor) override;
48 void OnCompositingStarted(ui::Compositor* compositor,
49 base::TimeTicks start_time) override {}
50 void OnCompositingEnded(ui::Compositor* compositor) override {}
51 void OnCompositingAborted(ui::Compositor* compositor) override {}
52 void OnCompositingLockStateChanged(ui::Compositor* compositor) override {}
53 void OnCompositingShuttingDown(ui::Compositor* compositor) override {}
54
45 scoped_ptr<ui::AcceleratedWidgetMac> accelerated_widget_mac_; 55 scoped_ptr<ui::AcceleratedWidgetMac> accelerated_widget_mac_;
46 ui::Compositor compositor_; 56 ui::Compositor compositor_;
47 scoped_refptr<ui::CompositorLock> compositor_suspended_lock_; 57 scoped_refptr<ui::CompositorLock> compositor_suspended_lock_;
48 58
49 DISALLOW_COPY_AND_ASSIGN(BrowserCompositorMac); 59 DISALLOW_COPY_AND_ASSIGN(BrowserCompositorMac);
50 }; 60 };
51 61
52 // A class to keep around whenever a BrowserCompositorMac may be created. 62 // A class to keep around whenever a BrowserCompositorMac may be created.
53 // While at least one instance of this class exists, a spare 63 // While at least one instance of this class exists, a spare
54 // BrowserCompositorViewCocoa will be kept around to be recycled so that the 64 // BrowserCompositorViewCocoa will be kept around to be recycled so that the
55 // next BrowserCompositorMac to be created will be be created quickly. 65 // next BrowserCompositorMac to be created will be be created quickly.
56 class BrowserCompositorMacPlaceholder { 66 class BrowserCompositorMacPlaceholder {
57 public: 67 public:
58 BrowserCompositorMacPlaceholder(); 68 BrowserCompositorMacPlaceholder();
59 ~BrowserCompositorMacPlaceholder(); 69 ~BrowserCompositorMacPlaceholder();
60 70
61 private: 71 private:
62 DISALLOW_COPY_AND_ASSIGN(BrowserCompositorMacPlaceholder); 72 DISALLOW_COPY_AND_ASSIGN(BrowserCompositorMacPlaceholder);
63 }; 73 };
64 74
65 } // namespace content 75 } // namespace content
66 76
67 #endif // CONTENT_BROWSER_COMPOSITOR_BROWSER_COMPOSITOR_VIEW_MAC_H_ 77 #endif // CONTENT_BROWSER_COMPOSITOR_BROWSER_COMPOSITOR_VIEW_MAC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698