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