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

Side by Side Diff: third_party/WebKit/Source/core/frame/LocalFrame.cpp

Issue 2791043002: Draw recorded content directly into the containing PaintCanvas, when possible. (Closed)
Patch Set: none Created 3 years, 8 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 /* 1 /*
2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> 2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
3 * 1999 Lars Knoll <knoll@kde.org> 3 * 1999 Lars Knoll <knoll@kde.org>
4 * 1999 Antti Koivisto <koivisto@kde.org> 4 * 1999 Antti Koivisto <koivisto@kde.org>
5 * 2000 Simon Hausmann <hausmann@kde.org> 5 * 2000 Simon Hausmann <hausmann@kde.org>
6 * 2000 Stefan Schimanski <1Stein@gmx.de> 6 * 2000 Stefan Schimanski <1Stein@gmx.de>
7 * 2001 George Staikos <staikos@kde.org> 7 * 2001 George Staikos <staikos@kde.org>
8 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All 8 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
9 * rights reserved. 9 * rights reserved.
10 * Copyright (C) 2005 Alexey Proskuryakov <ap@nypop.com> 10 * Copyright (C) 2005 Alexey Proskuryakov <ap@nypop.com>
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 return deviceBounds; 121 return deviceBounds;
122 } 122 }
123 123
124 // Returns a DragImage whose bitmap contains |contents|, positioned and scaled 124 // Returns a DragImage whose bitmap contains |contents|, positioned and scaled
125 // in device space. 125 // in device space.
126 static std::unique_ptr<DragImage> createDragImage( 126 static std::unique_ptr<DragImage> createDragImage(
127 const LocalFrame& frame, 127 const LocalFrame& frame,
128 float opacity, 128 float opacity,
129 RespectImageOrientationEnum imageOrientation, 129 RespectImageOrientationEnum imageOrientation,
130 const FloatRect& cssBounds, 130 const FloatRect& cssBounds,
131 sk_sp<PaintRecord> contents) { 131 PaintRecordBuilder& builder) {
132 float deviceScaleFactor = frame.page()->deviceScaleFactorDeprecated(); 132 float deviceScaleFactor = frame.page()->deviceScaleFactorDeprecated();
133 float pageScaleFactor = frame.page()->visualViewport().scale(); 133 float pageScaleFactor = frame.page()->visualViewport().scale();
134 134
135 FloatRect deviceBounds = deviceSpaceBounds(cssBounds, frame); 135 FloatRect deviceBounds = deviceSpaceBounds(cssBounds, frame);
136 136
137 AffineTransform transform; 137 AffineTransform transform;
138 transform.scale(deviceScaleFactor * pageScaleFactor); 138 transform.scale(deviceScaleFactor * pageScaleFactor);
139 transform.translate(-deviceBounds.x(), -deviceBounds.y()); 139 transform.translate(-deviceBounds.x(), -deviceBounds.y());
140 140
141 PaintRecorder recorder; 141 PaintRecorder recorder;
142 PaintCanvas* canvas = recorder.beginRecording(deviceBounds); 142 PaintCanvas* canvas = recorder.beginRecording(deviceBounds);
143 canvas->concat(affineTransformToSkMatrix(transform)); 143 canvas->concat(affineTransformToSkMatrix(transform));
144 canvas->drawPicture(contents); 144 builder.endRecording(*canvas);
145 145
146 // Rasterize upfront, since DragImage::create() is going to do it anyway 146 // Rasterize upfront, since DragImage::create() is going to do it anyway
147 // (SkImage::asLegacyBitmap). 147 // (SkImage::asLegacyBitmap).
148 SkSurfaceProps surfaceProps(0, kUnknown_SkPixelGeometry); 148 SkSurfaceProps surfaceProps(0, kUnknown_SkPixelGeometry);
149 sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul( 149 sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul(
150 deviceBounds.width(), deviceBounds.height(), &surfaceProps); 150 deviceBounds.width(), deviceBounds.height(), &surfaceProps);
151 if (!surface) 151 if (!surface)
152 return nullptr; 152 return nullptr;
153 recorder.finishRecordingAsPicture()->playback(surface->getCanvas()); 153 recorder.finishRecordingAsPicture()->playback(surface->getCanvas());
154 RefPtr<Image> image = StaticBitmapImage::create(surface->makeImageSnapshot()); 154 RefPtr<Image> image = StaticBitmapImage::create(surface->makeImageSnapshot());
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 GlobalPaintFlattenCompositingLayers, 209 GlobalPaintFlattenCompositingLayers,
210 LayoutSize()); 210 LayoutSize());
211 PaintLayerFlags flags = PaintLayerHaveTransparency | 211 PaintLayerFlags flags = PaintLayerHaveTransparency |
212 PaintLayerAppliedTransform | 212 PaintLayerAppliedTransform |
213 PaintLayerUncachedClipRects; 213 PaintLayerUncachedClipRects;
214 PaintRecordBuilder builder(deviceSpaceBounds(boundingBox, *m_localFrame)); 214 PaintRecordBuilder builder(deviceSpaceBounds(boundingBox, *m_localFrame));
215 PaintLayerPainter(*layer).paint(builder.context(), paintingInfo, flags); 215 PaintLayerPainter(*layer).paint(builder.context(), paintingInfo, flags);
216 return createDragImage( 216 return createDragImage(
217 *m_localFrame, 1.0f, 217 *m_localFrame, 1.0f,
218 LayoutObject::shouldRespectImageOrientation(draggedLayoutObject), 218 LayoutObject::shouldRespectImageOrientation(draggedLayoutObject),
219 boundingBox, builder.endRecording()); 219 boundingBox, builder);
220 } 220 }
221 221
222 private: 222 private:
223 const Member<const LocalFrame> m_localFrame; 223 const Member<const LocalFrame> m_localFrame;
224 const Member<Node> m_node; 224 const Member<Node> m_node;
225 #if DCHECK_IS_ON() 225 #if DCHECK_IS_ON()
226 const uint64_t m_domTreeVersion; 226 const uint64_t m_domTreeVersion;
227 #endif 227 #endif
228 }; 228 };
229 229
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 ASSERT(document()->isActive()); 731 ASSERT(document()->isActive());
732 732
733 FloatRect paintingRect = FloatRect(selection().bounds()); 733 FloatRect paintingRect = FloatRect(selection().bounds());
734 GlobalPaintFlags paintFlags = 734 GlobalPaintFlags paintFlags =
735 GlobalPaintSelectionOnly | GlobalPaintFlattenCompositingLayers; 735 GlobalPaintSelectionOnly | GlobalPaintFlattenCompositingLayers;
736 736
737 PaintRecordBuilder builder(deviceSpaceBounds(paintingRect, *this)); 737 PaintRecordBuilder builder(deviceSpaceBounds(paintingRect, *this));
738 m_view->paintContents(builder.context(), paintFlags, 738 m_view->paintContents(builder.context(), paintFlags,
739 enclosingIntRect(paintingRect)); 739 enclosingIntRect(paintingRect));
740 return createDragImage(*this, opacity, DoNotRespectImageOrientation, 740 return createDragImage(*this, opacity, DoNotRespectImageOrientation,
741 paintingRect, builder.endRecording()); 741 paintingRect, builder);
742 } 742 }
743 743
744 String LocalFrame::selectedText() const { 744 String LocalFrame::selectedText() const {
745 return selection().selectedText(); 745 return selection().selectedText();
746 } 746 }
747 747
748 String LocalFrame::selectedTextForClipboard() const { 748 String LocalFrame::selectedTextForClipboard() const {
749 if (!document()) 749 if (!document())
750 return emptyString; 750 return emptyString;
751 DCHECK(!document()->needsLayoutTreeUpdate()); 751 DCHECK(!document()->needsLayoutTreeUpdate());
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 if (m_frame && m_frame->client() && m_frame->client()->frameBlameContext()) 923 if (m_frame && m_frame->client() && m_frame->client()->frameBlameContext())
924 m_frame->client()->frameBlameContext()->Enter(); 924 m_frame->client()->frameBlameContext()->Enter();
925 } 925 }
926 926
927 ScopedFrameBlamer::~ScopedFrameBlamer() { 927 ScopedFrameBlamer::~ScopedFrameBlamer() {
928 if (m_frame && m_frame->client() && m_frame->client()->frameBlameContext()) 928 if (m_frame && m_frame->client() && m_frame->client()->frameBlameContext())
929 m_frame->client()->frameBlameContext()->Leave(); 929 m_frame->client()->frameBlameContext()->Leave();
930 } 930 }
931 931
932 } // namespace blink 932 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698