| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/android/compositor/tab_content_manager.h" | 5 #include "chrome/browser/android/compositor/tab_content_manager.h" |
| 6 | 6 |
| 7 #include <android/bitmap.h> | 7 #include <android/bitmap.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 | 75 |
| 76 if (!view) { | 76 if (!view) { |
| 77 result_callback.Run(SkBitmap(), content::READBACK_FAILED); | 77 result_callback.Run(SkBitmap(), content::READBACK_FAILED); |
| 78 return; | 78 return; |
| 79 } | 79 } |
| 80 | 80 |
| 81 DCHECK(view->GetWebContents()); | 81 DCHECK(view->GetWebContents()); |
| 82 content::RenderWidgetHost* rwh = view->GetWebContents() | 82 content::RenderWidgetHost* rwh = view->GetWebContents() |
| 83 ->GetRenderViewHost() | 83 ->GetRenderViewHost() |
| 84 ->GetWidget(); | 84 ->GetWidget(); |
| 85 rwh->LockBackingStore(); | |
| 86 | 85 |
| 87 SkColorType color_type = kN32_SkColorType; | 86 SkColorType color_type = kN32_SkColorType; |
| 88 gfx::Rect src_rect = rwh->GetView()->GetViewBounds(); | 87 gfx::Rect src_rect = rwh->GetView()->GetViewBounds(); |
| 89 gfx::Size dst_size( | 88 gfx::Size dst_size( |
| 90 gfx::ScaleToCeiledSize(src_rect.size(), thumbnail_scale_)); | 89 gfx::ScaleToCeiledSize(src_rect.size(), thumbnail_scale_)); |
| 91 rwh->CopyFromBackingStore(src_rect, dst_size, result_callback, color_type); | 90 rwh->CopyFromBackingStore(src_rect, dst_size, result_callback, color_type); |
| 92 } | 91 } |
| 93 | 92 |
| 94 void OnFinishGetTabThumbnailBitmap(const SkBitmap& bitmap, | 93 void OnFinishGetTabThumbnailBitmap(const SkBitmap& bitmap, |
| 95 content::ReadbackResponse response) { | 94 content::ReadbackResponse response) { |
| 96 DCHECK(!j_content_view_core_.is_null()); | 95 DCHECK(!j_content_view_core_.is_null()); |
| 97 JNIEnv* env = base::android::AttachCurrentThread(); | |
| 98 content::ContentViewCore* view = | |
| 99 content::ContentViewCore::GetNativeContentViewCore( | |
| 100 env, j_content_view_core_.obj()); | |
| 101 | |
| 102 if (view) { | |
| 103 DCHECK(view->GetWebContents()); | |
| 104 view->GetWebContents() | |
| 105 ->GetRenderViewHost() | |
| 106 ->GetWidget() | |
| 107 ->UnlockBackingStore(); | |
| 108 } | |
| 109 | |
| 110 if (response != content::READBACK_SUCCESS || drop_after_readback_) { | 96 if (response != content::READBACK_SUCCESS || drop_after_readback_) { |
| 111 end_callback_.Run(0.f, SkBitmap()); | 97 end_callback_.Run(0.f, SkBitmap()); |
| 112 return; | 98 return; |
| 113 } | 99 } |
| 114 | 100 |
| 115 SkBitmap result_bitmap = bitmap; | 101 SkBitmap result_bitmap = bitmap; |
| 116 result_bitmap.setImmutable(); | 102 result_bitmap.setImmutable(); |
| 117 end_callback_.Run(thumbnail_scale_, bitmap); | 103 end_callback_.Run(thumbnail_scale_, bitmap); |
| 118 } | 104 } |
| 119 | 105 |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 jboolean use_approximation_thumbnail) { | 371 jboolean use_approximation_thumbnail) { |
| 386 TabContentManager* manager = new TabContentManager( | 372 TabContentManager* manager = new TabContentManager( |
| 387 env, obj, default_cache_size, approximation_cache_size, | 373 env, obj, default_cache_size, approximation_cache_size, |
| 388 compression_queue_max_size, write_queue_max_size, | 374 compression_queue_max_size, write_queue_max_size, |
| 389 use_approximation_thumbnail); | 375 use_approximation_thumbnail); |
| 390 return reinterpret_cast<intptr_t>(manager); | 376 return reinterpret_cast<intptr_t>(manager); |
| 391 } | 377 } |
| 392 | 378 |
| 393 } // namespace android | 379 } // namespace android |
| 394 } // namespace chrome | 380 } // namespace chrome |
| OLD | NEW |