| 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 #include "ui/gl/gl_surface_egl.h" | 5 #include "ui/gl/gl_surface_egl.h" |
| 6 | 6 |
| 7 #if defined(OS_ANDROID) | 7 #if defined(OS_ANDROID) |
| 8 #include <android/native_window_jni.h> | 8 #include <android/native_window_jni.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 } | 525 } |
| 526 } | 526 } |
| 527 return config_; | 527 return config_; |
| 528 #endif | 528 #endif |
| 529 } | 529 } |
| 530 | 530 |
| 531 bool NativeViewGLSurfaceEGL::IsOffscreen() { | 531 bool NativeViewGLSurfaceEGL::IsOffscreen() { |
| 532 return false; | 532 return false; |
| 533 } | 533 } |
| 534 | 534 |
| 535 bool NativeViewGLSurfaceEGL::SwapBuffers() { | 535 gfx::SwapResult NativeViewGLSurfaceEGL::SwapBuffers() { |
| 536 TRACE_EVENT2("gpu", "NativeViewGLSurfaceEGL:RealSwapBuffers", | 536 TRACE_EVENT2("gpu", "NativeViewGLSurfaceEGL:RealSwapBuffers", |
| 537 "width", GetSize().width(), | 537 "width", GetSize().width(), |
| 538 "height", GetSize().height()); | 538 "height", GetSize().height()); |
| 539 | 539 |
| 540 #if defined(OS_WIN) | 540 #if defined(OS_WIN) |
| 541 if (swap_interval_ != 0) { | 541 if (swap_interval_ != 0) { |
| 542 // This code is a simple way of enforcing that we only vsync if one surface | 542 // This code is a simple way of enforcing that we only vsync if one surface |
| 543 // is swapping per frame. This provides single window cases a stable refresh | 543 // is swapping per frame. This provides single window cases a stable refresh |
| 544 // while allowing multi-window cases to not slow down due to multiple syncs | 544 // while allowing multi-window cases to not slow down due to multiple syncs |
| 545 // on a single thread. A better way to fix this problem would be to have | 545 // on a single thread. A better way to fix this problem would be to have |
| (...skipping 22 matching lines...) Expand all Loading... |
| 568 vsync_override_ = false; | 568 vsync_override_ = false; |
| 569 } | 569 } |
| 570 | 570 |
| 571 swaps_this_generation_++; | 571 swaps_this_generation_++; |
| 572 } | 572 } |
| 573 #endif | 573 #endif |
| 574 | 574 |
| 575 if (!eglSwapBuffers(GetDisplay(), surface_)) { | 575 if (!eglSwapBuffers(GetDisplay(), surface_)) { |
| 576 DVLOG(1) << "eglSwapBuffers failed with error " | 576 DVLOG(1) << "eglSwapBuffers failed with error " |
| 577 << GetLastEGLErrorString(); | 577 << GetLastEGLErrorString(); |
| 578 return false; | 578 return gfx::SWAP_FAILED; |
| 579 } | 579 } |
| 580 | 580 |
| 581 return true; | 581 return gfx::SWAP_ACK; |
| 582 } | 582 } |
| 583 | 583 |
| 584 gfx::Size NativeViewGLSurfaceEGL::GetSize() { | 584 gfx::Size NativeViewGLSurfaceEGL::GetSize() { |
| 585 EGLint width; | 585 EGLint width; |
| 586 EGLint height; | 586 EGLint height; |
| 587 if (!eglQuerySurface(GetDisplay(), surface_, EGL_WIDTH, &width) || | 587 if (!eglQuerySurface(GetDisplay(), surface_, EGL_WIDTH, &width) || |
| 588 !eglQuerySurface(GetDisplay(), surface_, EGL_HEIGHT, &height)) { | 588 !eglQuerySurface(GetDisplay(), surface_, EGL_HEIGHT, &height)) { |
| 589 NOTREACHED() << "eglQuerySurface failed with error " | 589 NOTREACHED() << "eglQuerySurface failed with error " |
| 590 << GetLastEGLErrorString(); | 590 << GetLastEGLErrorString(); |
| 591 return gfx::Size(); | 591 return gfx::Size(); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 630 } | 630 } |
| 631 | 631 |
| 632 EGLSurface NativeViewGLSurfaceEGL::GetHandle() { | 632 EGLSurface NativeViewGLSurfaceEGL::GetHandle() { |
| 633 return surface_; | 633 return surface_; |
| 634 } | 634 } |
| 635 | 635 |
| 636 bool NativeViewGLSurfaceEGL::SupportsPostSubBuffer() { | 636 bool NativeViewGLSurfaceEGL::SupportsPostSubBuffer() { |
| 637 return supports_post_sub_buffer_; | 637 return supports_post_sub_buffer_; |
| 638 } | 638 } |
| 639 | 639 |
| 640 bool NativeViewGLSurfaceEGL::PostSubBuffer( | 640 gfx::SwapResult NativeViewGLSurfaceEGL::PostSubBuffer(int x, |
| 641 int x, int y, int width, int height) { | 641 int y, |
| 642 int width, |
| 643 int height) { |
| 642 DCHECK(supports_post_sub_buffer_); | 644 DCHECK(supports_post_sub_buffer_); |
| 643 if (!eglPostSubBufferNV(GetDisplay(), surface_, x, y, width, height)) { | 645 if (!eglPostSubBufferNV(GetDisplay(), surface_, x, y, width, height)) { |
| 644 DVLOG(1) << "eglPostSubBufferNV failed with error " | 646 DVLOG(1) << "eglPostSubBufferNV failed with error " |
| 645 << GetLastEGLErrorString(); | 647 << GetLastEGLErrorString(); |
| 646 return false; | 648 return gfx::SWAP_FAILED; |
| 647 } | 649 } |
| 648 return true; | 650 return gfx::SWAP_ACK; |
| 649 } | 651 } |
| 650 | 652 |
| 651 VSyncProvider* NativeViewGLSurfaceEGL::GetVSyncProvider() { | 653 VSyncProvider* NativeViewGLSurfaceEGL::GetVSyncProvider() { |
| 652 return vsync_provider_.get(); | 654 return vsync_provider_.get(); |
| 653 } | 655 } |
| 654 | 656 |
| 655 void NativeViewGLSurfaceEGL::OnSetSwapInterval(int interval) { | 657 void NativeViewGLSurfaceEGL::OnSetSwapInterval(int interval) { |
| 656 swap_interval_ = interval; | 658 swap_interval_ = interval; |
| 657 } | 659 } |
| 658 | 660 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 719 } | 721 } |
| 720 | 722 |
| 721 EGLConfig PbufferGLSurfaceEGL::GetConfig() { | 723 EGLConfig PbufferGLSurfaceEGL::GetConfig() { |
| 722 return g_config; | 724 return g_config; |
| 723 } | 725 } |
| 724 | 726 |
| 725 bool PbufferGLSurfaceEGL::IsOffscreen() { | 727 bool PbufferGLSurfaceEGL::IsOffscreen() { |
| 726 return true; | 728 return true; |
| 727 } | 729 } |
| 728 | 730 |
| 729 bool PbufferGLSurfaceEGL::SwapBuffers() { | 731 gfx::SwapResult PbufferGLSurfaceEGL::SwapBuffers() { |
| 730 NOTREACHED() << "Attempted to call SwapBuffers on a PbufferGLSurfaceEGL."; | 732 NOTREACHED() << "Attempted to call SwapBuffers on a PbufferGLSurfaceEGL."; |
| 731 return false; | 733 return gfx::SWAP_FAILED; |
| 732 } | 734 } |
| 733 | 735 |
| 734 gfx::Size PbufferGLSurfaceEGL::GetSize() { | 736 gfx::Size PbufferGLSurfaceEGL::GetSize() { |
| 735 return size_; | 737 return size_; |
| 736 } | 738 } |
| 737 | 739 |
| 738 bool PbufferGLSurfaceEGL::Resize(const gfx::Size& size) { | 740 bool PbufferGLSurfaceEGL::Resize(const gfx::Size& size) { |
| 739 if (size == size_) | 741 if (size == size_) |
| 740 return true; | 742 return true; |
| 741 | 743 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 805 } | 807 } |
| 806 | 808 |
| 807 bool SurfacelessEGL::IsOffscreen() { | 809 bool SurfacelessEGL::IsOffscreen() { |
| 808 return true; | 810 return true; |
| 809 } | 811 } |
| 810 | 812 |
| 811 bool SurfacelessEGL::IsSurfaceless() const { | 813 bool SurfacelessEGL::IsSurfaceless() const { |
| 812 return true; | 814 return true; |
| 813 } | 815 } |
| 814 | 816 |
| 815 bool SurfacelessEGL::SwapBuffers() { | 817 gfx::SwapResult SurfacelessEGL::SwapBuffers() { |
| 816 LOG(ERROR) << "Attempted to call SwapBuffers with SurfacelessEGL."; | 818 LOG(ERROR) << "Attempted to call SwapBuffers with SurfacelessEGL."; |
| 817 return false; | 819 return gfx::SWAP_FAILED; |
| 818 } | 820 } |
| 819 | 821 |
| 820 gfx::Size SurfacelessEGL::GetSize() { | 822 gfx::Size SurfacelessEGL::GetSize() { |
| 821 return size_; | 823 return size_; |
| 822 } | 824 } |
| 823 | 825 |
| 824 bool SurfacelessEGL::Resize(const gfx::Size& size) { | 826 bool SurfacelessEGL::Resize(const gfx::Size& size) { |
| 825 size_ = size; | 827 size_ = size; |
| 826 return true; | 828 return true; |
| 827 } | 829 } |
| 828 | 830 |
| 829 EGLSurface SurfacelessEGL::GetHandle() { | 831 EGLSurface SurfacelessEGL::GetHandle() { |
| 830 return EGL_NO_SURFACE; | 832 return EGL_NO_SURFACE; |
| 831 } | 833 } |
| 832 | 834 |
| 833 void* SurfacelessEGL::GetShareHandle() { | 835 void* SurfacelessEGL::GetShareHandle() { |
| 834 return NULL; | 836 return NULL; |
| 835 } | 837 } |
| 836 | 838 |
| 837 SurfacelessEGL::~SurfacelessEGL() { | 839 SurfacelessEGL::~SurfacelessEGL() { |
| 838 } | 840 } |
| 839 | 841 |
| 840 } // namespace gfx | 842 } // namespace gfx |
| OLD | NEW |