Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_android.cc

Issue 1904773004: Revert of Introduce components/display_compositor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/renderer_host/render_widget_host_view_android.h" 5 #include "content/browser/renderer_host/render_widget_host_view_android.h"
6 6
7 #include <android/bitmap.h> 7 #include <android/bitmap.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 16 matching lines...) Expand all
27 #include "cc/output/copy_output_request.h" 27 #include "cc/output/copy_output_request.h"
28 #include "cc/output/copy_output_result.h" 28 #include "cc/output/copy_output_result.h"
29 #include "cc/output/latency_info_swap_promise.h" 29 #include "cc/output/latency_info_swap_promise.h"
30 #include "cc/output/viewport_selection_bound.h" 30 #include "cc/output/viewport_selection_bound.h"
31 #include "cc/resources/single_release_callback.h" 31 #include "cc/resources/single_release_callback.h"
32 #include "cc/surfaces/surface.h" 32 #include "cc/surfaces/surface.h"
33 #include "cc/surfaces/surface_factory.h" 33 #include "cc/surfaces/surface_factory.h"
34 #include "cc/surfaces/surface_id_allocator.h" 34 #include "cc/surfaces/surface_id_allocator.h"
35 #include "cc/surfaces/surface_manager.h" 35 #include "cc/surfaces/surface_manager.h"
36 #include "cc/trees/layer_tree_host.h" 36 #include "cc/trees/layer_tree_host.h"
37 #include "components/display_compositor/gl_helper.h"
38 #include "content/browser/accessibility/browser_accessibility_manager_android.h" 37 #include "content/browser/accessibility/browser_accessibility_manager_android.h"
39 #include "content/browser/android/composited_touch_handle_drawable.h" 38 #include "content/browser/android/composited_touch_handle_drawable.h"
40 #include "content/browser/android/content_view_core_impl.h" 39 #include "content/browser/android/content_view_core_impl.h"
41 #include "content/browser/android/overscroll_controller_android.h" 40 #include "content/browser/android/overscroll_controller_android.h"
42 #include "content/browser/android/popup_touch_handle_drawable.h" 41 #include "content/browser/android/popup_touch_handle_drawable.h"
43 #include "content/browser/android/synchronous_compositor_base.h" 42 #include "content/browser/android/synchronous_compositor_base.h"
43 #include "content/browser/compositor/gl_helper.h"
44 #include "content/browser/devtools/render_frame_devtools_agent_host.h" 44 #include "content/browser/devtools/render_frame_devtools_agent_host.h"
45 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" 45 #include "content/browser/gpu/browser_gpu_channel_host_factory.h"
46 #include "content/browser/gpu/compositor_util.h" 46 #include "content/browser/gpu/compositor_util.h"
47 #include "content/browser/gpu/gpu_data_manager_impl.h" 47 #include "content/browser/gpu/gpu_data_manager_impl.h"
48 #include "content/browser/gpu/gpu_process_host_ui_shim.h" 48 #include "content/browser/gpu/gpu_process_host_ui_shim.h"
49 #include "content/browser/media/android/media_web_contents_observer_android.h" 49 #include "content/browser/media/android/media_web_contents_observer_android.h"
50 #include "content/browser/renderer_host/compositor_impl_android.h" 50 #include "content/browser/renderer_host/compositor_impl_android.h"
51 #include "content/browser/renderer_host/dip_util.h" 51 #include "content/browser/renderer_host/dip_util.h"
52 #include "content/browser/renderer_host/frame_metadata_util.h" 52 #include "content/browser/renderer_host/frame_metadata_util.h"
53 #include "content/browser/renderer_host/input/synthetic_gesture_target_android.h " 53 #include "content/browser/renderer_host/input/synthetic_gesture_target_android.h "
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 } 115 }
116 116
117 const int kUndefinedOutputSurfaceId = -1; 117 const int kUndefinedOutputSurfaceId = -1;
118 118
119 static const char kAsyncReadBackString[] = "Compositing.CopyFromSurfaceTime"; 119 static const char kAsyncReadBackString[] = "Compositing.CopyFromSurfaceTime";
120 120
121 class GLHelperHolder { 121 class GLHelperHolder {
122 public: 122 public:
123 static GLHelperHolder* Create(); 123 static GLHelperHolder* Create();
124 124
125 display_compositor::GLHelper* gl_helper() { return gl_helper_.get(); } 125 GLHelper* gl_helper() { return gl_helper_.get(); }
126 bool IsLost() { 126 bool IsLost() {
127 if (!gl_helper_) 127 if (!gl_helper_)
128 return true; 128 return true;
129 return provider_->ContextGL()->GetGraphicsResetStatusKHR() != GL_NO_ERROR; 129 return provider_->ContextGL()->GetGraphicsResetStatusKHR() != GL_NO_ERROR;
130 } 130 }
131 131
132 private: 132 private:
133 GLHelperHolder() = default; 133 GLHelperHolder() = default;
134 void Initialize(); 134 void Initialize();
135 void OnContextLost(); 135 void OnContextLost();
136 136
137 scoped_refptr<ContextProviderCommandBuffer> provider_; 137 scoped_refptr<ContextProviderCommandBuffer> provider_;
138 std::unique_ptr<display_compositor::GLHelper> gl_helper_; 138 std::unique_ptr<GLHelper> gl_helper_;
139 139
140 DISALLOW_COPY_AND_ASSIGN(GLHelperHolder); 140 DISALLOW_COPY_AND_ASSIGN(GLHelperHolder);
141 }; 141 };
142 142
143 GLHelperHolder* GLHelperHolder::Create() { 143 GLHelperHolder* GLHelperHolder::Create() {
144 GLHelperHolder* holder = new GLHelperHolder; 144 GLHelperHolder* holder = new GLHelperHolder;
145 holder->Initialize(); 145 holder->Initialize();
146 return holder; 146 return holder;
147 } 147 }
148 148
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 provider_ = new ContextProviderCommandBuffer( 189 provider_ = new ContextProviderCommandBuffer(
190 std::move(context), limits, BROWSER_OFFSCREEN_MAINTHREAD_CONTEXT); 190 std::move(context), limits, BROWSER_OFFSCREEN_MAINTHREAD_CONTEXT);
191 if (!provider_->BindToCurrentThread()) 191 if (!provider_->BindToCurrentThread())
192 return; 192 return;
193 provider_->ContextGL()->TraceBeginCHROMIUM( 193 provider_->ContextGL()->TraceBeginCHROMIUM(
194 "gpu_toplevel", 194 "gpu_toplevel",
195 base::StringPrintf("CmdBufferImageTransportFactory-%p", provider_.get()) 195 base::StringPrintf("CmdBufferImageTransportFactory-%p", provider_.get())
196 .c_str()); 196 .c_str());
197 provider_->SetLostContextCallback( 197 provider_->SetLostContextCallback(
198 base::Bind(&GLHelperHolder::OnContextLost, base::Unretained(this))); 198 base::Bind(&GLHelperHolder::OnContextLost, base::Unretained(this)));
199 gl_helper_.reset(new display_compositor::GLHelper( 199 gl_helper_.reset(
200 provider_->ContextGL(), provider_->ContextSupport())); 200 new GLHelper(provider_->ContextGL(), provider_->ContextSupport()));
201 } 201 }
202 202
203 void GLHelperHolder::OnContextLost() { 203 void GLHelperHolder::OnContextLost() {
204 // Need to post a task because the command buffer client cannot be deleted 204 // Need to post a task because the command buffer client cannot be deleted
205 // from within this callback. 205 // from within this callback.
206 base::MessageLoop::current()->PostTask( 206 base::MessageLoop::current()->PostTask(
207 FROM_HERE, base::Bind(&RenderWidgetHostViewAndroid::OnContextLost)); 207 FROM_HERE, base::Bind(&RenderWidgetHostViewAndroid::OnContextLost));
208 } 208 }
209 209
210 // This can only be used for readback postprocessing. It may return null if the 210 // This can only be used for readback postprocessing. It may return null if the
211 // channel was lost and not reestablished yet. 211 // channel was lost and not reestablished yet.
212 display_compositor::GLHelper* GetPostReadbackGLHelper() { 212 GLHelper* GetPostReadbackGLHelper() {
213 static GLHelperHolder* g_readback_helper_holder = nullptr; 213 static GLHelperHolder* g_readback_helper_holder = nullptr;
214 214
215 if (g_readback_helper_holder && g_readback_helper_holder->IsLost()) { 215 if (g_readback_helper_holder && g_readback_helper_holder->IsLost()) {
216 delete g_readback_helper_holder; 216 delete g_readback_helper_holder;
217 g_readback_helper_holder = nullptr; 217 g_readback_helper_holder = nullptr;
218 } 218 }
219 219
220 if (!g_readback_helper_holder) 220 if (!g_readback_helper_holder)
221 g_readback_helper_holder = GLHelperHolder::Create(); 221 g_readback_helper_holder = GLHelperHolder::Create();
222 222
223 return g_readback_helper_holder->gl_helper(); 223 return g_readback_helper_holder->gl_helper();
224 } 224 }
225 225
226 void CopyFromCompositingSurfaceFinished( 226 void CopyFromCompositingSurfaceFinished(
227 const ReadbackRequestCallback& callback, 227 const ReadbackRequestCallback& callback,
228 std::unique_ptr<cc::SingleReleaseCallback> release_callback, 228 std::unique_ptr<cc::SingleReleaseCallback> release_callback,
229 std::unique_ptr<SkBitmap> bitmap, 229 std::unique_ptr<SkBitmap> bitmap,
230 const base::TimeTicks& start_time, 230 const base::TimeTicks& start_time,
231 std::unique_ptr<SkAutoLockPixels> bitmap_pixels_lock, 231 std::unique_ptr<SkAutoLockPixels> bitmap_pixels_lock,
232 bool result) { 232 bool result) {
233 TRACE_EVENT0( 233 TRACE_EVENT0(
234 "cc", "RenderWidgetHostViewAndroid::CopyFromCompositingSurfaceFinished"); 234 "cc", "RenderWidgetHostViewAndroid::CopyFromCompositingSurfaceFinished");
235 bitmap_pixels_lock.reset(); 235 bitmap_pixels_lock.reset();
236 gpu::SyncToken sync_token; 236 gpu::SyncToken sync_token;
237 if (result) { 237 if (result) {
238 display_compositor::GLHelper* gl_helper = GetPostReadbackGLHelper(); 238 GLHelper* gl_helper = GetPostReadbackGLHelper();
239 if (gl_helper) 239 if (gl_helper)
240 gl_helper->GenerateSyncToken(&sync_token); 240 gl_helper->GenerateSyncToken(&sync_token);
241 } 241 }
242 const bool lost_resource = !sync_token.HasData(); 242 const bool lost_resource = !sync_token.HasData();
243 release_callback->Run(sync_token, lost_resource); 243 release_callback->Run(sync_token, lost_resource);
244 UMA_HISTOGRAM_TIMES(kAsyncReadBackString, 244 UMA_HISTOGRAM_TIMES(kAsyncReadBackString,
245 base::TimeTicks::Now() - start_time); 245 base::TimeTicks::Now() - start_time);
246 ReadbackResponse response = result ? READBACK_SUCCESS : READBACK_FAILED; 246 ReadbackResponse response = result ? READBACK_SUCCESS : READBACK_FAILED;
247 callback.Run(*bitmap, response); 247 callback.Run(*bitmap, response);
248 } 248 }
(...skipping 1683 matching lines...) Expand 10 before | Expand all | Expand 10 after
1932 1932
1933 if (!result->HasTexture() || result->IsEmpty() || result->size().IsEmpty()) 1933 if (!result->HasTexture() || result->IsEmpty() || result->size().IsEmpty())
1934 return; 1934 return;
1935 1935
1936 gfx::Size output_size_in_pixel; 1936 gfx::Size output_size_in_pixel;
1937 if (dst_size_in_pixel.IsEmpty()) 1937 if (dst_size_in_pixel.IsEmpty())
1938 output_size_in_pixel = result->size(); 1938 output_size_in_pixel = result->size();
1939 else 1939 else
1940 output_size_in_pixel = dst_size_in_pixel; 1940 output_size_in_pixel = dst_size_in_pixel;
1941 1941
1942 display_compositor::GLHelper* gl_helper = GetPostReadbackGLHelper(); 1942 GLHelper* gl_helper = GetPostReadbackGLHelper();
1943 if (!gl_helper) 1943 if (!gl_helper)
1944 return; 1944 return;
1945 if (!gl_helper->IsReadbackConfigSupported(color_type)) 1945 if (!gl_helper->IsReadbackConfigSupported(color_type))
1946 color_type = kRGBA_8888_SkColorType; 1946 color_type = kRGBA_8888_SkColorType;
1947 std::unique_ptr<SkBitmap> bitmap(new SkBitmap); 1947 std::unique_ptr<SkBitmap> bitmap(new SkBitmap);
1948 if (!bitmap->tryAllocPixels(SkImageInfo::Make(output_size_in_pixel.width(), 1948 if (!bitmap->tryAllocPixels(SkImageInfo::Make(output_size_in_pixel.width(),
1949 output_size_in_pixel.height(), 1949 output_size_in_pixel.height(),
1950 color_type, 1950 color_type,
1951 kOpaque_SkAlphaType))) { 1951 kOpaque_SkAlphaType))) {
1952 scoped_callback_runner.Reset( 1952 scoped_callback_runner.Reset(
(...skipping 13 matching lines...) Expand all
1966 return; 1966 return;
1967 1967
1968 ignore_result(scoped_callback_runner.Release()); 1968 ignore_result(scoped_callback_runner.Release());
1969 1969
1970 gl_helper->CropScaleReadbackAndCleanMailbox( 1970 gl_helper->CropScaleReadbackAndCleanMailbox(
1971 texture_mailbox.mailbox(), texture_mailbox.sync_token(), result->size(), 1971 texture_mailbox.mailbox(), texture_mailbox.sync_token(), result->size(),
1972 gfx::Rect(result->size()), output_size_in_pixel, pixels, color_type, 1972 gfx::Rect(result->size()), output_size_in_pixel, pixels, color_type,
1973 base::Bind(&CopyFromCompositingSurfaceFinished, callback, 1973 base::Bind(&CopyFromCompositingSurfaceFinished, callback,
1974 base::Passed(&release_callback), base::Passed(&bitmap), 1974 base::Passed(&release_callback), base::Passed(&bitmap),
1975 start_time, base::Passed(&bitmap_pixels_lock)), 1975 start_time, base::Passed(&bitmap_pixels_lock)),
1976 display_compositor::GLHelper::SCALER_QUALITY_GOOD); 1976 GLHelper::SCALER_QUALITY_GOOD);
1977 } 1977 }
1978 1978
1979 void RenderWidgetHostViewAndroid::OnStylusSelectBegin(float x0, 1979 void RenderWidgetHostViewAndroid::OnStylusSelectBegin(float x0,
1980 float y0, 1980 float y0,
1981 float x1, 1981 float x1,
1982 float y1) { 1982 float y1) {
1983 SelectBetweenCoordinates(gfx::PointF(x0, y0), gfx::PointF(x1, y1)); 1983 SelectBetweenCoordinates(gfx::PointF(x0, y0), gfx::PointF(x1, y1));
1984 } 1984 }
1985 1985
1986 void RenderWidgetHostViewAndroid::OnStylusSelectUpdate(float x, float y) { 1986 void RenderWidgetHostViewAndroid::OnStylusSelectUpdate(float x, float y) {
(...skipping 27 matching lines...) Expand all
2014 results->orientationAngle = display.RotationAsDegree(); 2014 results->orientationAngle = display.RotationAsDegree();
2015 results->orientationType = 2015 results->orientationType =
2016 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display); 2016 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display);
2017 gfx::DeviceDisplayInfo info; 2017 gfx::DeviceDisplayInfo info;
2018 results->depth = info.GetBitsPerPixel(); 2018 results->depth = info.GetBitsPerPixel();
2019 results->depthPerComponent = info.GetBitsPerComponent(); 2019 results->depthPerComponent = info.GetBitsPerComponent();
2020 results->isMonochrome = (results->depthPerComponent == 0); 2020 results->isMonochrome = (results->depthPerComponent == 0);
2021 } 2021 }
2022 2022
2023 } // namespace content 2023 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698