| OLD | NEW |
| 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 #if defined(ENABLE_GPU) | 5 #if defined(ENABLE_GPU) |
| 6 | 6 |
| 7 #include "chrome/renderer/webgles2context_impl.h" | 7 #include "chrome/renderer/webgles2context_impl.h" |
| 8 | 8 |
| 9 #include "chrome/renderer/gpu_channel_host.h" | 9 #include "chrome/renderer/gpu_channel_host.h" |
| 10 #include "chrome/renderer/render_thread.h" | 10 #include "chrome/renderer/render_thread.h" |
| 11 #include "chrome/renderer/render_view.h" | 11 #include "chrome/renderer/render_view.h" |
| 12 #include "third_party/WebKit/WebKit/chromium/public/WebView.h" | 12 #include "third_party/WebKit/WebKit/chromium/public/WebView.h" |
| 13 | 13 |
| 14 | 14 |
| 15 WebGLES2ContextImpl::WebGLES2ContextImpl() : context_(NULL) { | 15 WebGLES2ContextImpl::WebGLES2ContextImpl() |
| 16 : context_(NULL) |
| 17 #if defined(OS_MACOSX) |
| 18 , plugin_handle_(gfx::kNullPluginWindow) |
| 19 , web_view_(NULL) |
| 20 #endif |
| 21 { |
| 16 } | 22 } |
| 17 | 23 |
| 18 WebGLES2ContextImpl::~WebGLES2ContextImpl() { | 24 WebGLES2ContextImpl::~WebGLES2ContextImpl() { |
| 19 destroy(); | 25 destroy(); |
| 20 } | 26 } |
| 21 | 27 |
| 22 // TODO(vangelis): Remove once the method is removed from the WebGLES2Context. | 28 // TODO(vangelis): Remove once the method is removed from the WebGLES2Context. |
| 23 bool WebGLES2ContextImpl::initialize(WebKit::WebView* web_view) { | 29 bool WebGLES2ContextImpl::initialize(WebKit::WebView* web_view) { |
| 24 return initialize(web_view, NULL); | 30 return initialize(web_view, NULL); |
| 25 } | 31 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 42 // into the window used by the WebView, otherwise create an offscreen | 48 // into the window used by the WebView, otherwise create an offscreen |
| 43 // context. | 49 // context. |
| 44 if (web_view) { | 50 if (web_view) { |
| 45 RenderView* renderview = RenderView::FromWebView(web_view); | 51 RenderView* renderview = RenderView::FromWebView(web_view); |
| 46 if (!renderview) | 52 if (!renderview) |
| 47 return false; | 53 return false; |
| 48 gfx::NativeViewId view_id; | 54 gfx::NativeViewId view_id; |
| 49 #if !defined(OS_MACOSX) | 55 #if !defined(OS_MACOSX) |
| 50 view_id = renderview->host_window(); | 56 view_id = renderview->host_window(); |
| 51 #else | 57 #else |
| 52 view_id = static_cast<gfx::NativeViewId>( | 58 plugin_handle_ = renderview->AllocateFakePluginWindowHandle(true, true); |
| 53 renderview->AllocateFakePluginWindowHandle(true, true)); | 59 web_view_ = web_view; |
| 60 view_id = static_cast<gfx::NativeViewId>(plugin_handle_); |
| 54 #endif | 61 #endif |
| 55 context_ = ggl::CreateViewContext( | 62 context_ = ggl::CreateViewContext( |
| 56 host, view_id, | 63 host, view_id, |
| 57 renderview->routing_id()); | 64 renderview->routing_id()); |
| 58 } else { | 65 } else { |
| 59 ggl::Context* parent_context = NULL; | 66 ggl::Context* parent_context = NULL; |
| 60 | 67 |
| 61 if (parent) { | 68 if (parent) { |
| 62 WebGLES2ContextImpl* parent_context_impl = | 69 WebGLES2ContextImpl* parent_context_impl = |
| 63 static_cast<WebGLES2ContextImpl*>(parent); | 70 static_cast<WebGLES2ContextImpl*>(parent); |
| 64 parent_context = parent_context_impl->context(); | 71 parent_context = parent_context_impl->context(); |
| 65 DCHECK(parent_context); | 72 DCHECK(parent_context); |
| 66 } | 73 } |
| 67 context_ = ggl::CreateOffscreenContext(host, parent_context, | 74 context_ = ggl::CreateOffscreenContext(host, parent_context, |
| 68 gfx::Size(1, 1)); | 75 gfx::Size(1, 1)); |
| 69 } | 76 } |
| 70 | 77 |
| 71 return (context_ != NULL); | 78 return (context_ != NULL); |
| 72 } | 79 } |
| 73 | 80 |
| 74 bool WebGLES2ContextImpl::makeCurrent() { | 81 bool WebGLES2ContextImpl::makeCurrent() { |
| 75 return ggl::MakeCurrent(context_); | 82 return ggl::MakeCurrent(context_); |
| 76 } | 83 } |
| 77 | 84 |
| 78 bool WebGLES2ContextImpl::destroy() { | 85 bool WebGLES2ContextImpl::destroy() { |
| 86 #if defined(OS_MACOSX) |
| 87 RenderView* renderview = RenderView::FromWebView(web_view_); |
| 88 DCHECK(plugin_handle_ == gfx::kNullPluginWindow || renderview); |
| 89 if (plugin_handle_ != gfx::kNullPluginWindow && renderview) |
| 90 renderview->DestroyFakePluginWindowHandle(plugin_handle_); |
| 91 plugin_handle_ = gfx::kNullPluginWindow; |
| 92 #endif |
| 79 return ggl::DestroyContext(context_); | 93 return ggl::DestroyContext(context_); |
| 80 } | 94 } |
| 81 | 95 |
| 82 bool WebGLES2ContextImpl::swapBuffers() { | 96 bool WebGLES2ContextImpl::swapBuffers() { |
| 83 return ggl::SwapBuffers(context_); | 97 return ggl::SwapBuffers(context_); |
| 84 } | 98 } |
| 85 | 99 |
| 86 void WebGLES2ContextImpl::resizeOffscreenContent(const WebKit::WebSize& size) { | 100 void WebGLES2ContextImpl::resizeOffscreenContent(const WebKit::WebSize& size) { |
| 87 ggl::ResizeOffscreenContext(context_, size); | 101 ggl::ResizeOffscreenContext(context_, size); |
| 88 } | 102 } |
| 89 | 103 |
| 90 unsigned WebGLES2ContextImpl::getOffscreenContentParentTextureId() { | 104 unsigned WebGLES2ContextImpl::getOffscreenContentParentTextureId() { |
| 91 return ggl::GetParentTextureId(context_); | 105 return ggl::GetParentTextureId(context_); |
| 92 } | 106 } |
| 93 | 107 |
| 94 #if defined(OS_MACOSX) | 108 #if defined(OS_MACOSX) |
| 95 void WebGLES2ContextImpl::resizeOnscreenContent(const WebKit::WebSize& size) { | 109 void WebGLES2ContextImpl::resizeOnscreenContent(const WebKit::WebSize& size) { |
| 96 ggl::ResizeOnscreenContext(context_, size); | 110 ggl::ResizeOnscreenContext(context_, size); |
| 97 } | 111 } |
| 98 #endif | 112 #endif |
| 99 | 113 |
| 100 #endif // defined(ENABLE_GPU) | 114 #endif // defined(ENABLE_GPU) |
| 101 | 115 |
| OLD | NEW |