| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "gpu/ipc/service/image_transport_surface_overlay_mac.h" | 5 #include "gpu/ipc/service/image_transport_surface_overlay_mac.h" |
| 6 | 6 |
| 7 #include <CoreGraphics/CoreGraphics.h> | 7 #include <CoreGraphics/CoreGraphics.h> |
| 8 #include <IOSurface/IOSurface.h> | 8 #include <IOSurface/IOSurface.h> |
| 9 #include <OpenGL/CGLRenderers.h> | 9 #include <OpenGL/CGLRenderers.h> |
| 10 #include <OpenGL/CGLTypes.h> | 10 #include <OpenGL/CGLTypes.h> |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 | 84 |
| 85 ImageTransportSurfaceOverlayMac::~ImageTransportSurfaceOverlayMac() { | 85 ImageTransportSurfaceOverlayMac::~ImageTransportSurfaceOverlayMac() { |
| 86 ui::GpuSwitchingManager::GetInstance()->RemoveObserver(this); | 86 ui::GpuSwitchingManager::GetInstance()->RemoveObserver(this); |
| 87 if (delegate_.get()) { | 87 if (delegate_.get()) { |
| 88 delegate_->SetLatencyInfoCallback( | 88 delegate_->SetLatencyInfoCallback( |
| 89 base::Callback<void(const std::vector<ui::LatencyInfo>&)>()); | 89 base::Callback<void(const std::vector<ui::LatencyInfo>&)>()); |
| 90 } | 90 } |
| 91 Destroy(); | 91 Destroy(); |
| 92 } | 92 } |
| 93 | 93 |
| 94 bool ImageTransportSurfaceOverlayMac::Initialize(gl::GLSurface::Format format) { | 94 bool ImageTransportSurfaceOverlayMac::Initialize(gl::GLSurfaceFormat format) { |
| 95 delegate_->SetLatencyInfoCallback( | 95 delegate_->SetLatencyInfoCallback( |
| 96 base::Bind(&ImageTransportSurfaceOverlayMac::SetLatencyInfo, | 96 base::Bind(&ImageTransportSurfaceOverlayMac::SetLatencyInfo, |
| 97 base::Unretained(this))); | 97 base::Unretained(this))); |
| 98 | 98 |
| 99 // Create the CAContext to send this to the GPU process, and the layer for | 99 // Create the CAContext to send this to the GPU process, and the layer for |
| 100 // the context. | 100 // the context. |
| 101 if (use_remote_layer_api_) { | 101 if (use_remote_layer_api_) { |
| 102 CGSConnectionID connection_id = CGSMainConnectionID(); | 102 CGSConnectionID connection_id = CGSMainConnectionID(); |
| 103 ca_context_.reset([ | 103 ca_context_.reset([ |
| 104 [CAContext contextWithCGSConnection:connection_id options:@{}] retain]); | 104 [CAContext contextWithCGSConnection:connection_id options:@{}] retain]); |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 gl_renderer_id_ = context_renderer_id & kCGLRendererIDMatchingMask; | 388 gl_renderer_id_ = context_renderer_id & kCGLRendererIDMatchingMask; |
| 389 | 389 |
| 390 // Post a task holding a reference to the new GL context. The reason for | 390 // Post a task holding a reference to the new GL context. The reason for |
| 391 // this is to avoid creating-then-destroying the context for every image | 391 // this is to avoid creating-then-destroying the context for every image |
| 392 // transport surface that is observing the GPU switch. | 392 // transport surface that is observing the GPU switch. |
| 393 base::ThreadTaskRunnerHandle::Get()->PostTask( | 393 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 394 FROM_HERE, base::Bind(&IOSurfaceContextNoOp, context_on_new_gpu)); | 394 FROM_HERE, base::Bind(&IOSurfaceContextNoOp, context_on_new_gpu)); |
| 395 } | 395 } |
| 396 | 396 |
| 397 } // namespace gpu | 397 } // namespace gpu |
| OLD | NEW |