| 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 10 matching lines...) Expand all Loading... |
| 21 #include "cc/surfaces/display_scheduler.h" | 21 #include "cc/surfaces/display_scheduler.h" |
| 22 #include "cc/surfaces/surface_id_allocator.h" | 22 #include "cc/surfaces/surface_id_allocator.h" |
| 23 #include "cc/surfaces/surface_manager.h" | 23 #include "cc/surfaces/surface_manager.h" |
| 24 #include "ui/gfx/geometry/rect.h" | 24 #include "ui/gfx/geometry/rect.h" |
| 25 #include "ui/gfx/geometry/size.h" | 25 #include "ui/gfx/geometry/size.h" |
| 26 #include "ui/gfx/transform.h" | 26 #include "ui/gfx/transform.h" |
| 27 | 27 |
| 28 namespace android_webview { | 28 namespace android_webview { |
| 29 | 29 |
| 30 namespace { | 30 namespace { |
| 31 // The client_id used here should not conflict with the client_id generated |
| 32 // from RenderWidgetHostImpl. |
| 33 constexpr uint32_t kDefaultClientId = 0u; |
| 31 SurfacesInstance* g_surfaces_instance = nullptr; | 34 SurfacesInstance* g_surfaces_instance = nullptr; |
| 32 } // namespace | 35 } // namespace |
| 33 | 36 |
| 34 // static | 37 // static |
| 35 scoped_refptr<SurfacesInstance> SurfacesInstance::GetOrCreateInstance() { | 38 scoped_refptr<SurfacesInstance> SurfacesInstance::GetOrCreateInstance() { |
| 36 if (g_surfaces_instance) | 39 if (g_surfaces_instance) |
| 37 return make_scoped_refptr(g_surfaces_instance); | 40 return make_scoped_refptr(g_surfaces_instance); |
| 38 return make_scoped_refptr(new SurfacesInstance); | 41 return make_scoped_refptr(new SurfacesInstance); |
| 39 } | 42 } |
| 40 | 43 |
| 41 SurfacesInstance::SurfacesInstance() | 44 SurfacesInstance::SurfacesInstance() |
| 42 : next_client_id_(1u), frame_sink_id_(AllocateFrameSinkId()) { | 45 : frame_sink_id_allocator_(kDefaultClientId), |
| 46 frame_sink_id_(AllocateFrameSinkId()) { |
| 43 cc::RendererSettings settings; | 47 cc::RendererSettings settings; |
| 44 | 48 |
| 45 // Should be kept in sync with compositor_impl_android.cc. | 49 // Should be kept in sync with compositor_impl_android.cc. |
| 46 settings.allow_antialiasing = false; | 50 settings.allow_antialiasing = false; |
| 47 settings.highp_threshold_min = 2048; | 51 settings.highp_threshold_min = 2048; |
| 48 | 52 |
| 49 // Webview does not own the surface so should not clear it. | 53 // Webview does not own the surface so should not clear it. |
| 50 settings.should_clear_root_render_pass = false; | 54 settings.should_clear_root_render_pass = false; |
| 51 | 55 |
| 52 surface_manager_.reset(new cc::SurfaceManager); | 56 surface_manager_.reset(new cc::SurfaceManager); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 g_surfaces_instance = nullptr; | 90 g_surfaces_instance = nullptr; |
| 87 DCHECK(child_ids_.empty()); | 91 DCHECK(child_ids_.empty()); |
| 88 } | 92 } |
| 89 | 93 |
| 90 void SurfacesInstance::DisplayOutputSurfaceLost() { | 94 void SurfacesInstance::DisplayOutputSurfaceLost() { |
| 91 // Android WebView does not handle context loss. | 95 // Android WebView does not handle context loss. |
| 92 LOG(FATAL) << "Render thread context loss"; | 96 LOG(FATAL) << "Render thread context loss"; |
| 93 } | 97 } |
| 94 | 98 |
| 95 cc::FrameSinkId SurfacesInstance::AllocateFrameSinkId() { | 99 cc::FrameSinkId SurfacesInstance::AllocateFrameSinkId() { |
| 96 return cc::FrameSinkId(next_client_id_++, 0 /* sink_id */); | 100 return frame_sink_id_allocator_.NextFrameSinkId(); |
| 97 } | 101 } |
| 98 | 102 |
| 99 cc::SurfaceManager* SurfacesInstance::GetSurfaceManager() { | 103 cc::SurfaceManager* SurfacesInstance::GetSurfaceManager() { |
| 100 return surface_manager_.get(); | 104 return surface_manager_.get(); |
| 101 } | 105 } |
| 102 | 106 |
| 103 void SurfacesInstance::DrawAndSwap(const gfx::Size& viewport, | 107 void SurfacesInstance::DrawAndSwap(const gfx::Size& viewport, |
| 104 const gfx::Rect& clip, | 108 const gfx::Rect& clip, |
| 105 const gfx::Transform& transform, | 109 const gfx::Transform& transform, |
| 106 const gfx::Size& frame_size, | 110 const gfx::Size& frame_size, |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 const cc::LocalSurfaceId& local_surface_id, | 177 const cc::LocalSurfaceId& local_surface_id, |
| 174 const gfx::Rect& damage_rect) {} | 178 const gfx::Rect& damage_rect) {} |
| 175 | 179 |
| 176 void SurfacesInstance::ReclaimResources( | 180 void SurfacesInstance::ReclaimResources( |
| 177 const cc::ReturnedResourceArray& resources) { | 181 const cc::ReturnedResourceArray& resources) { |
| 178 // Root surface should have no resources to return. | 182 // Root surface should have no resources to return. |
| 179 CHECK(resources.empty()); | 183 CHECK(resources.empty()); |
| 180 } | 184 } |
| 181 | 185 |
| 182 } // namespace android_webview | 186 } // namespace android_webview |
| OLD | NEW |