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

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

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 #include "content/browser/compositor/browser_compositor_view_mac.h" 5 #include "content/browser/compositor/browser_compositor_view_mac.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/trace_event/trace_event.h" 8 #include "base/trace_event/trace_event.h"
9 #include "content/browser/compositor/image_transport_factory.h" 9 #include "content/browser/compositor/image_transport_factory.h"
10 #include "content/browser/gpu/gpu_data_manager_impl.h" 10 #include "content/browser/gpu/gpu_data_manager_impl.h"
(...skipping 30 matching lines...) Expand all
41 41
42 BrowserCompositorMac::BrowserCompositorMac() 42 BrowserCompositorMac::BrowserCompositorMac()
43 : accelerated_widget_mac_( 43 : accelerated_widget_mac_(
44 new ui::AcceleratedWidgetMac(WidgetNeedsGLFinishWorkaround())), 44 new ui::AcceleratedWidgetMac(WidgetNeedsGLFinishWorkaround())),
45 compositor_( 45 compositor_(
46 accelerated_widget_mac_->accelerated_widget(), 46 accelerated_widget_mac_->accelerated_widget(),
47 content::GetContextFactory(), 47 content::GetContextFactory(),
48 RenderWidgetResizeHelper::Get()->task_runner()) { 48 RenderWidgetResizeHelper::Get()->task_runner()) {
49 compositor_.SetLocksWillTimeOut(false); 49 compositor_.SetLocksWillTimeOut(false);
50 Suspend(); 50 Suspend();
51 compositor_.AddObserver(this);
51 } 52 }
52 53
53 BrowserCompositorMac::~BrowserCompositorMac() {} 54 BrowserCompositorMac::~BrowserCompositorMac() {
55 compositor_.RemoveObserver(this);
56 }
54 57
55 void BrowserCompositorMac::Suspend() { 58 void BrowserCompositorMac::Suspend() {
56 compositor_suspended_lock_ = compositor_.GetCompositorLock(); 59 compositor_suspended_lock_ = compositor_.GetCompositorLock();
57 } 60 }
58 61
59 void BrowserCompositorMac::Unsuspend() { 62 void BrowserCompositorMac::Unsuspend() {
60 compositor_suspended_lock_ = nullptr; 63 compositor_suspended_lock_ = nullptr;
61 } 64 }
62 65
66 void BrowserCompositorMac::OnCompositingDidCommit(
67 ui::Compositor* compositor_that_did_commit) {
68 DCHECK_EQ(compositor_that_did_commit, compositor());
69 content::ImageTransportFactory::GetInstance()
70 ->SetCompositorSuspendedForRecycle(compositor(), false);
71 }
72
63 // static 73 // static
64 scoped_ptr<BrowserCompositorMac> BrowserCompositorMac::Create() { 74 scoped_ptr<BrowserCompositorMac> BrowserCompositorMac::Create() {
65 if (g_recyclable_browser_compositor.Get()) 75 if (g_recyclable_browser_compositor.Get())
66 return g_recyclable_browser_compositor.Get().Pass(); 76 return g_recyclable_browser_compositor.Get().Pass();
67 return scoped_ptr<BrowserCompositorMac>(new BrowserCompositorMac).Pass(); 77 return scoped_ptr<BrowserCompositorMac>(new BrowserCompositorMac).Pass();
68 } 78 }
69 79
70 // static 80 // static
71 void BrowserCompositorMac::Recycle( 81 void BrowserCompositorMac::Recycle(
72 scoped_ptr<BrowserCompositorMac> compositor) { 82 scoped_ptr<BrowserCompositorMac> compositor) {
73 DCHECK(compositor); 83 DCHECK(compositor);
74 content::ImageTransportFactory::GetInstance()->OnCompositorRecycled( 84 content::ImageTransportFactory::GetInstance()
75 compositor->compositor()); 85 ->SetCompositorSuspendedForRecycle(compositor->compositor(), true);
76 86
77 // It is an error to have a browser compositor continue to exist after 87 // It is an error to have a browser compositor continue to exist after
78 // shutdown. 88 // shutdown.
79 CHECK(!g_has_shut_down); 89 CHECK(!g_has_shut_down);
80 90
81 // Make this BrowserCompositorMac recyclable for future instances. 91 // Make this BrowserCompositorMac recyclable for future instances.
82 g_recyclable_browser_compositor.Get().swap(compositor); 92 g_recyclable_browser_compositor.Get().swap(compositor);
83 93
84 // If there are no placeholders allocated, destroy the recyclable 94 // If there are no placeholders allocated, destroy the recyclable
85 // BrowserCompositorMac that we just populated. 95 // BrowserCompositorMac that we just populated.
(...skipping 18 matching lines...) Expand all
104 DCHECK_GT(g_placeholder_count, 0u); 114 DCHECK_GT(g_placeholder_count, 0u);
105 g_placeholder_count -= 1; 115 g_placeholder_count -= 1;
106 116
107 // If there are no placeholders allocated, destroy the recyclable 117 // If there are no placeholders allocated, destroy the recyclable
108 // BrowserCompositorMac. 118 // BrowserCompositorMac.
109 if (!g_placeholder_count) 119 if (!g_placeholder_count)
110 g_recyclable_browser_compositor.Get().reset(); 120 g_recyclable_browser_compositor.Get().reset();
111 } 121 }
112 122
113 } // namespace content 123 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698