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

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

Issue 12881005: Allow CopyFromBackingStore to fallback to copying from the renderer side if the accelerated surface… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: unused include 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
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)
324 IPC_MESSAGE_UNHANDLED(handled = false) 325 IPC_MESSAGE_UNHANDLED(handled = false)
325 IPC_END_MESSAGE_MAP() 326 IPC_END_MESSAGE_MAP()
326 return handled; 327 return handled;
327 } 328 }
328 329
329 bool RenderWidget::Send(IPC::Message* message) { 330 bool RenderWidget::Send(IPC::Message* message) {
330 // Don't send any messages after the browser has told us to close, and filter 331 // Don't send any messages after the browser has told us to close, and filter
331 // most outgoing messages while swapped out. 332 // most outgoing messages while swapped out.
332 if ((is_swapped_out_ && 333 if ((is_swapped_out_ &&
333 !SwappedOutMessages::CanSendWhileSwappedOut(message)) || 334 !SwappedOutMessages::CanSendWhileSwappedOut(message)) ||
(...skipping 1479 matching lines...) Expand 10 before | Expand all | Expand 10 after
1813 // Paint the entire thing (using original bounds, not scaled bounds). 1814 // Paint the entire thing (using original bounds, not scaled bounds).
1814 PaintRect(orig_bounds, orig_bounds.origin(), canvas.get()); 1815 PaintRect(orig_bounds, orig_bounds.origin(), canvas.get());
1815 canvas->restore(); 1816 canvas->restore();
1816 1817
1817 // Return the widget to its previous size. 1818 // Return the widget to its previous size.
1818 webwidget_->resize(old_size); 1819 webwidget_->resize(old_size);
1819 1820
1820 Send(new ViewHostMsg_PaintAtSize_ACK(routing_id_, tag, bounds.size())); 1821 Send(new ViewHostMsg_PaintAtSize_ACK(routing_id_, tag, bounds.size()));
1821 } 1822 }
1822 1823
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
1823 void RenderWidget::OnRepaint(const gfx::Size& size_to_paint) { 1868 void RenderWidget::OnRepaint(const gfx::Size& size_to_paint) {
1824 // During shutdown we can just ignore this message. 1869 // During shutdown we can just ignore this message.
1825 if (!webwidget_) 1870 if (!webwidget_)
1826 return; 1871 return;
1827 1872
1828 set_next_paint_is_repaint_ack(); 1873 set_next_paint_is_repaint_ack();
1829 if (is_accelerated_compositing_active_) { 1874 if (is_accelerated_compositing_active_) {
1830 if (compositor_) 1875 if (compositor_)
1831 compositor_->setNeedsRedraw(); 1876 compositor_->setNeedsRedraw();
1832 scheduleComposite(); 1877 scheduleComposite();
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
2256 2301
2257 if (!context->Initialize( 2302 if (!context->Initialize(
2258 attributes, 2303 attributes,
2259 false /* bind generates resources */, 2304 false /* bind generates resources */,
2260 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE) ) 2305 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE) )
2261 return NULL; 2306 return NULL;
2262 return context.release(); 2307 return context.release();
2263 } 2308 }
2264 2309
2265 } // namespace content 2310 } // namespace content
OLDNEW
« content/common/view_messages.h ('K') | « content/renderer/render_widget.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698