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

Side by Side Diff: ui/gfx/gl/gl_surface_egl.cc

Issue 8512005: Plumb through EGL_NV_post_sub_buffer and GLX_MESA_copy_sub_buffer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: "" Created 9 years, 1 month 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 "ui/gfx/gl/gl_surface_egl.h" 5 #include "ui/gfx/gl/gl_surface_egl.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "third_party/angle/include/EGL/egl.h" 10 #include "third_party/angle/include/EGL/egl.h"
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 return g_software_display; 166 return g_software_display;
167 } 167 }
168 168
169 EGLNativeDisplayType GLSurfaceEGL::GetNativeDisplay() { 169 EGLNativeDisplayType GLSurfaceEGL::GetNativeDisplay() {
170 return g_native_display; 170 return g_native_display;
171 } 171 }
172 172
173 NativeViewGLSurfaceEGL::NativeViewGLSurfaceEGL(bool software, 173 NativeViewGLSurfaceEGL::NativeViewGLSurfaceEGL(bool software,
174 gfx::PluginWindowHandle window) 174 gfx::PluginWindowHandle window)
175 : window_(window), 175 : window_(window),
176 surface_(NULL) 176 surface_(NULL),
177 supports_post_sub_buffer_(false)
177 { 178 {
178 software_ = software; 179 software_ = software;
179 } 180 }
180 181
181 NativeViewGLSurfaceEGL::~NativeViewGLSurfaceEGL() { 182 NativeViewGLSurfaceEGL::~NativeViewGLSurfaceEGL() {
182 Destroy(); 183 Destroy();
183 } 184 }
184 185
185 bool NativeViewGLSurfaceEGL::Initialize() { 186 bool NativeViewGLSurfaceEGL::Initialize() {
186 DCHECK(!surface_); 187 DCHECK(!surface_);
187 188
188 if (!GetDisplay()) { 189 if (!GetDisplay()) {
189 LOG(ERROR) << "Trying to create surface with invalid display."; 190 LOG(ERROR) << "Trying to create surface with invalid display.";
190 return false; 191 return false;
191 } 192 }
192 193
194 static const EGLint egl_window_attributes_sub_buffer[] = {
195 EGL_POST_SUB_BUFFER_SUPPORTED_NV, EGL_TRUE,
196 EGL_NONE
197 };
198
193 // Create a surface for the native window. 199 // Create a surface for the native window.
194 surface_ = eglCreateWindowSurface(GetDisplay(), 200 surface_ = eglCreateWindowSurface(GetDisplay(),
195 GetConfig(), 201 GetConfig(),
196 window_, 202 window_,
197 NULL); 203 gfx::g_EGL_NV_post_sub_buffer ?
204 egl_window_attributes_sub_buffer :
205 NULL);
198 206
199 if (!surface_) { 207 if (!surface_) {
200 LOG(ERROR) << "eglCreateWindowSurface failed with error " 208 LOG(ERROR) << "eglCreateWindowSurface failed with error "
201 << GetLastEGLErrorString(); 209 << GetLastEGLErrorString();
202 Destroy(); 210 Destroy();
203 return false; 211 return false;
204 } 212 }
205 213
214 EGLint surfaceVal;
215 EGLBoolean retVal = eglQuerySurface(GetDisplay(),
apatrick_chromium 2011/11/10 19:33:16 Is it really the case that if you ask for a surfac
jonathan.backer 2011/11/10 21:00:25 I think so. I was inspired by some ChromeOS WM cod
216 surface_,
217 EGL_POST_SUB_BUFFER_SUPPORTED_NV,
218 &surfaceVal);
219 supports_post_sub_buffer_ = (surfaceVal && retVal) == EGL_TRUE;
220
206 return true; 221 return true;
207 } 222 }
208 223
209 void NativeViewGLSurfaceEGL::Destroy() { 224 void NativeViewGLSurfaceEGL::Destroy() {
210 if (surface_) { 225 if (surface_) {
211 if (!eglDestroySurface(GetDisplay(), surface_)) { 226 if (!eglDestroySurface(GetDisplay(), surface_)) {
212 LOG(ERROR) << "eglDestroySurface failed with error " 227 LOG(ERROR) << "eglDestroySurface failed with error "
213 << GetLastEGLErrorString(); 228 << GetLastEGLErrorString();
214 } 229 }
215 surface_ = NULL; 230 surface_ = NULL;
(...skipping 24 matching lines...) Expand all
240 return gfx::Size(); 255 return gfx::Size();
241 } 256 }
242 257
243 return gfx::Size(width, height); 258 return gfx::Size(width, height);
244 } 259 }
245 260
246 EGLSurface NativeViewGLSurfaceEGL::GetHandle() { 261 EGLSurface NativeViewGLSurfaceEGL::GetHandle() {
247 return surface_; 262 return surface_;
248 } 263 }
249 264
265 bool NativeViewGLSurfaceEGL::SupportsPostSubBuffer() {
266 return supports_post_sub_buffer_;
267 }
268
269 bool NativeViewGLSurfaceEGL::PostSubBuffer(
270 int x, int y, int width, int height) {
271 DCHECK(supports_post_sub_buffer_);
272 return eglPostSubBufferNV(GetDisplay(), surface_, x, y, width, height);
273 }
274
250 PbufferGLSurfaceEGL::PbufferGLSurfaceEGL(bool software, const gfx::Size& size) 275 PbufferGLSurfaceEGL::PbufferGLSurfaceEGL(bool software, const gfx::Size& size)
251 : size_(size), 276 : size_(size),
252 surface_(NULL) { 277 surface_(NULL) {
253 software_ = software; 278 software_ = software;
254 } 279 }
255 280
256 PbufferGLSurfaceEGL::~PbufferGLSurfaceEGL() { 281 PbufferGLSurfaceEGL::~PbufferGLSurfaceEGL() {
257 Destroy(); 282 Destroy();
258 } 283 }
259 284
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 GetHandle(), 355 GetHandle(),
331 EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE, 356 EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE,
332 &handle)) { 357 &handle)) {
333 return NULL; 358 return NULL;
334 } 359 }
335 360
336 return handle; 361 return handle;
337 } 362 }
338 363
339 } // namespace gfx 364 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698