OLD | NEW |
---|---|
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/gpu/renderer_gl_context.h" | 5 #include "content/common/gpu/client/content_gl_context.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/memory/singleton.h" | 12 #include "base/memory/singleton.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "base/shared_memory.h" | 14 #include "base/shared_memory.h" |
15 #include "content/common/view_messages.h" | 15 #include "content/common/gpu/client/command_buffer_proxy.h" |
16 #include "content/renderer/gpu/command_buffer_proxy.h" | 16 #include "content/common/gpu/client/gpu_channel_host.h" |
17 #include "content/renderer/gpu/gpu_channel_host.h" | 17 //#include "content/common/view_messages.h" |
apatrick_chromium
2012/02/06 23:05:55
This is commented out.
piman
2012/02/06 23:25:32
Removed.
| |
18 #include "content/renderer/render_widget.h" | |
19 #include "googleurl/src/gurl.h" | 18 #include "googleurl/src/gurl.h" |
20 #include "ipc/ipc_channel_handle.h" | 19 #include "ipc/ipc_channel_handle.h" |
21 | 20 |
22 #if defined(ENABLE_GPU) | 21 #if defined(ENABLE_GPU) |
23 #include "gpu/command_buffer/client/gles2_cmd_helper.h" | 22 #include "gpu/command_buffer/client/gles2_cmd_helper.h" |
24 #include "gpu/command_buffer/client/gles2_implementation.h" | 23 #include "gpu/command_buffer/client/gles2_implementation.h" |
25 #include "gpu/command_buffer/client/gles2_lib.h" | 24 #include "gpu/command_buffer/client/gles2_lib.h" |
26 #include "gpu/command_buffer/client/transfer_buffer.h" | 25 #include "gpu/command_buffer/client/transfer_buffer.h" |
27 #include "gpu/command_buffer/common/constants.h" | 26 #include "gpu/command_buffer/common/constants.h" |
28 #endif // ENABLE_GPU | 27 #endif // ENABLE_GPU |
(...skipping 23 matching lines...) Expand all Loading... | |
52 }; | 51 }; |
53 | 52 |
54 //////////////////////////////////////////////////////////////////////////////// | 53 //////////////////////////////////////////////////////////////////////////////// |
55 | 54 |
56 base::LazyInstance<GLES2Initializer> g_gles2_initializer = | 55 base::LazyInstance<GLES2Initializer> g_gles2_initializer = |
57 LAZY_INSTANCE_INITIALIZER; | 56 LAZY_INSTANCE_INITIALIZER; |
58 | 57 |
59 //////////////////////////////////////////////////////////////////////////////// | 58 //////////////////////////////////////////////////////////////////////////////// |
60 | 59 |
61 #if defined(ENABLE_GPU) | 60 #if defined(ENABLE_GPU) |
62 RendererGLContext::ContextLostReason ConvertReason( | 61 ContentGLContext::ContextLostReason ConvertReason( |
63 gpu::error::ContextLostReason reason) { | 62 gpu::error::ContextLostReason reason) { |
64 switch (reason) { | 63 switch (reason) { |
65 case gpu::error::kGuilty: | 64 case gpu::error::kGuilty: |
66 return RendererGLContext::kGuilty; | 65 return ContentGLContext::kGuilty; |
67 case gpu::error::kInnocent: | 66 case gpu::error::kInnocent: |
68 return RendererGLContext::kInnocent; | 67 return ContentGLContext::kInnocent; |
69 case gpu::error::kUnknown: | 68 case gpu::error::kUnknown: |
70 return RendererGLContext::kUnknown; | 69 return ContentGLContext::kUnknown; |
71 } | 70 } |
72 NOTREACHED(); | 71 NOTREACHED(); |
73 return RendererGLContext::kUnknown; | 72 return ContentGLContext::kUnknown; |
74 } | 73 } |
75 #endif | 74 #endif |
76 | 75 |
77 } // namespace | 76 } // namespace |
78 | 77 |
79 RendererGLContext::~RendererGLContext() { | 78 ContentGLContext::~ContentGLContext() { |
80 Destroy(); | 79 Destroy(); |
81 } | 80 } |
82 | 81 |
83 RendererGLContext* RendererGLContext::CreateViewContext( | 82 ContentGLContext* ContentGLContext::CreateViewContext( |
84 GpuChannelHost* channel, | 83 GpuChannelHost* channel, |
85 int32 surface_id, | 84 int32 surface_id, |
86 RendererGLContext* share_group, | 85 ContentGLContext* share_group, |
87 const char* allowed_extensions, | 86 const char* allowed_extensions, |
88 const int32* attrib_list, | 87 const int32* attrib_list, |
89 const GURL& active_url, | 88 const GURL& active_url, |
90 gfx::GpuPreference gpu_preference) { | 89 gfx::GpuPreference gpu_preference) { |
91 #if defined(ENABLE_GPU) | 90 #if defined(ENABLE_GPU) |
92 scoped_ptr<RendererGLContext> context(new RendererGLContext(channel)); | 91 scoped_ptr<ContentGLContext> context(new ContentGLContext(channel)); |
93 if (!context->Initialize( | 92 if (!context->Initialize( |
94 true, | 93 true, |
95 surface_id, | 94 surface_id, |
96 gfx::Size(), | 95 gfx::Size(), |
97 share_group, | 96 share_group, |
98 allowed_extensions, | 97 allowed_extensions, |
99 attrib_list, | 98 attrib_list, |
100 active_url, | 99 active_url, |
101 gpu_preference)) | 100 gpu_preference)) |
102 return NULL; | 101 return NULL; |
103 | 102 |
104 return context.release(); | 103 return context.release(); |
105 #else | 104 #else |
106 return NULL; | 105 return NULL; |
107 #endif | 106 #endif |
108 } | 107 } |
109 | 108 |
110 RendererGLContext* RendererGLContext::CreateOffscreenContext( | 109 ContentGLContext* ContentGLContext::CreateOffscreenContext( |
111 GpuChannelHost* channel, | 110 GpuChannelHost* channel, |
112 const gfx::Size& size, | 111 const gfx::Size& size, |
113 RendererGLContext* share_group, | 112 ContentGLContext* share_group, |
114 const char* allowed_extensions, | 113 const char* allowed_extensions, |
115 const int32* attrib_list, | 114 const int32* attrib_list, |
116 const GURL& active_url, | 115 const GURL& active_url, |
117 gfx::GpuPreference gpu_preference) { | 116 gfx::GpuPreference gpu_preference) { |
118 #if defined(ENABLE_GPU) | 117 #if defined(ENABLE_GPU) |
119 scoped_ptr<RendererGLContext> context(new RendererGLContext(channel)); | 118 scoped_ptr<ContentGLContext> context(new ContentGLContext(channel)); |
120 if (!context->Initialize( | 119 if (!context->Initialize( |
121 false, | 120 false, |
122 0, | 121 0, |
123 size, | 122 size, |
124 share_group, | 123 share_group, |
125 allowed_extensions, | 124 allowed_extensions, |
126 attrib_list, | 125 attrib_list, |
127 active_url, | 126 active_url, |
128 gpu_preference)) | 127 gpu_preference)) |
129 return NULL; | 128 return NULL; |
130 | 129 |
131 return context.release(); | 130 return context.release(); |
132 #else | 131 #else |
133 return NULL; | 132 return NULL; |
134 #endif | 133 #endif |
135 } | 134 } |
136 | 135 |
137 bool RendererGLContext::SetParent(RendererGLContext* new_parent) { | 136 bool ContentGLContext::SetParent(ContentGLContext* new_parent) { |
138 if (parent_.get() == new_parent) | 137 if (parent_.get() == new_parent) |
139 return true; | 138 return true; |
140 | 139 |
141 // Allocate a texture ID with respect to the parent and change the parent. | 140 // Allocate a texture ID with respect to the parent and change the parent. |
142 uint32 new_parent_texture_id = 0; | 141 uint32 new_parent_texture_id = 0; |
143 if (command_buffer_) { | 142 if (command_buffer_) { |
144 if (new_parent) { | 143 if (new_parent) { |
145 TRACE_EVENT0("gpu", "RendererGLContext::SetParent::flushParent"); | 144 TRACE_EVENT0("gpu", "ContentGLContext::SetParent::flushParent"); |
146 // Flush any remaining commands in the parent context to make sure the | 145 // Flush any remaining commands in the parent context to make sure the |
147 // texture id accounting stays consistent. | 146 // texture id accounting stays consistent. |
148 int32 token = new_parent->gles2_helper_->InsertToken(); | 147 int32 token = new_parent->gles2_helper_->InsertToken(); |
149 new_parent->gles2_helper_->WaitForToken(token); | 148 new_parent->gles2_helper_->WaitForToken(token); |
150 new_parent_texture_id = | 149 new_parent_texture_id = |
151 new_parent->gles2_implementation_->MakeTextureId(); | 150 new_parent->gles2_implementation_->MakeTextureId(); |
152 | 151 |
153 if (!command_buffer_->SetParent(new_parent->command_buffer_, | 152 if (!command_buffer_->SetParent(new_parent->command_buffer_, |
154 new_parent_texture_id)) { | 153 new_parent_texture_id)) { |
155 new_parent->gles2_implementation_->FreeTextureId(parent_texture_id_); | 154 new_parent->gles2_implementation_->FreeTextureId(parent_texture_id_); |
(...skipping 19 matching lines...) Expand all Loading... | |
175 parent_ = new_parent->AsWeakPtr(); | 174 parent_ = new_parent->AsWeakPtr(); |
176 parent_texture_id_ = new_parent_texture_id; | 175 parent_texture_id_ = new_parent_texture_id; |
177 } else { | 176 } else { |
178 parent_.reset(); | 177 parent_.reset(); |
179 parent_texture_id_ = 0; | 178 parent_texture_id_ = 0; |
180 } | 179 } |
181 | 180 |
182 return true; | 181 return true; |
183 } | 182 } |
184 | 183 |
185 uint32 RendererGLContext::GetParentTextureId() { | 184 uint32 ContentGLContext::GetParentTextureId() { |
186 return parent_texture_id_; | 185 return parent_texture_id_; |
187 } | 186 } |
188 | 187 |
189 uint32 RendererGLContext::CreateParentTexture(const gfx::Size& size) { | 188 uint32 ContentGLContext::CreateParentTexture(const gfx::Size& size) { |
190 uint32 texture_id = 0; | 189 uint32 texture_id = 0; |
191 gles2_implementation_->GenTextures(1, &texture_id); | 190 gles2_implementation_->GenTextures(1, &texture_id); |
192 gles2_implementation_->Flush(); | 191 gles2_implementation_->Flush(); |
193 return texture_id; | 192 return texture_id; |
194 } | 193 } |
195 | 194 |
196 void RendererGLContext::DeleteParentTexture(uint32 texture) { | 195 void ContentGLContext::DeleteParentTexture(uint32 texture) { |
197 gles2_implementation_->DeleteTextures(1, &texture); | 196 gles2_implementation_->DeleteTextures(1, &texture); |
198 } | 197 } |
199 | 198 |
200 void RendererGLContext::SetContextLostCallback( | 199 void ContentGLContext::SetContextLostCallback( |
201 const base::Callback<void (ContextLostReason)>& callback) { | 200 const base::Callback<void (ContextLostReason)>& callback) { |
202 context_lost_callback_ = callback; | 201 context_lost_callback_ = callback; |
203 } | 202 } |
204 | 203 |
205 bool RendererGLContext::MakeCurrent(RendererGLContext* context) { | 204 bool ContentGLContext::MakeCurrent(ContentGLContext* context) { |
206 if (context) { | 205 if (context) { |
207 DCHECK(context->CalledOnValidThread()); | 206 DCHECK(context->CalledOnValidThread()); |
208 gles2::SetGLContext(context->gles2_implementation_); | 207 gles2::SetGLContext(context->gles2_implementation_); |
209 | 208 |
210 // Don't request latest error status from service. Just use the locally | 209 // Don't request latest error status from service. Just use the locally |
211 // cached information from the last flush. | 210 // cached information from the last flush. |
212 // TODO(apatrick): I'm not sure if this should actually change the | 211 // TODO(apatrick): I'm not sure if this should actually change the |
213 // current context if it fails. For now it gets changed even if it fails | 212 // current context if it fails. For now it gets changed even if it fails |
214 // because making GL calls with a NULL context crashes. | 213 // because making GL calls with a NULL context crashes. |
215 if (context->command_buffer_->GetLastState().error != gpu::error::kNoError) | 214 if (context->command_buffer_->GetLastState().error != gpu::error::kNoError) |
216 return false; | 215 return false; |
217 } else { | 216 } else { |
218 gles2::SetGLContext(NULL); | 217 gles2::SetGLContext(NULL); |
219 } | 218 } |
220 | 219 |
221 return true; | 220 return true; |
222 } | 221 } |
223 | 222 |
224 bool RendererGLContext::SwapBuffers() { | 223 bool ContentGLContext::SwapBuffers() { |
225 TRACE_EVENT1("gpu", "RendererGLContext::SwapBuffers", "frame", frame_number_); | 224 TRACE_EVENT1("gpu", "ContentGLContext::SwapBuffers", "frame", frame_number_); |
226 frame_number_++; | 225 frame_number_++; |
227 | 226 |
228 // Don't request latest error status from service. Just use the locally cached | 227 // Don't request latest error status from service. Just use the locally cached |
229 // information from the last flush. | 228 // information from the last flush. |
230 if (command_buffer_->GetLastState().error != gpu::error::kNoError) | 229 if (command_buffer_->GetLastState().error != gpu::error::kNoError) |
231 return false; | 230 return false; |
232 | 231 |
233 gles2_implementation_->SwapBuffers(); | 232 gles2_implementation_->SwapBuffers(); |
234 | 233 |
235 return true; | 234 return true; |
236 } | 235 } |
237 | 236 |
238 bool RendererGLContext::Echo(const base::Closure& task) { | 237 bool ContentGLContext::Echo(const base::Closure& task) { |
239 return command_buffer_->Echo(task); | 238 return command_buffer_->Echo(task); |
240 } | 239 } |
241 | 240 |
242 RendererGLContext::Error RendererGLContext::GetError() { | 241 ContentGLContext::Error ContentGLContext::GetError() { |
243 gpu::CommandBuffer::State state = command_buffer_->GetState(); | 242 gpu::CommandBuffer::State state = command_buffer_->GetState(); |
244 if (state.error == gpu::error::kNoError) { | 243 if (state.error == gpu::error::kNoError) { |
245 Error old_error = last_error_; | 244 Error old_error = last_error_; |
246 last_error_ = SUCCESS; | 245 last_error_ = SUCCESS; |
247 return old_error; | 246 return old_error; |
248 } else { | 247 } else { |
249 // All command buffer errors are unrecoverable. The error is treated as a | 248 // All command buffer errors are unrecoverable. The error is treated as a |
250 // lost context: destroy the context and create another one. | 249 // lost context: destroy the context and create another one. |
251 return CONTEXT_LOST; | 250 return CONTEXT_LOST; |
252 } | 251 } |
253 } | 252 } |
254 | 253 |
255 bool RendererGLContext::IsCommandBufferContextLost() { | 254 bool ContentGLContext::IsCommandBufferContextLost() { |
256 // If the channel shut down unexpectedly, let that supersede the | 255 // If the channel shut down unexpectedly, let that supersede the |
257 // command buffer's state. | 256 // command buffer's state. |
258 if (channel_->state() == GpuChannelHost::kLost) | 257 if (channel_->state() == GpuChannelHost::kLost) |
259 return true; | 258 return true; |
260 gpu::CommandBuffer::State state = command_buffer_->GetLastState(); | 259 gpu::CommandBuffer::State state = command_buffer_->GetLastState(); |
261 return state.error == gpu::error::kLostContext; | 260 return state.error == gpu::error::kLostContext; |
262 } | 261 } |
263 | 262 |
264 CommandBufferProxy* RendererGLContext::GetCommandBufferProxy() { | 263 CommandBufferProxy* ContentGLContext::GetCommandBufferProxy() { |
265 return command_buffer_; | 264 return command_buffer_; |
266 } | 265 } |
267 | 266 |
268 bool RendererGLContext::SetSurfaceVisible(bool visible) { | 267 bool ContentGLContext::SetSurfaceVisible(bool visible) { |
269 return GetCommandBufferProxy()->SetSurfaceVisible(visible); | 268 return GetCommandBufferProxy()->SetSurfaceVisible(visible); |
270 } | 269 } |
271 | 270 |
272 // TODO(gman): Remove This | 271 // TODO(gman): Remove This |
273 void RendererGLContext::DisableShaderTranslation() { | 272 void ContentGLContext::DisableShaderTranslation() { |
274 NOTREACHED(); | 273 NOTREACHED(); |
275 } | 274 } |
276 | 275 |
277 gpu::gles2::GLES2Implementation* RendererGLContext::GetImplementation() { | 276 gpu::gles2::GLES2Implementation* ContentGLContext::GetImplementation() { |
278 return gles2_implementation_; | 277 return gles2_implementation_; |
279 } | 278 } |
280 | 279 |
281 RendererGLContext::RendererGLContext(GpuChannelHost* channel) | 280 ContentGLContext::ContentGLContext(GpuChannelHost* channel) |
282 : channel_(channel), | 281 : channel_(channel), |
283 parent_(base::WeakPtr<RendererGLContext>()), | 282 parent_(base::WeakPtr<ContentGLContext>()), |
284 parent_texture_id_(0), | 283 parent_texture_id_(0), |
285 command_buffer_(NULL), | 284 command_buffer_(NULL), |
286 gles2_helper_(NULL), | 285 gles2_helper_(NULL), |
287 transfer_buffer_(NULL), | 286 transfer_buffer_(NULL), |
288 gles2_implementation_(NULL), | 287 gles2_implementation_(NULL), |
289 last_error_(SUCCESS), | 288 last_error_(SUCCESS), |
290 frame_number_(0) { | 289 frame_number_(0) { |
291 DCHECK(channel); | 290 DCHECK(channel); |
292 } | 291 } |
293 | 292 |
294 bool RendererGLContext::Initialize(bool onscreen, | 293 bool ContentGLContext::Initialize(bool onscreen, |
295 int32 surface_id, | 294 int32 surface_id, |
296 const gfx::Size& size, | 295 const gfx::Size& size, |
297 RendererGLContext* share_group, | 296 ContentGLContext* share_group, |
298 const char* allowed_extensions, | 297 const char* allowed_extensions, |
299 const int32* attrib_list, | 298 const int32* attrib_list, |
300 const GURL& active_url, | 299 const GURL& active_url, |
301 gfx::GpuPreference gpu_preference) { | 300 gfx::GpuPreference gpu_preference) { |
302 DCHECK(CalledOnValidThread()); | 301 DCHECK(CalledOnValidThread()); |
303 DCHECK(size.width() >= 0 && size.height() >= 0); | 302 DCHECK(size.width() >= 0 && size.height() >= 0); |
304 TRACE_EVENT2("gpu", "RendererGLContext::Initialize", | 303 TRACE_EVENT2("gpu", "ContentGLContext::Initialize", |
305 "on_screen", onscreen, "num_pixels", size.GetArea()); | 304 "on_screen", onscreen, "num_pixels", size.GetArea()); |
306 | 305 |
307 if (channel_->state() != GpuChannelHost::kConnected) | 306 if (channel_->state() != GpuChannelHost::kConnected) |
308 return false; | 307 return false; |
309 | 308 |
310 // Ensure the gles2 library is initialized first in a thread safe way. | 309 // Ensure the gles2 library is initialized first in a thread safe way. |
311 g_gles2_initializer.Get(); | 310 g_gles2_initializer.Get(); |
312 | 311 |
313 bool share_resources = true; | 312 bool share_resources = true; |
314 bool bind_generates_resources = true; | 313 bool bind_generates_resources = true; |
(...skipping 27 matching lines...) Expand all Loading... | |
342 last_error_ = BAD_ATTRIBUTE; | 341 last_error_ = BAD_ATTRIBUTE; |
343 attribs.push_back(NONE); | 342 attribs.push_back(NONE); |
344 attrib_list = NULL; | 343 attrib_list = NULL; |
345 break; | 344 break; |
346 } | 345 } |
347 } | 346 } |
348 | 347 |
349 // Create a proxy to a command buffer in the GPU process. | 348 // Create a proxy to a command buffer in the GPU process. |
350 if (onscreen) { | 349 if (onscreen) { |
351 TRACE_EVENT0("gpu", | 350 TRACE_EVENT0("gpu", |
352 "RendererGLContext::Initialize::CreateViewCommandBuffer"); | 351 "ContentGLContext::Initialize::CreateViewCommandBuffer"); |
353 command_buffer_ = channel_->CreateViewCommandBuffer( | 352 command_buffer_ = channel_->CreateViewCommandBuffer( |
354 surface_id, | 353 surface_id, |
355 share_group ? share_group->command_buffer_ : NULL, | 354 share_group ? share_group->command_buffer_ : NULL, |
356 allowed_extensions, | 355 allowed_extensions, |
357 attribs, | 356 attribs, |
358 active_url, | 357 active_url, |
359 gpu_preference); | 358 gpu_preference); |
360 } else { | 359 } else { |
361 command_buffer_ = channel_->CreateOffscreenCommandBuffer( | 360 command_buffer_ = channel_->CreateOffscreenCommandBuffer( |
362 size, | 361 size, |
363 share_group ? share_group->command_buffer_ : NULL, | 362 share_group ? share_group->command_buffer_ : NULL, |
364 allowed_extensions, | 363 allowed_extensions, |
365 attribs, | 364 attribs, |
366 active_url, | 365 active_url, |
367 gpu_preference); | 366 gpu_preference); |
368 } | 367 } |
369 if (!command_buffer_) { | 368 if (!command_buffer_) { |
370 Destroy(); | 369 Destroy(); |
371 return false; | 370 return false; |
372 } | 371 } |
373 | 372 |
374 { | 373 { |
375 TRACE_EVENT0("gpu", | 374 TRACE_EVENT0("gpu", |
376 "RendererGLContext::Initialize::InitializeCommandBuffer"); | 375 "ContentGLContext::Initialize::InitializeCommandBuffer"); |
377 // Initiaize the command buffer. | 376 // Initiaize the command buffer. |
378 if (!command_buffer_->Initialize()) { | 377 if (!command_buffer_->Initialize()) { |
379 Destroy(); | 378 Destroy(); |
380 return false; | 379 return false; |
381 } | 380 } |
382 } | 381 } |
383 | 382 |
384 command_buffer_->SetChannelErrorCallback( | 383 command_buffer_->SetChannelErrorCallback( |
385 base::Bind(&RendererGLContext::OnContextLost, base::Unretained(this))); | 384 base::Bind(&ContentGLContext::OnContextLost, base::Unretained(this))); |
386 | 385 |
387 // Create the GLES2 helper, which writes the command buffer protocol. | 386 // Create the GLES2 helper, which writes the command buffer protocol. |
388 gles2_helper_ = new gpu::gles2::GLES2CmdHelper(command_buffer_); | 387 gles2_helper_ = new gpu::gles2::GLES2CmdHelper(command_buffer_); |
389 if (!gles2_helper_->Initialize(kCommandBufferSize)) { | 388 if (!gles2_helper_->Initialize(kCommandBufferSize)) { |
390 Destroy(); | 389 Destroy(); |
391 return false; | 390 return false; |
392 } | 391 } |
393 | 392 |
394 { | 393 { |
395 TRACE_EVENT0("gpu", "RendererGLContext::Initialize::CreateTransferBuffer"); | 394 TRACE_EVENT0("gpu", "ContentGLContext::Initialize::CreateTransferBuffer"); |
396 // Create a transfer buffer used to copy resources between the renderer | 395 // Create a transfer buffer used to copy resources between the renderer |
397 // process and the GPU process. | 396 // process and the GPU process. |
398 transfer_buffer_ = new gpu::TransferBuffer(gles2_helper_); | 397 transfer_buffer_ = new gpu::TransferBuffer(gles2_helper_); |
399 } | 398 } |
400 | 399 |
401 // Create the object exposing the OpenGL API. | 400 // Create the object exposing the OpenGL API. |
402 gles2_implementation_ = new gpu::gles2::GLES2Implementation( | 401 gles2_implementation_ = new gpu::gles2::GLES2Implementation( |
403 gles2_helper_, | 402 gles2_helper_, |
404 transfer_buffer_, | 403 transfer_buffer_, |
405 share_resources, | 404 share_resources, |
406 bind_generates_resources); | 405 bind_generates_resources); |
407 | 406 |
408 if (!gles2_implementation_->Initialize( | 407 if (!gles2_implementation_->Initialize( |
409 kStartTransferBufferSize, | 408 kStartTransferBufferSize, |
410 kMinTransferBufferSize, | 409 kMinTransferBufferSize, |
411 kMaxTransferBufferSize)) { | 410 kMaxTransferBufferSize)) { |
412 Destroy(); | 411 Destroy(); |
413 return false; | 412 return false; |
414 } | 413 } |
415 | 414 |
416 return true; | 415 return true; |
417 } | 416 } |
418 | 417 |
419 void RendererGLContext::Destroy() { | 418 void ContentGLContext::Destroy() { |
420 TRACE_EVENT0("gpu", "RendererGLContext::Destroy"); | 419 TRACE_EVENT0("gpu", "ContentGLContext::Destroy"); |
421 DCHECK(CalledOnValidThread()); | 420 DCHECK(CalledOnValidThread()); |
422 SetParent(NULL); | 421 SetParent(NULL); |
423 | 422 |
424 if (gles2_implementation_) { | 423 if (gles2_implementation_) { |
425 // First flush the context to ensure that any pending frees of resources | 424 // First flush the context to ensure that any pending frees of resources |
426 // are completed. Otherwise, if this context is part of a share group, | 425 // are completed. Otherwise, if this context is part of a share group, |
427 // those resources might leak. Also, any remaining side effects of commands | 426 // those resources might leak. Also, any remaining side effects of commands |
428 // issued on this context might not be visible to other contexts in the | 427 // issued on this context might not be visible to other contexts in the |
429 // share group. | 428 // share group. |
430 gles2_implementation_->Flush(); | 429 gles2_implementation_->Flush(); |
(...skipping 11 matching lines...) Expand all Loading... | |
442 gles2_helper_ = NULL; | 441 gles2_helper_ = NULL; |
443 | 442 |
444 if (channel_ && command_buffer_) { | 443 if (channel_ && command_buffer_) { |
445 channel_->DestroyCommandBuffer(command_buffer_); | 444 channel_->DestroyCommandBuffer(command_buffer_); |
446 command_buffer_ = NULL; | 445 command_buffer_ = NULL; |
447 } | 446 } |
448 | 447 |
449 channel_ = NULL; | 448 channel_ = NULL; |
450 } | 449 } |
451 | 450 |
452 void RendererGLContext::OnContextLost() { | 451 void ContentGLContext::OnContextLost() { |
453 if (!context_lost_callback_.is_null()) { | 452 if (!context_lost_callback_.is_null()) { |
454 RendererGLContext::ContextLostReason reason = kUnknown; | 453 ContentGLContext::ContextLostReason reason = kUnknown; |
455 if (command_buffer_) { | 454 if (command_buffer_) { |
456 reason = ConvertReason( | 455 reason = ConvertReason( |
457 command_buffer_->GetLastState().context_lost_reason); | 456 command_buffer_->GetLastState().context_lost_reason); |
458 } | 457 } |
459 context_lost_callback_.Run(reason); | 458 context_lost_callback_.Run(reason); |
460 } | 459 } |
461 } | 460 } |
OLD | NEW |