| 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 1847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1858 } | 1858 } |
| 1859 | 1859 |
| 1860 if (result->HasTexture()) { | 1860 if (result->HasTexture()) { |
| 1861 PrepareTextureCopyOutputResult(dst_size_in_pixel, config, | 1861 PrepareTextureCopyOutputResult(dst_size_in_pixel, config, |
| 1862 callback, | 1862 callback, |
| 1863 result.Pass()); | 1863 result.Pass()); |
| 1864 return; | 1864 return; |
| 1865 } | 1865 } |
| 1866 | 1866 |
| 1867 DCHECK(result->HasBitmap()); | 1867 DCHECK(result->HasBitmap()); |
| 1868 PrepareBitmapCopyOutputResult(dst_size_in_pixel, callback, result.Pass()); | 1868 PrepareBitmapCopyOutputResult(dst_size_in_pixel, config, callback, |
| 1869 result.Pass()); |
| 1869 } | 1870 } |
| 1870 | 1871 |
| 1871 static void CopyFromCompositingSurfaceFinished( | 1872 static void CopyFromCompositingSurfaceFinished( |
| 1872 const base::Callback<void(bool, const SkBitmap&)>& callback, | 1873 const base::Callback<void(bool, const SkBitmap&)>& callback, |
| 1873 scoped_ptr<cc::SingleReleaseCallback> release_callback, | 1874 scoped_ptr<cc::SingleReleaseCallback> release_callback, |
| 1874 scoped_ptr<SkBitmap> bitmap, | 1875 scoped_ptr<SkBitmap> bitmap, |
| 1875 scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock, | 1876 scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock, |
| 1876 bool result) { | 1877 bool result) { |
| 1877 bitmap_pixels_lock.reset(); | 1878 bitmap_pixels_lock.reset(); |
| 1878 release_callback->Run(0, false); | 1879 release_callback->Run(0, false); |
| 1879 callback.Run(result, *bitmap); | 1880 callback.Run(result, *bitmap); |
| 1880 } | 1881 } |
| 1881 | 1882 |
| 1882 // static | 1883 // static |
| 1883 void RenderWidgetHostViewAura::PrepareTextureCopyOutputResult( | 1884 void RenderWidgetHostViewAura::PrepareTextureCopyOutputResult( |
| 1884 const gfx::Size& dst_size_in_pixel, | 1885 const gfx::Size& dst_size_in_pixel, |
| 1885 const SkBitmap::Config config, | 1886 const SkBitmap::Config config, |
| 1886 const base::Callback<void(bool, const SkBitmap&)>& callback, | 1887 const base::Callback<void(bool, const SkBitmap&)>& callback, |
| 1887 scoped_ptr<cc::CopyOutputResult> result) { | 1888 scoped_ptr<cc::CopyOutputResult> result) { |
| 1888 base::ScopedClosureRunner scoped_callback_runner( | 1889 base::ScopedClosureRunner scoped_callback_runner( |
| 1889 base::Bind(callback, false, SkBitmap())); | 1890 base::Bind(callback, false, SkBitmap())); |
| 1890 | 1891 |
| 1891 DCHECK(result->HasTexture()); | 1892 DCHECK(result->HasTexture()); |
| 1892 if (!result->HasTexture()) | 1893 if (!result->HasTexture()) |
| 1893 return; | 1894 return; |
| 1894 | 1895 |
| 1895 scoped_ptr<SkBitmap> bitmap(new SkBitmap); | 1896 scoped_ptr<SkBitmap> bitmap(new SkBitmap); |
| 1896 bitmap->setConfig(SkBitmap::kARGB_8888_Config, | 1897 bitmap->setConfig(config, |
| 1897 dst_size_in_pixel.width(), dst_size_in_pixel.height(), | 1898 dst_size_in_pixel.width(), dst_size_in_pixel.height(), |
| 1898 0, kOpaque_SkAlphaType); | 1899 0, kOpaque_SkAlphaType); |
| 1899 if (!bitmap->allocPixels()) | 1900 if (!bitmap->allocPixels()) |
| 1900 return; | 1901 return; |
| 1901 | 1902 |
| 1902 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 1903 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
| 1903 GLHelper* gl_helper = factory->GetGLHelper(); | 1904 GLHelper* gl_helper = factory->GetGLHelper(); |
| 1904 if (!gl_helper) | 1905 if (!gl_helper) |
| 1905 return; | 1906 return; |
| 1906 | 1907 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1928 base::Bind(&CopyFromCompositingSurfaceFinished, | 1929 base::Bind(&CopyFromCompositingSurfaceFinished, |
| 1929 callback, | 1930 callback, |
| 1930 base::Passed(&release_callback), | 1931 base::Passed(&release_callback), |
| 1931 base::Passed(&bitmap), | 1932 base::Passed(&bitmap), |
| 1932 base::Passed(&bitmap_pixels_lock))); | 1933 base::Passed(&bitmap_pixels_lock))); |
| 1933 } | 1934 } |
| 1934 | 1935 |
| 1935 // static | 1936 // static |
| 1936 void RenderWidgetHostViewAura::PrepareBitmapCopyOutputResult( | 1937 void RenderWidgetHostViewAura::PrepareBitmapCopyOutputResult( |
| 1937 const gfx::Size& dst_size_in_pixel, | 1938 const gfx::Size& dst_size_in_pixel, |
| 1939 const SkBitmap::Config config, |
| 1938 const base::Callback<void(bool, const SkBitmap&)>& callback, | 1940 const base::Callback<void(bool, const SkBitmap&)>& callback, |
| 1939 scoped_ptr<cc::CopyOutputResult> result) { | 1941 scoped_ptr<cc::CopyOutputResult> result) { |
| 1942 if (config != SkBitmap::kARGB_8888_Config) { |
| 1943 NOTIMPLEMENTED(); |
| 1944 callback.Run(false, SkBitmap()); |
| 1945 return; |
| 1946 } |
| 1940 DCHECK(result->HasBitmap()); | 1947 DCHECK(result->HasBitmap()); |
| 1941 | |
| 1942 base::ScopedClosureRunner scoped_callback_runner( | 1948 base::ScopedClosureRunner scoped_callback_runner( |
| 1943 base::Bind(callback, false, SkBitmap())); | 1949 base::Bind(callback, false, SkBitmap())); |
| 1944 if (!result->HasBitmap()) | 1950 if (!result->HasBitmap()) |
| 1945 return; | 1951 return; |
| 1946 | 1952 |
| 1947 scoped_ptr<SkBitmap> source = result->TakeBitmap(); | 1953 scoped_ptr<SkBitmap> source = result->TakeBitmap(); |
| 1948 DCHECK(source); | 1954 DCHECK(source); |
| 1949 if (!source) | 1955 if (!source) |
| 1950 return; | 1956 return; |
| 1951 | 1957 |
| (...skipping 1624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3576 RenderWidgetHost* widget) { | 3582 RenderWidgetHost* widget) { |
| 3577 return new RenderWidgetHostViewAura(widget); | 3583 return new RenderWidgetHostViewAura(widget); |
| 3578 } | 3584 } |
| 3579 | 3585 |
| 3580 // static | 3586 // static |
| 3581 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { | 3587 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { |
| 3582 GetScreenInfoForWindow(results, NULL); | 3588 GetScreenInfoForWindow(results, NULL); |
| 3583 } | 3589 } |
| 3584 | 3590 |
| 3585 } // namespace content | 3591 } // namespace content |
| OLD | NEW |