Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 |
| 11 #include "base/android/application_status_listener.h" | 11 #include "base/android/application_status_listener.h" |
| 12 #include "base/android/build_info.h" | 12 #include "base/android/build_info.h" |
| 13 #include "base/android/context_utils.h" | 13 #include "base/android/context_utils.h" |
| 14 #include "base/bind.h" | 14 #include "base/bind.h" |
| 15 #include "base/callback_helpers.h" | 15 #include "base/callback_helpers.h" |
| 16 #include "base/command_line.h" | 16 #include "base/command_line.h" |
| 17 #include "base/location.h" | 17 #include "base/location.h" |
| 18 #include "base/logging.h" | 18 #include "base/logging.h" |
| 19 #include "base/macros.h" | 19 #include "base/macros.h" |
| 20 #include "base/memory/memory_pressure_listener.h" | 20 #include "base/memory/ref_counted.h" |
| 21 #include "base/metrics/histogram_macros.h" | 21 #include "base/metrics/histogram_macros.h" |
| 22 #include "base/single_thread_task_runner.h" | 22 #include "base/single_thread_task_runner.h" |
| 23 #include "base/strings/utf_string_conversions.h" | 23 #include "base/strings/utf_string_conversions.h" |
| 24 #include "base/sys_info.h" | 24 #include "base/sys_info.h" |
| 25 #include "base/threading/thread_task_runner_handle.h" | 25 #include "base/threading/thread_task_runner_handle.h" |
| 26 #include "base/threading/worker_pool.h" | 26 #include "base/threading/worker_pool.h" |
| 27 #include "cc/layers/layer.h" | 27 #include "cc/layers/layer.h" |
| 28 #include "cc/layers/surface_layer.h" | 28 #include "cc/layers/surface_layer.h" |
| 29 #include "cc/output/compositor_frame.h" | 29 #include "cc/output/compositor_frame.h" |
| 30 #include "cc/output/copy_output_request.h" | 30 #include "cc/output/copy_output_request.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 95 #include "ui/touch_selection/touch_selection_controller.h" | 95 #include "ui/touch_selection/touch_selection_controller.h" |
| 96 | 96 |
| 97 namespace content { | 97 namespace content { |
| 98 | 98 |
| 99 namespace { | 99 namespace { |
| 100 | 100 |
| 101 const int kUndefinedCompositorFrameSinkId = -1; | 101 const int kUndefinedCompositorFrameSinkId = -1; |
| 102 | 102 |
| 103 static const char kAsyncReadBackString[] = "Compositing.CopyFromSurfaceTime"; | 103 static const char kAsyncReadBackString[] = "Compositing.CopyFromSurfaceTime"; |
| 104 | 104 |
| 105 class PendingReadbackLock; | |
| 106 | |
| 107 PendingReadbackLock* g_pending_readback_lock = nullptr; | |
| 108 | |
| 109 class PendingReadbackLock : public base::RefCounted<PendingReadbackLock> { | |
|
danakj
2016/10/03 20:47:43
This is fine, but another way to do this would be
| |
| 110 public: | |
| 111 PendingReadbackLock() { | |
| 112 DCHECK_EQ(g_pending_readback_lock, nullptr); | |
| 113 g_pending_readback_lock = this; | |
| 114 } | |
| 115 | |
| 116 ~PendingReadbackLock() { | |
|
danakj
2016/10/03 20:47:43
Destructor should be private with friend of RefCou
no sievers
2016/10/05 00:38:40
Done.
| |
| 117 DCHECK_EQ(g_pending_readback_lock, this); | |
| 118 g_pending_readback_lock = nullptr; | |
| 119 } | |
| 120 }; | |
| 121 | |
| 105 using base::android::ApplicationState; | 122 using base::android::ApplicationState; |
| 106 using base::android::ApplicationStatusListener; | 123 using base::android::ApplicationStatusListener; |
| 107 using base::MemoryPressureListener; | 124 using base::MemoryPressureListener; |
| 108 | 125 |
| 109 class GLHelperHolder { | 126 class GLHelperHolder { |
| 110 public: | 127 public: |
| 111 static GLHelperHolder* Create(); | 128 static GLHelperHolder* Create(); |
| 112 | 129 |
| 113 display_compositor::GLHelper* gl_helper() { return gl_helper_.get(); } | 130 display_compositor::GLHelper* gl_helper() { return gl_helper_.get(); } |
| 114 bool IsLost() { | 131 bool IsLost() { |
| 115 if (!gl_helper_) | 132 if (!gl_helper_) |
| 116 return true; | 133 return true; |
| 117 return provider_->ContextGL()->GetGraphicsResetStatusKHR() != GL_NO_ERROR; | 134 return provider_->ContextGL()->GetGraphicsResetStatusKHR() != GL_NO_ERROR; |
| 118 } | 135 } |
| 119 | 136 |
| 120 void FreeUnusedSharedMemoryIfNeeded(); | 137 void ReleaseIfPossible(); |
| 121 | 138 |
| 122 private: | 139 private: |
| 123 GLHelperHolder(); | 140 GLHelperHolder(); |
| 124 void Initialize(); | 141 void Initialize(); |
| 125 void OnContextLost(); | 142 void OnContextLost(); |
| 126 void OnApplicationStatusChanged(ApplicationState new_state); | 143 void OnApplicationStatusChanged(ApplicationState new_state); |
| 127 void OnMemoryPressure(MemoryPressureListener::MemoryPressureLevel level); | |
| 128 | 144 |
| 129 scoped_refptr<ContextProviderCommandBuffer> provider_; | 145 scoped_refptr<ContextProviderCommandBuffer> provider_; |
| 130 std::unique_ptr<display_compositor::GLHelper> gl_helper_; | 146 std::unique_ptr<display_compositor::GLHelper> gl_helper_; |
| 131 | 147 |
| 132 // Set to |false| if there are only stopped activities (or none). | 148 // Set to |false| if there are only stopped activities (or none). |
| 133 bool has_running_or_paused_activities_; | 149 bool has_running_or_paused_activities_; |
| 134 // Whether we recently were signaled a low memory condition. | |
| 135 bool did_signal_memory_pressure_; | |
| 136 | 150 |
| 137 std::unique_ptr<ApplicationStatusListener> app_status_listener_; | 151 std::unique_ptr<ApplicationStatusListener> app_status_listener_; |
| 138 std::unique_ptr<MemoryPressureListener> mem_pressure_listener_; | |
| 139 | 152 |
| 140 DISALLOW_COPY_AND_ASSIGN(GLHelperHolder); | 153 DISALLOW_COPY_AND_ASSIGN(GLHelperHolder); |
| 141 }; | 154 }; |
| 142 | 155 |
| 143 GLHelperHolder::GLHelperHolder() | 156 GLHelperHolder::GLHelperHolder() |
| 144 : has_running_or_paused_activities_( | 157 : has_running_or_paused_activities_( |
| 145 (ApplicationStatusListener::GetState() == | 158 (ApplicationStatusListener::GetState() == |
| 146 base::android::APPLICATION_STATE_HAS_RUNNING_ACTIVITIES) || | 159 base::android::APPLICATION_STATE_HAS_RUNNING_ACTIVITIES) || |
| 147 (ApplicationStatusListener::GetState() == | 160 (ApplicationStatusListener::GetState() == |
| 148 base::android::APPLICATION_STATE_HAS_PAUSED_ACTIVITIES)), | 161 base::android::APPLICATION_STATE_HAS_PAUSED_ACTIVITIES)) {} |
| 149 did_signal_memory_pressure_(false) {} | |
| 150 | 162 |
| 151 GLHelperHolder* GLHelperHolder::Create() { | 163 GLHelperHolder* GLHelperHolder::Create() { |
| 152 GLHelperHolder* holder = new GLHelperHolder; | 164 GLHelperHolder* holder = new GLHelperHolder; |
| 153 holder->Initialize(); | 165 holder->Initialize(); |
| 154 return holder; | 166 return holder; |
| 155 } | 167 } |
| 156 | 168 |
| 157 void GLHelperHolder::Initialize() { | 169 void GLHelperHolder::Initialize() { |
| 158 auto* factory = BrowserGpuChannelHostFactory::instance(); | 170 auto* factory = BrowserGpuChannelHostFactory::instance(); |
| 159 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host(factory->GetGpuChannel()); | 171 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host(factory->GetGpuChannel()); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 207 base::StringPrintf("CmdBufferImageTransportFactory-%p", provider_.get()) | 219 base::StringPrintf("CmdBufferImageTransportFactory-%p", provider_.get()) |
| 208 .c_str()); | 220 .c_str()); |
| 209 provider_->SetLostContextCallback( | 221 provider_->SetLostContextCallback( |
| 210 base::Bind(&GLHelperHolder::OnContextLost, base::Unretained(this))); | 222 base::Bind(&GLHelperHolder::OnContextLost, base::Unretained(this))); |
| 211 gl_helper_.reset(new display_compositor::GLHelper( | 223 gl_helper_.reset(new display_compositor::GLHelper( |
| 212 provider_->ContextGL(), provider_->ContextSupport())); | 224 provider_->ContextGL(), provider_->ContextSupport())); |
| 213 | 225 |
| 214 // Unretained() is safe because |this| owns the following two callbacks. | 226 // Unretained() is safe because |this| owns the following two callbacks. |
| 215 app_status_listener_.reset(new ApplicationStatusListener(base::Bind( | 227 app_status_listener_.reset(new ApplicationStatusListener(base::Bind( |
| 216 &GLHelperHolder::OnApplicationStatusChanged, base::Unretained(this)))); | 228 &GLHelperHolder::OnApplicationStatusChanged, base::Unretained(this)))); |
| 217 mem_pressure_listener_.reset(new MemoryPressureListener(base::Bind( | |
| 218 &GLHelperHolder::OnMemoryPressure, base::Unretained(this)))); | |
| 219 } | 229 } |
| 220 | 230 |
| 221 void GLHelperHolder::FreeUnusedSharedMemoryIfNeeded() { | 231 void GLHelperHolder::ReleaseIfPossible() { |
| 222 if (!has_running_or_paused_activities_ || did_signal_memory_pressure_) | 232 if (!has_running_or_paused_activities_ && !g_pending_readback_lock) { |
| 223 provider_->FreeUnusedSharedMemory(); | 233 gl_helper_.reset(); |
| 234 provider_ = nullptr; | |
| 235 } | |
| 224 } | 236 } |
| 225 | 237 |
| 226 void GLHelperHolder::OnContextLost() { | 238 void GLHelperHolder::OnContextLost() { |
| 227 app_status_listener_.reset(); | 239 app_status_listener_.reset(); |
| 228 mem_pressure_listener_.reset(); | |
| 229 gl_helper_.reset(); | 240 gl_helper_.reset(); |
| 230 // Need to post a task because the command buffer client cannot be deleted | 241 // Need to post a task because the command buffer client cannot be deleted |
| 231 // from within this callback. | 242 // from within this callback. |
| 232 base::ThreadTaskRunnerHandle::Get()->PostTask( | 243 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 233 FROM_HERE, base::Bind(&RenderWidgetHostViewAndroid::OnContextLost)); | 244 FROM_HERE, base::Bind(&RenderWidgetHostViewAndroid::OnContextLost)); |
| 234 } | 245 } |
| 235 | 246 |
| 236 void GLHelperHolder::OnApplicationStatusChanged(ApplicationState new_state) { | 247 void GLHelperHolder::OnApplicationStatusChanged(ApplicationState new_state) { |
| 237 bool new_has_running_or_paused_activities = | 248 has_running_or_paused_activities_ = |
| 238 new_state == base::android::APPLICATION_STATE_HAS_RUNNING_ACTIVITIES || | 249 new_state == base::android::APPLICATION_STATE_HAS_RUNNING_ACTIVITIES || |
| 239 new_state == base::android::APPLICATION_STATE_HAS_PAUSED_ACTIVITIES; | 250 new_state == base::android::APPLICATION_STATE_HAS_PAUSED_ACTIVITIES; |
| 240 | 251 ReleaseIfPossible(); |
| 241 if (!has_running_or_paused_activities_ && | |
| 242 new_has_running_or_paused_activities) { | |
| 243 // Reset at this time since on Android there is no 'back to normal' | |
| 244 // notification (but only onTrim/onLowMemory). | |
| 245 did_signal_memory_pressure_ = false; | |
| 246 } else if (!new_has_running_or_paused_activities) { | |
| 247 provider_->FreeUnusedSharedMemory(); | |
| 248 } | |
| 249 | |
| 250 has_running_or_paused_activities_ = new_has_running_or_paused_activities; | |
| 251 } | |
| 252 | |
| 253 void GLHelperHolder::OnMemoryPressure( | |
| 254 MemoryPressureListener::MemoryPressureLevel level) { | |
| 255 if (level == MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE || | |
| 256 level == MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL) { | |
| 257 did_signal_memory_pressure_ = true; | |
| 258 provider_->FreeUnusedSharedMemory(); | |
| 259 } | |
| 260 } | 252 } |
| 261 | 253 |
| 262 GLHelperHolder* GetPostReadbackGLHelperHolder(bool create_if_necessary) { | 254 GLHelperHolder* GetPostReadbackGLHelperHolder(bool create_if_necessary) { |
| 263 static GLHelperHolder* g_readback_helper_holder = nullptr; | 255 static GLHelperHolder* g_readback_helper_holder = nullptr; |
| 264 | 256 |
| 265 if (!create_if_necessary && !g_readback_helper_holder) | 257 if (!create_if_necessary && !g_readback_helper_holder) |
| 266 return nullptr; | 258 return nullptr; |
| 267 | 259 |
| 268 if (g_readback_helper_holder && g_readback_helper_holder->IsLost()) { | 260 if (g_readback_helper_holder && g_readback_helper_holder->IsLost()) { |
| 269 delete g_readback_helper_holder; | 261 delete g_readback_helper_holder; |
| 270 g_readback_helper_holder = nullptr; | 262 g_readback_helper_holder = nullptr; |
| 271 } | 263 } |
| 272 | 264 |
| 273 if (!g_readback_helper_holder) | 265 if (!g_readback_helper_holder) |
| 274 g_readback_helper_holder = GLHelperHolder::Create(); | 266 g_readback_helper_holder = GLHelperHolder::Create(); |
| 275 | 267 |
| 276 return g_readback_helper_holder; | 268 return g_readback_helper_holder; |
| 277 } | 269 } |
| 278 | 270 |
| 279 display_compositor::GLHelper* GetPostReadbackGLHelper() { | 271 display_compositor::GLHelper* GetPostReadbackGLHelper() { |
| 280 bool create_if_necessary = true; | 272 bool create_if_necessary = true; |
| 281 return GetPostReadbackGLHelperHolder(create_if_necessary)->gl_helper(); | 273 return GetPostReadbackGLHelperHolder(create_if_necessary)->gl_helper(); |
| 282 } | 274 } |
| 283 | 275 |
| 284 void FreeUnusedGLHelperMemory() { | 276 void ReleaseGLHelper() { |
| 285 bool create_if_necessary = false; | 277 bool create_if_necessary = false; |
| 286 GLHelperHolder* holder = GetPostReadbackGLHelperHolder(create_if_necessary); | 278 GLHelperHolder* holder = GetPostReadbackGLHelperHolder(create_if_necessary); |
| 287 | 279 |
| 288 if (holder) { | 280 if (holder) { |
| 289 holder->FreeUnusedSharedMemoryIfNeeded(); | 281 holder->ReleaseIfPossible(); |
| 290 } | 282 } |
| 291 } | 283 } |
| 292 | 284 |
| 293 void CopyFromCompositingSurfaceFinished( | 285 void CopyFromCompositingSurfaceFinished( |
| 294 const ReadbackRequestCallback& callback, | 286 const ReadbackRequestCallback& callback, |
| 295 std::unique_ptr<cc::SingleReleaseCallback> release_callback, | 287 std::unique_ptr<cc::SingleReleaseCallback> release_callback, |
| 296 std::unique_ptr<SkBitmap> bitmap, | 288 std::unique_ptr<SkBitmap> bitmap, |
| 297 const base::TimeTicks& start_time, | 289 const base::TimeTicks& start_time, |
| 298 std::unique_ptr<SkAutoLockPixels> bitmap_pixels_lock, | 290 std::unique_ptr<SkAutoLockPixels> bitmap_pixels_lock, |
| 291 scoped_refptr<PendingReadbackLock> readback_lock, | |
| 299 bool result) { | 292 bool result) { |
| 300 TRACE_EVENT0( | 293 TRACE_EVENT0( |
| 301 "cc", "RenderWidgetHostViewAndroid::CopyFromCompositingSurfaceFinished"); | 294 "cc", "RenderWidgetHostViewAndroid::CopyFromCompositingSurfaceFinished"); |
| 302 bitmap_pixels_lock.reset(); | 295 bitmap_pixels_lock.reset(); |
| 303 gpu::SyncToken sync_token; | 296 gpu::SyncToken sync_token; |
| 304 if (result) { | 297 if (result) { |
| 305 display_compositor::GLHelper* gl_helper = GetPostReadbackGLHelper(); | 298 display_compositor::GLHelper* gl_helper = GetPostReadbackGLHelper(); |
| 306 if (gl_helper) | 299 if (gl_helper) |
| 307 gl_helper->GenerateSyncToken(&sync_token); | 300 gl_helper->GenerateSyncToken(&sync_token); |
| 308 } | 301 } |
| 309 | 302 |
| 310 FreeUnusedGLHelperMemory(); | 303 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
|
danakj
2016/10/03 20:47:44
I'd like a comment explaining why this is posting
no sievers
2016/10/05 00:38:40
Done.
| |
| 304 base::Bind(&ReleaseGLHelper)); | |
| 311 | 305 |
| 312 const bool lost_resource = !sync_token.HasData(); | 306 const bool lost_resource = !sync_token.HasData(); |
| 313 release_callback->Run(sync_token, lost_resource); | 307 release_callback->Run(sync_token, lost_resource); |
| 314 UMA_HISTOGRAM_TIMES(kAsyncReadBackString, | 308 UMA_HISTOGRAM_TIMES(kAsyncReadBackString, |
| 315 base::TimeTicks::Now() - start_time); | 309 base::TimeTicks::Now() - start_time); |
| 316 ReadbackResponse response = result ? READBACK_SUCCESS : READBACK_FAILED; | 310 ReadbackResponse response = result ? READBACK_SUCCESS : READBACK_FAILED; |
| 317 callback.Run(*bitmap, response); | 311 callback.Run(*bitmap, response); |
| 318 } | 312 } |
| 319 | 313 |
| 320 std::unique_ptr<ui::TouchSelectionController> CreateSelectionController( | 314 std::unique_ptr<ui::TouchSelectionController> CreateSelectionController( |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 345 gfx::RectF GetSelectionRect(const ui::TouchSelectionController& controller) { | 339 gfx::RectF GetSelectionRect(const ui::TouchSelectionController& controller) { |
| 346 gfx::RectF rect = controller.GetRectBetweenBounds(); | 340 gfx::RectF rect = controller.GetRectBetweenBounds(); |
| 347 if (rect.IsEmpty()) | 341 if (rect.IsEmpty()) |
| 348 return rect; | 342 return rect; |
| 349 | 343 |
| 350 rect.Union(controller.GetStartHandleRect()); | 344 rect.Union(controller.GetStartHandleRect()); |
| 351 rect.Union(controller.GetEndHandleRect()); | 345 rect.Union(controller.GetEndHandleRect()); |
| 352 return rect; | 346 return rect; |
| 353 } | 347 } |
| 354 | 348 |
| 349 void PrepareTextureCopyOutputResult( | |
| 350 const gfx::Size& dst_size_in_pixel, | |
| 351 SkColorType color_type, | |
| 352 const base::TimeTicks& start_time, | |
| 353 const ReadbackRequestCallback& callback, | |
| 354 scoped_refptr<PendingReadbackLock> readback_lock, | |
| 355 std::unique_ptr<cc::CopyOutputResult> result); | |
| 356 | |
| 355 } // anonymous namespace | 357 } // anonymous namespace |
| 356 | 358 |
| 357 RenderWidgetHostViewAndroid::LastFrameInfo::LastFrameInfo( | 359 RenderWidgetHostViewAndroid::LastFrameInfo::LastFrameInfo( |
| 358 uint32_t compositor_frame_sink_id, | 360 uint32_t compositor_frame_sink_id, |
| 359 cc::CompositorFrame output_frame) | 361 cc::CompositorFrame output_frame) |
| 360 : compositor_frame_sink_id(compositor_frame_sink_id), | 362 : compositor_frame_sink_id(compositor_frame_sink_id), |
| 361 frame(std::move(output_frame)) {} | 363 frame(std::move(output_frame)) {} |
| 362 | 364 |
| 363 RenderWidgetHostViewAndroid::LastFrameInfo::~LastFrameInfo() {} | 365 RenderWidgetHostViewAndroid::LastFrameInfo::~LastFrameInfo() {} |
| 364 | 366 |
| (...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 941 preferred_color_type); | 943 preferred_color_type); |
| 942 UMA_HISTOGRAM_TIMES("Compositing.CopyFromSurfaceTimeSynchronous", | 944 UMA_HISTOGRAM_TIMES("Compositing.CopyFromSurfaceTimeSynchronous", |
| 943 base::TimeTicks::Now() - start_time); | 945 base::TimeTicks::Now() - start_time); |
| 944 return; | 946 return; |
| 945 } | 947 } |
| 946 | 948 |
| 947 ui::WindowAndroidCompositor* compositor = | 949 ui::WindowAndroidCompositor* compositor = |
| 948 content_view_core_->GetWindowAndroid()->GetCompositor(); | 950 content_view_core_->GetWindowAndroid()->GetCompositor(); |
| 949 DCHECK(compositor); | 951 DCHECK(compositor); |
| 950 DCHECK(delegated_frame_host_); | 952 DCHECK(delegated_frame_host_); |
| 953 scoped_refptr<PendingReadbackLock> readback_lock( | |
| 954 g_pending_readback_lock ? g_pending_readback_lock | |
| 955 : new PendingReadbackLock); | |
| 951 delegated_frame_host_->RequestCopyOfSurface( | 956 delegated_frame_host_->RequestCopyOfSurface( |
| 952 compositor, src_subrect_in_pixel, | 957 compositor, src_subrect_in_pixel, |
| 953 base::Bind(&PrepareTextureCopyOutputResult, dst_size_in_pixel, | 958 base::Bind(&PrepareTextureCopyOutputResult, dst_size_in_pixel, |
| 954 preferred_color_type, start_time, callback)); | 959 preferred_color_type, start_time, callback, readback_lock)); |
| 955 } | 960 } |
| 956 | 961 |
| 957 void RenderWidgetHostViewAndroid::CopyFromCompositingSurfaceToVideoFrame( | 962 void RenderWidgetHostViewAndroid::CopyFromCompositingSurfaceToVideoFrame( |
| 958 const gfx::Rect& src_subrect, | 963 const gfx::Rect& src_subrect, |
| 959 const scoped_refptr<media::VideoFrame>& target, | 964 const scoped_refptr<media::VideoFrame>& target, |
| 960 const base::Callback<void(const gfx::Rect&, bool)>& callback) { | 965 const base::Callback<void(const gfx::Rect&, bool)>& callback) { |
| 961 NOTIMPLEMENTED(); | 966 NOTIMPLEMENTED(); |
| 962 callback.Run(gfx::Rect(), false); | 967 callback.Run(gfx::Rect(), false); |
| 963 } | 968 } |
| 964 | 969 |
| (...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1857 ReleaseLocksOnSurface(); | 1862 ReleaseLocksOnSurface(); |
| 1858 DestroyDelegatedContent(); | 1863 DestroyDelegatedContent(); |
| 1859 DCHECK(ack_callbacks_.empty()); | 1864 DCHECK(ack_callbacks_.empty()); |
| 1860 } | 1865 } |
| 1861 | 1866 |
| 1862 // TODO(wjmaclean): There is significant overlap between | 1867 // TODO(wjmaclean): There is significant overlap between |
| 1863 // PrepareTextureCopyOutputResult and CopyFromCompositingSurfaceFinished in | 1868 // PrepareTextureCopyOutputResult and CopyFromCompositingSurfaceFinished in |
| 1864 // this file, and the versions in surface_utils.cc. They should | 1869 // this file, and the versions in surface_utils.cc. They should |
| 1865 // be merged. See https://crbug.com/582955 | 1870 // be merged. See https://crbug.com/582955 |
| 1866 | 1871 |
| 1867 // static | 1872 namespace { |
|
danakj
2016/10/03 20:47:44
bonus points if this method can move up to the ano
no sievers
2016/10/05 00:38:40
Done.
| |
| 1868 void RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult( | 1873 |
| 1874 void PrepareTextureCopyOutputResult( | |
| 1869 const gfx::Size& dst_size_in_pixel, | 1875 const gfx::Size& dst_size_in_pixel, |
| 1870 SkColorType color_type, | 1876 SkColorType color_type, |
| 1871 const base::TimeTicks& start_time, | 1877 const base::TimeTicks& start_time, |
| 1872 const ReadbackRequestCallback& callback, | 1878 const ReadbackRequestCallback& callback, |
| 1879 scoped_refptr<PendingReadbackLock> readback_lock, | |
| 1873 std::unique_ptr<cc::CopyOutputResult> result) { | 1880 std::unique_ptr<cc::CopyOutputResult> result) { |
| 1874 base::ScopedClosureRunner scoped_callback_runner( | 1881 base::ScopedClosureRunner scoped_callback_runner( |
| 1875 base::Bind(callback, SkBitmap(), READBACK_FAILED)); | 1882 base::Bind(callback, SkBitmap(), READBACK_FAILED)); |
| 1876 TRACE_EVENT0("cc", | 1883 TRACE_EVENT0("cc", |
| 1877 "RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult"); | 1884 "RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult"); |
| 1878 if (!result->HasTexture() || result->IsEmpty() || result->size().IsEmpty()) | 1885 if (!result->HasTexture() || result->IsEmpty() || result->size().IsEmpty()) |
| 1879 return; | 1886 return; |
| 1880 cc::TextureMailbox texture_mailbox; | 1887 cc::TextureMailbox texture_mailbox; |
| 1881 std::unique_ptr<cc::SingleReleaseCallback> release_callback; | 1888 std::unique_ptr<cc::SingleReleaseCallback> release_callback; |
| 1882 result->TakeTexture(&texture_mailbox, &release_callback); | 1889 result->TakeTexture(&texture_mailbox, &release_callback); |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 1909 new SkAutoLockPixels(*bitmap)); | 1916 new SkAutoLockPixels(*bitmap)); |
| 1910 uint8_t* pixels = static_cast<uint8_t*>(bitmap->getPixels()); | 1917 uint8_t* pixels = static_cast<uint8_t*>(bitmap->getPixels()); |
| 1911 | 1918 |
| 1912 ignore_result(scoped_callback_runner.Release()); | 1919 ignore_result(scoped_callback_runner.Release()); |
| 1913 | 1920 |
| 1914 gl_helper->CropScaleReadbackAndCleanMailbox( | 1921 gl_helper->CropScaleReadbackAndCleanMailbox( |
| 1915 texture_mailbox.mailbox(), texture_mailbox.sync_token(), result->size(), | 1922 texture_mailbox.mailbox(), texture_mailbox.sync_token(), result->size(), |
| 1916 gfx::Rect(result->size()), output_size_in_pixel, pixels, color_type, | 1923 gfx::Rect(result->size()), output_size_in_pixel, pixels, color_type, |
| 1917 base::Bind(&CopyFromCompositingSurfaceFinished, callback, | 1924 base::Bind(&CopyFromCompositingSurfaceFinished, callback, |
| 1918 base::Passed(&release_callback), base::Passed(&bitmap), | 1925 base::Passed(&release_callback), base::Passed(&bitmap), |
| 1919 start_time, base::Passed(&bitmap_pixels_lock)), | 1926 start_time, base::Passed(&bitmap_pixels_lock), readback_lock), |
| 1920 display_compositor::GLHelper::SCALER_QUALITY_GOOD); | 1927 display_compositor::GLHelper::SCALER_QUALITY_GOOD); |
| 1921 } | 1928 } |
| 1922 | 1929 |
| 1930 } // anonymous namespace | |
|
danakj
2016/10/03 20:47:44
just "// namespace"
no sievers
2016/10/05 00:38:40
Done.
| |
| 1931 | |
| 1923 void RenderWidgetHostViewAndroid::OnStylusSelectBegin(float x0, | 1932 void RenderWidgetHostViewAndroid::OnStylusSelectBegin(float x0, |
| 1924 float y0, | 1933 float y0, |
| 1925 float x1, | 1934 float x1, |
| 1926 float y1) { | 1935 float y1) { |
| 1927 SelectBetweenCoordinates(gfx::PointF(x0, y0), gfx::PointF(x1, y1)); | 1936 SelectBetweenCoordinates(gfx::PointF(x0, y0), gfx::PointF(x1, y1)); |
| 1928 } | 1937 } |
| 1929 | 1938 |
| 1930 void RenderWidgetHostViewAndroid::OnStylusSelectUpdate(float x, float y) { | 1939 void RenderWidgetHostViewAndroid::OnStylusSelectUpdate(float x, float y) { |
| 1931 MoveRangeSelectionExtent(gfx::PointF(x, y)); | 1940 MoveRangeSelectionExtent(gfx::PointF(x, y)); |
| 1932 } | 1941 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1964 case ui::MotionEvent::ACTION_UP: | 1973 case ui::MotionEvent::ACTION_UP: |
| 1965 case ui::MotionEvent::ACTION_POINTER_UP: | 1974 case ui::MotionEvent::ACTION_POINTER_UP: |
| 1966 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED", | 1975 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED", |
| 1967 delta.InMicroseconds(), 1, 1000000, 50); | 1976 delta.InMicroseconds(), 1, 1000000, 50); |
| 1968 default: | 1977 default: |
| 1969 return; | 1978 return; |
| 1970 } | 1979 } |
| 1971 } | 1980 } |
| 1972 | 1981 |
| 1973 } // namespace content | 1982 } // namespace content |
| OLD | NEW |