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 #include "gpu/ipc/common/gpu_surface_tracker.h" |
10 | 11 |
11 namespace blimp { | 12 namespace blimp { |
12 namespace client { | 13 namespace client { |
13 | 14 |
14 BrowserCompositor::BrowserCompositor( | 15 BrowserCompositor::BrowserCompositor( |
15 CompositorDependencies* compositor_dependencies) | 16 CompositorDependencies* compositor_dependencies) |
16 : BlimpEmbedderCompositor(compositor_dependencies) {} | 17 : BlimpEmbedderCompositor(compositor_dependencies) {} |
17 | 18 |
18 BrowserCompositor::~BrowserCompositor() = default; | 19 BrowserCompositor::~BrowserCompositor() { |
| 20 if (surface_handle_ != gpu::kNullSurfaceHandle) { |
| 21 gpu::GpuSurfaceTracker::Get()->RemoveSurface(surface_handle_); |
| 22 } |
| 23 } |
19 | 24 |
20 void BrowserCompositor::SetAcceleratedWidget(gfx::AcceleratedWidget widget) { | 25 void BrowserCompositor::SetAcceleratedWidget(gfx::AcceleratedWidget widget) { |
21 scoped_refptr<cc::ContextProvider> provider; | 26 scoped_refptr<cc::ContextProvider> provider; |
22 | 27 |
23 if (widget != gfx::kNullAcceleratedWidget) { | 28 if (widget != gfx::kNullAcceleratedWidget) { |
| 29 DCHECK_EQ(gpu::kNullSurfaceHandle, surface_handle_); |
| 30 surface_handle_ = |
| 31 gpu::GpuSurfaceTracker::Get()->AddSurfaceForNativeWidget(widget); |
24 provider = BlimpContextProvider::Create( | 32 provider = BlimpContextProvider::Create( |
25 widget, compositor_dependencies()->GetGpuMemoryBufferManager()); | 33 surface_handle_, |
| 34 compositor_dependencies()->GetGpuMemoryBufferManager()); |
26 } | 35 } |
27 | 36 |
28 SetContextProvider(std::move(provider)); | 37 SetContextProvider(std::move(provider)); |
29 } | 38 } |
30 | 39 |
31 void BrowserCompositor::DidReceiveCompositorFrameAck() { | 40 void BrowserCompositor::DidReceiveCompositorFrameAck() { |
32 if (!did_complete_swap_buffers_.is_null()) { | 41 if (!did_complete_swap_buffers_.is_null()) { |
33 did_complete_swap_buffers_.Run(); | 42 did_complete_swap_buffers_.Run(); |
34 } | 43 } |
35 } | 44 } |
36 | 45 |
37 } // namespace client | 46 } // namespace client |
38 } // namespace blimp | 47 } // namespace blimp |
OLD | NEW |