| 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 |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 if (holder) { | 277 if (holder) { |
| 278 holder->ReleaseIfPossible(); | 278 holder->ReleaseIfPossible(); |
| 279 } | 279 } |
| 280 } | 280 } |
| 281 | 281 |
| 282 void CopyFromCompositingSurfaceFinished( | 282 void CopyFromCompositingSurfaceFinished( |
| 283 const ReadbackRequestCallback& callback, | 283 const ReadbackRequestCallback& callback, |
| 284 std::unique_ptr<cc::SingleReleaseCallback> release_callback, | 284 std::unique_ptr<cc::SingleReleaseCallback> release_callback, |
| 285 std::unique_ptr<SkBitmap> bitmap, | 285 std::unique_ptr<SkBitmap> bitmap, |
| 286 const base::TimeTicks& start_time, | 286 const base::TimeTicks& start_time, |
| 287 std::unique_ptr<SkAutoLockPixels> bitmap_pixels_lock, | |
| 288 scoped_refptr<PendingReadbackLock> readback_lock, | 287 scoped_refptr<PendingReadbackLock> readback_lock, |
| 289 bool result) { | 288 bool result) { |
| 290 TRACE_EVENT0( | 289 TRACE_EVENT0( |
| 291 "cc", "RenderWidgetHostViewAndroid::CopyFromCompositingSurfaceFinished"); | 290 "cc", "RenderWidgetHostViewAndroid::CopyFromCompositingSurfaceFinished"); |
| 292 bitmap_pixels_lock.reset(); | |
| 293 gpu::SyncToken sync_token; | 291 gpu::SyncToken sync_token; |
| 294 if (result) { | 292 if (result) { |
| 295 display_compositor::GLHelper* gl_helper = GetPostReadbackGLHelper(); | 293 display_compositor::GLHelper* gl_helper = GetPostReadbackGLHelper(); |
| 296 if (gl_helper) | 294 if (gl_helper) |
| 297 gl_helper->GenerateSyncToken(&sync_token); | 295 gl_helper->GenerateSyncToken(&sync_token); |
| 298 } | 296 } |
| 299 | 297 |
| 300 // PostTask() to make sure the |readback_lock| is released. Also do this | 298 // PostTask() to make sure the |readback_lock| is released. Also do this |
| 301 // synchronous GPU operation in a clean callstack. | 299 // synchronous GPU operation in a clean callstack. |
| 302 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 300 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 std::unique_ptr<SkBitmap> bitmap(new SkBitmap); | 374 std::unique_ptr<SkBitmap> bitmap(new SkBitmap); |
| 377 if (!bitmap->tryAllocPixels(SkImageInfo::Make(output_size_in_pixel.width(), | 375 if (!bitmap->tryAllocPixels(SkImageInfo::Make(output_size_in_pixel.width(), |
| 378 output_size_in_pixel.height(), | 376 output_size_in_pixel.height(), |
| 379 color_type, | 377 color_type, |
| 380 kOpaque_SkAlphaType))) { | 378 kOpaque_SkAlphaType))) { |
| 381 scoped_callback_runner.ReplaceClosure( | 379 scoped_callback_runner.ReplaceClosure( |
| 382 base::Bind(callback, SkBitmap(), READBACK_BITMAP_ALLOCATION_FAILURE)); | 380 base::Bind(callback, SkBitmap(), READBACK_BITMAP_ALLOCATION_FAILURE)); |
| 383 return; | 381 return; |
| 384 } | 382 } |
| 385 | 383 |
| 386 std::unique_ptr<SkAutoLockPixels> bitmap_pixels_lock( | |
| 387 new SkAutoLockPixels(*bitmap)); | |
| 388 uint8_t* pixels = static_cast<uint8_t*>(bitmap->getPixels()); | 384 uint8_t* pixels = static_cast<uint8_t*>(bitmap->getPixels()); |
| 389 | 385 |
| 390 ignore_result(scoped_callback_runner.Release()); | 386 ignore_result(scoped_callback_runner.Release()); |
| 391 | 387 |
| 392 gl_helper->CropScaleReadbackAndCleanMailbox( | 388 gl_helper->CropScaleReadbackAndCleanMailbox( |
| 393 texture_mailbox.mailbox(), texture_mailbox.sync_token(), result->size(), | 389 texture_mailbox.mailbox(), texture_mailbox.sync_token(), result->size(), |
| 394 gfx::Rect(result->size()), output_size_in_pixel, pixels, color_type, | 390 gfx::Rect(result->size()), output_size_in_pixel, pixels, color_type, |
| 395 base::Bind(&CopyFromCompositingSurfaceFinished, callback, | 391 base::Bind(&CopyFromCompositingSurfaceFinished, callback, |
| 396 base::Passed(&release_callback), base::Passed(&bitmap), | 392 base::Passed(&release_callback), base::Passed(&bitmap), |
| 397 start_time, base::Passed(&bitmap_pixels_lock), readback_lock), | 393 start_time, readback_lock), |
| 398 display_compositor::GLHelper::SCALER_QUALITY_GOOD); | 394 display_compositor::GLHelper::SCALER_QUALITY_GOOD); |
| 399 } | 395 } |
| 400 | 396 |
| 401 void RecordToolTypeForActionDown(const ui::MotionEventAndroid& event) { | 397 void RecordToolTypeForActionDown(const ui::MotionEventAndroid& event) { |
| 402 ui::MotionEventAndroid::Action action = event.GetAction(); | 398 ui::MotionEventAndroid::Action action = event.GetAction(); |
| 403 if (action == ui::MotionEventAndroid::ACTION_DOWN || | 399 if (action == ui::MotionEventAndroid::ACTION_DOWN || |
| 404 action == ui::MotionEventAndroid::ACTION_POINTER_DOWN || | 400 action == ui::MotionEventAndroid::ACTION_POINTER_DOWN || |
| 405 action == ui::MotionEventAndroid::ACTION_BUTTON_PRESS) { | 401 action == ui::MotionEventAndroid::ACTION_BUTTON_PRESS) { |
| 406 UMA_HISTOGRAM_ENUMERATION("Event.AndroidActionDown.ToolType", | 402 UMA_HISTOGRAM_ENUMERATION("Event.AndroidActionDown.ToolType", |
| 407 event.GetToolType(0), | 403 event.GetToolType(0), |
| (...skipping 1787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2195 | 2191 |
| 2196 ui::WindowAndroidCompositor* compositor = window_android->GetCompositor(); | 2192 ui::WindowAndroidCompositor* compositor = window_android->GetCompositor(); |
| 2197 if (!compositor) | 2193 if (!compositor) |
| 2198 return; | 2194 return; |
| 2199 | 2195 |
| 2200 overscroll_controller_ = base::MakeUnique<OverscrollControllerAndroid>( | 2196 overscroll_controller_ = base::MakeUnique<OverscrollControllerAndroid>( |
| 2201 overscroll_refresh_handler, compositor, view_.GetDipScale()); | 2197 overscroll_refresh_handler, compositor, view_.GetDipScale()); |
| 2202 } | 2198 } |
| 2203 | 2199 |
| 2204 } // namespace content | 2200 } // namespace content |
| OLD | NEW |