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 "android_webview/browser/surfaces_instance.h" | 5 #include "android_webview/browser/surfaces_instance.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "android_webview/browser/aw_gl_surface.h" | 10 #include "android_webview/browser/aw_gl_surface.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 // Should be kept in sync with compositor_impl_android.cc. | 45 // Should be kept in sync with compositor_impl_android.cc. |
46 settings.allow_antialiasing = false; | 46 settings.allow_antialiasing = false; |
47 settings.highp_threshold_min = 2048; | 47 settings.highp_threshold_min = 2048; |
48 | 48 |
49 // Webview does not own the surface so should not clear it. | 49 // Webview does not own the surface so should not clear it. |
50 settings.should_clear_root_render_pass = false; | 50 settings.should_clear_root_render_pass = false; |
51 | 51 |
52 surface_manager_.reset(new cc::SurfaceManager); | 52 surface_manager_.reset(new cc::SurfaceManager); |
53 surface_id_allocator_.reset( | 53 surface_id_allocator_.reset( |
54 new cc::SurfaceIdAllocator(next_surface_client_id_++)); | 54 new cc::SurfaceIdAllocator(next_surface_client_id_++)); |
55 surface_id_allocator_->RegisterSurfaceClientId(surface_manager_.get()); | 55 surface_manager_->RegisterSurfaceClientId(surface_id_allocator_->client_id()); |
56 | 56 |
57 std::unique_ptr<cc::BeginFrameSource> begin_frame_source( | 57 std::unique_ptr<cc::BeginFrameSource> begin_frame_source( |
58 new cc::StubBeginFrameSource); | 58 new cc::StubBeginFrameSource); |
59 std::unique_ptr<cc::TextureMailboxDeleter> texture_mailbox_deleter( | 59 std::unique_ptr<cc::TextureMailboxDeleter> texture_mailbox_deleter( |
60 new cc::TextureMailboxDeleter(nullptr)); | 60 new cc::TextureMailboxDeleter(nullptr)); |
61 std::unique_ptr<ParentOutputSurface> output_surface_holder( | 61 std::unique_ptr<ParentOutputSurface> output_surface_holder( |
62 new ParentOutputSurface(AwRenderThreadContextProvider::Create( | 62 new ParentOutputSurface(AwRenderThreadContextProvider::Create( |
63 gl_surface_, DeferredGpuCommandService::GetInstance()))); | 63 gl_surface_, DeferredGpuCommandService::GetInstance()))); |
64 output_surface_ = output_surface_holder.get(); | 64 output_surface_ = output_surface_holder.get(); |
65 std::unique_ptr<cc::DisplayScheduler> scheduler(new cc::DisplayScheduler( | 65 std::unique_ptr<cc::DisplayScheduler> scheduler(new cc::DisplayScheduler( |
(...skipping 14 matching lines...) Expand all Loading... |
80 | 80 |
81 } | 81 } |
82 | 82 |
83 SurfacesInstance::~SurfacesInstance() { | 83 SurfacesInstance::~SurfacesInstance() { |
84 DCHECK_EQ(g_surfaces_instance, this); | 84 DCHECK_EQ(g_surfaces_instance, this); |
85 g_surfaces_instance = nullptr; | 85 g_surfaces_instance = nullptr; |
86 | 86 |
87 DCHECK(child_ids_.empty()); | 87 DCHECK(child_ids_.empty()); |
88 if (!root_id_.is_null()) | 88 if (!root_id_.is_null()) |
89 surface_factory_->Destroy(root_id_); | 89 surface_factory_->Destroy(root_id_); |
| 90 |
| 91 surface_manager_->InvalidateSurfaceClientId( |
| 92 surface_id_allocator_->client_id()); |
90 } | 93 } |
91 | 94 |
92 std::unique_ptr<cc::SurfaceIdAllocator> | 95 uint32_t SurfacesInstance::AllocateSurfaceClientId() { |
93 SurfacesInstance::CreateSurfaceIdAllocator() { | 96 return next_surface_client_id_++; |
94 std::unique_ptr<cc::SurfaceIdAllocator> allocator = | |
95 base::WrapUnique(new cc::SurfaceIdAllocator(next_surface_client_id_++)); | |
96 allocator->RegisterSurfaceClientId(surface_manager_.get()); | |
97 return allocator; | |
98 } | 97 } |
99 | 98 |
100 cc::SurfaceManager* SurfacesInstance::GetSurfaceManager() { | 99 cc::SurfaceManager* SurfacesInstance::GetSurfaceManager() { |
101 return surface_manager_.get(); | 100 return surface_manager_.get(); |
102 } | 101 } |
103 | 102 |
104 void SurfacesInstance::SetBackingFrameBufferObject( | 103 void SurfacesInstance::SetBackingFrameBufferObject( |
105 int framebuffer_binding_ext) { | 104 int framebuffer_binding_ext) { |
106 gl_surface_->SetBackingFrameBufferObject(framebuffer_binding_ext); | 105 gl_surface_->SetBackingFrameBufferObject(framebuffer_binding_ext); |
107 } | 106 } |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 CHECK(resources.empty()); | 184 CHECK(resources.empty()); |
186 } | 185 } |
187 | 186 |
188 void SurfacesInstance::SetBeginFrameSource( | 187 void SurfacesInstance::SetBeginFrameSource( |
189 cc::BeginFrameSource* begin_frame_source) { | 188 cc::BeginFrameSource* begin_frame_source) { |
190 // Parent compsitor calls DrawAndSwap directly and doesn't use | 189 // Parent compsitor calls DrawAndSwap directly and doesn't use |
191 // BeginFrameSource. | 190 // BeginFrameSource. |
192 } | 191 } |
193 | 192 |
194 } // namespace android_webview | 193 } // namespace android_webview |
OLD | NEW |