| 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 1038 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1049 } | 1049 } |
| 1050 | 1050 |
| 1051 BackingStore* RenderWidgetHostViewAura::AllocBackingStore( | 1051 BackingStore* RenderWidgetHostViewAura::AllocBackingStore( |
| 1052 const gfx::Size& size) { | 1052 const gfx::Size& size) { |
| 1053 return new BackingStoreAura(host_, size); | 1053 return new BackingStoreAura(host_, size); |
| 1054 } | 1054 } |
| 1055 | 1055 |
| 1056 void RenderWidgetHostViewAura::CopyFromCompositingSurface( | 1056 void RenderWidgetHostViewAura::CopyFromCompositingSurface( |
| 1057 const gfx::Rect& src_subrect, | 1057 const gfx::Rect& src_subrect, |
| 1058 const gfx::Size& dst_size, | 1058 const gfx::Size& dst_size, |
| 1059 const base::Callback<void(bool, const SkBitmap&)>& callback) { | 1059 const base::Callback<void(bool, const SkBitmap&)>& callback, |
| 1060 bool readback_config_rgb565) { |
| 1060 if (!CanCopyToBitmap()) { | 1061 if (!CanCopyToBitmap()) { |
| 1061 callback.Run(false, SkBitmap()); | 1062 callback.Run(false, SkBitmap()); |
| 1062 return; | 1063 return; |
| 1063 } | 1064 } |
| 1064 | 1065 |
| 1065 const gfx::Size& dst_size_in_pixel = ConvertViewSizeToPixel(this, dst_size); | 1066 const gfx::Size& dst_size_in_pixel = ConvertViewSizeToPixel(this, dst_size); |
| 1066 scoped_ptr<cc::CopyOutputRequest> request = | 1067 scoped_ptr<cc::CopyOutputRequest> request = |
| 1067 cc::CopyOutputRequest::CreateRequest(base::Bind( | 1068 cc::CopyOutputRequest::CreateRequest(base::Bind( |
| 1068 &RenderWidgetHostViewAura::CopyFromCompositingSurfaceHasResult, | 1069 &RenderWidgetHostViewAura::CopyFromCompositingSurfaceHasResult, |
| 1069 dst_size_in_pixel, | 1070 dst_size_in_pixel, |
| 1071 readback_config_rgb565, |
| 1070 callback)); | 1072 callback)); |
| 1071 gfx::Rect src_subrect_in_pixel = | 1073 gfx::Rect src_subrect_in_pixel = |
| 1072 ConvertRectToPixel(current_device_scale_factor_, src_subrect); | 1074 ConvertRectToPixel(current_device_scale_factor_, src_subrect); |
| 1073 request->set_area(src_subrect_in_pixel); | 1075 request->set_area(src_subrect_in_pixel); |
| 1074 RequestCopyOfOutput(request.Pass()); | 1076 RequestCopyOfOutput(request.Pass()); |
| 1075 } | 1077 } |
| 1076 | 1078 |
| 1077 void RenderWidgetHostViewAura::CopyFromCompositingSurfaceToVideoFrame( | 1079 void RenderWidgetHostViewAura::CopyFromCompositingSurfaceToVideoFrame( |
| 1078 const gfx::Rect& src_subrect, | 1080 const gfx::Rect& src_subrect, |
| 1079 const scoped_refptr<media::VideoFrame>& target, | 1081 const scoped_refptr<media::VideoFrame>& target, |
| (...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1802 return false; | 1804 return false; |
| 1803 } | 1805 } |
| 1804 | 1806 |
| 1805 void RenderWidgetHostViewAura::SetSurfaceNotInUseByCompositor( | 1807 void RenderWidgetHostViewAura::SetSurfaceNotInUseByCompositor( |
| 1806 scoped_refptr<ui::Texture>) { | 1808 scoped_refptr<ui::Texture>) { |
| 1807 } | 1809 } |
| 1808 | 1810 |
| 1809 // static | 1811 // static |
| 1810 void RenderWidgetHostViewAura::CopyFromCompositingSurfaceHasResult( | 1812 void RenderWidgetHostViewAura::CopyFromCompositingSurfaceHasResult( |
| 1811 const gfx::Size& dst_size_in_pixel, | 1813 const gfx::Size& dst_size_in_pixel, |
| 1814 bool readback_config_rgb565, |
| 1812 const base::Callback<void(bool, const SkBitmap&)>& callback, | 1815 const base::Callback<void(bool, const SkBitmap&)>& callback, |
| 1813 scoped_ptr<cc::CopyOutputResult> result) { | 1816 scoped_ptr<cc::CopyOutputResult> result) { |
| 1814 if (result->IsEmpty() || result->size().IsEmpty()) { | 1817 if (result->IsEmpty() || result->size().IsEmpty()) { |
| 1815 callback.Run(false, SkBitmap()); | 1818 callback.Run(false, SkBitmap()); |
| 1816 return; | 1819 return; |
| 1817 } | 1820 } |
| 1818 | 1821 |
| 1819 if (result->HasTexture()) { | 1822 if (result->HasTexture()) { |
| 1820 PrepareTextureCopyOutputResult(dst_size_in_pixel, callback, result.Pass()); | 1823 PrepareTextureCopyOutputResult(dst_size_in_pixel, readback_config_rgb565, |
| 1824 callback, |
| 1825 result.Pass()); |
| 1821 return; | 1826 return; |
| 1822 } | 1827 } |
| 1823 | 1828 |
| 1824 DCHECK(result->HasBitmap()); | 1829 DCHECK(result->HasBitmap()); |
| 1825 PrepareBitmapCopyOutputResult(dst_size_in_pixel, callback, result.Pass()); | 1830 PrepareBitmapCopyOutputResult(dst_size_in_pixel, callback, result.Pass()); |
| 1826 } | 1831 } |
| 1827 | 1832 |
| 1828 static void CopyFromCompositingSurfaceFinished( | 1833 static void CopyFromCompositingSurfaceFinished( |
| 1829 const base::Callback<void(bool, const SkBitmap&)>& callback, | 1834 const base::Callback<void(bool, const SkBitmap&)>& callback, |
| 1830 scoped_ptr<cc::SingleReleaseCallback> release_callback, | 1835 scoped_ptr<cc::SingleReleaseCallback> release_callback, |
| 1831 scoped_ptr<SkBitmap> bitmap, | 1836 scoped_ptr<SkBitmap> bitmap, |
| 1832 scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock, | 1837 scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock, |
| 1833 bool result) { | 1838 bool result) { |
| 1834 bitmap_pixels_lock.reset(); | 1839 bitmap_pixels_lock.reset(); |
| 1835 release_callback->Run(0, false); | 1840 release_callback->Run(0, false); |
| 1836 callback.Run(result, *bitmap); | 1841 callback.Run(result, *bitmap); |
| 1837 } | 1842 } |
| 1838 | 1843 |
| 1839 // static | 1844 // static |
| 1840 void RenderWidgetHostViewAura::PrepareTextureCopyOutputResult( | 1845 void RenderWidgetHostViewAura::PrepareTextureCopyOutputResult( |
| 1841 const gfx::Size& dst_size_in_pixel, | 1846 const gfx::Size& dst_size_in_pixel, |
| 1847 bool readback_config_rgb565, |
| 1842 const base::Callback<void(bool, const SkBitmap&)>& callback, | 1848 const base::Callback<void(bool, const SkBitmap&)>& callback, |
| 1843 scoped_ptr<cc::CopyOutputResult> result) { | 1849 scoped_ptr<cc::CopyOutputResult> result) { |
| 1844 base::ScopedClosureRunner scoped_callback_runner( | 1850 base::ScopedClosureRunner scoped_callback_runner( |
| 1845 base::Bind(callback, false, SkBitmap())); | 1851 base::Bind(callback, false, SkBitmap())); |
| 1846 | 1852 |
| 1847 DCHECK(result->HasTexture()); | 1853 DCHECK(result->HasTexture()); |
| 1848 if (!result->HasTexture()) | 1854 if (!result->HasTexture()) |
| 1849 return; | 1855 return; |
| 1850 | 1856 |
| 1851 scoped_ptr<SkBitmap> bitmap(new SkBitmap); | 1857 scoped_ptr<SkBitmap> bitmap(new SkBitmap); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1872 return; | 1878 return; |
| 1873 | 1879 |
| 1874 ignore_result(scoped_callback_runner.Release()); | 1880 ignore_result(scoped_callback_runner.Release()); |
| 1875 | 1881 |
| 1876 gl_helper->CropScaleReadbackAndCleanMailbox( | 1882 gl_helper->CropScaleReadbackAndCleanMailbox( |
| 1877 texture_mailbox.name(), | 1883 texture_mailbox.name(), |
| 1878 texture_mailbox.sync_point(), | 1884 texture_mailbox.sync_point(), |
| 1879 result->size(), | 1885 result->size(), |
| 1880 gfx::Rect(result->size()), | 1886 gfx::Rect(result->size()), |
| 1881 dst_size_in_pixel, | 1887 dst_size_in_pixel, |
| 1888 readback_config_rgb565, |
| 1882 pixels, | 1889 pixels, |
| 1883 base::Bind(&CopyFromCompositingSurfaceFinished, | 1890 base::Bind(&CopyFromCompositingSurfaceFinished, |
| 1884 callback, | 1891 callback, |
| 1885 base::Passed(&release_callback), | 1892 base::Passed(&release_callback), |
| 1886 base::Passed(&bitmap), | 1893 base::Passed(&bitmap), |
| 1887 base::Passed(&bitmap_pixels_lock))); | 1894 base::Passed(&bitmap_pixels_lock))); |
| 1888 } | 1895 } |
| 1889 | 1896 |
| 1890 // static | 1897 // static |
| 1891 void RenderWidgetHostViewAura::PrepareBitmapCopyOutputResult( | 1898 void RenderWidgetHostViewAura::PrepareBitmapCopyOutputResult( |
| (...skipping 1651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3543 RenderWidgetHost* widget) { | 3550 RenderWidgetHost* widget) { |
| 3544 return new RenderWidgetHostViewAura(widget); | 3551 return new RenderWidgetHostViewAura(widget); |
| 3545 } | 3552 } |
| 3546 | 3553 |
| 3547 // static | 3554 // static |
| 3548 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { | 3555 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { |
| 3549 GetScreenInfoForWindow(results, NULL); | 3556 GetScreenInfoForWindow(results, NULL); |
| 3550 } | 3557 } |
| 3551 | 3558 |
| 3552 } // namespace content | 3559 } // namespace content |
| OLD | NEW |