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

Side by Side Diff: gpu/command_buffer/service/in_process_command_buffer.cc

Issue 22066002: Add FBO support in Android WebView (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address joth's comments 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 | « gpu/command_buffer/service/in_process_command_buffer.h ('k') | ui/gl/gl_surface_stub.h » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "gpu/command_buffer/service/in_process_command_buffer.h" 5 #include "gpu/command_buffer/service/in_process_command_buffer.h"
6 6
7 #include <queue> 7 #include <queue>
8 #include <utility> 8 #include <utility>
9 9
10 #include <GLES2/gl2.h> 10 #include <GLES2/gl2.h>
(...skipping 14 matching lines...) Expand all
25 #include "gpu/command_buffer/service/command_buffer_service.h" 25 #include "gpu/command_buffer/service/command_buffer_service.h"
26 #include "gpu/command_buffer/service/context_group.h" 26 #include "gpu/command_buffer/service/context_group.h"
27 #include "gpu/command_buffer/service/gl_context_virtual.h" 27 #include "gpu/command_buffer/service/gl_context_virtual.h"
28 #include "gpu/command_buffer/service/gpu_scheduler.h" 28 #include "gpu/command_buffer/service/gpu_scheduler.h"
29 #include "gpu/command_buffer/service/image_manager.h" 29 #include "gpu/command_buffer/service/image_manager.h"
30 #include "gpu/command_buffer/service/transfer_buffer_manager.h" 30 #include "gpu/command_buffer/service/transfer_buffer_manager.h"
31 #include "ui/gfx/size.h" 31 #include "ui/gfx/size.h"
32 #include "ui/gl/gl_context.h" 32 #include "ui/gl/gl_context.h"
33 #include "ui/gl/gl_image.h" 33 #include "ui/gl/gl_image.h"
34 #include "ui/gl/gl_share_group.h" 34 #include "ui/gl/gl_share_group.h"
35 #include "ui/gl/gl_surface.h"
36 35
37 namespace gpu { 36 namespace gpu {
38 37
39 namespace { 38 namespace {
40 39
41 static base::LazyInstance<std::set<InProcessCommandBuffer*> > 40 static base::LazyInstance<std::set<InProcessCommandBuffer*> >
42 g_all_shared_contexts = LAZY_INSTANCE_INITIALIZER; 41 g_all_shared_contexts = LAZY_INSTANCE_INITIALIZER;
43 42
44 static bool g_use_virtualized_gl_context = false; 43 static bool g_use_virtualized_gl_context = false;
45 static bool g_uses_explicit_scheduling = false; 44 static bool g_uses_explicit_scheduling = false;
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 (error::IsError(state.error) && context_lost_)); 279 (error::IsError(state.error) && context_lost_));
281 } 280 }
282 281
283 bool InProcessCommandBuffer::GetBufferChanged(int32 transfer_buffer_id) { 282 bool InProcessCommandBuffer::GetBufferChanged(int32 transfer_buffer_id) {
284 command_buffer_lock_.AssertAcquired(); 283 command_buffer_lock_.AssertAcquired();
285 command_buffer_->SetGetBuffer(transfer_buffer_id); 284 command_buffer_->SetGetBuffer(transfer_buffer_id);
286 return true; 285 return true;
287 } 286 }
288 287
289 bool InProcessCommandBuffer::Initialize( 288 bool InProcessCommandBuffer::Initialize(
289 scoped_refptr<gfx::GLSurface> surface,
no sievers 2013/08/05 20:41:09 Hmm, this is dangerous. GLSurface is not RefCounte
boliu 2013/08/05 20:42:52 Bah...good point.
290 bool is_offscreen, 290 bool is_offscreen,
291 bool share_resources, 291 bool share_resources,
292 gfx::AcceleratedWidget window, 292 gfx::AcceleratedWidget window,
293 const gfx::Size& size, 293 const gfx::Size& size,
294 const char* allowed_extensions, 294 const char* allowed_extensions,
295 const std::vector<int32>& attribs, 295 const std::vector<int32>& attribs,
296 gfx::GpuPreference gpu_preference, 296 gfx::GpuPreference gpu_preference,
297 const base::Closure& context_lost_callback, 297 const base::Closure& context_lost_callback,
298 unsigned int share_group_id) { 298 unsigned int share_group_id) {
299 299
300 share_resources_ = share_resources; 300 share_resources_ = share_resources;
301 context_lost_callback_ = WrapCallback(context_lost_callback); 301 context_lost_callback_ = WrapCallback(context_lost_callback);
302 share_group_id_ = share_group_id; 302 share_group_id_ = share_group_id;
303 surface_ = surface;
303 304
304 base::WaitableEvent completion(true, false);
305 bool result = false;
306 base::Callback<bool(void)> init_task = 305 base::Callback<bool(void)> init_task =
307 base::Bind(&InProcessCommandBuffer::InitializeOnGpuThread, 306 base::Bind(&InProcessCommandBuffer::InitializeOnGpuThread,
308 base::Unretained(this), 307 base::Unretained(this),
309 is_offscreen, 308 is_offscreen,
310 window, 309 window,
311 size, 310 size,
312 allowed_extensions, 311 allowed_extensions,
313 attribs, 312 attribs,
314 gpu_preference); 313 gpu_preference);
314
315 base::WaitableEvent completion(true, false);
316 bool result = false;
315 QueueTask( 317 QueueTask(
316 base::Bind(&RunTaskWithResult<bool>, init_task, &result, &completion)); 318 base::Bind(&RunTaskWithResult<bool>, init_task, &result, &completion));
317 completion.Wait(); 319 completion.Wait();
318 return result; 320 return result;
319 } 321 }
320 322
321 bool InProcessCommandBuffer::InitializeOnGpuThread( 323 bool InProcessCommandBuffer::InitializeOnGpuThread(
322 bool is_offscreen, 324 bool is_offscreen,
323 gfx::AcceleratedWidget window, 325 gfx::AcceleratedWidget window,
324 const gfx::Size& size, 326 const gfx::Size& size,
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 NULL, NULL, NULL, NULL, bind_generates_resource))); 376 NULL, NULL, NULL, NULL, bind_generates_resource)));
375 377
376 gpu_scheduler_.reset( 378 gpu_scheduler_.reset(
377 new GpuScheduler(command_buffer.get(), decoder_.get(), decoder_.get())); 379 new GpuScheduler(command_buffer.get(), decoder_.get(), decoder_.get()));
378 command_buffer->SetGetBufferChangeCallback(base::Bind( 380 command_buffer->SetGetBufferChangeCallback(base::Bind(
379 &GpuScheduler::SetGetBuffer, base::Unretained(gpu_scheduler_.get()))); 381 &GpuScheduler::SetGetBuffer, base::Unretained(gpu_scheduler_.get())));
380 command_buffer_ = command_buffer.Pass(); 382 command_buffer_ = command_buffer.Pass();
381 383
382 decoder_->set_engine(gpu_scheduler_.get()); 384 decoder_->set_engine(gpu_scheduler_.get());
383 385
384 if (is_offscreen) 386 if (!surface_) {
385 surface_ = gfx::GLSurface::CreateOffscreenGLSurface(size); 387 if (is_offscreen)
386 else 388 surface_ = gfx::GLSurface::CreateOffscreenGLSurface(size);
387 surface_ = gfx::GLSurface::CreateViewGLSurface(window); 389 else
390 surface_ = gfx::GLSurface::CreateViewGLSurface(window);
391 }
388 392
389 if (!surface_.get()) { 393 if (!surface_.get()) {
390 LOG(ERROR) << "Could not create GLSurface."; 394 LOG(ERROR) << "Could not create GLSurface.";
391 DestroyOnGpuThread(); 395 DestroyOnGpuThread();
392 return false; 396 return false;
393 } 397 }
394 398
395 if (g_use_virtualized_gl_context) { 399 if (g_use_virtualized_gl_context) {
396 context_ = share_group->GetSharedContext(); 400 context_ = share_group->GetSharedContext();
397 if (!context_.get()) { 401 if (!context_.get()) {
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 g_uses_explicit_scheduling = true; 698 g_uses_explicit_scheduling = true;
695 g_gpu_queue.Get().SetScheduleCallback(callback); 699 g_gpu_queue.Get().SetScheduleCallback(callback);
696 } 700 }
697 701
698 // static 702 // static
699 void InProcessCommandBuffer::ProcessGpuWorkOnCurrentThread() { 703 void InProcessCommandBuffer::ProcessGpuWorkOnCurrentThread() {
700 g_gpu_queue.Get().RunTasks(); 704 g_gpu_queue.Get().RunTasks();
701 } 705 }
702 706
703 } // namespace gpu 707 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/in_process_command_buffer.h ('k') | ui/gl/gl_surface_stub.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698