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 1837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1848 } | 1848 } |
1849 | 1849 |
1850 if (result->HasTexture()) { | 1850 if (result->HasTexture()) { |
1851 PrepareTextureCopyOutputResult(dst_size_in_pixel, config, | 1851 PrepareTextureCopyOutputResult(dst_size_in_pixel, config, |
1852 callback, | 1852 callback, |
1853 result.Pass()); | 1853 result.Pass()); |
1854 return; | 1854 return; |
1855 } | 1855 } |
1856 | 1856 |
1857 DCHECK(result->HasBitmap()); | 1857 DCHECK(result->HasBitmap()); |
1858 PrepareBitmapCopyOutputResult(dst_size_in_pixel, callback, result.Pass()); | 1858 PrepareBitmapCopyOutputResult(dst_size_in_pixel, config, callback, |
| 1859 result.Pass()); |
1859 } | 1860 } |
1860 | 1861 |
1861 static void CopyFromCompositingSurfaceFinished( | 1862 static void CopyFromCompositingSurfaceFinished( |
1862 const base::Callback<void(bool, const SkBitmap&)>& callback, | 1863 const base::Callback<void(bool, const SkBitmap&)>& callback, |
1863 scoped_ptr<cc::SingleReleaseCallback> release_callback, | 1864 scoped_ptr<cc::SingleReleaseCallback> release_callback, |
1864 scoped_ptr<SkBitmap> bitmap, | 1865 scoped_ptr<SkBitmap> bitmap, |
1865 scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock, | 1866 scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock, |
1866 bool result) { | 1867 bool result) { |
1867 bitmap_pixels_lock.reset(); | 1868 bitmap_pixels_lock.reset(); |
1868 release_callback->Run(0, false); | 1869 release_callback->Run(0, false); |
1869 callback.Run(result, *bitmap); | 1870 callback.Run(result, *bitmap); |
1870 } | 1871 } |
1871 | 1872 |
1872 // static | 1873 // static |
1873 void RenderWidgetHostViewAura::PrepareTextureCopyOutputResult( | 1874 void RenderWidgetHostViewAura::PrepareTextureCopyOutputResult( |
1874 const gfx::Size& dst_size_in_pixel, | 1875 const gfx::Size& dst_size_in_pixel, |
1875 const SkBitmap::Config config, | 1876 const SkBitmap::Config config, |
1876 const base::Callback<void(bool, const SkBitmap&)>& callback, | 1877 const base::Callback<void(bool, const SkBitmap&)>& callback, |
1877 scoped_ptr<cc::CopyOutputResult> result) { | 1878 scoped_ptr<cc::CopyOutputResult> result) { |
1878 base::ScopedClosureRunner scoped_callback_runner( | 1879 base::ScopedClosureRunner scoped_callback_runner( |
1879 base::Bind(callback, false, SkBitmap())); | 1880 base::Bind(callback, false, SkBitmap())); |
1880 | 1881 |
1881 DCHECK(result->HasTexture()); | 1882 DCHECK(result->HasTexture()); |
1882 if (!result->HasTexture()) | 1883 if (!result->HasTexture()) |
1883 return; | 1884 return; |
1884 | 1885 |
1885 scoped_ptr<SkBitmap> bitmap(new SkBitmap); | 1886 scoped_ptr<SkBitmap> bitmap(new SkBitmap); |
1886 bitmap->setConfig(SkBitmap::kARGB_8888_Config, | 1887 bitmap->setConfig(config, |
1887 dst_size_in_pixel.width(), dst_size_in_pixel.height(), | 1888 dst_size_in_pixel.width(), dst_size_in_pixel.height(), |
1888 0, kOpaque_SkAlphaType); | 1889 0, kOpaque_SkAlphaType); |
1889 if (!bitmap->allocPixels()) | 1890 if (!bitmap->allocPixels()) |
1890 return; | 1891 return; |
1891 | 1892 |
1892 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 1893 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
1893 GLHelper* gl_helper = factory->GetGLHelper(); | 1894 GLHelper* gl_helper = factory->GetGLHelper(); |
1894 if (!gl_helper) | 1895 if (!gl_helper) |
1895 return; | 1896 return; |
1896 | 1897 |
(...skipping 21 matching lines...) Expand all Loading... |
1918 base::Bind(&CopyFromCompositingSurfaceFinished, | 1919 base::Bind(&CopyFromCompositingSurfaceFinished, |
1919 callback, | 1920 callback, |
1920 base::Passed(&release_callback), | 1921 base::Passed(&release_callback), |
1921 base::Passed(&bitmap), | 1922 base::Passed(&bitmap), |
1922 base::Passed(&bitmap_pixels_lock))); | 1923 base::Passed(&bitmap_pixels_lock))); |
1923 } | 1924 } |
1924 | 1925 |
1925 // static | 1926 // static |
1926 void RenderWidgetHostViewAura::PrepareBitmapCopyOutputResult( | 1927 void RenderWidgetHostViewAura::PrepareBitmapCopyOutputResult( |
1927 const gfx::Size& dst_size_in_pixel, | 1928 const gfx::Size& dst_size_in_pixel, |
| 1929 const SkBitmap::Config config, |
1928 const base::Callback<void(bool, const SkBitmap&)>& callback, | 1930 const base::Callback<void(bool, const SkBitmap&)>& callback, |
1929 scoped_ptr<cc::CopyOutputResult> result) { | 1931 scoped_ptr<cc::CopyOutputResult> result) { |
| 1932 if (config != SkBitmap::kARGB_8888_Config) { |
| 1933 NOTIMPLEMENTED(); |
| 1934 callback.Run(false, SkBitmap()); |
| 1935 return; |
| 1936 } |
1930 DCHECK(result->HasBitmap()); | 1937 DCHECK(result->HasBitmap()); |
1931 | |
1932 base::ScopedClosureRunner scoped_callback_runner( | 1938 base::ScopedClosureRunner scoped_callback_runner( |
1933 base::Bind(callback, false, SkBitmap())); | 1939 base::Bind(callback, false, SkBitmap())); |
1934 if (!result->HasBitmap()) | 1940 if (!result->HasBitmap()) |
1935 return; | 1941 return; |
1936 | 1942 |
1937 scoped_ptr<SkBitmap> source = result->TakeBitmap(); | 1943 scoped_ptr<SkBitmap> source = result->TakeBitmap(); |
1938 DCHECK(source); | 1944 DCHECK(source); |
1939 if (!source) | 1945 if (!source) |
1940 return; | 1946 return; |
1941 | 1947 |
(...skipping 1620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3562 RenderWidgetHost* widget) { | 3568 RenderWidgetHost* widget) { |
3563 return new RenderWidgetHostViewAura(widget); | 3569 return new RenderWidgetHostViewAura(widget); |
3564 } | 3570 } |
3565 | 3571 |
3566 // static | 3572 // static |
3567 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { | 3573 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { |
3568 GetScreenInfoForWindow(results, NULL); | 3574 GetScreenInfoForWindow(results, NULL); |
3569 } | 3575 } |
3570 | 3576 |
3571 } // namespace content | 3577 } // namespace content |
OLD | NEW |