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

Side by Side Diff: content/renderer/pepper/pepper_platform_context_3d_impl.cc

Issue 10386145: Add the necessary plumbing mechanisms to ensure proper WebGL support inside the <browser> tag, whic… (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Address comments; remove createOffscreenGraphicsContext3D Created 8 years, 7 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 (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 "content/renderer/pepper/pepper_platform_context_3d_impl.h" 5 #include "content/renderer/pepper/pepper_platform_context_3d_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "content/common/gpu/client/gpu_channel_host.h" 8 #include "content/common/gpu/client/gpu_channel_host.h"
9 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" 9 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
10 #include "content/renderer/pepper/pepper_parent_context_provider.h" 10 #include "content/renderer/pepper/pepper_parent_context_provider.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 channel_->DestroyCommandBuffer(command_buffer_); 44 channel_->DestroyCommandBuffer(command_buffer_);
45 command_buffer_ = NULL; 45 command_buffer_ = NULL;
46 if (channel_->WillGpuSwitchOccur(false, gfx::PreferDiscreteGpu)) { 46 if (channel_->WillGpuSwitchOccur(false, gfx::PreferDiscreteGpu)) {
47 channel_->ForciblyCloseChannel(); 47 channel_->ForciblyCloseChannel();
48 } 48 }
49 } 49 }
50 50
51 channel_ = NULL; 51 channel_ = NULL;
52 } 52 }
53 53
54 bool PlatformContext3DImpl::Init(const int32* attrib_list) { 54 bool PlatformContext3DImpl::Init(const int32* attrib_list,
55 PlatformContext3D* share_context) {
55 // Ignore initializing more than once. 56 // Ignore initializing more than once.
56 if (command_buffer_) 57 if (command_buffer_)
57 return true; 58 return true;
58 59
59 if (!parent_context_provider_) 60 if (!parent_context_provider_)
60 return false; 61 return false;
61 62
62 RenderThreadImpl* render_thread = RenderThreadImpl::current(); 63 RenderThreadImpl* render_thread = RenderThreadImpl::current();
63 if (!render_thread) 64 if (!render_thread)
64 return false; 65 return false;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 // fall-through 108 // fall-through
108 default: 109 default:
109 attribs.push_back(attr[0]); 110 attribs.push_back(attr[0]);
110 attribs.push_back(attr[1]); 111 attribs.push_back(attr[1]);
111 break; 112 break;
112 } 113 }
113 } 114 }
114 attribs.push_back(PP_GRAPHICS3DATTRIB_NONE); 115 attribs.push_back(PP_GRAPHICS3DATTRIB_NONE);
115 } 116 }
116 117
118 CommandBufferProxy* share_buffer = 0;
piman 2012/05/16 23:38:45 nit: share_buffer = NULL
(scshunt) 2012/05/17 16:55:45 picked.
119 if (share_context) {
120 PlatformContext3DImpl* share_impl =
121 static_cast<PlatformContext3DImpl*>(share_context);
piman 2012/05/16 23:38:45 nit: indent for continuation should be +4
(scshunt) 2012/05/17 16:55:45 picked.
122 share_buffer = share_impl->command_buffer_;
123 }
124
117 command_buffer_ = channel_->CreateOffscreenCommandBuffer( 125 command_buffer_ = channel_->CreateOffscreenCommandBuffer(
118 surface_size, 126 surface_size,
119 NULL, 127 share_buffer,
120 "*", 128 "*",
121 attribs, 129 attribs,
122 GURL::EmptyGURL(), 130 GURL::EmptyGURL(),
123 gpu_preference); 131 gpu_preference);
124 if (!command_buffer_) 132 if (!command_buffer_)
125 return false; 133 return false;
126 134
127 command_buffer_->SetChannelErrorCallback( 135 command_buffer_->SetChannelErrorCallback(
128 base::Bind(&PlatformContext3DImpl::OnContextLost, 136 base::Bind(&PlatformContext3DImpl::OnContextLost,
129 weak_ptr_factory_.GetWeakPtr())); 137 weak_ptr_factory_.GetWeakPtr()));
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 void PlatformContext3DImpl::OnConsoleMessage(const std::string& msg, int id) { 207 void PlatformContext3DImpl::OnConsoleMessage(const std::string& msg, int id) {
200 DCHECK(command_buffer_); 208 DCHECK(command_buffer_);
201 209
202 if (!console_message_callback_.is_null()) 210 if (!console_message_callback_.is_null())
203 console_message_callback_.Run(msg, id); 211 console_message_callback_.Run(msg, id);
204 } 212 }
205 213
206 } // namespace content 214 } // namespace content
207 215
208 #endif // ENABLE_GPU 216 #endif // ENABLE_GPU
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698