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

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

Issue 1486773002: Add NativeViewGLSurfaceEGL::CommitOverlayPlanes support for Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cop-bare-implementation
Patch Set: typo Created 5 years 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
« no previous file with comments | « ui/gl/gl_surface_egl.h ('k') | ui/gl/gl_surface_overlay.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 665 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 swaps_this_generation_++; 676 swaps_this_generation_++;
677 } 677 }
678 #endif 678 #endif
679 679
680 if (!eglSwapBuffers(GetDisplay(), surface_)) { 680 if (!eglSwapBuffers(GetDisplay(), surface_)) {
681 DVLOG(1) << "eglSwapBuffers failed with error " 681 DVLOG(1) << "eglSwapBuffers failed with error "
682 << GetLastEGLErrorString(); 682 << GetLastEGLErrorString();
683 return gfx::SwapResult::SWAP_FAILED; 683 return gfx::SwapResult::SWAP_FAILED;
684 } 684 }
685 685
686 if (SupportsCommitOverlayPlanes() && !CommitAndClearPendingOverlays())
piman 2015/12/01 01:06:45 SupportsCommitOverlayPlanes() seems orthogonal to
watk 2015/12/01 01:55:55 That makes a lot of sense. Done.
687 return gfx::SwapResult::SWAP_FAILED;
688
686 return gfx::SwapResult::SWAP_ACK; 689 return gfx::SwapResult::SWAP_ACK;
687 } 690 }
688 691
689 gfx::Size NativeViewGLSurfaceEGL::GetSize() { 692 gfx::Size NativeViewGLSurfaceEGL::GetSize() {
690 EGLint width; 693 EGLint width;
691 EGLint height; 694 EGLint height;
692 if (!eglQuerySurface(GetDisplay(), surface_, EGL_WIDTH, &width) || 695 if (!eglQuerySurface(GetDisplay(), surface_, EGL_WIDTH, &width) ||
693 !eglQuerySurface(GetDisplay(), surface_, EGL_HEIGHT, &height)) { 696 !eglQuerySurface(GetDisplay(), surface_, EGL_HEIGHT, &height)) {
694 NOTREACHED() << "eglQuerySurface failed with error " 697 NOTREACHED() << "eglQuerySurface failed with error "
695 << GetLastEGLErrorString(); 698 << GetLastEGLErrorString();
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 gfx::SwapResult NativeViewGLSurfaceEGL::PostSubBuffer(int x, 748 gfx::SwapResult NativeViewGLSurfaceEGL::PostSubBuffer(int x,
746 int y, 749 int y,
747 int width, 750 int width,
748 int height) { 751 int height) {
749 DCHECK(supports_post_sub_buffer_); 752 DCHECK(supports_post_sub_buffer_);
750 if (!eglPostSubBufferNV(GetDisplay(), surface_, x, y, width, height)) { 753 if (!eglPostSubBufferNV(GetDisplay(), surface_, x, y, width, height)) {
751 DVLOG(1) << "eglPostSubBufferNV failed with error " 754 DVLOG(1) << "eglPostSubBufferNV failed with error "
752 << GetLastEGLErrorString(); 755 << GetLastEGLErrorString();
753 return gfx::SwapResult::SWAP_FAILED; 756 return gfx::SwapResult::SWAP_FAILED;
754 } 757 }
758 if (SupportsCommitOverlayPlanes() && !CommitAndClearPendingOverlays())
piman 2015/12/01 01:06:45 (same here)
watk 2015/12/01 01:55:55 Done.
759 return gfx::SwapResult::SWAP_FAILED;
755 return gfx::SwapResult::SWAP_ACK; 760 return gfx::SwapResult::SWAP_ACK;
756 } 761 }
757 762
763 bool NativeViewGLSurfaceEGL::SupportsCommitOverlayPlanes() {
764 #if defined(OS_ANDROID)
765 return true;
766 #else
767 return false;
768 #endif
769 }
770
771 gfx::SwapResult NativeViewGLSurfaceEGL::CommitOverlayPlanes() {
772 DCHECK(SupportsCommitOverlayPlanes());
773 return CommitAndClearPendingOverlays()
774 ? gfx::SwapResult::SWAP_ACK
775 : gfx::SwapResult::SWAP_FAILED;
776 }
777
758 VSyncProvider* NativeViewGLSurfaceEGL::GetVSyncProvider() { 778 VSyncProvider* NativeViewGLSurfaceEGL::GetVSyncProvider() {
759 return vsync_provider_.get(); 779 return vsync_provider_.get();
760 } 780 }
761 781
762 bool NativeViewGLSurfaceEGL::ScheduleOverlayPlane(int z_order, 782 bool NativeViewGLSurfaceEGL::ScheduleOverlayPlane(int z_order,
763 OverlayTransform transform, 783 OverlayTransform transform,
764 gl::GLImage* image, 784 gl::GLImage* image,
765 const Rect& bounds_rect, 785 const Rect& bounds_rect,
766 const RectF& crop_rect) { 786 const RectF& crop_rect) {
767 #if defined(OS_ANDROID) 787 #if !defined(OS_ANDROID)
768 // Overlay planes are used on Android for fullscreen video. The image is
769 // expected to update the plane as soon as possible to display the video frame
770 // chosen for this vsync interval.
771 return image->ScheduleOverlayPlane(window_, z_order, transform, bounds_rect,
772 crop_rect);
773 #else
774 NOTIMPLEMENTED(); 788 NOTIMPLEMENTED();
775 return false; 789 return false;
790 #else
791 pending_overlays_.push_back(
792 GLSurfaceOverlay(z_order, transform, image, bounds_rect, crop_rect));
793 return true;
776 #endif 794 #endif
777 } 795 }
778 796
779 void NativeViewGLSurfaceEGL::OnSetSwapInterval(int interval) { 797 void NativeViewGLSurfaceEGL::OnSetSwapInterval(int interval) {
780 swap_interval_ = interval; 798 swap_interval_ = interval;
781 } 799 }
782 800
783 NativeViewGLSurfaceEGL::~NativeViewGLSurfaceEGL() { 801 NativeViewGLSurfaceEGL::~NativeViewGLSurfaceEGL() {
784 Destroy(); 802 Destroy();
785 #if defined(OS_ANDROID) 803 #if defined(OS_ANDROID)
786 if (window_) 804 if (window_)
787 ANativeWindow_release(window_); 805 ANativeWindow_release(window_);
788 #endif 806 #endif
789 } 807 }
790 808
809 bool NativeViewGLSurfaceEGL::CommitAndClearPendingOverlays() {
810 bool success = true;
811 for (const auto& overlay : pending_overlays_) {
812 // It's expected that GLImage::ScheduleOverlayPlane will overlay contents on
813 // the screen now.
814 success &= overlay.ScheduleOverlayPlane(window_);
815 }
816 pending_overlays_.clear();
817 return success;
818 }
819
791 PbufferGLSurfaceEGL::PbufferGLSurfaceEGL(const gfx::Size& size) 820 PbufferGLSurfaceEGL::PbufferGLSurfaceEGL(const gfx::Size& size)
792 : size_(size), 821 : size_(size),
793 surface_(NULL) { 822 surface_(NULL) {
794 // Some implementations of Pbuffer do not support having a 0 size. For such 823 // Some implementations of Pbuffer do not support having a 0 size. For such
795 // cases use a (1, 1) surface. 824 // cases use a (1, 1) surface.
796 if (size_.GetArea() == 0) 825 if (size_.GetArea() == 0)
797 size_.SetSize(1, 1); 826 size_.SetSize(1, 1);
798 } 827 }
799 828
800 bool PbufferGLSurfaceEGL::Initialize() { 829 bool PbufferGLSurfaceEGL::Initialize() {
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
955 } 984 }
956 985
957 void* SurfacelessEGL::GetShareHandle() { 986 void* SurfacelessEGL::GetShareHandle() {
958 return NULL; 987 return NULL;
959 } 988 }
960 989
961 SurfacelessEGL::~SurfacelessEGL() { 990 SurfacelessEGL::~SurfacelessEGL() {
962 } 991 }
963 992
964 } // namespace gfx 993 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gl/gl_surface_egl.h ('k') | ui/gl/gl_surface_overlay.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698