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 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
| 11 #include <memory> |
11 #include <vector> | 12 #include <vector> |
12 | 13 |
13 #include "base/command_line.h" | 14 #include "base/command_line.h" |
14 #include "base/logging.h" | 15 #include "base/logging.h" |
15 #include "base/macros.h" | 16 #include "base/macros.h" |
16 #include "base/memory/scoped_ptr.h" | |
17 #include "base/message_loop/message_loop.h" | 17 #include "base/message_loop/message_loop.h" |
18 #include "base/metrics/histogram_macros.h" | 18 #include "base/metrics/histogram_macros.h" |
19 #include "base/strings/string_number_conversions.h" | 19 #include "base/strings/string_number_conversions.h" |
20 #include "base/sys_info.h" | 20 #include "base/sys_info.h" |
21 #include "base/trace_event/trace_event.h" | 21 #include "base/trace_event/trace_event.h" |
22 #include "build/build_config.h" | 22 #include "build/build_config.h" |
23 #include "ui/gfx/geometry/rect.h" | 23 #include "ui/gfx/geometry/rect.h" |
24 #include "ui/gl/egl_util.h" | 24 #include "ui/gl/egl_util.h" |
25 #include "ui/gl/gl_context.h" | 25 #include "ui/gl/gl_context.h" |
26 #include "ui/gl/gl_image.h" | 26 #include "ui/gl/gl_image.h" |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 | 315 |
316 EGLint num_configs; | 316 EGLint num_configs; |
317 EGLint config_size = 1; | 317 EGLint config_size = 1; |
318 EGLConfig config = nullptr; | 318 EGLConfig config = nullptr; |
319 EGLConfig* config_data = &config; | 319 EGLConfig* config_data = &config; |
320 // Validate if there are any configs for given attribs. | 320 // Validate if there are any configs for given attribs. |
321 if (!ValidateEglConfig(g_display, choose_attributes, &num_configs)) { | 321 if (!ValidateEglConfig(g_display, choose_attributes, &num_configs)) { |
322 return config; | 322 return config; |
323 } | 323 } |
324 | 324 |
325 scoped_ptr<EGLConfig[]> matching_configs(new EGLConfig[num_configs]); | 325 std::unique_ptr<EGLConfig[]> matching_configs(new EGLConfig[num_configs]); |
326 if (format == GLSurface::SURFACE_RGB565) { | 326 if (format == GLSurface::SURFACE_RGB565) { |
327 config_size = num_configs; | 327 config_size = num_configs; |
328 config_data = matching_configs.get(); | 328 config_data = matching_configs.get(); |
329 } | 329 } |
330 | 330 |
331 if (!eglChooseConfig(g_display, choose_attributes, config_data, config_size, | 331 if (!eglChooseConfig(g_display, choose_attributes, config_data, config_size, |
332 &num_configs)) { | 332 &num_configs)) { |
333 LOG(ERROR) << "eglChooseConfig failed with error " | 333 LOG(ERROR) << "eglChooseConfig failed with error " |
334 << GetLastEGLErrorString(); | 334 << GetLastEGLErrorString(); |
335 return config; | 335 return config; |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 size_ = gfx::Rect(windowRect).size(); | 626 size_ = gfx::Rect(windowRect).size(); |
627 #endif | 627 #endif |
628 } | 628 } |
629 | 629 |
630 bool NativeViewGLSurfaceEGL::Initialize(GLSurface::Format format) { | 630 bool NativeViewGLSurfaceEGL::Initialize(GLSurface::Format format) { |
631 format_ = format; | 631 format_ = format; |
632 return Initialize(nullptr); | 632 return Initialize(nullptr); |
633 } | 633 } |
634 | 634 |
635 bool NativeViewGLSurfaceEGL::Initialize( | 635 bool NativeViewGLSurfaceEGL::Initialize( |
636 scoped_ptr<VSyncProvider> sync_provider) { | 636 std::unique_ptr<VSyncProvider> sync_provider) { |
637 DCHECK(!surface_); | 637 DCHECK(!surface_); |
638 | 638 |
639 if (!GetDisplay()) { | 639 if (!GetDisplay()) { |
640 LOG(ERROR) << "Trying to create surface with invalid display."; | 640 LOG(ERROR) << "Trying to create surface with invalid display."; |
641 return false; | 641 return false; |
642 } | 642 } |
643 | 643 |
644 // We need to make sure that window_ is correctly initialized with all | 644 // We need to make sure that window_ is correctly initialized with all |
645 // the platform-dependant quirks, if any, before creating the surface. | 645 // the platform-dependant quirks, if any, before creating the surface. |
646 if (!InitializeNativeWindow()) { | 646 if (!InitializeNativeWindow()) { |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
796 } | 796 } |
797 | 797 |
798 bool NativeViewGLSurfaceEGL::Resize(const gfx::Size& size, | 798 bool NativeViewGLSurfaceEGL::Resize(const gfx::Size& size, |
799 float scale_factor, | 799 float scale_factor, |
800 bool has_alpha) { | 800 bool has_alpha) { |
801 if (size == GetSize()) | 801 if (size == GetSize()) |
802 return true; | 802 return true; |
803 | 803 |
804 size_ = size; | 804 size_ = size; |
805 | 805 |
806 scoped_ptr<ui::ScopedMakeCurrent> scoped_make_current; | 806 std::unique_ptr<ui::ScopedMakeCurrent> scoped_make_current; |
807 GLContext* current_context = GLContext::GetCurrent(); | 807 GLContext* current_context = GLContext::GetCurrent(); |
808 bool was_current = | 808 bool was_current = |
809 current_context && current_context->IsCurrent(this); | 809 current_context && current_context->IsCurrent(this); |
810 if (was_current) { | 810 if (was_current) { |
811 scoped_make_current.reset( | 811 scoped_make_current.reset( |
812 new ui::ScopedMakeCurrent(current_context, this)); | 812 new ui::ScopedMakeCurrent(current_context, this)); |
813 current_context->ReleaseCurrent(this); | 813 current_context->ReleaseCurrent(this); |
814 } | 814 } |
815 | 815 |
816 Destroy(); | 816 Destroy(); |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1017 gfx::Size PbufferGLSurfaceEGL::GetSize() { | 1017 gfx::Size PbufferGLSurfaceEGL::GetSize() { |
1018 return size_; | 1018 return size_; |
1019 } | 1019 } |
1020 | 1020 |
1021 bool PbufferGLSurfaceEGL::Resize(const gfx::Size& size, | 1021 bool PbufferGLSurfaceEGL::Resize(const gfx::Size& size, |
1022 float scale_factor, | 1022 float scale_factor, |
1023 bool has_alpha) { | 1023 bool has_alpha) { |
1024 if (size == size_) | 1024 if (size == size_) |
1025 return true; | 1025 return true; |
1026 | 1026 |
1027 scoped_ptr<ui::ScopedMakeCurrent> scoped_make_current; | 1027 std::unique_ptr<ui::ScopedMakeCurrent> scoped_make_current; |
1028 GLContext* current_context = GLContext::GetCurrent(); | 1028 GLContext* current_context = GLContext::GetCurrent(); |
1029 bool was_current = | 1029 bool was_current = |
1030 current_context && current_context->IsCurrent(this); | 1030 current_context && current_context->IsCurrent(this); |
1031 if (was_current) { | 1031 if (was_current) { |
1032 scoped_make_current.reset( | 1032 scoped_make_current.reset( |
1033 new ui::ScopedMakeCurrent(current_context, this)); | 1033 new ui::ScopedMakeCurrent(current_context, this)); |
1034 } | 1034 } |
1035 | 1035 |
1036 size_ = size; | 1036 size_ = size; |
1037 | 1037 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1120 } | 1120 } |
1121 | 1121 |
1122 void* SurfacelessEGL::GetShareHandle() { | 1122 void* SurfacelessEGL::GetShareHandle() { |
1123 return NULL; | 1123 return NULL; |
1124 } | 1124 } |
1125 | 1125 |
1126 SurfacelessEGL::~SurfacelessEGL() { | 1126 SurfacelessEGL::~SurfacelessEGL() { |
1127 } | 1127 } |
1128 | 1128 |
1129 } // namespace gfx | 1129 } // namespace gfx |
OLD | NEW |