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