Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(276)

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_aura.cc

Issue 19990007: Don't leak CopyResult textures. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/output/copy_output_result.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 1701 matching lines...) Expand 10 before | Expand all | Expand 10 after
1712 PrepareTextureCopyOutputResult(dst_size_in_pixel, callback, result.Pass()); 1712 PrepareTextureCopyOutputResult(dst_size_in_pixel, callback, result.Pass());
1713 return; 1713 return;
1714 } 1714 }
1715 1715
1716 DCHECK(result->HasBitmap()); 1716 DCHECK(result->HasBitmap());
1717 PrepareBitmapCopyOutputResult(dst_size_in_pixel, callback, result.Pass()); 1717 PrepareBitmapCopyOutputResult(dst_size_in_pixel, callback, result.Pass());
1718 } 1718 }
1719 1719
1720 static void CopyFromCompositingSurfaceFinished( 1720 static void CopyFromCompositingSurfaceFinished(
1721 const base::Callback<void(bool, const SkBitmap&)>& callback, 1721 const base::Callback<void(bool, const SkBitmap&)>& callback,
1722 const cc::TextureMailbox::ReleaseCallback& release_callback,
1722 scoped_ptr<SkBitmap> bitmap, 1723 scoped_ptr<SkBitmap> bitmap,
1723 scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock, 1724 scoped_ptr<SkAutoLockPixels> bitmap_pixels_lock,
1724 bool result) { 1725 bool result) {
1725 bitmap_pixels_lock.reset(); 1726 bitmap_pixels_lock.reset();
1727 release_callback.Run(0, false);
1726 callback.Run(result, *bitmap); 1728 callback.Run(result, *bitmap);
1727 } 1729 }
1728 1730
1729 // static 1731 // static
1730 void RenderWidgetHostViewAura::PrepareTextureCopyOutputResult( 1732 void RenderWidgetHostViewAura::PrepareTextureCopyOutputResult(
1731 const gfx::Size& dst_size_in_pixel, 1733 const gfx::Size& dst_size_in_pixel,
1732 const base::Callback<void(bool, const SkBitmap&)>& callback, 1734 const base::Callback<void(bool, const SkBitmap&)>& callback,
1733 scoped_ptr<cc::CopyOutputResult> result) { 1735 scoped_ptr<cc::CopyOutputResult> result) {
1734 base::ScopedClosureRunner scoped_callback_runner( 1736 base::ScopedClosureRunner scoped_callback_runner(
1735 base::Bind(callback, false, SkBitmap())); 1737 base::Bind(callback, false, SkBitmap()));
(...skipping 27 matching lines...) Expand all
1763 1765
1764 gl_helper->CropScaleReadbackAndCleanMailbox( 1766 gl_helper->CropScaleReadbackAndCleanMailbox(
1765 texture_mailbox->name(), 1767 texture_mailbox->name(),
1766 texture_mailbox->sync_point(), 1768 texture_mailbox->sync_point(),
1767 result->size(), 1769 result->size(),
1768 gfx::Rect(result->size()), 1770 gfx::Rect(result->size()),
1769 dst_size_in_pixel, 1771 dst_size_in_pixel,
1770 pixels, 1772 pixels,
1771 base::Bind(&CopyFromCompositingSurfaceFinished, 1773 base::Bind(&CopyFromCompositingSurfaceFinished,
1772 callback, 1774 callback,
1775 texture_mailbox->callback(),
1773 base::Passed(&bitmap), 1776 base::Passed(&bitmap),
1774 base::Passed(&bitmap_pixels_lock))); 1777 base::Passed(&bitmap_pixels_lock)));
1775 } 1778 }
1776 1779
1777 // static 1780 // static
1778 void RenderWidgetHostViewAura::PrepareBitmapCopyOutputResult( 1781 void RenderWidgetHostViewAura::PrepareBitmapCopyOutputResult(
1779 const gfx::Size& dst_size_in_pixel, 1782 const gfx::Size& dst_size_in_pixel,
1780 const base::Callback<void(bool, const SkBitmap&)>& callback, 1783 const base::Callback<void(bool, const SkBitmap&)>& callback,
1781 scoped_ptr<cc::CopyOutputResult> result) { 1784 scoped_ptr<cc::CopyOutputResult> result) {
1782 DCHECK(result->HasBitmap()); 1785 DCHECK(result->HasBitmap());
(...skipping 11 matching lines...) Expand all
1794 scoped_callback_runner.Release(); 1797 scoped_callback_runner.Release();
1795 1798
1796 SkBitmap bitmap = skia::ImageOperations::Resize( 1799 SkBitmap bitmap = skia::ImageOperations::Resize(
1797 *source, 1800 *source,
1798 skia::ImageOperations::RESIZE_BEST, 1801 skia::ImageOperations::RESIZE_BEST,
1799 dst_size_in_pixel.width(), 1802 dst_size_in_pixel.width(),
1800 dst_size_in_pixel.height()); 1803 dst_size_in_pixel.height());
1801 callback.Run(true, bitmap); 1804 callback.Run(true, bitmap);
1802 } 1805 }
1803 1806
1807 static void CopyFromCompositingSurfaceFinishedForVideo(
1808 const base::Callback<void(bool)>& callback,
1809 const cc::TextureMailbox::ReleaseCallback& release_callback,
1810 bool result) {
1811 release_callback.Run(0, false);
1812 callback.Run(result);
1813 }
1814
1804 // static 1815 // static
1805 void RenderWidgetHostViewAura::CopyFromCompositingSurfaceHasResultForVideo( 1816 void RenderWidgetHostViewAura::CopyFromCompositingSurfaceHasResultForVideo(
1806 base::WeakPtr<RenderWidgetHostViewAura> rwhva, 1817 base::WeakPtr<RenderWidgetHostViewAura> rwhva,
1807 scoped_refptr<media::VideoFrame> video_frame, 1818 scoped_refptr<media::VideoFrame> video_frame,
1808 const base::Callback<void(bool)>& callback, 1819 const base::Callback<void(bool)>& callback,
1809 scoped_ptr<cc::CopyOutputResult> result) { 1820 scoped_ptr<cc::CopyOutputResult> result) {
1810 base::ScopedClosureRunner scoped_callback_runner(base::Bind(callback, false)); 1821 base::ScopedClosureRunner scoped_callback_runner(base::Bind(callback, false));
1811 1822
1812 if (!rwhva) 1823 if (!rwhva)
1813 return; 1824 return;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1877 result_rect.size(), 1888 result_rect.size(),
1878 result_rect, 1889 result_rect,
1879 video_frame->coded_size(), 1890 video_frame->coded_size(),
1880 region_in_frame, 1891 region_in_frame,
1881 true, 1892 true,
1882 false)); 1893 false));
1883 yuv_readback_pipeline = rwhva->yuv_readback_pipeline_.get(); 1894 yuv_readback_pipeline = rwhva->yuv_readback_pipeline_.get();
1884 } 1895 }
1885 1896
1886 scoped_callback_runner.Release(); 1897 scoped_callback_runner.Release();
1898 base::Callback<void(bool result)> finished_callback = base::Bind(
1899 &CopyFromCompositingSurfaceFinishedForVideo,
1900 callback,
1901 texture_mailbox->callback());
1887 yuv_readback_pipeline->ReadbackYUV( 1902 yuv_readback_pipeline->ReadbackYUV(
1888 texture_mailbox->name(), 1903 texture_mailbox->name(),
1889 texture_mailbox->sync_point(), 1904 texture_mailbox->sync_point(),
1890 video_frame.get(), 1905 video_frame.get(),
1891 callback); 1906 finished_callback);
1892 } 1907 }
1893 1908
1894 void RenderWidgetHostViewAura::GetScreenInfo(WebScreenInfo* results) { 1909 void RenderWidgetHostViewAura::GetScreenInfo(WebScreenInfo* results) {
1895 GetScreenInfoForWindow(results, window_->GetRootWindow() ? window_ : NULL); 1910 GetScreenInfoForWindow(results, window_->GetRootWindow() ? window_ : NULL);
1896 } 1911 }
1897 1912
1898 gfx::Rect RenderWidgetHostViewAura::GetBoundsInRootWindow() { 1913 gfx::Rect RenderWidgetHostViewAura::GetBoundsInRootWindow() {
1899 return window_->GetToplevelWindow()->GetBoundsInScreen(); 1914 return window_->GetToplevelWindow()->GetBoundsInScreen();
1900 } 1915 }
1901 1916
(...skipping 1222 matching lines...) Expand 10 before | Expand all | Expand 10 after
3124 RenderWidgetHost* widget) { 3139 RenderWidgetHost* widget) {
3125 return new RenderWidgetHostViewAura(widget); 3140 return new RenderWidgetHostViewAura(widget);
3126 } 3141 }
3127 3142
3128 // static 3143 // static
3129 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { 3144 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) {
3130 GetScreenInfoForWindow(results, NULL); 3145 GetScreenInfoForWindow(results, NULL);
3131 } 3146 }
3132 3147
3133 } // namespace content 3148 } // namespace content
OLDNEW
« no previous file with comments | « cc/output/copy_output_result.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698