| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/gl/gl_surface.h" | 5 #include "ui/gl/gl_surface.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 scoped_ptr<ui::SurfaceOzoneEGL> ozone_surface_; | 68 scoped_ptr<ui::SurfaceOzoneEGL> ozone_surface_; |
| 69 AcceleratedWidget widget_; | 69 AcceleratedWidget widget_; |
| 70 | 70 |
| 71 DISALLOW_COPY_AND_ASSIGN(GLSurfaceOzoneEGL); | 71 DISALLOW_COPY_AND_ASSIGN(GLSurfaceOzoneEGL); |
| 72 }; | 72 }; |
| 73 | 73 |
| 74 GLSurfaceOzoneEGL::GLSurfaceOzoneEGL( | 74 GLSurfaceOzoneEGL::GLSurfaceOzoneEGL( |
| 75 scoped_ptr<ui::SurfaceOzoneEGL> ozone_surface, | 75 scoped_ptr<ui::SurfaceOzoneEGL> ozone_surface, |
| 76 AcceleratedWidget widget) | 76 AcceleratedWidget widget) |
| 77 : NativeViewGLSurfaceEGL(ozone_surface->GetNativeWindow()), | 77 : NativeViewGLSurfaceEGL(ozone_surface->GetNativeWindow()), |
| 78 ozone_surface_(ozone_surface.Pass()), | 78 ozone_surface_(std::move(ozone_surface)), |
| 79 widget_(widget) {} | 79 widget_(widget) {} |
| 80 | 80 |
| 81 bool GLSurfaceOzoneEGL::Initialize() { | 81 bool GLSurfaceOzoneEGL::Initialize() { |
| 82 return Initialize(ozone_surface_->CreateVSyncProvider()); | 82 return Initialize(ozone_surface_->CreateVSyncProvider()); |
| 83 } | 83 } |
| 84 | 84 |
| 85 bool GLSurfaceOzoneEGL::Resize(const gfx::Size& size, | 85 bool GLSurfaceOzoneEGL::Resize(const gfx::Size& size, |
| 86 float scale_factor, | 86 float scale_factor, |
| 87 bool has_alpha) { | 87 bool has_alpha) { |
| 88 if (!ozone_surface_->ResizeNativeWindow(size)) { | 88 if (!ozone_surface_->ResizeNativeWindow(size)) { |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 for (const auto& overlay : overlays) | 212 for (const auto& overlay : overlays) |
| 213 if (!overlay.ScheduleOverlayPlane(widget)) | 213 if (!overlay.ScheduleOverlayPlane(widget)) |
| 214 return false; | 214 return false; |
| 215 return true; | 215 return true; |
| 216 } | 216 } |
| 217 | 217 |
| 218 GLSurfaceOzoneSurfaceless::GLSurfaceOzoneSurfaceless( | 218 GLSurfaceOzoneSurfaceless::GLSurfaceOzoneSurfaceless( |
| 219 scoped_ptr<ui::SurfaceOzoneEGL> ozone_surface, | 219 scoped_ptr<ui::SurfaceOzoneEGL> ozone_surface, |
| 220 AcceleratedWidget widget) | 220 AcceleratedWidget widget) |
| 221 : SurfacelessEGL(gfx::Size()), | 221 : SurfacelessEGL(gfx::Size()), |
| 222 ozone_surface_(ozone_surface.Pass()), | 222 ozone_surface_(std::move(ozone_surface)), |
| 223 widget_(widget), | 223 widget_(widget), |
| 224 has_implicit_external_sync_( | 224 has_implicit_external_sync_( |
| 225 HasEGLExtension("EGL_ARM_implicit_external_sync")), | 225 HasEGLExtension("EGL_ARM_implicit_external_sync")), |
| 226 last_swap_buffers_result_(true), | 226 last_swap_buffers_result_(true), |
| 227 swap_buffers_pending_(false), | 227 swap_buffers_pending_(false), |
| 228 weak_factory_(this) { | 228 weak_factory_(this) { |
| 229 unsubmitted_frames_.push_back(new PendingFrame()); | 229 unsubmitted_frames_.push_back(new PendingFrame()); |
| 230 } | 230 } |
| 231 | 231 |
| 232 bool GLSurfaceOzoneSurfaceless::Initialize() { | 232 bool GLSurfaceOzoneSurfaceless::Initialize() { |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 GLuint fbo_; | 442 GLuint fbo_; |
| 443 GLuint textures_[2]; | 443 GLuint textures_[2]; |
| 444 scoped_refptr<GLImage> images_[2]; | 444 scoped_refptr<GLImage> images_[2]; |
| 445 int current_surface_; | 445 int current_surface_; |
| 446 DISALLOW_COPY_AND_ASSIGN(GLSurfaceOzoneSurfacelessSurfaceImpl); | 446 DISALLOW_COPY_AND_ASSIGN(GLSurfaceOzoneSurfacelessSurfaceImpl); |
| 447 }; | 447 }; |
| 448 | 448 |
| 449 GLSurfaceOzoneSurfacelessSurfaceImpl::GLSurfaceOzoneSurfacelessSurfaceImpl( | 449 GLSurfaceOzoneSurfacelessSurfaceImpl::GLSurfaceOzoneSurfacelessSurfaceImpl( |
| 450 scoped_ptr<ui::SurfaceOzoneEGL> ozone_surface, | 450 scoped_ptr<ui::SurfaceOzoneEGL> ozone_surface, |
| 451 AcceleratedWidget widget) | 451 AcceleratedWidget widget) |
| 452 : GLSurfaceOzoneSurfaceless(ozone_surface.Pass(), widget), | 452 : GLSurfaceOzoneSurfaceless(std::move(ozone_surface), widget), |
| 453 context_(nullptr), | 453 context_(nullptr), |
| 454 fbo_(0), | 454 fbo_(0), |
| 455 current_surface_(0) { | 455 current_surface_(0) { |
| 456 for (auto& texture : textures_) | 456 for (auto& texture : textures_) |
| 457 texture = 0; | 457 texture = 0; |
| 458 } | 458 } |
| 459 | 459 |
| 460 unsigned int | 460 unsigned int |
| 461 GLSurfaceOzoneSurfacelessSurfaceImpl::GetBackingFrameBufferObject() { | 461 GLSurfaceOzoneSurfacelessSurfaceImpl::GetBackingFrameBufferObject() { |
| 462 return fbo_; | 462 return fbo_; |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 | 587 |
| 588 scoped_refptr<GLSurface> CreateViewGLSurfaceOzone( | 588 scoped_refptr<GLSurface> CreateViewGLSurfaceOzone( |
| 589 gfx::AcceleratedWidget window) { | 589 gfx::AcceleratedWidget window) { |
| 590 scoped_ptr<ui::SurfaceOzoneEGL> surface_ozone = | 590 scoped_ptr<ui::SurfaceOzoneEGL> surface_ozone = |
| 591 ui::OzonePlatform::GetInstance() | 591 ui::OzonePlatform::GetInstance() |
| 592 ->GetSurfaceFactoryOzone() | 592 ->GetSurfaceFactoryOzone() |
| 593 ->CreateEGLSurfaceForWidget(window); | 593 ->CreateEGLSurfaceForWidget(window); |
| 594 if (!surface_ozone) | 594 if (!surface_ozone) |
| 595 return nullptr; | 595 return nullptr; |
| 596 scoped_refptr<GLSurface> surface = | 596 scoped_refptr<GLSurface> surface = |
| 597 new GLSurfaceOzoneEGL(surface_ozone.Pass(), window); | 597 new GLSurfaceOzoneEGL(std::move(surface_ozone), window); |
| 598 if (!surface->Initialize()) | 598 if (!surface->Initialize()) |
| 599 return nullptr; | 599 return nullptr; |
| 600 return surface; | 600 return surface; |
| 601 } | 601 } |
| 602 | 602 |
| 603 scoped_refptr<GLSurface> CreateViewGLSurfaceOzoneSurfacelessSurfaceImpl( | 603 scoped_refptr<GLSurface> CreateViewGLSurfaceOzoneSurfacelessSurfaceImpl( |
| 604 gfx::AcceleratedWidget window) { | 604 gfx::AcceleratedWidget window) { |
| 605 scoped_ptr<ui::SurfaceOzoneEGL> surface_ozone = | 605 scoped_ptr<ui::SurfaceOzoneEGL> surface_ozone = |
| 606 ui::OzonePlatform::GetInstance() | 606 ui::OzonePlatform::GetInstance() |
| 607 ->GetSurfaceFactoryOzone() | 607 ->GetSurfaceFactoryOzone() |
| 608 ->CreateSurfacelessEGLSurfaceForWidget(window); | 608 ->CreateSurfacelessEGLSurfaceForWidget(window); |
| 609 if (!surface_ozone) | 609 if (!surface_ozone) |
| 610 return nullptr; | 610 return nullptr; |
| 611 scoped_refptr<GLSurface> surface = | 611 scoped_refptr<GLSurface> surface = new GLSurfaceOzoneSurfacelessSurfaceImpl( |
| 612 new GLSurfaceOzoneSurfacelessSurfaceImpl(surface_ozone.Pass(), window); | 612 std::move(surface_ozone), window); |
| 613 if (!surface->Initialize()) | 613 if (!surface->Initialize()) |
| 614 return nullptr; | 614 return nullptr; |
| 615 return surface; | 615 return surface; |
| 616 } | 616 } |
| 617 | 617 |
| 618 } // namespace | 618 } // namespace |
| 619 | 619 |
| 620 // static | 620 // static |
| 621 bool GLSurface::InitializeOneOffInternal() { | 621 bool GLSurface::InitializeOneOffInternal() { |
| 622 switch (GetGLImplementation()) { | 622 switch (GetGLImplementation()) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 641 if (GetGLImplementation() == kGLImplementationEGLGLES2 && | 641 if (GetGLImplementation() == kGLImplementationEGLGLES2 && |
| 642 window != kNullAcceleratedWidget && | 642 window != kNullAcceleratedWidget && |
| 643 GLSurfaceEGL::IsEGLSurfacelessContextSupported()) { | 643 GLSurfaceEGL::IsEGLSurfacelessContextSupported()) { |
| 644 scoped_ptr<ui::SurfaceOzoneEGL> surface_ozone = | 644 scoped_ptr<ui::SurfaceOzoneEGL> surface_ozone = |
| 645 ui::OzonePlatform::GetInstance() | 645 ui::OzonePlatform::GetInstance() |
| 646 ->GetSurfaceFactoryOzone() | 646 ->GetSurfaceFactoryOzone() |
| 647 ->CreateSurfacelessEGLSurfaceForWidget(window); | 647 ->CreateSurfacelessEGLSurfaceForWidget(window); |
| 648 if (!surface_ozone) | 648 if (!surface_ozone) |
| 649 return nullptr; | 649 return nullptr; |
| 650 scoped_refptr<GLSurface> surface; | 650 scoped_refptr<GLSurface> surface; |
| 651 surface = new GLSurfaceOzoneSurfaceless(surface_ozone.Pass(), window); | 651 surface = new GLSurfaceOzoneSurfaceless(std::move(surface_ozone), window); |
| 652 if (surface->Initialize()) | 652 if (surface->Initialize()) |
| 653 return surface; | 653 return surface; |
| 654 } | 654 } |
| 655 | 655 |
| 656 return nullptr; | 656 return nullptr; |
| 657 } | 657 } |
| 658 | 658 |
| 659 // static | 659 // static |
| 660 scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface( | 660 scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface( |
| 661 gfx::AcceleratedWidget window) { | 661 gfx::AcceleratedWidget window) { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 713 } | 713 } |
| 714 } | 714 } |
| 715 | 715 |
| 716 EGLNativeDisplayType GetPlatformDefaultEGLNativeDisplay() { | 716 EGLNativeDisplayType GetPlatformDefaultEGLNativeDisplay() { |
| 717 return ui::OzonePlatform::GetInstance() | 717 return ui::OzonePlatform::GetInstance() |
| 718 ->GetSurfaceFactoryOzone() | 718 ->GetSurfaceFactoryOzone() |
| 719 ->GetNativeDisplay(); | 719 ->GetNativeDisplay(); |
| 720 } | 720 } |
| 721 | 721 |
| 722 } // namespace gfx | 722 } // namespace gfx |
| OLD | NEW |