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); | |
496 } | 492 } |
497 | 493 |
498 bool PbufferGLSurfaceEGL::Initialize() { | 494 bool PbufferGLSurfaceEGL::Initialize() { |
499 EGLSurface old_surface = surface_; | 495 EGLSurface old_surface = surface_; |
500 | 496 |
501 EGLDisplay display = GetDisplay(); | 497 EGLDisplay display = GetDisplay(); |
502 if (!display) { | 498 if (!display) { |
503 LOG(ERROR) << "Trying to create surface with invalid display."; | 499 LOG(ERROR) << "Trying to create surface with invalid display."; |
504 return false; | 500 return false; |
505 } | 501 } |
506 | 502 |
| 503 if (size_.GetArea() == 0) { |
| 504 LOG(ERROR) << "Error: surface has zero area " |
| 505 << size_.width() << " x " << size_.height(); |
| 506 return false; |
| 507 } |
| 508 |
507 // Allocate the new pbuffer surface before freeing the old one to ensure | 509 // Allocate the new pbuffer surface before freeing the old one to ensure |
508 // they have different addresses. If they have the same address then a | 510 // they have different addresses. If they have the same address then a |
509 // future call to MakeCurrent might early out because it appears the current | 511 // future call to MakeCurrent might early out because it appears the current |
510 // context and surface have not changed. | 512 // context and surface have not changed. |
511 const EGLint pbuffer_attribs[] = { | 513 const EGLint pbuffer_attribs[] = { |
512 EGL_WIDTH, size_.width(), | 514 EGL_WIDTH, size_.width(), |
513 EGL_HEIGHT, size_.height(), | 515 EGL_HEIGHT, size_.height(), |
514 EGL_NONE | 516 EGL_NONE |
515 }; | 517 }; |
516 | 518 |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
649 } | 651 } |
650 | 652 |
651 void* SurfacelessEGL::GetShareHandle() { | 653 void* SurfacelessEGL::GetShareHandle() { |
652 return NULL; | 654 return NULL; |
653 } | 655 } |
654 | 656 |
655 SurfacelessEGL::~SurfacelessEGL() { | 657 SurfacelessEGL::~SurfacelessEGL() { |
656 } | 658 } |
657 | 659 |
658 } // namespace gfx | 660 } // namespace gfx |
OLD | NEW |