OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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 "blimp/client/app/compositor/browser_compositor.h" | 5 #include "blimp/client/app/compositor/browser_compositor.h" |
6 | 6 |
7 #include "blimp/client/public/compositor/compositor_dependencies.h" | 7 #include "blimp/client/public/compositor/compositor_dependencies.h" |
8 #include "blimp/client/support/compositor/blimp_context_provider.h" | 8 #include "blimp/client/support/compositor/blimp_context_provider.h" |
9 #include "cc/output/context_provider.h" | 9 #include "cc/output/context_provider.h" |
10 | 10 |
| 11 #if !defined(GPU_SURFACE_HANDLE_IS_ACCELERATED_WINDOW) |
| 12 #include "gpu/ipc/common/gpu_surface_tracker.h" |
| 13 #endif |
| 14 |
11 namespace blimp { | 15 namespace blimp { |
12 namespace client { | 16 namespace client { |
13 | 17 |
14 BrowserCompositor::BrowserCompositor( | 18 BrowserCompositor::BrowserCompositor( |
15 CompositorDependencies* compositor_dependencies) | 19 CompositorDependencies* compositor_dependencies) |
16 : BlimpEmbedderCompositor(compositor_dependencies) {} | 20 : BlimpEmbedderCompositor(compositor_dependencies) {} |
17 | 21 |
18 BrowserCompositor::~BrowserCompositor() = default; | 22 BrowserCompositor::~BrowserCompositor() { |
| 23 #if !defined(GPU_SURFACE_HANDLE_IS_ACCELERATED_WINDOW) |
| 24 if (surface_handle_ != gpu::kNullSurfaceHandle) |
| 25 gpu::GpuSurfaceTracker::Get()->RemoveSurface(surface_handle_); |
| 26 #endif |
| 27 } |
19 | 28 |
20 void BrowserCompositor::SetAcceleratedWidget(gfx::AcceleratedWidget widget) { | 29 void BrowserCompositor::SetAcceleratedWidget(gfx::AcceleratedWidget widget) { |
21 scoped_refptr<cc::ContextProvider> provider; | 30 scoped_refptr<cc::ContextProvider> provider; |
22 | 31 |
23 if (widget != gfx::kNullAcceleratedWidget) { | 32 if (widget != gfx::kNullAcceleratedWidget) { |
| 33 DCHECK_EQ(gpu::kNullSurfaceHandle, surface_handle_); |
| 34 #if !defined(GPU_SURFACE_HANDLE_IS_ACCELERATED_WINDOW) |
| 35 surface_handle_ = |
| 36 gpu::GpuSurfaceTracker::Get()->AddSurfaceForNativeWidget(widget); |
| 37 #else |
| 38 surface_handle_ = widget; |
| 39 #endif |
24 provider = BlimpContextProvider::Create( | 40 provider = BlimpContextProvider::Create( |
25 widget, compositor_dependencies()->GetGpuMemoryBufferManager()); | 41 surface_handle_, |
| 42 compositor_dependencies()->GetGpuMemoryBufferManager()); |
26 } | 43 } |
27 | 44 |
28 SetContextProvider(std::move(provider)); | 45 SetContextProvider(std::move(provider)); |
29 } | 46 } |
30 | 47 |
31 void BrowserCompositor::DidReceiveCompositorFrameAck() { | 48 void BrowserCompositor::DidReceiveCompositorFrameAck() { |
32 if (!did_complete_swap_buffers_.is_null()) { | 49 if (!did_complete_swap_buffers_.is_null()) { |
33 did_complete_swap_buffers_.Run(); | 50 did_complete_swap_buffers_.Run(); |
34 } | 51 } |
35 } | 52 } |
36 | 53 |
37 } // namespace client | 54 } // namespace client |
38 } // namespace blimp | 55 } // namespace blimp |
OLD | NEW |