| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // This include must be here so that the includes provided transitively | 5 // This include must be here so that the includes provided transitively |
| 6 // by gl_surface_egl.h don't make it impossible to compile this code. | 6 // by gl_surface_egl.h don't make it impossible to compile this code. |
| 7 #include "third_party/mesa/src/include/GL/osmesa.h" | 7 #include "third_party/mesa/src/include/GL/osmesa.h" |
| 8 | 8 |
| 9 #include "ui/gl/gl_surface_egl.h" | 9 #include "ui/gl/gl_surface_egl.h" |
| 10 | 10 |
| (...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 #endif | 482 #endif |
| 483 } | 483 } |
| 484 | 484 |
| 485 void NativeViewGLSurfaceEGL::SetHandle(EGLSurface surface) { | 485 void NativeViewGLSurfaceEGL::SetHandle(EGLSurface surface) { |
| 486 surface_ = surface; | 486 surface_ = surface; |
| 487 } | 487 } |
| 488 | 488 |
| 489 PbufferGLSurfaceEGL::PbufferGLSurfaceEGL(const gfx::Size& size) | 489 PbufferGLSurfaceEGL::PbufferGLSurfaceEGL(const gfx::Size& size) |
| 490 : size_(size), | 490 : size_(size), |
| 491 surface_(NULL) { | 491 surface_(NULL) { |
| 492 // Some implementations of Pbuffer do not support having a 0 size. For such |
| 493 // cases use a (1, 1) surface. |
| 494 if (size_.GetArea() == 0) |
| 495 size_.SetSize(1, 1); |
| 492 } | 496 } |
| 493 | 497 |
| 494 bool PbufferGLSurfaceEGL::Initialize() { | 498 bool PbufferGLSurfaceEGL::Initialize() { |
| 495 EGLSurface old_surface = surface_; | 499 EGLSurface old_surface = surface_; |
| 496 | 500 |
| 497 EGLDisplay display = GetDisplay(); | 501 EGLDisplay display = GetDisplay(); |
| 498 if (!display) { | 502 if (!display) { |
| 499 LOG(ERROR) << "Trying to create surface with invalid display."; | 503 LOG(ERROR) << "Trying to create surface with invalid display."; |
| 500 return false; | 504 return false; |
| 501 } | 505 } |
| 502 | 506 |
| 503 if (size_.GetArea() == 0) { | |
| 504 LOG(ERROR) << "Error: surface has zero area " | |
| 505 << size_.width() << " x " << size_.height(); | |
| 506 return false; | |
| 507 } | |
| 508 | |
| 509 // Allocate the new pbuffer surface before freeing the old one to ensure | 507 // Allocate the new pbuffer surface before freeing the old one to ensure |
| 510 // they have different addresses. If they have the same address then a | 508 // they have different addresses. If they have the same address then a |
| 511 // future call to MakeCurrent might early out because it appears the current | 509 // future call to MakeCurrent might early out because it appears the current |
| 512 // context and surface have not changed. | 510 // context and surface have not changed. |
| 513 const EGLint pbuffer_attribs[] = { | 511 const EGLint pbuffer_attribs[] = { |
| 514 EGL_WIDTH, size_.width(), | 512 EGL_WIDTH, size_.width(), |
| 515 EGL_HEIGHT, size_.height(), | 513 EGL_HEIGHT, size_.height(), |
| 516 EGL_NONE | 514 EGL_NONE |
| 517 }; | 515 }; |
| 518 | 516 |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 651 } | 649 } |
| 652 | 650 |
| 653 void* SurfacelessEGL::GetShareHandle() { | 651 void* SurfacelessEGL::GetShareHandle() { |
| 654 return NULL; | 652 return NULL; |
| 655 } | 653 } |
| 656 | 654 |
| 657 SurfacelessEGL::~SurfacelessEGL() { | 655 SurfacelessEGL::~SurfacelessEGL() { |
| 658 } | 656 } |
| 659 | 657 |
| 660 } // namespace gfx | 658 } // namespace gfx |
| OLD | NEW |