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

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

Issue 21026005: aura: Remove CreateOffscreenContext from ui::ContextFactory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: offscreencontext: rebase Created 7 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 | Annotate | Revision Log
« no previous file with comments | « ui/compositor/compositor.h ('k') | ui/compositor/compositor.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/compositor.h" 5 #include "ui/compositor/compositor.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <deque> 8 #include <deque>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/memory/singleton.h" 12 #include "base/memory/singleton.h"
13 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
14 #include "base/run_loop.h" 14 #include "base/run_loop.h"
15 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
16 #include "base/threading/thread.h" 16 #include "base/threading/thread.h"
17 #include "base/threading/thread_restrictions.h" 17 #include "base/threading/thread_restrictions.h"
18 #include "cc/base/switches.h" 18 #include "cc/base/switches.h"
19 #include "cc/debug/fake_context_provider.h"
19 #include "cc/input/input_handler.h" 20 #include "cc/input/input_handler.h"
20 #include "cc/layers/layer.h" 21 #include "cc/layers/layer.h"
21 #include "cc/output/context_provider.h" 22 #include "cc/output/context_provider.h"
22 #include "cc/output/output_surface.h" 23 #include "cc/output/output_surface.h"
23 #include "cc/trees/layer_tree_host.h" 24 #include "cc/trees/layer_tree_host.h"
24 #include "third_party/skia/include/core/SkBitmap.h" 25 #include "third_party/skia/include/core/SkBitmap.h"
25 #include "ui/compositor/compositor_observer.h" 26 #include "ui/compositor/compositor_observer.h"
26 #include "ui/compositor/compositor_switches.h" 27 #include "ui/compositor/compositor_switches.h"
27 #include "ui/compositor/context_provider_from_context_factory.h"
28 #include "ui/compositor/dip_util.h" 28 #include "ui/compositor/dip_util.h"
29 #include "ui/compositor/layer.h" 29 #include "ui/compositor/layer.h"
30 #include "ui/compositor/reflector.h" 30 #include "ui/compositor/reflector.h"
31 #include "ui/compositor/test_web_graphics_context_3d.h" 31 #include "ui/compositor/test_web_graphics_context_3d.h"
32 #include "ui/gl/gl_context.h" 32 #include "ui/gl/gl_context.h"
33 #include "ui/gl/gl_implementation.h" 33 #include "ui/gl/gl_implementation.h"
34 #include "ui/gl/gl_surface.h" 34 #include "ui/gl/gl_surface.h"
35 #include "ui/gl/gl_switches.h" 35 #include "ui/gl/gl_switches.h"
36 #include "webkit/common/gpu/grcontext_for_webgraphicscontext3d.h" 36 #include "webkit/common/gpu/grcontext_for_webgraphicscontext3d.h"
37 #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl. h" 37 #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl. h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 } 132 }
133 return true; 133 return true;
134 } 134 }
135 135
136 scoped_ptr<cc::OutputSurface> DefaultContextFactory::CreateOutputSurface( 136 scoped_ptr<cc::OutputSurface> DefaultContextFactory::CreateOutputSurface(
137 Compositor* compositor) { 137 Compositor* compositor) {
138 return make_scoped_ptr(new cc::OutputSurface( 138 return make_scoped_ptr(new cc::OutputSurface(
139 CreateContextCommon(compositor, false))); 139 CreateContextCommon(compositor, false)));
140 } 140 }
141 141
142 scoped_ptr<WebKit::WebGraphicsContext3D>
143 DefaultContextFactory::CreateOffscreenContext() {
144 return CreateContextCommon(NULL, true);
145 }
146
147 scoped_refptr<Reflector> DefaultContextFactory::CreateReflector( 142 scoped_refptr<Reflector> DefaultContextFactory::CreateReflector(
148 Compositor* mirroed_compositor, 143 Compositor* mirroed_compositor,
149 Layer* mirroring_layer) { 144 Layer* mirroring_layer) {
150 return NULL; 145 return NULL;
151 } 146 }
152 147
153 void DefaultContextFactory::RemoveReflector( 148 void DefaultContextFactory::RemoveReflector(
154 scoped_refptr<Reflector> reflector) { 149 scoped_refptr<Reflector> reflector) {
155 } 150 }
156 151
157 scoped_refptr<cc::ContextProvider> 152 scoped_refptr<cc::ContextProvider>
158 DefaultContextFactory::OffscreenContextProviderForMainThread() { 153 DefaultContextFactory::OffscreenContextProviderForMainThread() {
159 if (!offscreen_contexts_main_thread_.get() || 154 if (!offscreen_contexts_main_thread_.get() ||
160 !offscreen_contexts_main_thread_->DestroyedOnMainThread()) { 155 !offscreen_contexts_main_thread_->DestroyedOnMainThread()) {
161 offscreen_contexts_main_thread_ = 156 Compositor* compositor = NULL;
162 ContextProviderFromContextFactory::CreateForOffscreen(this); 157 bool offscreen = true;
158 offscreen_contexts_main_thread_ = cc::FakeContextProvider::Create(
159 base::Bind(&DefaultContextFactory::CreateContextCommon,
160 compositor,
161 offscreen));
piman 2013/07/30 20:15:10 If we don't make it create the GrContext any more,
danakj 2013/07/30 20:32:08 Oh, this should be the in process ContextProvider
piman 2013/07/30 20:42:02 Yeah, I think that'd work fine. Quite possibly we
163 if (offscreen_contexts_main_thread_.get() && 162 if (offscreen_contexts_main_thread_.get() &&
164 !offscreen_contexts_main_thread_->BindToCurrentThread()) 163 !offscreen_contexts_main_thread_->BindToCurrentThread())
165 offscreen_contexts_main_thread_ = NULL; 164 offscreen_contexts_main_thread_ = NULL;
166 } 165 }
167 return offscreen_contexts_main_thread_; 166 return offscreen_contexts_main_thread_;
168 } 167 }
169 168
170 scoped_refptr<cc::ContextProvider> 169 scoped_refptr<cc::ContextProvider>
171 DefaultContextFactory::OffscreenContextProviderForCompositorThread() { 170 DefaultContextFactory::OffscreenContextProviderForCompositorThread() {
172 if (!offscreen_contexts_compositor_thread_.get() || 171 if (!offscreen_contexts_compositor_thread_.get() ||
173 !offscreen_contexts_compositor_thread_->DestroyedOnMainThread()) { 172 !offscreen_contexts_compositor_thread_->DestroyedOnMainThread()) {
174 offscreen_contexts_compositor_thread_ = 173 Compositor* compositor = NULL;
175 ContextProviderFromContextFactory::CreateForOffscreen(this); 174 bool offscreen = true;
175 offscreen_contexts_compositor_thread_ = cc::FakeContextProvider::Create(
176 base::Bind(&DefaultContextFactory::CreateContextCommon,
177 compositor,
178 offscreen));
176 } 179 }
177 return offscreen_contexts_compositor_thread_; 180 return offscreen_contexts_compositor_thread_;
178 } 181 }
179 182
180 void DefaultContextFactory::RemoveCompositor(Compositor* compositor) { 183 void DefaultContextFactory::RemoveCompositor(Compositor* compositor) {
181 } 184 }
182 185
186 // static
183 scoped_ptr<WebKit::WebGraphicsContext3D> 187 scoped_ptr<WebKit::WebGraphicsContext3D>
184 DefaultContextFactory::CreateContextCommon(Compositor* compositor, 188 DefaultContextFactory::CreateContextCommon(Compositor* compositor,
185 bool offscreen) { 189 bool offscreen) {
186 DCHECK(offscreen || compositor); 190 DCHECK(offscreen || compositor);
187 WebKit::WebGraphicsContext3D::Attributes attrs; 191 WebKit::WebGraphicsContext3D::Attributes attrs;
188 attrs.depth = false; 192 attrs.depth = false;
189 attrs.stencil = false; 193 attrs.stencil = false;
190 attrs.antialias = false; 194 attrs.antialias = false;
191 attrs.shareResources = true; 195 attrs.shareResources = true;
192 using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl; 196 using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl;
193 if (offscreen) { 197 if (offscreen) {
194 return WebGraphicsContext3DInProcessCommandBufferImpl:: 198 return WebGraphicsContext3DInProcessCommandBufferImpl::
195 CreateOffscreenContext(attrs); 199 CreateOffscreenContext(attrs);
196 } 200 }
197 return WebGraphicsContext3DInProcessCommandBufferImpl::CreateViewContext( 201 return WebGraphicsContext3DInProcessCommandBufferImpl::CreateViewContext(
198 attrs, compositor->widget()); 202 attrs, compositor->widget());
199 } 203 }
200 204
201 TestContextFactory::TestContextFactory() {} 205 TestContextFactory::TestContextFactory() {}
202 206
203 TestContextFactory::~TestContextFactory() {} 207 TestContextFactory::~TestContextFactory() {}
204 208
205 scoped_ptr<cc::OutputSurface> TestContextFactory::CreateOutputSurface( 209 scoped_ptr<cc::OutputSurface> TestContextFactory::CreateOutputSurface(
206 Compositor* compositor) { 210 Compositor* compositor) {
207 return make_scoped_ptr(new cc::OutputSurface(CreateOffscreenContext())); 211 return make_scoped_ptr(new cc::OutputSurface(CreateOffscreenContext()));
208 } 212 }
209 213
210 scoped_ptr<WebKit::WebGraphicsContext3D>
211 TestContextFactory::CreateOffscreenContext() {
212 scoped_ptr<ui::TestWebGraphicsContext3D> context(
213 new ui::TestWebGraphicsContext3D);
214 context->Initialize();
215 return context.PassAs<WebKit::WebGraphicsContext3D>();
216 }
217
218 scoped_refptr<Reflector> TestContextFactory::CreateReflector( 214 scoped_refptr<Reflector> TestContextFactory::CreateReflector(
219 Compositor* mirrored_compositor, 215 Compositor* mirrored_compositor,
220 Layer* mirroring_layer) { 216 Layer* mirroring_layer) {
221 return new Reflector(); 217 return new Reflector();
222 } 218 }
223 219
224 void TestContextFactory::RemoveReflector(scoped_refptr<Reflector> reflector) { 220 void TestContextFactory::RemoveReflector(scoped_refptr<Reflector> reflector) {
225 } 221 }
226 222
227 scoped_refptr<cc::ContextProvider> 223 scoped_refptr<cc::ContextProvider>
228 TestContextFactory::OffscreenContextProviderForMainThread() { 224 TestContextFactory::OffscreenContextProviderForMainThread() {
229 if (!offscreen_contexts_main_thread_.get() || 225 if (!offscreen_contexts_main_thread_.get() ||
230 offscreen_contexts_main_thread_->DestroyedOnMainThread()) { 226 offscreen_contexts_main_thread_->DestroyedOnMainThread()) {
231 offscreen_contexts_main_thread_ = 227 offscreen_contexts_main_thread_ = cc::FakeContextProvider::Create(
232 ContextProviderFromContextFactory::CreateForOffscreen(this); 228 base::Bind(&TestContextFactory::CreateOffscreenContext));
233 CHECK(offscreen_contexts_main_thread_->BindToCurrentThread()); 229 CHECK(offscreen_contexts_main_thread_->BindToCurrentThread());
234 } 230 }
235 return offscreen_contexts_main_thread_; 231 return offscreen_contexts_main_thread_;
236 } 232 }
237 233
238 scoped_refptr<cc::ContextProvider> 234 scoped_refptr<cc::ContextProvider>
239 TestContextFactory::OffscreenContextProviderForCompositorThread() { 235 TestContextFactory::OffscreenContextProviderForCompositorThread() {
240 if (!offscreen_contexts_compositor_thread_.get() || 236 if (!offscreen_contexts_compositor_thread_.get() ||
241 offscreen_contexts_compositor_thread_->DestroyedOnMainThread()) { 237 offscreen_contexts_compositor_thread_->DestroyedOnMainThread()) {
242 offscreen_contexts_compositor_thread_ = 238 offscreen_contexts_compositor_thread_ = cc::FakeContextProvider::Create(
243 ContextProviderFromContextFactory::CreateForOffscreen(this); 239 base::Bind(&TestContextFactory::CreateOffscreenContext));
244 } 240 }
245 return offscreen_contexts_compositor_thread_; 241 return offscreen_contexts_compositor_thread_;
246 } 242 }
247 243
248 void TestContextFactory::RemoveCompositor(Compositor* compositor) { 244 void TestContextFactory::RemoveCompositor(Compositor* compositor) {
249 } 245 }
250 246
247 // static
248 scoped_ptr<WebKit::WebGraphicsContext3D>
249 TestContextFactory::CreateOffscreenContext() {
250 scoped_ptr<ui::TestWebGraphicsContext3D> context(
251 new ui::TestWebGraphicsContext3D);
252 context->Initialize();
253 return context.PassAs<WebKit::WebGraphicsContext3D>();
254 }
255
251 Texture::Texture(bool flipped, const gfx::Size& size, float device_scale_factor) 256 Texture::Texture(bool flipped, const gfx::Size& size, float device_scale_factor)
252 : size_(size), 257 : size_(size),
253 flipped_(flipped), 258 flipped_(flipped),
254 device_scale_factor_(device_scale_factor) { 259 device_scale_factor_(device_scale_factor) {
255 } 260 }
256 261
257 Texture::~Texture() { 262 Texture::~Texture() {
258 } 263 }
259 264
260 std::string Texture::Produce() { 265 std::string Texture::Produce() {
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 COMPOSITOR_EXPORT void DisableTestCompositor() { 773 COMPOSITOR_EXPORT void DisableTestCompositor() {
769 ResetImplicitFactory(); 774 ResetImplicitFactory();
770 g_test_compositor_enabled = false; 775 g_test_compositor_enabled = false;
771 } 776 }
772 777
773 COMPOSITOR_EXPORT bool IsTestCompositorEnabled() { 778 COMPOSITOR_EXPORT bool IsTestCompositorEnabled() {
774 return g_test_compositor_enabled; 779 return g_test_compositor_enabled;
775 } 780 }
776 781
777 } // namespace ui 782 } // namespace ui
OLDNEW
« no previous file with comments | « ui/compositor/compositor.h ('k') | ui/compositor/compositor.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698