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

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

Issue 2134006: Added EGL based GLContext.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 6 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "app/gfx/gl/gl_context.h" 5 #include "app/gfx/gl/gl_context.h"
6 #include "gpu/command_buffer/service/gpu_processor.h" 6 #include "gpu/command_buffer/service/gpu_processor.h"
7 7
8 using ::base::SharedMemory; 8 using ::base::SharedMemory;
9 9
10 namespace gpu { 10 namespace gpu {
11 11
12 bool GPUProcessor::Initialize(gfx::PluginWindowHandle window, 12 bool GPUProcessor::Initialize(gfx::PluginWindowHandle window,
13 const gfx::Size& size, 13 const gfx::Size& size,
14 GPUProcessor* parent, 14 GPUProcessor* parent,
15 uint32 parent_texture_id) { 15 uint32 parent_texture_id) {
16 // Cannot reinitialize. 16 // Cannot reinitialize.
17 if (context_.get()) 17 if (context_.get())
18 return false; 18 return false;
19 19
20 // Get the parent decoder and the GLContext to share IDs with, if any. 20 // Get the parent decoder and the GLContext to share IDs with, if any.
21 gles2::GLES2Decoder* parent_decoder = NULL; 21 gles2::GLES2Decoder* parent_decoder = NULL;
22 gfx::GLContext* parent_context = NULL; 22 gfx::GLContext* parent_context = NULL;
23 void* parent_handle = NULL;
24 if (parent) { 23 if (parent) {
25 parent_decoder = parent->decoder_.get(); 24 parent_decoder = parent->decoder_.get();
26 DCHECK(parent_decoder); 25 DCHECK(parent_decoder);
27 26
28 parent_context = parent_decoder->GetGLContext(); 27 parent_context = parent_decoder->GetGLContext();
29 DCHECK(parent_context); 28 DCHECK(parent_context);
30
31 parent_handle = parent_context->GetHandle();
32 DCHECK(parent_handle);
33 } 29 }
34 30
35 context_.reset(gfx::GLContext::CreateOffscreenGLContext(parent_handle)); 31 context_.reset(gfx::GLContext::CreateOffscreenGLContext(parent_context));
36 if (!context_.get()) 32 if (!context_.get())
37 return false; 33 return false;
38 34
39 // On Mac OS X since we can not render on-screen we don't even 35 // On Mac OS X since we can not render on-screen we don't even
40 // attempt to create a view based GLContext. The only difference 36 // attempt to create a view based GLContext. The only difference
41 // between "on-screen" and "off-screen" rendering on this platform 37 // between "on-screen" and "off-screen" rendering on this platform
42 // is whether we allocate an AcceleratedSurface, which transmits the 38 // is whether we allocate an AcceleratedSurface, which transmits the
43 // rendering results back to the browser. 39 // rendering results back to the browser.
44 if (window) { 40 if (window) {
45 #if !defined(UNIT_TEST)
46 surface_.reset(new AcceleratedSurface()); 41 surface_.reset(new AcceleratedSurface());
47 // TODO(apatrick): AcceleratedSurface will not work with an OSMesa context. 42 // TODO(apatrick): AcceleratedSurface will not work with an OSMesa context.
48 if (!surface_->Initialize( 43 if (!surface_->Initialize(
49 static_cast<CGLContextObj>(context_->GetHandle()), false)) { 44 static_cast<CGLContextObj>(context_->GetHandle()), false)) {
50 Destroy(); 45 Destroy();
51 return false; 46 return false;
52 } 47 }
53 #endif
54 } 48 }
55 49
56 return InitializeCommon(size, parent_decoder, parent_texture_id); 50 return InitializeCommon(size, parent_decoder, parent_texture_id);
57 51
58 return true; 52 return true;
59 } 53 }
60 54
61 void GPUProcessor::Destroy() { 55 void GPUProcessor::Destroy() {
62 #if !defined(UNIT_TEST)
63 if (surface_.get()) { 56 if (surface_.get()) {
64 surface_->Destroy(); 57 surface_->Destroy();
65 } 58 }
66 surface_.reset(); 59 surface_.reset();
67 #endif
68 DestroyCommon(); 60 DestroyCommon();
69 } 61 }
70 62
71 uint64 GPUProcessor::SetWindowSizeForIOSurface(const gfx::Size& size) { 63 uint64 GPUProcessor::SetWindowSizeForIOSurface(const gfx::Size& size) {
72 #if !defined(UNIT_TEST)
73 ResizeOffscreenFrameBuffer(size); 64 ResizeOffscreenFrameBuffer(size);
74 decoder_->UpdateOffscreenFrameBufferSize(); 65 decoder_->UpdateOffscreenFrameBufferSize();
75 return surface_->SetSurfaceSize(size); 66 return surface_->SetSurfaceSize(size);
76 #else
77 return 0;
78 #endif
79 } 67 }
80 68
81 TransportDIB::Handle GPUProcessor::SetWindowSizeForTransportDIB( 69 TransportDIB::Handle GPUProcessor::SetWindowSizeForTransportDIB(
82 const gfx::Size& size) { 70 const gfx::Size& size) {
83 #if !defined(UNIT_TEST)
84 ResizeOffscreenFrameBuffer(size); 71 ResizeOffscreenFrameBuffer(size);
85 decoder_->UpdateOffscreenFrameBufferSize(); 72 decoder_->UpdateOffscreenFrameBufferSize();
86 return surface_->SetTransportDIBSize(size); 73 return surface_->SetTransportDIBSize(size);
87 #else
88 return TransportDIB::DefaultHandleValue();
89 #endif
90 } 74 }
91 75
92 void GPUProcessor::SetTransportDIBAllocAndFree( 76 void GPUProcessor::SetTransportDIBAllocAndFree(
93 Callback2<size_t, TransportDIB::Handle*>::Type* allocator, 77 Callback2<size_t, TransportDIB::Handle*>::Type* allocator,
94 Callback1<TransportDIB::Id>::Type* deallocator) { 78 Callback1<TransportDIB::Id>::Type* deallocator) {
95 #if !defined(UNIT_TEST)
96 surface_->SetTransportDIBAllocAndFree(allocator, deallocator); 79 surface_->SetTransportDIBAllocAndFree(allocator, deallocator);
97 #endif
98 } 80 }
99 81
100 void GPUProcessor::WillSwapBuffers() { 82 void GPUProcessor::WillSwapBuffers() {
101 DCHECK(context_->IsCurrent()); 83 DCHECK(context_->IsCurrent());
102 #if !defined(UNIT_TEST)
103 if (surface_.get()) { 84 if (surface_.get()) {
104 surface_->SwapBuffers(); 85 surface_->SwapBuffers();
105 } 86 }
106 #endif
107 87
108 if (wrapped_swap_buffers_callback_.get()) { 88 if (wrapped_swap_buffers_callback_.get()) {
109 wrapped_swap_buffers_callback_->Run(); 89 wrapped_swap_buffers_callback_->Run();
110 } 90 }
111 } 91 }
112 92
113 } // namespace gpu 93 } // namespace gpu
114 94
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gpu_processor_linux.cc ('k') | gpu/command_buffer/service/gpu_processor_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698