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

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

Issue 143683003: Support format using enum argument for Async readback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Code changes as per review. Created 6 years, 11 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_aura.h" 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 1071 matching lines...) Expand 10 before | Expand all | Expand 10 after
1082 1082
1083 BackingStore* RenderWidgetHostViewAura::AllocBackingStore( 1083 BackingStore* RenderWidgetHostViewAura::AllocBackingStore(
1084 const gfx::Size& size) { 1084 const gfx::Size& size) {
1085 return new BackingStoreAura(host_, size); 1085 return new BackingStoreAura(host_, size);
1086 } 1086 }
1087 1087
1088 void RenderWidgetHostViewAura::CopyFromCompositingSurface( 1088 void RenderWidgetHostViewAura::CopyFromCompositingSurface(
1089 const gfx::Rect& src_subrect, 1089 const gfx::Rect& src_subrect,
1090 const gfx::Size& dst_size, 1090 const gfx::Size& dst_size,
1091 const base::Callback<void(bool, const SkBitmap&)>& callback, 1091 const base::Callback<void(bool, const SkBitmap&)>& callback,
1092 bool readback_config_rgb565) { 1092 const SkBitmap::Config config) {
1093 // Only ARGB888 and RGB565 supported as of now.
1094 bool format_support = ((config == SkBitmap::kRGB_565_Config) ||
1095 (config == SkBitmap::kARGB_8888_Config));
1096 if (!format_support) {
1097 DCHECK(format_support);
1098 callback.Run(false, SkBitmap());
1099 return;
1100 }
1093 if (!CanCopyToBitmap()) { 1101 if (!CanCopyToBitmap()) {
1094 callback.Run(false, SkBitmap()); 1102 callback.Run(false, SkBitmap());
1095 return; 1103 return;
1096 } 1104 }
1097 1105
1098 const gfx::Size& dst_size_in_pixel = ConvertViewSizeToPixel(this, dst_size); 1106 const gfx::Size& dst_size_in_pixel = ConvertViewSizeToPixel(this, dst_size);
1099 scoped_ptr<cc::CopyOutputRequest> request = 1107 scoped_ptr<cc::CopyOutputRequest> request =
1100 cc::CopyOutputRequest::CreateRequest(base::Bind( 1108 cc::CopyOutputRequest::CreateRequest(base::Bind(
1101 &RenderWidgetHostViewAura::CopyFromCompositingSurfaceHasResult, 1109 &RenderWidgetHostViewAura::CopyFromCompositingSurfaceHasResult,
1102 dst_size_in_pixel, 1110 dst_size_in_pixel,
1103 readback_config_rgb565, 1111 config,
1104 callback)); 1112 callback));
1105 gfx::Rect src_subrect_in_pixel = 1113 gfx::Rect src_subrect_in_pixel =
1106 ConvertRectToPixel(current_device_scale_factor_, src_subrect); 1114 ConvertRectToPixel(current_device_scale_factor_, src_subrect);
1107 request->set_area(src_subrect_in_pixel); 1115 request->set_area(src_subrect_in_pixel);
1108 RequestCopyOfOutput(request.Pass()); 1116 RequestCopyOfOutput(request.Pass());
1109 } 1117 }
1110 1118
1111 void RenderWidgetHostViewAura::CopyFromCompositingSurfaceToVideoFrame( 1119 void RenderWidgetHostViewAura::CopyFromCompositingSurfaceToVideoFrame(
1112 const gfx::Rect& src_subrect, 1120 const gfx::Rect& src_subrect,
1113 const scoped_refptr<media::VideoFrame>& target, 1121 const scoped_refptr<media::VideoFrame>& target,
(...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after
1826 return false; 1834 return false;
1827 } 1835 }
1828 1836
1829 void RenderWidgetHostViewAura::SetSurfaceNotInUseByCompositor( 1837 void RenderWidgetHostViewAura::SetSurfaceNotInUseByCompositor(
1830 scoped_refptr<ui::Texture>) { 1838 scoped_refptr<ui::Texture>) {
1831 } 1839 }
1832 1840
1833 // static 1841 // static
1834 void RenderWidgetHostViewAura::CopyFromCompositingSurfaceHasResult( 1842 void RenderWidgetHostViewAura::CopyFromCompositingSurfaceHasResult(
1835 const gfx::Size& dst_size_in_pixel, 1843 const gfx::Size& dst_size_in_pixel,
1836 bool readback_config_rgb565, 1844 const SkBitmap::Config config,
1837 const base::Callback<void(bool, const SkBitmap&)>& callback, 1845 const base::Callback<void(bool, const SkBitmap&)>& callback,
1838 scoped_ptr<cc::CopyOutputResult> result) { 1846 scoped_ptr<cc::CopyOutputResult> result) {
1839 if (result->IsEmpty() || result->size().IsEmpty()) { 1847 if (result->IsEmpty() || result->size().IsEmpty()) {
1840 callback.Run(false, SkBitmap()); 1848 callback.Run(false, SkBitmap());
1841 return; 1849 return;
1842 } 1850 }
1843 1851
1844 if (result->HasTexture()) { 1852 if (result->HasTexture()) {
1845 PrepareTextureCopyOutputResult(dst_size_in_pixel, readback_config_rgb565, 1853 PrepareTextureCopyOutputResult(dst_size_in_pixel, config,
1846 callback, 1854 callback,
1847 result.Pass()); 1855 result.Pass());
1848 return; 1856 return;
1849 } 1857 }
1850 1858
1851 DCHECK(result->HasBitmap()); 1859 DCHECK(result->HasBitmap());
1852 PrepareBitmapCopyOutputResult(dst_size_in_pixel, callback, result.Pass()); 1860 PrepareBitmapCopyOutputResult(dst_size_in_pixel, callback, result.Pass());
1853 } 1861 }
1854 1862
1855 static void CopyFromCompositingSurfaceFinished( 1863 static void CopyFromCompositingSurfaceFinished(
1856 const base::Callback<void(bool, const SkBitmap&)>& callback, 1864 const base::Callback<void(bool, const SkBitmap&)>& callback,
1857 scoped_ptr<cc::SingleReleaseCallback> release_callback, 1865 scoped_ptr<cc::SingleReleaseCallback> release_callback,
1858 scoped_ptr<SkBitmap> bitmap, 1866 scoped_ptr<SkBitmap> bitmap,
1859 scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock, 1867 scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock,
1860 bool result) { 1868 bool result) {
1861 bitmap_pixels_lock.reset(); 1869 bitmap_pixels_lock.reset();
1862 release_callback->Run(0, false); 1870 release_callback->Run(0, false);
1863 callback.Run(result, *bitmap); 1871 callback.Run(result, *bitmap);
1864 } 1872 }
1865 1873
1866 // static 1874 // static
1867 void RenderWidgetHostViewAura::PrepareTextureCopyOutputResult( 1875 void RenderWidgetHostViewAura::PrepareTextureCopyOutputResult(
1868 const gfx::Size& dst_size_in_pixel, 1876 const gfx::Size& dst_size_in_pixel,
1869 bool readback_config_rgb565, 1877 const SkBitmap::Config config,
1870 const base::Callback<void(bool, const SkBitmap&)>& callback, 1878 const base::Callback<void(bool, const SkBitmap&)>& callback,
1871 scoped_ptr<cc::CopyOutputResult> result) { 1879 scoped_ptr<cc::CopyOutputResult> result) {
1872 base::ScopedClosureRunner scoped_callback_runner( 1880 base::ScopedClosureRunner scoped_callback_runner(
1873 base::Bind(callback, false, SkBitmap())); 1881 base::Bind(callback, false, SkBitmap()));
1874 1882
1875 DCHECK(result->HasTexture()); 1883 DCHECK(result->HasTexture());
1876 if (!result->HasTexture()) 1884 if (!result->HasTexture())
1877 return; 1885 return;
1878 1886
1879 scoped_ptr<SkBitmap> bitmap(new SkBitmap); 1887 scoped_ptr<SkBitmap> bitmap(new SkBitmap);
(...skipping 21 matching lines...) Expand all
1901 1909
1902 ignore_result(scoped_callback_runner.Release()); 1910 ignore_result(scoped_callback_runner.Release());
1903 1911
1904 gl_helper->CropScaleReadbackAndCleanMailbox( 1912 gl_helper->CropScaleReadbackAndCleanMailbox(
1905 texture_mailbox.name(), 1913 texture_mailbox.name(),
1906 texture_mailbox.sync_point(), 1914 texture_mailbox.sync_point(),
1907 result->size(), 1915 result->size(),
1908 gfx::Rect(result->size()), 1916 gfx::Rect(result->size()),
1909 dst_size_in_pixel, 1917 dst_size_in_pixel,
1910 pixels, 1918 pixels,
1911 readback_config_rgb565, 1919 config,
1912 base::Bind(&CopyFromCompositingSurfaceFinished, 1920 base::Bind(&CopyFromCompositingSurfaceFinished,
1913 callback, 1921 callback,
1914 base::Passed(&release_callback), 1922 base::Passed(&release_callback),
1915 base::Passed(&bitmap), 1923 base::Passed(&bitmap),
1916 base::Passed(&bitmap_pixels_lock))); 1924 base::Passed(&bitmap_pixels_lock)));
1917 } 1925 }
1918 1926
1919 // static 1927 // static
1920 void RenderWidgetHostViewAura::PrepareBitmapCopyOutputResult( 1928 void RenderWidgetHostViewAura::PrepareBitmapCopyOutputResult(
1921 const gfx::Size& dst_size_in_pixel, 1929 const gfx::Size& dst_size_in_pixel,
(...skipping 1636 matching lines...) Expand 10 before | Expand all | Expand 10 after
3558 RenderWidgetHost* widget) { 3566 RenderWidgetHost* widget) {
3559 return new RenderWidgetHostViewAura(widget); 3567 return new RenderWidgetHostViewAura(widget);
3560 } 3568 }
3561 3569
3562 // static 3570 // static
3563 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { 3571 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) {
3564 GetScreenInfoForWindow(results, NULL); 3572 GetScreenInfoForWindow(results, NULL);
3565 } 3573 }
3566 3574
3567 } // namespace content 3575 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698