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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 DCHECK(!g_surfaces_instance); | 78 DCHECK(!g_surfaces_instance); |
79 g_surfaces_instance = this; | 79 g_surfaces_instance = this; |
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 surface_factory_->EvictSurface(); | 88 if (root_id_.is_valid()) |
| 89 surface_factory_->Destroy(root_id_); |
89 | 90 |
90 surface_manager_->InvalidateFrameSinkId(frame_sink_id_); | 91 surface_manager_->InvalidateFrameSinkId(frame_sink_id_); |
91 } | 92 } |
92 | 93 |
93 void SurfacesInstance::DisplayOutputSurfaceLost() { | 94 void SurfacesInstance::DisplayOutputSurfaceLost() { |
94 // Android WebView does not handle context loss. | 95 // Android WebView does not handle context loss. |
95 LOG(FATAL) << "Render thread context loss"; | 96 LOG(FATAL) << "Render thread context loss"; |
96 } | 97 } |
97 | 98 |
98 cc::FrameSinkId SurfacesInstance::AllocateFrameSinkId() { | 99 cc::FrameSinkId SurfacesInstance::AllocateFrameSinkId() { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 render_pass->CreateAndAppendDrawQuad<cc::SurfaceDrawQuad>(); | 131 render_pass->CreateAndAppendDrawQuad<cc::SurfaceDrawQuad>(); |
131 surface_quad->SetNew(quad_state, gfx::Rect(quad_state->quad_layer_bounds), | 132 surface_quad->SetNew(quad_state, gfx::Rect(quad_state->quad_layer_bounds), |
132 gfx::Rect(quad_state->quad_layer_bounds), child_id); | 133 gfx::Rect(quad_state->quad_layer_bounds), child_id); |
133 | 134 |
134 cc::CompositorFrame frame; | 135 cc::CompositorFrame frame; |
135 frame.render_pass_list.push_back(std::move(render_pass)); | 136 frame.render_pass_list.push_back(std::move(render_pass)); |
136 frame.metadata.referenced_surfaces = child_ids_; | 137 frame.metadata.referenced_surfaces = child_ids_; |
137 | 138 |
138 if (!root_id_.is_valid()) { | 139 if (!root_id_.is_valid()) { |
139 root_id_ = surface_id_allocator_->GenerateId(); | 140 root_id_ = surface_id_allocator_->GenerateId(); |
| 141 surface_factory_->Create(root_id_); |
140 display_->SetLocalFrameId(root_id_, 1.f); | 142 display_->SetLocalFrameId(root_id_, 1.f); |
141 } | 143 } |
142 surface_factory_->SubmitCompositorFrame(root_id_, std::move(frame), | 144 surface_factory_->SubmitCompositorFrame(root_id_, std::move(frame), |
143 cc::SurfaceFactory::DrawCallback()); | 145 cc::SurfaceFactory::DrawCallback()); |
144 | 146 |
145 display_->Resize(viewport); | 147 display_->Resize(viewport); |
146 display_->DrawAndSwap(); | 148 display_->DrawAndSwap(); |
147 } | 149 } |
148 | 150 |
149 void SurfacesInstance::AddChildId(const cc::SurfaceId& child_id) { | 151 void SurfacesInstance::AddChildId(const cc::SurfaceId& child_id) { |
(...skipping 25 matching lines...) Expand all Loading... |
175 CHECK(resources.empty()); | 177 CHECK(resources.empty()); |
176 } | 178 } |
177 | 179 |
178 void SurfacesInstance::SetBeginFrameSource( | 180 void SurfacesInstance::SetBeginFrameSource( |
179 cc::BeginFrameSource* begin_frame_source) { | 181 cc::BeginFrameSource* begin_frame_source) { |
180 // Parent compsitor calls DrawAndSwap directly and doesn't use | 182 // Parent compsitor calls DrawAndSwap directly and doesn't use |
181 // BeginFrameSource. | 183 // BeginFrameSource. |
182 } | 184 } |
183 | 185 |
184 } // namespace android_webview | 186 } // namespace android_webview |
OLD | NEW |