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

Side by Side Diff: content/renderer/render_widget.cc

Issue 12746009: Revert 189969 "Add RenderWidgetHost::GetSnapshotFromRenderer met..." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1450/src/
Patch Set: Created 7 years, 9 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 | « content/renderer/render_widget.h ('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/renderer/render_widget.h" 5 #include "content/renderer/render_widget.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 IPC_MESSAGE_HANDLER(ViewMsg_Repaint, OnRepaint) 314 IPC_MESSAGE_HANDLER(ViewMsg_Repaint, OnRepaint)
315 IPC_MESSAGE_HANDLER(ViewMsg_SmoothScrollCompleted, OnSmoothScrollCompleted) 315 IPC_MESSAGE_HANDLER(ViewMsg_SmoothScrollCompleted, OnSmoothScrollCompleted)
316 IPC_MESSAGE_HANDLER(ViewMsg_SetTextDirection, OnSetTextDirection) 316 IPC_MESSAGE_HANDLER(ViewMsg_SetTextDirection, OnSetTextDirection)
317 IPC_MESSAGE_HANDLER(ViewMsg_Move_ACK, OnRequestMoveAck) 317 IPC_MESSAGE_HANDLER(ViewMsg_Move_ACK, OnRequestMoveAck)
318 IPC_MESSAGE_HANDLER(ViewMsg_ScreenInfoChanged, OnScreenInfoChanged) 318 IPC_MESSAGE_HANDLER(ViewMsg_ScreenInfoChanged, OnScreenInfoChanged)
319 IPC_MESSAGE_HANDLER(ViewMsg_UpdateScreenRects, OnUpdateScreenRects) 319 IPC_MESSAGE_HANDLER(ViewMsg_UpdateScreenRects, OnUpdateScreenRects)
320 #if defined(OS_ANDROID) 320 #if defined(OS_ANDROID)
321 IPC_MESSAGE_HANDLER(ViewMsg_ImeBatchStateChanged, OnImeBatchStateChanged) 321 IPC_MESSAGE_HANDLER(ViewMsg_ImeBatchStateChanged, OnImeBatchStateChanged)
322 IPC_MESSAGE_HANDLER(ViewMsg_ShowImeIfNeeded, OnShowImeIfNeeded) 322 IPC_MESSAGE_HANDLER(ViewMsg_ShowImeIfNeeded, OnShowImeIfNeeded)
323 #endif 323 #endif
324 IPC_MESSAGE_HANDLER(ViewMsg_Snapshot, OnSnapshot)
325 IPC_MESSAGE_UNHANDLED(handled = false) 324 IPC_MESSAGE_UNHANDLED(handled = false)
326 IPC_END_MESSAGE_MAP() 325 IPC_END_MESSAGE_MAP()
327 return handled; 326 return handled;
328 } 327 }
329 328
330 bool RenderWidget::Send(IPC::Message* message) { 329 bool RenderWidget::Send(IPC::Message* message) {
331 // Don't send any messages after the browser has told us to close, and filter 330 // Don't send any messages after the browser has told us to close, and filter
332 // most outgoing messages while swapped out. 331 // most outgoing messages while swapped out.
333 if ((is_swapped_out_ && 332 if ((is_swapped_out_ &&
334 !SwappedOutMessages::CanSendWhileSwappedOut(message)) || 333 !SwappedOutMessages::CanSendWhileSwappedOut(message)) ||
(...skipping 1479 matching lines...) Expand 10 before | Expand all | Expand 10 after
1814 // Paint the entire thing (using original bounds, not scaled bounds). 1813 // Paint the entire thing (using original bounds, not scaled bounds).
1815 PaintRect(orig_bounds, orig_bounds.origin(), canvas.get()); 1814 PaintRect(orig_bounds, orig_bounds.origin(), canvas.get());
1816 canvas->restore(); 1815 canvas->restore();
1817 1816
1818 // Return the widget to its previous size. 1817 // Return the widget to its previous size.
1819 webwidget_->resize(old_size); 1818 webwidget_->resize(old_size);
1820 1819
1821 Send(new ViewHostMsg_PaintAtSize_ACK(routing_id_, tag, bounds.size())); 1820 Send(new ViewHostMsg_PaintAtSize_ACK(routing_id_, tag, bounds.size()));
1822 } 1821 }
1823 1822
1824 void RenderWidget::OnSnapshot(const gfx::Rect& src_subrect) {
1825 SkBitmap snapshot;
1826
1827 if (OnSnapshotHelper(src_subrect, &snapshot)) {
1828 Send(new ViewHostMsg_Snapshot(routing_id(), true, snapshot));
1829 } else {
1830 Send(new ViewHostMsg_Snapshot(routing_id(), false, SkBitmap()));
1831 }
1832 }
1833
1834 bool RenderWidget::OnSnapshotHelper(const gfx::Rect& src_subrect,
1835 SkBitmap* snapshot) {
1836 base::TimeTicks beginning_time = base::TimeTicks::Now();
1837
1838 if (!webwidget_ || src_subrect.IsEmpty())
1839 return false;
1840
1841 gfx::Rect viewport_size = gfx::IntersectRects(
1842 src_subrect, gfx::Rect(physical_backing_size_));
1843
1844 skia::RefPtr<SkCanvas> canvas = skia::AdoptRef(
1845 skia::CreatePlatformCanvas(viewport_size.width(),
1846 viewport_size.height(),
1847 true,
1848 NULL,
1849 skia::RETURN_NULL_ON_FAILURE));
1850 if (!canvas.get())
1851 return false;
1852
1853 canvas->save();
1854 webwidget_->layout();
1855
1856 PaintRect(viewport_size, viewport_size.origin(), canvas.get());
1857 canvas->restore();
1858
1859 const SkBitmap& bitmap = skia::GetTopDevice(*canvas)->accessBitmap(false);
1860 if (!bitmap.copyTo(snapshot, SkBitmap::kARGB_8888_Config))
1861 return false;
1862
1863 UMA_HISTOGRAM_TIMES("Renderer4.Snapshot",
1864 base::TimeTicks::Now() - beginning_time);
1865 return true;
1866 }
1867
1868 void RenderWidget::OnRepaint(const gfx::Size& size_to_paint) { 1823 void RenderWidget::OnRepaint(const gfx::Size& size_to_paint) {
1869 // During shutdown we can just ignore this message. 1824 // During shutdown we can just ignore this message.
1870 if (!webwidget_) 1825 if (!webwidget_)
1871 return; 1826 return;
1872 1827
1873 set_next_paint_is_repaint_ack(); 1828 set_next_paint_is_repaint_ack();
1874 if (is_accelerated_compositing_active_) { 1829 if (is_accelerated_compositing_active_) {
1875 if (compositor_) 1830 if (compositor_)
1876 compositor_->setNeedsRedraw(); 1831 compositor_->setNeedsRedraw();
1877 scheduleComposite(); 1832 scheduleComposite();
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
2301 2256
2302 if (!context->Initialize( 2257 if (!context->Initialize(
2303 attributes, 2258 attributes,
2304 false /* bind generates resources */, 2259 false /* bind generates resources */,
2305 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE) ) 2260 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE) )
2306 return NULL; 2261 return NULL;
2307 return context.release(); 2262 return context.release();
2308 } 2263 }
2309 2264
2310 } // namespace content 2265 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_widget.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698