OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ui/ozone/platform/cast/gl_surface_cast.h" |
| 6 |
| 7 #include "ui/ozone/common/egl_util.h" |
| 8 #include "ui/ozone/platform/cast/surface_factory_cast.h" |
| 9 |
| 10 namespace ui { |
| 11 |
| 12 GLSurfaceCast::GLSurfaceCast(gfx::AcceleratedWidget widget, |
| 13 SurfaceFactoryCast* parent) |
| 14 : NativeViewGLSurfaceEGL(parent->GetNativeWindow()), |
| 15 widget_(widget), |
| 16 parent_(parent) { |
| 17 DCHECK(parent_); |
| 18 } |
| 19 |
| 20 gfx::SwapResult GLSurfaceCast::SwapBuffers() { |
| 21 gfx::SwapResult result = NativeViewGLSurfaceEGL::SwapBuffers(); |
| 22 if (result == gfx::SwapResult::SWAP_ACK) |
| 23 parent_->OnSwapBuffers(); |
| 24 |
| 25 return result; |
| 26 } |
| 27 |
| 28 bool GLSurfaceCast::Resize(const gfx::Size& size, |
| 29 float scale_factor, |
| 30 bool has_alpha) { |
| 31 return parent_->ResizeDisplay(size) && |
| 32 NativeViewGLSurfaceEGL::Resize(size, scale_factor, has_alpha); |
| 33 } |
| 34 |
| 35 bool GLSurfaceCast::ScheduleOverlayPlane(int z_order, |
| 36 gfx::OverlayTransform transform, |
| 37 gl::GLImage* image, |
| 38 const gfx::Rect& bounds_rect, |
| 39 const gfx::RectF& crop_rect) { |
| 40 return image->ScheduleOverlayPlane(widget_, z_order, transform, bounds_rect, |
| 41 crop_rect); |
| 42 } |
| 43 |
| 44 EGLConfig GLSurfaceCast::GetConfig() { |
| 45 if (!config_) { |
| 46 EGLint config_attribs[] = {EGL_BUFFER_SIZE, |
| 47 32, |
| 48 EGL_ALPHA_SIZE, |
| 49 8, |
| 50 EGL_BLUE_SIZE, |
| 51 8, |
| 52 EGL_GREEN_SIZE, |
| 53 8, |
| 54 EGL_RED_SIZE, |
| 55 8, |
| 56 EGL_RENDERABLE_TYPE, |
| 57 EGL_OPENGL_ES2_BIT, |
| 58 EGL_SURFACE_TYPE, |
| 59 EGL_WINDOW_BIT, |
| 60 EGL_NONE}; |
| 61 config_ = ChooseEGLConfig(GetDisplay(), config_attribs); |
| 62 } |
| 63 return config_; |
| 64 } |
| 65 |
| 66 GLSurfaceCast::~GLSurfaceCast() { |
| 67 Destroy(); |
| 68 parent_->ChildDestroyed(); |
| 69 } |
| 70 |
| 71 } // namespace ui |
OLD | NEW |