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