| OLD | NEW | 
|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/renderer/gpu/renderer_gl_context.h" | 
| 6 | 6 | 
| 7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" | 
| 8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" | 
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" | 
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" | 
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 148     base::LINKER_INITIALIZED); | 148     base::LINKER_INITIALIZED); | 
| 149 | 149 | 
| 150 }  // namespace anonymous | 150 }  // namespace anonymous | 
| 151 | 151 | 
| 152 RendererGLContext::~RendererGLContext() { | 152 RendererGLContext::~RendererGLContext() { | 
| 153   Destroy(); | 153   Destroy(); | 
| 154 } | 154 } | 
| 155 | 155 | 
| 156 RendererGLContext* RendererGLContext::CreateViewContext( | 156 RendererGLContext* RendererGLContext::CreateViewContext( | 
| 157     GpuChannelHost* channel, | 157     GpuChannelHost* channel, | 
| 158     gfx::PluginWindowHandle render_surface, |  | 
| 159     int render_view_id, | 158     int render_view_id, | 
| 160     const char* allowed_extensions, | 159     const char* allowed_extensions, | 
| 161     const int32* attrib_list, | 160     const int32* attrib_list, | 
| 162     const GURL& active_url) { | 161     const GURL& active_url) { | 
| 163 #if defined(ENABLE_GPU) | 162 #if defined(ENABLE_GPU) | 
| 164   scoped_ptr<RendererGLContext> context(new RendererGLContext(channel)); | 163   scoped_ptr<RendererGLContext> context(new RendererGLContext(channel)); | 
| 165   if (!context->Initialize( | 164   if (!context->Initialize( | 
| 166       true, | 165       true, | 
| 167       render_surface, |  | 
| 168       render_view_id, | 166       render_view_id, | 
| 169       gfx::Size(), | 167       gfx::Size(), | 
| 170       allowed_extensions, | 168       allowed_extensions, | 
| 171       attrib_list, | 169       attrib_list, | 
| 172       active_url)) | 170       active_url)) | 
| 173     return NULL; | 171     return NULL; | 
| 174 | 172 | 
| 175   return context.release(); | 173   return context.release(); | 
| 176 #else | 174 #else | 
| 177   return NULL; | 175   return NULL; | 
| (...skipping 11 matching lines...) Expand all  Loading... | 
| 189 RendererGLContext* RendererGLContext::CreateOffscreenContext( | 187 RendererGLContext* RendererGLContext::CreateOffscreenContext( | 
| 190     GpuChannelHost* channel, | 188     GpuChannelHost* channel, | 
| 191     const gfx::Size& size, | 189     const gfx::Size& size, | 
| 192     const char* allowed_extensions, | 190     const char* allowed_extensions, | 
| 193     const int32* attrib_list, | 191     const int32* attrib_list, | 
| 194     const GURL& active_url) { | 192     const GURL& active_url) { | 
| 195 #if defined(ENABLE_GPU) | 193 #if defined(ENABLE_GPU) | 
| 196   scoped_ptr<RendererGLContext> context(new RendererGLContext(channel)); | 194   scoped_ptr<RendererGLContext> context(new RendererGLContext(channel)); | 
| 197   if (!context->Initialize( | 195   if (!context->Initialize( | 
| 198       false, | 196       false, | 
| 199       gfx::kNullPluginWindow, |  | 
| 200       0, | 197       0, | 
| 201       size, | 198       size, | 
| 202       allowed_extensions, | 199       allowed_extensions, | 
| 203       attrib_list, | 200       attrib_list, | 
| 204       active_url)) | 201       active_url)) | 
| 205     return NULL; | 202     return NULL; | 
| 206 | 203 | 
| 207   return context.release(); | 204   return context.release(); | 
| 208 #else | 205 #else | 
| 209   return NULL; | 206   return NULL; | 
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 390       command_buffer_(NULL), | 387       command_buffer_(NULL), | 
| 391       gles2_helper_(NULL), | 388       gles2_helper_(NULL), | 
| 392       transfer_buffer_id_(-1), | 389       transfer_buffer_id_(-1), | 
| 393       gles2_implementation_(NULL), | 390       gles2_implementation_(NULL), | 
| 394       last_error_(SUCCESS), | 391       last_error_(SUCCESS), | 
| 395       frame_number_(0) { | 392       frame_number_(0) { | 
| 396   DCHECK(channel); | 393   DCHECK(channel); | 
| 397 } | 394 } | 
| 398 | 395 | 
| 399 bool RendererGLContext::Initialize(bool onscreen, | 396 bool RendererGLContext::Initialize(bool onscreen, | 
| 400                                    gfx::PluginWindowHandle render_surface, |  | 
| 401                                    int render_view_id, | 397                                    int render_view_id, | 
| 402                                    const gfx::Size& size, | 398                                    const gfx::Size& size, | 
| 403                                    const char* allowed_extensions, | 399                                    const char* allowed_extensions, | 
| 404                                    const int32* attrib_list, | 400                                    const int32* attrib_list, | 
| 405                                    const GURL& active_url) { | 401                                    const GURL& active_url) { | 
| 406   DCHECK(size.width() >= 0 && size.height() >= 0); | 402   DCHECK(size.width() >= 0 && size.height() >= 0); | 
| 407   TRACE_EVENT2("gpu", "RendererGLContext::Initialize", | 403   TRACE_EVENT2("gpu", "RendererGLContext::Initialize", | 
| 408                    "on_screen", onscreen, "num_pixels", size.GetArea()); | 404                    "on_screen", onscreen, "num_pixels", size.GetArea()); | 
| 409 | 405 | 
| 410   if (channel_->state() != GpuChannelHost::kConnected) | 406   if (channel_->state() != GpuChannelHost::kConnected) | 
| (...skipping 25 matching lines...) Expand all  Loading... | 
| 436       default: | 432       default: | 
| 437         last_error_ = BAD_ATTRIBUTE; | 433         last_error_ = BAD_ATTRIBUTE; | 
| 438         attribs.push_back(NONE); | 434         attribs.push_back(NONE); | 
| 439         attrib_list = NULL; | 435         attrib_list = NULL; | 
| 440         break; | 436         break; | 
| 441     } | 437     } | 
| 442   } | 438   } | 
| 443 | 439 | 
| 444   // Create a proxy to a command buffer in the GPU process. | 440   // Create a proxy to a command buffer in the GPU process. | 
| 445   if (onscreen) { | 441   if (onscreen) { | 
| 446     if (render_surface == gfx::kNullPluginWindow) { | 442     TRACE_EVENT0("gpu", | 
| 447       LOG(ERROR) << "Invalid surface handle for onscreen context."; | 443                  "RendererGLContext::Initialize::CreateViewCommandBuffer"); | 
| 448       command_buffer_ = NULL; | 444     command_buffer_ = channel_->CreateViewCommandBuffer( | 
| 449     } else { | 445         render_view_id, | 
| 450       TRACE_EVENT0("gpu", | 446         allowed_extensions, | 
| 451                    "RendererGLContext::Initialize::CreateViewCommandBuffer"); | 447         attribs, | 
| 452       command_buffer_ = channel_->CreateViewCommandBuffer( | 448         active_url); | 
| 453           render_surface, |  | 
| 454           render_view_id, |  | 
| 455           allowed_extensions, |  | 
| 456           attribs, |  | 
| 457           active_url); |  | 
| 458     } |  | 
| 459   } else { | 449   } else { | 
| 460     command_buffer_ = channel_->CreateOffscreenCommandBuffer( | 450     command_buffer_ = channel_->CreateOffscreenCommandBuffer( | 
| 461         size, | 451         size, | 
| 462         allowed_extensions, | 452         allowed_extensions, | 
| 463         attribs, | 453         attribs, | 
| 464         active_url); | 454         active_url); | 
| 465   } | 455   } | 
| 466   if (!command_buffer_) { | 456   if (!command_buffer_) { | 
| 467     Destroy(); | 457     Destroy(); | 
| 468     return false; | 458     return false; | 
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 597 | 587 | 
| 598 bool RendererGLContext::GetParentToChildLatch(uint32* parent_to_child_latch) { | 588 bool RendererGLContext::GetParentToChildLatch(uint32* parent_to_child_latch) { | 
| 599   *parent_to_child_latch = parent_to_child_latch_; | 589   *parent_to_child_latch = parent_to_child_latch_; | 
| 600   return true; | 590   return true; | 
| 601 } | 591 } | 
| 602 | 592 | 
| 603 bool RendererGLContext::GetChildToParentLatch(uint32* child_to_parent_latch) { | 593 bool RendererGLContext::GetChildToParentLatch(uint32* child_to_parent_latch) { | 
| 604   *child_to_parent_latch = child_to_parent_latch_; | 594   *child_to_parent_latch = child_to_parent_latch_; | 
| 605   return true; | 595   return true; | 
| 606 } | 596 } | 
| OLD | NEW | 
|---|