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

Side by Side Diff: Source/web/WebPluginContainerImpl.cpp

Issue 1220583004: Refactor DrawingRecorders to check for cached drawings earlier (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 5 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
« no previous file with comments | « Source/web/WebLocalFrameImpl.cpp ('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 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * Copyright (C) 2014 Opera Software ASA. All rights reserved. 3 * Copyright (C) 2014 Opera Software ASA. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 112
113 void WebPluginContainerImpl::paint(GraphicsContext* context, const IntRect& rect ) 113 void WebPluginContainerImpl::paint(GraphicsContext* context, const IntRect& rect )
114 { 114 {
115 if (!parent()) 115 if (!parent())
116 return; 116 return;
117 117
118 // Don't paint anything if the plugin doesn't intersect. 118 // Don't paint anything if the plugin doesn't intersect.
119 if (!frameRect().intersects(rect)) 119 if (!frameRect().intersects(rect))
120 return; 120 return;
121 121
122 LayoutObjectDrawingRecorder drawingRecorder(*context, *m_element->layoutObje ct(), DisplayItem::Type::WebPlugin, rect); 122 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*context, *m_ele ment->layoutObject(), DisplayItem::Type::WebPlugin))
123 if (drawingRecorder.canUseCachedDrawing())
124 return; 123 return;
125 124
125 LayoutObjectDrawingRecorder drawingRecorder(*context, *m_element->layoutObje ct(), DisplayItem::Type::WebPlugin, rect);
126 context->save(); 126 context->save();
127 127
128 ASSERT(parent()->isFrameView()); 128 ASSERT(parent()->isFrameView());
129 FrameView* view = toFrameView(parent()); 129 FrameView* view = toFrameView(parent());
130 130
131 // The plugin is positioned in the root frame's coordinates, so it needs to 131 // The plugin is positioned in the root frame's coordinates, so it needs to
132 // be painted in them too. 132 // be painted in them too.
133 IntPoint origin = view->contentsToRootFrame(IntPoint(0, 0)); 133 IntPoint origin = view->contentsToRootFrame(IntPoint(0, 0));
134 context->translate(static_cast<float>(-origin.x()), static_cast<float>(-orig in.y())); 134 context->translate(static_cast<float>(-origin.x()), static_cast<float>(-orig in.y()));
135 135
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 return m_webPlugin->getPrintPresetOptionsFromDocument(presetOptions); 347 return m_webPlugin->getPrintPresetOptionsFromDocument(presetOptions);
348 } 348 }
349 349
350 int WebPluginContainerImpl::printBegin(const WebPrintParams& printParams) const 350 int WebPluginContainerImpl::printBegin(const WebPrintParams& printParams) const
351 { 351 {
352 return m_webPlugin->printBegin(printParams); 352 return m_webPlugin->printBegin(printParams);
353 } 353 }
354 354
355 void WebPluginContainerImpl::printPage(int pageNumber, GraphicsContext* gc, cons t IntRect& printRect) 355 void WebPluginContainerImpl::printPage(int pageNumber, GraphicsContext* gc, cons t IntRect& printRect)
356 { 356 {
357 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*gc, *m_element- >layoutObject(), DisplayItem::Type::WebPlugin))
358 return;
359
357 LayoutObjectDrawingRecorder drawingRecorder(*gc, *m_element->layoutObject(), DisplayItem::Type::WebPlugin, printRect); 360 LayoutObjectDrawingRecorder drawingRecorder(*gc, *m_element->layoutObject(), DisplayItem::Type::WebPlugin, printRect);
358 if (drawingRecorder.canUseCachedDrawing())
359 return;
360 gc->save(); 361 gc->save();
361 WebCanvas* canvas = gc->canvas(); 362 WebCanvas* canvas = gc->canvas();
362 m_webPlugin->printPage(pageNumber, canvas); 363 m_webPlugin->printPage(pageNumber, canvas);
363 gc->restore(); 364 gc->restore();
364 } 365 }
365 366
366 void WebPluginContainerImpl::printEnd() 367 void WebPluginContainerImpl::printEnd()
367 { 368 {
368 m_webPlugin->printEnd(); 369 m_webPlugin->printEnd();
369 } 370 }
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after
972 for (size_t i = 0; i < cutOutRects.size(); i++) 973 for (size_t i = 0; i < cutOutRects.size(); i++)
973 cutOutRects[i].move(-frameRect().x(), -frameRect().y()); 974 cutOutRects[i].move(-frameRect().x(), -frameRect().y());
974 } 975 }
975 976
976 bool WebPluginContainerImpl::pluginShouldPersist() const 977 bool WebPluginContainerImpl::pluginShouldPersist() const
977 { 978 {
978 return m_webPlugin->shouldPersist(); 979 return m_webPlugin->shouldPersist();
979 } 980 }
980 981
981 } // namespace blink 982 } // namespace blink
OLDNEW
« no previous file with comments | « Source/web/WebLocalFrameImpl.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698