Chromium Code Reviews| 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.h" | 5 #include "ui/gl/gl_surface.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
| 13 #include "base/threading/thread_local.h" | 13 #include "base/threading/thread_local.h" |
| 14 #include "base/trace_event/trace_event.h" | 14 #include "base/trace_event/trace_event.h" |
| 15 #include "ui/gfx/swap_result.h" | 15 #include "ui/gfx/swap_result.h" |
| 16 #include "ui/gl/gl_context.h" | 16 #include "ui/gl/gl_context.h" |
| 17 #include "ui/gl/gl_image.h" | 17 #include "ui/gl/gl_image.h" |
| 18 #include "ui/gl/gl_implementation.h" | 18 #include "ui/gl/gl_implementation.h" |
| 19 #include "ui/gl/gl_surface_format.h" | |
| 19 #include "ui/gl/gl_switches.h" | 20 #include "ui/gl/gl_switches.h" |
| 20 | 21 |
| 21 namespace gl { | 22 namespace gl { |
| 22 | 23 |
| 23 namespace { | 24 namespace { |
| 24 base::LazyInstance<base::ThreadLocalPointer<GLSurface> >::Leaky | 25 base::LazyInstance<base::ThreadLocalPointer<GLSurface> >::Leaky |
| 25 current_surface_ = LAZY_INSTANCE_INITIALIZER; | 26 current_surface_ = LAZY_INSTANCE_INITIALIZER; |
| 26 } // namespace | 27 } // namespace |
| 27 | 28 |
| 28 GLSurface::GLSurface() {} | 29 GLSurface::GLSurface() {} |
| 29 | 30 |
| 30 bool GLSurface::Initialize() { | 31 bool GLSurface::Initialize() { |
| 31 return Initialize(SURFACE_DEFAULT); | 32 return Initialize(GLSurfaceFormat()); |
| 32 } | 33 } |
| 33 | 34 |
| 34 bool GLSurface::Initialize(GLSurface::Format format) { | 35 bool GLSurface::Initialize(GLSurfaceFormat format) { |
| 35 return true; | 36 return true; |
| 36 } | 37 } |
| 37 | 38 |
| 38 bool GLSurface::Resize(const gfx::Size& size, | 39 bool GLSurface::Resize(const gfx::Size& size, |
| 39 float scale_factor, | 40 float scale_factor, |
| 40 bool has_alpha) { | 41 bool has_alpha) { |
| 41 NOTIMPLEMENTED(); | 42 NOTIMPLEMENTED(); |
| 42 return false; | 43 return false; |
| 43 } | 44 } |
| 44 | 45 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 127 | 128 |
| 128 void* GLSurface::GetConfig() { | 129 void* GLSurface::GetConfig() { |
| 129 NOTIMPLEMENTED(); | 130 NOTIMPLEMENTED(); |
| 130 return NULL; | 131 return NULL; |
| 131 } | 132 } |
| 132 | 133 |
| 133 unsigned long GLSurface::GetCompatibilityKey() { | 134 unsigned long GLSurface::GetCompatibilityKey() { |
| 134 return 0; | 135 return 0; |
| 135 } | 136 } |
| 136 | 137 |
| 137 GLSurface::Format GLSurface::GetFormat() { | 138 GLSurfaceFormat GLSurface::GetFormat() { |
| 138 NOTIMPLEMENTED(); | 139 NOTIMPLEMENTED(); |
| 139 return SURFACE_DEFAULT; | 140 return GLSurfaceFormat(); |
| 140 } | 141 } |
| 141 | 142 |
| 142 gfx::VSyncProvider* GLSurface::GetVSyncProvider() { | 143 gfx::VSyncProvider* GLSurface::GetVSyncProvider() { |
| 143 return NULL; | 144 return NULL; |
| 144 } | 145 } |
| 145 | 146 |
| 146 bool GLSurface::ScheduleOverlayPlane(int z_order, | 147 bool GLSurface::ScheduleOverlayPlane(int z_order, |
| 147 gfx::OverlayTransform transform, | 148 gfx::OverlayTransform transform, |
| 148 GLImage* image, | 149 GLImage* image, |
| 149 const gfx::Rect& bounds_rect, | 150 const gfx::Rect& bounds_rect, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 198 delimited_name += " "; | 199 delimited_name += " "; |
| 199 | 200 |
| 200 return extensions.find(delimited_name) != std::string::npos; | 201 return extensions.find(delimited_name) != std::string::npos; |
| 201 } | 202 } |
| 202 | 203 |
| 203 void GLSurface::OnSetSwapInterval(int interval) { | 204 void GLSurface::OnSetSwapInterval(int interval) { |
| 204 } | 205 } |
| 205 | 206 |
| 206 GLSurfaceAdapter::GLSurfaceAdapter(GLSurface* surface) : surface_(surface) {} | 207 GLSurfaceAdapter::GLSurfaceAdapter(GLSurface* surface) : surface_(surface) {} |
| 207 | 208 |
| 208 bool GLSurfaceAdapter::Initialize(GLSurface::Format format) { | 209 bool GLSurfaceAdapter::Initialize(GLSurfaceFormat format) { |
| 209 return surface_->Initialize(format); | 210 return surface_->Initialize(format); |
| 210 } | 211 } |
| 211 | 212 |
| 212 void GLSurfaceAdapter::Destroy() { | 213 void GLSurfaceAdapter::Destroy() { |
| 213 surface_->Destroy(); | 214 surface_->Destroy(); |
| 214 } | 215 } |
| 215 | 216 |
| 216 bool GLSurfaceAdapter::Resize(const gfx::Size& size, | 217 bool GLSurfaceAdapter::Resize(const gfx::Size& size, |
| 217 float scale_factor, | 218 float scale_factor, |
| 218 bool has_alpha) { | 219 bool has_alpha) { |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 321 } | 322 } |
| 322 | 323 |
| 323 void* GLSurfaceAdapter::GetConfig() { | 324 void* GLSurfaceAdapter::GetConfig() { |
| 324 return surface_->GetConfig(); | 325 return surface_->GetConfig(); |
| 325 } | 326 } |
| 326 | 327 |
| 327 unsigned long GLSurfaceAdapter::GetCompatibilityKey() { | 328 unsigned long GLSurfaceAdapter::GetCompatibilityKey() { |
| 328 return surface_->GetCompatibilityKey(); | 329 return surface_->GetCompatibilityKey(); |
| 329 } | 330 } |
| 330 | 331 |
| 331 GLSurface::Format GLSurfaceAdapter::GetFormat() { | 332 GLSurfaceFormat GLSurfaceAdapter::GetFormat() { |
| 332 return surface_->GetFormat(); | 333 return surface_->GetFormat(); |
| 333 } | 334 } |
| 334 | 335 |
| 335 gfx::VSyncProvider* GLSurfaceAdapter::GetVSyncProvider() { | 336 gfx::VSyncProvider* GLSurfaceAdapter::GetVSyncProvider() { |
| 336 return surface_->GetVSyncProvider(); | 337 return surface_->GetVSyncProvider(); |
| 337 } | 338 } |
| 338 | 339 |
| 339 bool GLSurfaceAdapter::ScheduleOverlayPlane(int z_order, | 340 bool GLSurfaceAdapter::ScheduleOverlayPlane(int z_order, |
| 340 gfx::OverlayTransform transform, | 341 gfx::OverlayTransform transform, |
| 341 GLImage* image, | 342 GLImage* image, |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 352 bool GLSurfaceAdapter::FlipsVertically() const { | 353 bool GLSurfaceAdapter::FlipsVertically() const { |
| 353 return surface_->FlipsVertically(); | 354 return surface_->FlipsVertically(); |
| 354 } | 355 } |
| 355 | 356 |
| 356 bool GLSurfaceAdapter::BuffersFlipped() const { | 357 bool GLSurfaceAdapter::BuffersFlipped() const { |
| 357 return surface_->BuffersFlipped(); | 358 return surface_->BuffersFlipped(); |
| 358 } | 359 } |
| 359 | 360 |
| 360 GLSurfaceAdapter::~GLSurfaceAdapter() {} | 361 GLSurfaceAdapter::~GLSurfaceAdapter() {} |
| 361 | 362 |
| 362 scoped_refptr<GLSurface> InitializeGLSurface(scoped_refptr<GLSurface> surface) { | 363 scoped_refptr<GLSurface> InitializeGLSurfaceWithFormat( |
| 363 if (!surface->Initialize()) | 364 scoped_refptr<GLSurface> surface, GLSurfaceFormat format) { |
|
bajones
2017/01/04 22:31:55
Nit: This function doesn't actually need to change
klausw
2017/01/05 00:55:13
I needed a new Initialize..WithFormat, and I don't
| |
| 365 if (!surface->Initialize(format)) | |
| 364 return nullptr; | 366 return nullptr; |
| 365 return surface; | 367 return surface; |
| 366 } | 368 } |
| 367 | 369 |
| 370 scoped_refptr<GLSurface> InitializeGLSurface(scoped_refptr<GLSurface> surface) { | |
| 371 return InitializeGLSurfaceWithFormat(surface, GLSurfaceFormat()); | |
| 372 } | |
| 373 | |
| 368 GLSurface::CALayerInUseQuery::CALayerInUseQuery() = default; | 374 GLSurface::CALayerInUseQuery::CALayerInUseQuery() = default; |
| 369 GLSurface::CALayerInUseQuery::CALayerInUseQuery(const CALayerInUseQuery&) = | 375 GLSurface::CALayerInUseQuery::CALayerInUseQuery(const CALayerInUseQuery&) = |
| 370 default; | 376 default; |
| 371 GLSurface::CALayerInUseQuery::~CALayerInUseQuery() = default; | 377 GLSurface::CALayerInUseQuery::~CALayerInUseQuery() = default; |
| 372 | 378 |
| 373 } // namespace gl | 379 } // namespace gl |
| OLD | NEW |