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

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

Issue 7530010: Added PPB_Graphics3D_Dev::Resize to let plugins resize the backing surface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 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 | « content/renderer/pepper_platform_context_3d_impl.h ('k') | ppapi/c/dev/ppb_graphics_3d_dev.h » ('j') | 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) 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/pepper_platform_context_3d_impl.h" 5 #include "content/renderer/pepper_platform_context_3d_impl.h"
6 6
7 #include "content/renderer/render_thread.h" 7 #include "content/renderer/render_thread.h"
8 #include "content/renderer/gpu/renderer_gl_context.h" 8 #include "content/renderer/gpu/renderer_gl_context.h"
9 #include "content/renderer/gpu/gpu_channel_host.h" 9 #include "content/renderer/gpu/gpu_channel_host.h"
10 #include "content/renderer/gpu/command_buffer_proxy.h" 10 #include "content/renderer/gpu/command_buffer_proxy.h"
(...skipping 22 matching lines...) Expand all
33 33
34 if (command_buffer_) { 34 if (command_buffer_) {
35 DCHECK(channel_.get()); 35 DCHECK(channel_.get());
36 channel_->DestroyCommandBuffer(command_buffer_); 36 channel_->DestroyCommandBuffer(command_buffer_);
37 command_buffer_ = NULL; 37 command_buffer_ = NULL;
38 } 38 }
39 39
40 channel_ = NULL; 40 channel_ = NULL;
41 } 41 }
42 42
43 bool PlatformContext3DImpl::Init() { 43 bool PlatformContext3DImpl::Init(const int32* attrib_list) {
44 // Ignore initializing more than once. 44 // Ignore initializing more than once.
45 if (command_buffer_) 45 if (command_buffer_)
46 return true; 46 return true;
47 47
48 // Parent may already have been deleted. 48 // Parent may already have been deleted.
49 if (!parent_context_.get()) 49 if (!parent_context_.get())
50 return false; 50 return false;
51 51
52 RenderThread* render_thread = RenderThread::current(); 52 RenderThread* render_thread = RenderThread::current();
53 if (!render_thread) 53 if (!render_thread)
54 return false; 54 return false;
55 55
56 channel_ = render_thread->GetGpuChannel(); 56 channel_ = render_thread->GetGpuChannel();
57 if (!channel_.get()) 57 if (!channel_.get())
58 return false; 58 return false;
59 59
60 DCHECK(channel_->state() == GpuChannelHost::kConnected); 60 DCHECK(channel_->state() == GpuChannelHost::kConnected);
61 61
62 // Flush any remaining commands in the parent context to make sure the 62 // Flush any remaining commands in the parent context to make sure the
63 // texture id accounting stays consistent. 63 // texture id accounting stays consistent.
64 gpu::gles2::GLES2Implementation* parent_gles2 = 64 gpu::gles2::GLES2Implementation* parent_gles2 =
65 parent_context_->GetImplementation(); 65 parent_context_->GetImplementation();
66 parent_gles2->helper()->CommandBufferHelper::Finish(); 66 parent_gles2->helper()->CommandBufferHelper::Finish();
67 parent_texture_id_ = parent_gles2->MakeTextureId(); 67 parent_texture_id_ = parent_gles2->MakeTextureId();
68 68
69 // TODO(apatrick): Let Pepper plugins configure their back buffer surface. 69 gfx::Size surface_size;
70 static const int32 kAttribs[] = { 70 std::vector<int32> attribs;
71 RendererGLContext::ALPHA_SIZE, 8, 71 // TODO(alokp): Change GpuChannelHost::CreateOffscreenCommandBuffer()
72 RendererGLContext::DEPTH_SIZE, 24, 72 // interface to accept width and height in the attrib_list so that
73 RendererGLContext::STENCIL_SIZE, 8, 73 // we do not need to filter for width and height here.
74 RendererGLContext::SAMPLES, 0, 74 if (attrib_list) {
75 RendererGLContext::SAMPLE_BUFFERS, 0, 75 for (const int32_t* attr = attrib_list;
76 RendererGLContext::NONE, 76 attr[0] != RendererGLContext::NONE;
77 }; 77 attr += 2) {
78 std::vector<int32> attribs(kAttribs, kAttribs + ARRAYSIZE_UNSAFE(kAttribs)); 78 switch (attr[0]) {
79 case RendererGLContext::WIDTH:
80 surface_size.set_width(attr[1]);
81 break;
82 case RendererGLContext::HEIGHT:
83 surface_size.set_height(attr[1]);
84 break;
85 default:
86 attribs.push_back(attr[0]);
87 attribs.push_back(attr[1]);
88 break;
89 }
90 }
91 attribs.push_back(RendererGLContext::NONE);
92 }
93
79 CommandBufferProxy* parent_command_buffer = 94 CommandBufferProxy* parent_command_buffer =
80 parent_context_->GetCommandBufferProxy(); 95 parent_context_->GetCommandBufferProxy();
81 command_buffer_ = channel_->CreateOffscreenCommandBuffer( 96 command_buffer_ = channel_->CreateOffscreenCommandBuffer(
82 gfx::Size(1, 1), 97 surface_size,
83 "*", 98 "*",
84 attribs, 99 attribs,
85 GURL::EmptyGURL()); 100 GURL::EmptyGURL());
86 if (!command_buffer_) 101 if (!command_buffer_)
87 return false; 102 return false;
88 103
89 if (!command_buffer_->SetParent(parent_command_buffer, parent_texture_id_)) 104 if (!command_buffer_->SetParent(parent_command_buffer, parent_texture_id_))
90 return false; 105 return false;
91 106
92 command_buffer_->SetChannelErrorCallback(callback_factory_.NewCallback( 107 command_buffer_->SetChannelErrorCallback(callback_factory_.NewCallback(
(...skipping 26 matching lines...) Expand all
119 } 134 }
120 135
121 void PlatformContext3DImpl::OnContextLost() { 136 void PlatformContext3DImpl::OnContextLost() {
122 DCHECK(command_buffer_); 137 DCHECK(command_buffer_);
123 138
124 if (context_lost_callback_.get()) 139 if (context_lost_callback_.get())
125 context_lost_callback_->Run(); 140 context_lost_callback_->Run();
126 } 141 }
127 142
128 #endif // ENABLE_GPU 143 #endif // ENABLE_GPU
OLDNEW
« no previous file with comments | « content/renderer/pepper_platform_context_3d_impl.h ('k') | ppapi/c/dev/ppb_graphics_3d_dev.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698