| 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/logging.h" | 8 #include "base/logging.h" |
| 8 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 9 #include "ui/gfx/native_widget_types.h" | 10 #include "ui/gfx/native_widget_types.h" |
| 11 #include "ui/gl/egl_util.h" |
| 10 #include "ui/gl/gl_context.h" | 12 #include "ui/gl/gl_context.h" |
| 11 #include "ui/gl/gl_image.h" | 13 #include "ui/gl/gl_image.h" |
| 12 #include "ui/gl/gl_implementation.h" | 14 #include "ui/gl/gl_implementation.h" |
| 13 #include "ui/gl/gl_surface_egl.h" | 15 #include "ui/gl/gl_surface_egl.h" |
| 14 #include "ui/gl/gl_surface_osmesa.h" | 16 #include "ui/gl/gl_surface_osmesa.h" |
| 15 #include "ui/gl/gl_surface_stub.h" | 17 #include "ui/gl/gl_surface_stub.h" |
| 16 #include "ui/gl/scoped_make_current.h" | 18 #include "ui/gl/scoped_make_current.h" |
| 17 #include "ui/ozone/public/surface_factory_ozone.h" | 19 #include "ui/ozone/public/surface_factory_ozone.h" |
| 18 #include "ui/ozone/public/surface_ozone_egl.h" | 20 #include "ui/ozone/public/surface_ozone_egl.h" |
| 19 | 21 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 50 } | 52 } |
| 51 virtual bool ScheduleOverlayPlane(int z_order, | 53 virtual bool ScheduleOverlayPlane(int z_order, |
| 52 OverlayTransform transform, | 54 OverlayTransform transform, |
| 53 GLImage* image, | 55 GLImage* image, |
| 54 const Rect& bounds_rect, | 56 const Rect& bounds_rect, |
| 55 const RectF& crop_rect) override { | 57 const RectF& crop_rect) override { |
| 56 return image->ScheduleOverlayPlane( | 58 return image->ScheduleOverlayPlane( |
| 57 widget_, z_order, transform, bounds_rect, crop_rect); | 59 widget_, z_order, transform, bounds_rect, crop_rect); |
| 58 } | 60 } |
| 59 | 61 |
| 62 EGLConfig GetConfig() override { |
| 63 if (!config_) { |
| 64 ui::SurfaceFactoryOzone::EglConfigInfo egl; |
| 65 egl.choose_config = base::Bind(&GLSurfaceOzoneEGL::EglChooseConfig, |
| 66 base::Unretained(this)); |
| 67 egl.get_config_attribute = base::Bind( |
| 68 &GLSurfaceOzoneEGL::EglGetConfigAttribute, base::Unretained(this)); |
| 69 egl.get_last_error_string = base::Bind(&ui::GetLastEGLErrorString); |
| 70 config_ = ui::SurfaceFactoryOzone::GetInstance()->GetEGLSurfaceConfig( |
| 71 egl, ozone_surface_.get()); |
| 72 } |
| 73 if (config_) |
| 74 return config_; |
| 75 return NativeViewGLSurfaceEGL::GetConfig(); |
| 76 } |
| 77 |
| 60 private: | 78 private: |
| 61 using NativeViewGLSurfaceEGL::Initialize; | 79 using NativeViewGLSurfaceEGL::Initialize; |
| 62 | 80 |
| 63 virtual ~GLSurfaceOzoneEGL() { | 81 virtual ~GLSurfaceOzoneEGL() { |
| 64 Destroy(); // EGL surface must be destroyed before SurfaceOzone | 82 Destroy(); // EGL surface must be destroyed before SurfaceOzone |
| 65 } | 83 } |
| 66 | 84 |
| 85 bool EglChooseConfig(const int32* attribs, |
| 86 void** /* EGLConfig* */ configs, |
| 87 int32 config_size, |
| 88 int32* num_configs) { |
| 89 return eglChooseConfig(GetDisplay(), attribs, configs, config_size, |
| 90 num_configs); |
| 91 } |
| 92 |
| 93 bool EglGetConfigAttribute(void* /* EGLConfig */ config, |
| 94 int32 attribute, |
| 95 int32* value) { |
| 96 return eglGetConfigAttrib(GetDisplay(), config, attribute, value); |
| 97 } |
| 98 |
| 67 bool ReinitializeNativeSurface() { | 99 bool ReinitializeNativeSurface() { |
| 68 scoped_ptr<ui::ScopedMakeCurrent> scoped_make_current; | 100 scoped_ptr<ui::ScopedMakeCurrent> scoped_make_current; |
| 69 GLContext* current_context = GLContext::GetCurrent(); | 101 GLContext* current_context = GLContext::GetCurrent(); |
| 70 bool was_current = | 102 bool was_current = |
| 71 current_context && current_context->IsCurrent(this); | 103 current_context && current_context->IsCurrent(this); |
| 72 if (was_current) { | 104 if (was_current) { |
| 73 scoped_make_current.reset( | 105 scoped_make_current.reset( |
| 74 new ui::ScopedMakeCurrent(current_context, this)); | 106 new ui::ScopedMakeCurrent(current_context, this)); |
| 75 } | 107 } |
| 76 | 108 |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 NOTREACHED(); | 279 NOTREACHED(); |
| 248 return NULL; | 280 return NULL; |
| 249 } | 281 } |
| 250 } | 282 } |
| 251 | 283 |
| 252 EGLNativeDisplayType GetPlatformDefaultEGLNativeDisplay() { | 284 EGLNativeDisplayType GetPlatformDefaultEGLNativeDisplay() { |
| 253 return ui::SurfaceFactoryOzone::GetInstance()->GetNativeDisplay(); | 285 return ui::SurfaceFactoryOzone::GetInstance()->GetNativeDisplay(); |
| 254 } | 286 } |
| 255 | 287 |
| 256 } // namespace gfx | 288 } // namespace gfx |
| OLD | NEW |