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

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

Issue 88033002: Add RGB565 Texture readback support in gl_helper (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased to ToT! 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 1039 matching lines...) Expand 10 before | Expand all | Expand 10 after
1050 } 1050 }
1051 1051
1052 BackingStore* RenderWidgetHostViewAura::AllocBackingStore( 1052 BackingStore* RenderWidgetHostViewAura::AllocBackingStore(
1053 const gfx::Size& size) { 1053 const gfx::Size& size) {
1054 return new BackingStoreAura(host_, size); 1054 return new BackingStoreAura(host_, size);
1055 } 1055 }
1056 1056
1057 void RenderWidgetHostViewAura::CopyFromCompositingSurface( 1057 void RenderWidgetHostViewAura::CopyFromCompositingSurface(
1058 const gfx::Rect& src_subrect, 1058 const gfx::Rect& src_subrect,
1059 const gfx::Size& dst_size, 1059 const gfx::Size& dst_size,
1060 const base::Callback<void(bool, const SkBitmap&)>& callback) { 1060 const base::Callback<void(bool, const SkBitmap&)>& callback,
1061 bool readback_config_rgb565) {
1061 if (!CanCopyToBitmap()) { 1062 if (!CanCopyToBitmap()) {
1062 callback.Run(false, SkBitmap()); 1063 callback.Run(false, SkBitmap());
1063 return; 1064 return;
1064 } 1065 }
1065 1066
1066 const gfx::Size& dst_size_in_pixel = ConvertViewSizeToPixel(this, dst_size); 1067 const gfx::Size& dst_size_in_pixel = ConvertViewSizeToPixel(this, dst_size);
1067 scoped_ptr<cc::CopyOutputRequest> request = 1068 scoped_ptr<cc::CopyOutputRequest> request =
1068 cc::CopyOutputRequest::CreateRequest(base::Bind( 1069 cc::CopyOutputRequest::CreateRequest(base::Bind(
1069 &RenderWidgetHostViewAura::CopyFromCompositingSurfaceHasResult, 1070 &RenderWidgetHostViewAura::CopyFromCompositingSurfaceHasResult,
1070 dst_size_in_pixel, 1071 dst_size_in_pixel,
1072 readback_config_rgb565,
1071 callback)); 1073 callback));
1072 gfx::Rect src_subrect_in_pixel = 1074 gfx::Rect src_subrect_in_pixel =
1073 ConvertRectToPixel(current_device_scale_factor_, src_subrect); 1075 ConvertRectToPixel(current_device_scale_factor_, src_subrect);
1074 request->set_area(src_subrect_in_pixel); 1076 request->set_area(src_subrect_in_pixel);
1075 RequestCopyOfOutput(request.Pass()); 1077 RequestCopyOfOutput(request.Pass());
1076 } 1078 }
1077 1079
1078 void RenderWidgetHostViewAura::CopyFromCompositingSurfaceToVideoFrame( 1080 void RenderWidgetHostViewAura::CopyFromCompositingSurfaceToVideoFrame(
1079 const gfx::Rect& src_subrect, 1081 const gfx::Rect& src_subrect,
1080 const scoped_refptr<media::VideoFrame>& target, 1082 const scoped_refptr<media::VideoFrame>& target,
(...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after
1793 return false; 1795 return false;
1794 } 1796 }
1795 1797
1796 void RenderWidgetHostViewAura::SetSurfaceNotInUseByCompositor( 1798 void RenderWidgetHostViewAura::SetSurfaceNotInUseByCompositor(
1797 scoped_refptr<ui::Texture>) { 1799 scoped_refptr<ui::Texture>) {
1798 } 1800 }
1799 1801
1800 // static 1802 // static
1801 void RenderWidgetHostViewAura::CopyFromCompositingSurfaceHasResult( 1803 void RenderWidgetHostViewAura::CopyFromCompositingSurfaceHasResult(
1802 const gfx::Size& dst_size_in_pixel, 1804 const gfx::Size& dst_size_in_pixel,
1805 bool readback_config_rgb565,
1803 const base::Callback<void(bool, const SkBitmap&)>& callback, 1806 const base::Callback<void(bool, const SkBitmap&)>& callback,
1804 scoped_ptr<cc::CopyOutputResult> result) { 1807 scoped_ptr<cc::CopyOutputResult> result) {
1805 if (result->IsEmpty() || result->size().IsEmpty()) { 1808 if (result->IsEmpty() || result->size().IsEmpty()) {
1806 callback.Run(false, SkBitmap()); 1809 callback.Run(false, SkBitmap());
1807 return; 1810 return;
1808 } 1811 }
1809 1812
1810 if (result->HasTexture()) { 1813 if (result->HasTexture()) {
1811 PrepareTextureCopyOutputResult(dst_size_in_pixel, callback, result.Pass()); 1814 PrepareTextureCopyOutputResult(dst_size_in_pixel, readback_config_rgb565,
1815 callback,
1816 result.Pass());
1812 return; 1817 return;
1813 } 1818 }
1814 1819
1815 DCHECK(result->HasBitmap()); 1820 DCHECK(result->HasBitmap());
1816 PrepareBitmapCopyOutputResult(dst_size_in_pixel, callback, result.Pass()); 1821 PrepareBitmapCopyOutputResult(dst_size_in_pixel, callback, result.Pass());
1817 } 1822 }
1818 1823
1819 static void CopyFromCompositingSurfaceFinished( 1824 static void CopyFromCompositingSurfaceFinished(
1820 const base::Callback<void(bool, const SkBitmap&)>& callback, 1825 const base::Callback<void(bool, const SkBitmap&)>& callback,
1821 scoped_ptr<cc::SingleReleaseCallback> release_callback, 1826 scoped_ptr<cc::SingleReleaseCallback> release_callback,
1822 scoped_ptr<SkBitmap> bitmap, 1827 scoped_ptr<SkBitmap> bitmap,
1823 scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock, 1828 scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock,
1824 bool result) { 1829 bool result) {
1825 bitmap_pixels_lock.reset(); 1830 bitmap_pixels_lock.reset();
1826 release_callback->Run(0, false); 1831 release_callback->Run(0, false);
1827 callback.Run(result, *bitmap); 1832 callback.Run(result, *bitmap);
1828 } 1833 }
1829 1834
1830 // static 1835 // static
1831 void RenderWidgetHostViewAura::PrepareTextureCopyOutputResult( 1836 void RenderWidgetHostViewAura::PrepareTextureCopyOutputResult(
1832 const gfx::Size& dst_size_in_pixel, 1837 const gfx::Size& dst_size_in_pixel,
1838 bool readback_config_rgb565,
1833 const base::Callback<void(bool, const SkBitmap&)>& callback, 1839 const base::Callback<void(bool, const SkBitmap&)>& callback,
1834 scoped_ptr<cc::CopyOutputResult> result) { 1840 scoped_ptr<cc::CopyOutputResult> result) {
1835 base::ScopedClosureRunner scoped_callback_runner( 1841 base::ScopedClosureRunner scoped_callback_runner(
1836 base::Bind(callback, false, SkBitmap())); 1842 base::Bind(callback, false, SkBitmap()));
1837 1843
1838 DCHECK(result->HasTexture()); 1844 DCHECK(result->HasTexture());
1839 if (!result->HasTexture()) 1845 if (!result->HasTexture())
1840 return; 1846 return;
1841 1847
1842 scoped_ptr<SkBitmap> bitmap(new SkBitmap); 1848 scoped_ptr<SkBitmap> bitmap(new SkBitmap);
(...skipping 21 matching lines...) Expand all
1864 1870
1865 ignore_result(scoped_callback_runner.Release()); 1871 ignore_result(scoped_callback_runner.Release());
1866 1872
1867 gl_helper->CropScaleReadbackAndCleanMailbox( 1873 gl_helper->CropScaleReadbackAndCleanMailbox(
1868 texture_mailbox.name(), 1874 texture_mailbox.name(),
1869 texture_mailbox.sync_point(), 1875 texture_mailbox.sync_point(),
1870 result->size(), 1876 result->size(),
1871 gfx::Rect(result->size()), 1877 gfx::Rect(result->size()),
1872 dst_size_in_pixel, 1878 dst_size_in_pixel,
1873 pixels, 1879 pixels,
1880 readback_config_rgb565,
1874 base::Bind(&CopyFromCompositingSurfaceFinished, 1881 base::Bind(&CopyFromCompositingSurfaceFinished,
1875 callback, 1882 callback,
1876 base::Passed(&release_callback), 1883 base::Passed(&release_callback),
1877 base::Passed(&bitmap), 1884 base::Passed(&bitmap),
1878 base::Passed(&bitmap_pixels_lock))); 1885 base::Passed(&bitmap_pixels_lock)));
1879 } 1886 }
1880 1887
1881 // static 1888 // static
1882 void RenderWidgetHostViewAura::PrepareBitmapCopyOutputResult( 1889 void RenderWidgetHostViewAura::PrepareBitmapCopyOutputResult(
1883 const gfx::Size& dst_size_in_pixel, 1890 const gfx::Size& dst_size_in_pixel,
(...skipping 1636 matching lines...) Expand 10 before | Expand all | Expand 10 after
3520 RenderWidgetHost* widget) { 3527 RenderWidgetHost* widget) {
3521 return new RenderWidgetHostViewAura(widget); 3528 return new RenderWidgetHostViewAura(widget);
3522 } 3529 }
3523 3530
3524 // static 3531 // static
3525 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { 3532 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) {
3526 GetScreenInfoForWindow(results, NULL); 3533 GetScreenInfoForWindow(results, NULL);
3527 } 3534 }
3528 3535
3529 } // namespace content 3536 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698