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

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

Issue 154083008: Remove Tabpose feature on mac, and supporting infrastructure (PaintAtSize) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase, merge Created 6 years, 10 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') | content/renderer/render_widget_browsertest.cc » ('j') | 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/debug/trace_event_synthetic_delay.h" 10 #include "base/debug/trace_event_synthetic_delay.h"
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 IPC_MESSAGE_HANDLER(ViewMsg_WasSwappedOut, OnWasSwappedOut) 599 IPC_MESSAGE_HANDLER(ViewMsg_WasSwappedOut, OnWasSwappedOut)
600 IPC_MESSAGE_HANDLER(ViewMsg_UpdateRect_ACK, OnUpdateRectAck) 600 IPC_MESSAGE_HANDLER(ViewMsg_UpdateRect_ACK, OnUpdateRectAck)
601 IPC_MESSAGE_HANDLER(ViewMsg_SwapBuffers_ACK, OnSwapBuffersComplete) 601 IPC_MESSAGE_HANDLER(ViewMsg_SwapBuffers_ACK, OnSwapBuffersComplete)
602 IPC_MESSAGE_HANDLER(ViewMsg_SetInputMethodActive, OnSetInputMethodActive) 602 IPC_MESSAGE_HANDLER(ViewMsg_SetInputMethodActive, OnSetInputMethodActive)
603 IPC_MESSAGE_HANDLER(ViewMsg_CandidateWindowShown, OnCandidateWindowShown) 603 IPC_MESSAGE_HANDLER(ViewMsg_CandidateWindowShown, OnCandidateWindowShown)
604 IPC_MESSAGE_HANDLER(ViewMsg_CandidateWindowUpdated, 604 IPC_MESSAGE_HANDLER(ViewMsg_CandidateWindowUpdated,
605 OnCandidateWindowUpdated) 605 OnCandidateWindowUpdated)
606 IPC_MESSAGE_HANDLER(ViewMsg_CandidateWindowHidden, OnCandidateWindowHidden) 606 IPC_MESSAGE_HANDLER(ViewMsg_CandidateWindowHidden, OnCandidateWindowHidden)
607 IPC_MESSAGE_HANDLER(ViewMsg_ImeSetComposition, OnImeSetComposition) 607 IPC_MESSAGE_HANDLER(ViewMsg_ImeSetComposition, OnImeSetComposition)
608 IPC_MESSAGE_HANDLER(ViewMsg_ImeConfirmComposition, OnImeConfirmComposition) 608 IPC_MESSAGE_HANDLER(ViewMsg_ImeConfirmComposition, OnImeConfirmComposition)
609 IPC_MESSAGE_HANDLER(ViewMsg_PaintAtSize, OnPaintAtSize)
610 IPC_MESSAGE_HANDLER(ViewMsg_Repaint, OnRepaint) 609 IPC_MESSAGE_HANDLER(ViewMsg_Repaint, OnRepaint)
611 IPC_MESSAGE_HANDLER(ViewMsg_SetTextDirection, OnSetTextDirection) 610 IPC_MESSAGE_HANDLER(ViewMsg_SetTextDirection, OnSetTextDirection)
612 IPC_MESSAGE_HANDLER(ViewMsg_Move_ACK, OnRequestMoveAck) 611 IPC_MESSAGE_HANDLER(ViewMsg_Move_ACK, OnRequestMoveAck)
613 IPC_MESSAGE_HANDLER(ViewMsg_UpdateScreenRects, OnUpdateScreenRects) 612 IPC_MESSAGE_HANDLER(ViewMsg_UpdateScreenRects, OnUpdateScreenRects)
614 #if defined(OS_ANDROID) 613 #if defined(OS_ANDROID)
615 IPC_MESSAGE_HANDLER(ViewMsg_ShowImeIfNeeded, OnShowImeIfNeeded) 614 IPC_MESSAGE_HANDLER(ViewMsg_ShowImeIfNeeded, OnShowImeIfNeeded)
616 IPC_MESSAGE_HANDLER(ViewMsg_ImeEventAck, OnImeEventAck) 615 IPC_MESSAGE_HANDLER(ViewMsg_ImeEventAck, OnImeEventAck)
617 #endif 616 #endif
618 IPC_MESSAGE_HANDLER(ViewMsg_Snapshot, OnSnapshot) 617 IPC_MESSAGE_HANDLER(ViewMsg_Snapshot, OnSnapshot)
619 IPC_MESSAGE_UNHANDLED(handled = false) 618 IPC_MESSAGE_UNHANDLED(handled = false)
(...skipping 1543 matching lines...) Expand 10 before | Expand all | Expand 10 after
2163 else if (keep_selection) 2162 else if (keep_selection)
2164 webwidget_->confirmComposition(WebWidget::KeepSelection); 2163 webwidget_->confirmComposition(WebWidget::KeepSelection);
2165 else 2164 else
2166 webwidget_->confirmComposition(WebWidget::DoNotKeepSelection); 2165 webwidget_->confirmComposition(WebWidget::DoNotKeepSelection);
2167 handling_input_event_ = false; 2166 handling_input_event_ = false;
2168 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA) 2167 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA)
2169 UpdateCompositionInfo(true); 2168 UpdateCompositionInfo(true);
2170 #endif 2169 #endif
2171 } 2170 }
2172 2171
2173 // This message causes the renderer to render an image of the
2174 // desired_size, regardless of whether the tab is hidden or not.
2175 void RenderWidget::OnPaintAtSize(const TransportDIB::Handle& dib_handle,
2176 int tag,
2177 const gfx::Size& page_size,
2178 const gfx::Size& desired_size) {
2179 if (!webwidget_ || !TransportDIB::is_valid_handle(dib_handle)) {
2180 if (TransportDIB::is_valid_handle(dib_handle)) {
2181 // Close our unused handle.
2182 #if defined(OS_WIN)
2183 ::CloseHandle(dib_handle);
2184 #elif defined(OS_MACOSX)
2185 base::SharedMemory::CloseHandle(dib_handle);
2186 #endif
2187 }
2188 return;
2189 }
2190
2191 if (page_size.IsEmpty() || desired_size.IsEmpty()) {
2192 // If one of these is empty, then we just return the dib we were
2193 // given, to avoid leaking it.
2194 Send(new ViewHostMsg_PaintAtSize_ACK(routing_id_, tag, desired_size));
2195 return;
2196 }
2197
2198 // Map the given DIB ID into this process, and unmap it at the end
2199 // of this function.
2200 scoped_ptr<TransportDIB> paint_at_size_buffer(
2201 TransportDIB::CreateWithHandle(dib_handle));
2202
2203 gfx::Size page_size_in_pixel = gfx::ToFlooredSize(
2204 gfx::ScaleSize(page_size, device_scale_factor_));
2205 gfx::Size desired_size_in_pixel = gfx::ToFlooredSize(
2206 gfx::ScaleSize(desired_size, device_scale_factor_));
2207 gfx::Size canvas_size = page_size_in_pixel;
2208 float x_scale = static_cast<float>(desired_size_in_pixel.width()) /
2209 static_cast<float>(canvas_size.width());
2210 float y_scale = static_cast<float>(desired_size_in_pixel.height()) /
2211 static_cast<float>(canvas_size.height());
2212
2213 gfx::Rect orig_bounds(canvas_size);
2214 canvas_size.set_width(static_cast<int>(canvas_size.width() * x_scale));
2215 canvas_size.set_height(static_cast<int>(canvas_size.height() * y_scale));
2216 gfx::Rect bounds(canvas_size);
2217
2218 scoped_ptr<skia::PlatformCanvas> canvas(
2219 paint_at_size_buffer->GetPlatformCanvas(canvas_size.width(),
2220 canvas_size.height()));
2221 if (!canvas) {
2222 NOTREACHED();
2223 return;
2224 }
2225
2226 // Reset bounds to what we actually received, but they should be the
2227 // same.
2228 DCHECK_EQ(bounds.width(), canvas->getDevice()->width());
2229 DCHECK_EQ(bounds.height(), canvas->getDevice()->height());
2230 bounds.set_width(canvas->getDevice()->width());
2231 bounds.set_height(canvas->getDevice()->height());
2232
2233 canvas->save();
2234 // Add the scale factor to the canvas, so that we'll get the desired size.
2235 canvas->scale(SkFloatToScalar(x_scale), SkFloatToScalar(y_scale));
2236
2237 // Have to make sure we're laid out at the right size before
2238 // rendering.
2239 gfx::Size old_size = webwidget_->size();
2240 webwidget_->resize(page_size);
2241 webwidget_->layout();
2242
2243 // Paint the entire thing (using original bounds, not scaled bounds).
2244 PaintRect(orig_bounds, orig_bounds.origin(), canvas.get());
2245 canvas->restore();
2246
2247 // Return the widget to its previous size.
2248 webwidget_->resize(old_size);
2249
2250 Send(new ViewHostMsg_PaintAtSize_ACK(routing_id_, tag, bounds.size()));
2251 }
2252
2253 void RenderWidget::OnSnapshot(const gfx::Rect& src_subrect) { 2172 void RenderWidget::OnSnapshot(const gfx::Rect& src_subrect) {
2254 SkBitmap snapshot; 2173 SkBitmap snapshot;
2255 2174
2256 if (OnSnapshotHelper(src_subrect, &snapshot)) { 2175 if (OnSnapshotHelper(src_subrect, &snapshot)) {
2257 Send(new ViewHostMsg_Snapshot(routing_id(), true, snapshot)); 2176 Send(new ViewHostMsg_Snapshot(routing_id(), true, snapshot));
2258 } else { 2177 } else {
2259 Send(new ViewHostMsg_Snapshot(routing_id(), false, SkBitmap())); 2178 Send(new ViewHostMsg_Snapshot(routing_id(), false, SkBitmap()));
2260 } 2179 }
2261 } 2180 }
2262 2181
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
2868 2787
2869 void RenderWidget::RegisterSwappedOutChildFrame(RenderFrameImpl* frame) { 2788 void RenderWidget::RegisterSwappedOutChildFrame(RenderFrameImpl* frame) {
2870 swapped_out_frames_.AddObserver(frame); 2789 swapped_out_frames_.AddObserver(frame);
2871 } 2790 }
2872 2791
2873 void RenderWidget::UnregisterSwappedOutChildFrame(RenderFrameImpl* frame) { 2792 void RenderWidget::UnregisterSwappedOutChildFrame(RenderFrameImpl* frame) {
2874 swapped_out_frames_.RemoveObserver(frame); 2793 swapped_out_frames_.RemoveObserver(frame);
2875 } 2794 }
2876 2795
2877 } // namespace content 2796 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_widget.h ('k') | content/renderer/render_widget_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698