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

Side by Side Diff: ui/compositor/test/in_process_context_factory.cc

Issue 1317743002: cc: Implement shared worker contexts. (v1) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: invalidate weak ptrs when detaching context from thread Created 5 years, 3 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 "ui/compositor/test/in_process_context_factory.h" 5 #include "ui/compositor/test/in_process_context_factory.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/threading/thread.h" 9 #include "base/threading/thread.h"
10 #include "cc/output/compositor_frame.h" 10 #include "cc/output/compositor_frame.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 attribs.fail_if_major_perf_caveat = false; 108 attribs.fail_if_major_perf_caveat = false;
109 attribs.bind_generates_resource = false; 109 attribs.bind_generates_resource = false;
110 110
111 scoped_refptr<InProcessContextProvider> context_provider = 111 scoped_refptr<InProcessContextProvider> context_provider =
112 InProcessContextProvider::Create(attribs, &gpu_memory_buffer_manager_, 112 InProcessContextProvider::Create(attribs, &gpu_memory_buffer_manager_,
113 &image_factory_, 113 &image_factory_,
114 compositor->widget(), "UICompositor"); 114 compositor->widget(), "UICompositor");
115 scoped_refptr<InProcessContextProvider> worker_context_provider = 115 scoped_refptr<InProcessContextProvider> worker_context_provider =
116 InProcessContextProvider::CreateOffscreen(&gpu_memory_buffer_manager_, 116 InProcessContextProvider::CreateOffscreen(&gpu_memory_buffer_manager_,
117 &image_factory_); 117 &image_factory_);
118 if (worker_context_provider &&
119 !worker_context_provider->BindToCurrentThread())
120 worker_context_provider = nullptr;
121 if (worker_context_provider) {
122 worker_context_provider->SetupLock();
123 // Detach from thread to allow context to be destroyed on a different
124 // thread without being used.
125 worker_context_provider->DetachFromThread();
126 }
118 127
119 scoped_ptr<cc::OutputSurface> real_output_surface; 128 scoped_ptr<cc::OutputSurface> real_output_surface;
120 129
121 if (use_test_surface_) { 130 if (use_test_surface_) {
122 bool flipped_output_surface = false; 131 bool flipped_output_surface = false;
123 real_output_surface = make_scoped_ptr(new cc::PixelTestOutputSurface( 132 real_output_surface = make_scoped_ptr(new cc::PixelTestOutputSurface(
124 context_provider, worker_context_provider, flipped_output_surface)); 133 context_provider, worker_context_provider, flipped_output_surface));
125 } else { 134 } else {
126 real_output_surface = make_scoped_ptr( 135 real_output_surface = make_scoped_ptr(
127 new DirectOutputSurface(context_provider, worker_context_provider)); 136 new DirectOutputSurface(context_provider, worker_context_provider));
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 } 221 }
213 222
214 void InProcessContextFactory::ResizeDisplay(ui::Compositor* compositor, 223 void InProcessContextFactory::ResizeDisplay(ui::Compositor* compositor,
215 const gfx::Size& size) { 224 const gfx::Size& size) {
216 if (!per_compositor_data_.count(compositor)) 225 if (!per_compositor_data_.count(compositor))
217 return; 226 return;
218 per_compositor_data_[compositor]->display()->Resize(size); 227 per_compositor_data_[compositor]->display()->Resize(size);
219 } 228 }
220 229
221 } // namespace ui 230 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698