| 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 29 matching lines...) Expand all Loading... |
| 82 g_surfaces_instance = nullptr; | 86 g_surfaces_instance = nullptr; |
| 83 DCHECK(child_ids_.empty()); | 87 DCHECK(child_ids_.empty()); |
| 84 } | 88 } |
| 85 | 89 |
| 86 void SurfacesInstance::DisplayOutputSurfaceLost() { | 90 void SurfacesInstance::DisplayOutputSurfaceLost() { |
| 87 // Android WebView does not handle context loss. | 91 // Android WebView does not handle context loss. |
| 88 LOG(FATAL) << "Render thread context loss"; | 92 LOG(FATAL) << "Render thread context loss"; |
| 89 } | 93 } |
| 90 | 94 |
| 91 cc::FrameSinkId SurfacesInstance::AllocateFrameSinkId() { | 95 cc::FrameSinkId SurfacesInstance::AllocateFrameSinkId() { |
| 92 return cc::FrameSinkId(next_client_id_++, 0 /* sink_id */); | 96 return frame_sink_id_allocator_.NextFrameSinkId(); |
| 93 } | 97 } |
| 94 | 98 |
| 95 cc::SurfaceManager* SurfacesInstance::GetSurfaceManager() { | 99 cc::SurfaceManager* SurfacesInstance::GetSurfaceManager() { |
| 96 return surface_manager_.get(); | 100 return surface_manager_.get(); |
| 97 } | 101 } |
| 98 | 102 |
| 99 void SurfacesInstance::DrawAndSwap(const gfx::Size& viewport, | 103 void SurfacesInstance::DrawAndSwap(const gfx::Size& viewport, |
| 100 const gfx::Rect& clip, | 104 const gfx::Rect& clip, |
| 101 const gfx::Transform& transform, | 105 const gfx::Transform& transform, |
| 102 const gfx::Size& frame_size, | 106 const gfx::Size& frame_size, |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 | 170 |
| 167 void SurfacesInstance::WillDrawSurface() {} | 171 void SurfacesInstance::WillDrawSurface() {} |
| 168 | 172 |
| 169 void SurfacesInstance::ReclaimResources( | 173 void SurfacesInstance::ReclaimResources( |
| 170 const cc::ReturnedResourceArray& resources) { | 174 const cc::ReturnedResourceArray& resources) { |
| 171 // Root surface should have no resources to return. | 175 // Root surface should have no resources to return. |
| 172 CHECK(resources.empty()); | 176 CHECK(resources.empty()); |
| 173 } | 177 } |
| 174 | 178 |
| 175 } // namespace android_webview | 179 } // namespace android_webview |
| OLD | NEW |