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