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

Side by Side Diff: content/renderer/browser_plugin/browser_plugin_compositing_helper.cc

Issue 12483002: browser plugin: Get the offscreen shared context from RenderThreadImpl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/browser_plugin/browser_plugin_compositing_helper.h" 5 #include "content/renderer/browser_plugin/browser_plugin_compositing_helper.h"
6 6
7 #include "cc/context_provider.h"
7 #include "cc/solid_color_layer.h" 8 #include "cc/solid_color_layer.h"
8 #include "cc/texture_layer.h" 9 #include "cc/texture_layer.h"
9 #include "content/common/browser_plugin/browser_plugin_messages.h" 10 #include "content/common/browser_plugin/browser_plugin_messages.h"
10 #include "content/renderer/browser_plugin/browser_plugin_manager.h" 11 #include "content/renderer/browser_plugin/browser_plugin_manager.h"
11 #include "content/renderer/render_thread_impl.h" 12 #include "content/renderer/render_thread_impl.h"
12 #include "third_party/khronos/GLES2/gl2.h" 13 #include "third_party/khronos/GLES2/gl2.h"
13 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3 D.h" 14 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3 D.h"
14 #include "third_party/WebKit/Source/Platform/chromium/public/WebSharedGraphicsCo ntext3D.h"
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h"
16 #include "ui/gfx/size_conversions.h" 16 #include "ui/gfx/size_conversions.h"
17 #include "webkit/compositor_bindings/web_layer_impl.h" 17 #include "webkit/compositor_bindings/web_layer_impl.h"
18 18
19 namespace content { 19 namespace content {
20 20
21 BrowserPluginCompositingHelper::BrowserPluginCompositingHelper( 21 BrowserPluginCompositingHelper::BrowserPluginCompositingHelper(
22 WebKit::WebPluginContainer* container, 22 WebKit::WebPluginContainer* container,
23 BrowserPluginManager* manager, 23 BrowserPluginManager* manager,
24 int instance_id, 24 int instance_id,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 // To free the mailbox memory, we need a context to consume it 60 // To free the mailbox memory, we need a context to consume it
61 // into a texture ID and then delete this texture ID. 61 // into a texture ID and then delete this texture ID.
62 // We use a shared graphics context accessible from the main 62 // We use a shared graphics context accessible from the main
63 // thread to do it. 63 // thread to do it.
64 void BrowserPluginCompositingHelper::FreeMailboxMemory( 64 void BrowserPluginCompositingHelper::FreeMailboxMemory(
65 const std::string& mailbox_name, 65 const std::string& mailbox_name,
66 unsigned sync_point) { 66 unsigned sync_point) {
67 if (mailbox_name.empty()) 67 if (mailbox_name.empty())
68 return; 68 return;
69 69
70 WebKit::WebGraphicsContext3D *context = 70 scoped_refptr<cc::ContextProvider> context_provider =
71 WebKit::WebSharedGraphicsContext3D::mainThreadContext(); 71 RenderThreadImpl::current()->OffscreenContextProviderForMainThread();
72 if (!context) 72 if (!context_provider->InitializeOnMainThread())
73 return; 73 return;
74 if (!context_provider->BindToCurrentThread())
75 return;
76
77 WebKit::WebGraphicsContext3D *context = context_provider->Context3d();
74 // When a buffer is released from the compositor, we also get a 78 // When a buffer is released from the compositor, we also get a
75 // sync point that specifies when in the command buffer 79 // sync point that specifies when in the command buffer
76 // it's safe to use it again. 80 // it's safe to use it again.
77 // If the sync point is non-zero, we need to tell our context 81 // If the sync point is non-zero, we need to tell our context
78 // to wait until this sync point is reached before we can safely 82 // to wait until this sync point is reached before we can safely
79 // delete the buffer. 83 // delete the buffer.
80 if (sync_point) 84 if (sync_point)
81 context->waitSyncPoint(sync_point); 85 context->waitSyncPoint(sync_point);
82 86
83 unsigned texture_id = context->createTexture(); 87 unsigned texture_id = context->createTexture();
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 callback)); 221 callback));
218 last_mailbox_valid_ = current_mailbox_valid; 222 last_mailbox_valid_ = current_mailbox_valid;
219 } 223 }
220 224
221 void BrowserPluginCompositingHelper::UpdateVisibility(bool visible) { 225 void BrowserPluginCompositingHelper::UpdateVisibility(bool visible) {
222 if (texture_layer_) 226 if (texture_layer_)
223 texture_layer_->setIsDrawable(visible); 227 texture_layer_->setIsDrawable(visible);
224 } 228 }
225 229
226 } // namespace content 230 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698