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