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

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

Issue 9340012: Move gpu client files to content_common, in content/common/gpu/client (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove unneeded enums Created 8 years, 10 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
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 "base/bind.h" 7 #include "base/bind.h"
8 #include "content/common/gpu/client/content_gl_context.h"
9 #include "content/common/gpu/client/gpu_channel_host.h"
10 #include "content/common/gpu/client/command_buffer_proxy.h"
8 #include "content/renderer/pepper_parent_context_provider.h" 11 #include "content/renderer/pepper_parent_context_provider.h"
9 #include "content/renderer/render_thread_impl.h" 12 #include "content/renderer/render_thread_impl.h"
10 #include "content/renderer/gpu/renderer_gl_context.h"
11 #include "content/renderer/gpu/gpu_channel_host.h"
12 #include "content/renderer/gpu/command_buffer_proxy.h"
13 #include "googleurl/src/gurl.h" 13 #include "googleurl/src/gurl.h"
14 #include "gpu/command_buffer/client/gles2_cmd_helper.h" 14 #include "gpu/command_buffer/client/gles2_cmd_helper.h"
15 #include "gpu/command_buffer/client/gles2_implementation.h" 15 #include "gpu/command_buffer/client/gles2_implementation.h"
16 #include "ui/gfx/gl/gpu_preference.h" 16 #include "ui/gfx/gl/gpu_preference.h"
17 17
18 #ifdef ENABLE_GPU 18 #ifdef ENABLE_GPU
19 19
20 PlatformContext3DImpl::PlatformContext3DImpl( 20 PlatformContext3DImpl::PlatformContext3DImpl(
21 PepperParentContextProvider* parent_context_provider) 21 PepperParentContextProvider* parent_context_provider)
22 : parent_context_provider_(parent_context_provider), 22 : parent_context_provider_(parent_context_provider),
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 } 82 }
83 } while (retry); 83 } while (retry);
84 84
85 gfx::Size surface_size; 85 gfx::Size surface_size;
86 std::vector<int32> attribs; 86 std::vector<int32> attribs;
87 // TODO(alokp): Change GpuChannelHost::CreateOffscreenCommandBuffer() 87 // TODO(alokp): Change GpuChannelHost::CreateOffscreenCommandBuffer()
88 // interface to accept width and height in the attrib_list so that 88 // interface to accept width and height in the attrib_list so that
89 // we do not need to filter for width and height here. 89 // we do not need to filter for width and height here.
90 if (attrib_list) { 90 if (attrib_list) {
91 for (const int32_t* attr = attrib_list; 91 for (const int32_t* attr = attrib_list;
92 attr[0] != RendererGLContext::NONE; 92 attr[0] != ContentGLContext::NONE;
93 attr += 2) { 93 attr += 2) {
94 switch (attr[0]) { 94 switch (attr[0]) {
95 case RendererGLContext::WIDTH: 95 case ContentGLContext::WIDTH:
96 surface_size.set_width(attr[1]); 96 surface_size.set_width(attr[1]);
97 break; 97 break;
98 case RendererGLContext::HEIGHT: 98 case ContentGLContext::HEIGHT:
99 surface_size.set_height(attr[1]); 99 surface_size.set_height(attr[1]);
100 break; 100 break;
101 default: 101 default:
102 attribs.push_back(attr[0]); 102 attribs.push_back(attr[0]);
103 attribs.push_back(attr[1]); 103 attribs.push_back(attr[1]);
104 break; 104 break;
105 } 105 }
106 } 106 }
107 attribs.push_back(RendererGLContext::NONE); 107 attribs.push_back(ContentGLContext::NONE);
108 } 108 }
109 109
110 command_buffer_ = channel_->CreateOffscreenCommandBuffer( 110 command_buffer_ = channel_->CreateOffscreenCommandBuffer(
111 surface_size, 111 surface_size,
112 NULL, 112 NULL,
113 "*", 113 "*",
114 attribs, 114 attribs,
115 GURL::EmptyGURL(), 115 GURL::EmptyGURL(),
116 gpu_preference); 116 gpu_preference);
117 if (!command_buffer_) 117 if (!command_buffer_)
118 return false; 118 return false;
119 119
120 command_buffer_->SetChannelErrorCallback( 120 command_buffer_->SetChannelErrorCallback(
121 base::Bind(&PlatformContext3DImpl::OnContextLost, 121 base::Bind(&PlatformContext3DImpl::OnContextLost,
122 weak_ptr_factory_.GetWeakPtr())); 122 weak_ptr_factory_.GetWeakPtr()));
123 123
124 // Fetch the parent context now, after any potential shutdown of the 124 // Fetch the parent context now, after any potential shutdown of the
125 // channel due to GPU switching, and creation of the Pepper 3D 125 // channel due to GPU switching, and creation of the Pepper 3D
126 // context with the discrete GPU preference. 126 // context with the discrete GPU preference.
127 RendererGLContext* parent_context = 127 ContentGLContext* parent_context =
128 parent_context_provider_->GetParentContextForPlatformContext3D(); 128 parent_context_provider_->GetParentContextForPlatformContext3D();
129 if (!parent_context) 129 if (!parent_context)
130 return false; 130 return false;
131 131
132 parent_context_provider_ = NULL; 132 parent_context_provider_ = NULL;
133 parent_context_ = parent_context->AsWeakPtr(); 133 parent_context_ = parent_context->AsWeakPtr();
134 134
135 // Flush any remaining commands in the parent context to make sure the 135 // Flush any remaining commands in the parent context to make sure the
136 // texture id accounting stays consistent. 136 // texture id accounting stays consistent.
137 gpu::gles2::GLES2Implementation* parent_gles2 = 137 gpu::gles2::GLES2Implementation* parent_gles2 =
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 } 170 }
171 171
172 void PlatformContext3DImpl::OnContextLost() { 172 void PlatformContext3DImpl::OnContextLost() {
173 DCHECK(command_buffer_); 173 DCHECK(command_buffer_);
174 174
175 if (!context_lost_callback_.is_null()) 175 if (!context_lost_callback_.is_null())
176 context_lost_callback_.Run(); 176 context_lost_callback_.Run();
177 } 177 }
178 178
179 #endif // ENABLE_GPU 179 #endif // ENABLE_GPU
OLDNEW
« no previous file with comments | « content/renderer/pepper_platform_context_3d_impl.h ('k') | content/renderer/pepper_plugin_delegate_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698