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

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

Issue 2241383002: Android: Attach hidden layer for CopyFromCompositingSurface() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: rebase Created 4 years, 4 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 880 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 preferred_color_type); 891 preferred_color_type);
892 UMA_HISTOGRAM_TIMES("Compositing.CopyFromSurfaceTimeSynchronous", 892 UMA_HISTOGRAM_TIMES("Compositing.CopyFromSurfaceTimeSynchronous",
893 base::TimeTicks::Now() - start_time); 893 base::TimeTicks::Now() - start_time);
894 return; 894 return;
895 } 895 }
896 896
897 ui::WindowAndroidCompositor* compositor = 897 ui::WindowAndroidCompositor* compositor =
898 content_view_core_->GetWindowAndroid()->GetCompositor(); 898 content_view_core_->GetWindowAndroid()->GetCompositor();
899 DCHECK(compositor); 899 DCHECK(compositor);
900 DCHECK(!surface_id_.is_null()); 900 DCHECK(!surface_id_.is_null());
901 scoped_refptr<cc::Layer> layer = CreateDelegatedLayer();
902 layer->SetHideLayerAndSubtree(true);
903 compositor->AttachLayerForReadback(layer);
904
901 std::unique_ptr<cc::CopyOutputRequest> request = 905 std::unique_ptr<cc::CopyOutputRequest> request =
902 cc::CopyOutputRequest::CreateRequest(base::Bind( 906 cc::CopyOutputRequest::CreateRequest(
903 &PrepareTextureCopyOutputResult, weak_ptr_factory_.GetWeakPtr(), 907 base::Bind(&PrepareTextureCopyOutputResult,
904 dst_size_in_pixel, preferred_color_type, start_time, callback)); 908 weak_ptr_factory_.GetWeakPtr(), layer, dst_size_in_pixel,
909 preferred_color_type, start_time, callback));
910
905 if (!src_subrect_in_pixel.IsEmpty()) 911 if (!src_subrect_in_pixel.IsEmpty())
906 request->set_area(src_subrect_in_pixel); 912 request->set_area(src_subrect_in_pixel);
907 // Make sure the current frame doesn't get deleted until we fulfill the 913 // Make sure the current frame doesn't get deleted until we fulfill the
908 // request. 914 // request.
909 LockCompositingSurface(); 915 LockCompositingSurface();
910 surface_factory_->RequestCopyOfSurface(surface_id_, std::move(request)); 916 surface_factory_->RequestCopyOfSurface(surface_id_, std::move(request));
911 } 917 }
912 918
913 void RenderWidgetHostViewAndroid::CopyFromCompositingSurfaceToVideoFrame( 919 void RenderWidgetHostViewAndroid::CopyFromCompositingSurfaceToVideoFrame(
914 const gfx::Rect& src_subrect, 920 const gfx::Rect& src_subrect,
(...skipping 980 matching lines...) Expand 10 before | Expand all | Expand 10 after
1895 } 1901 }
1896 1902
1897 // TODO(wjmaclean): There is significant overlap between 1903 // TODO(wjmaclean): There is significant overlap between
1898 // PrepareTextureCopyOutputResult and CopyFromCompositingSurfaceFinished in 1904 // PrepareTextureCopyOutputResult and CopyFromCompositingSurfaceFinished in
1899 // this file, and the versions in surface_utils.cc. They should 1905 // this file, and the versions in surface_utils.cc. They should
1900 // be merged. See https://crbug.com/582955 1906 // be merged. See https://crbug.com/582955
1901 1907
1902 // static 1908 // static
1903 void RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult( 1909 void RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult(
1904 base::WeakPtr<RenderWidgetHostViewAndroid> rwhva, 1910 base::WeakPtr<RenderWidgetHostViewAndroid> rwhva,
1911 scoped_refptr<cc::Layer> readback_layer,
1905 const gfx::Size& dst_size_in_pixel, 1912 const gfx::Size& dst_size_in_pixel,
1906 SkColorType color_type, 1913 SkColorType color_type,
1907 const base::TimeTicks& start_time, 1914 const base::TimeTicks& start_time,
1908 const ReadbackRequestCallback& callback, 1915 const ReadbackRequestCallback& callback,
1909 std::unique_ptr<cc::CopyOutputResult> result) { 1916 std::unique_ptr<cc::CopyOutputResult> result) {
1910 base::ScopedClosureRunner scoped_callback_runner( 1917 base::ScopedClosureRunner scoped_callback_runner(
1911 base::Bind(callback, SkBitmap(), READBACK_FAILED)); 1918 base::Bind(callback, SkBitmap(), READBACK_FAILED));
1912 TRACE_EVENT0("cc", 1919 TRACE_EVENT0("cc",
1913 "RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult"); 1920 "RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult");
1921 readback_layer->RemoveFromParent();
1914 if (rwhva) 1922 if (rwhva)
1915 rwhva->UnlockCompositingSurface(); 1923 rwhva->UnlockCompositingSurface();
1916 if (!result->HasTexture() || result->IsEmpty() || result->size().IsEmpty()) 1924 if (!result->HasTexture() || result->IsEmpty() || result->size().IsEmpty())
1917 return; 1925 return;
1918 cc::TextureMailbox texture_mailbox; 1926 cc::TextureMailbox texture_mailbox;
1919 std::unique_ptr<cc::SingleReleaseCallback> release_callback; 1927 std::unique_ptr<cc::SingleReleaseCallback> release_callback;
1920 result->TakeTexture(&texture_mailbox, &release_callback); 1928 result->TakeTexture(&texture_mailbox, &release_callback);
1921 DCHECK(texture_mailbox.IsTexture()); 1929 DCHECK(texture_mailbox.IsTexture());
1922 if (!texture_mailbox.IsTexture()) 1930 if (!texture_mailbox.IsTexture())
1923 return; 1931 return;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
2020 case ui::MotionEvent::ACTION_UP: 2028 case ui::MotionEvent::ACTION_UP:
2021 case ui::MotionEvent::ACTION_POINTER_UP: 2029 case ui::MotionEvent::ACTION_POINTER_UP:
2022 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED", 2030 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED",
2023 delta.InMicroseconds(), 1, 1000000, 50); 2031 delta.InMicroseconds(), 1, 1000000, 50);
2024 default: 2032 default:
2025 return; 2033 return;
2026 } 2034 }
2027 } 2035 }
2028 2036
2029 } // namespace content 2037 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_android.h ('k') | ui/android/window_android_compositor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698