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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/RecordingImageBufferSurface.cpp

Issue 2640983002: Rename paint data structures (Closed)
Patch Set: DrawingDisplayItem Created 3 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "platform/graphics/RecordingImageBufferSurface.h" 5 #include "platform/graphics/RecordingImageBufferSurface.h"
6 6
7 #include "platform/Histogram.h" 7 #include "platform/Histogram.h"
8 #include "platform/graphics/CanvasMetrics.h" 8 #include "platform/graphics/CanvasMetrics.h"
9 #include "platform/graphics/ExpensiveCanvasHeuristicParameters.h" 9 #include "platform/graphics/ExpensiveCanvasHeuristicParameters.h"
10 #include "platform/graphics/GraphicsContext.h" 10 #include "platform/graphics/GraphicsContext.h"
11 #include "platform/graphics/ImageBuffer.h" 11 #include "platform/graphics/ImageBuffer.h"
12 #include "third_party/skia/include/core/SkCanvas.h" 12 #include "platform/graphics/paint/PaintRecorder.h"
13 #include "third_party/skia/include/core/SkPictureRecorder.h"
14 #include "wtf/PassRefPtr.h" 13 #include "wtf/PassRefPtr.h"
15 #include "wtf/PtrUtil.h" 14 #include "wtf/PtrUtil.h"
16 #include <memory> 15 #include <memory>
17 16
18 namespace blink { 17 namespace blink {
19 18
20 RecordingImageBufferSurface::RecordingImageBufferSurface( 19 RecordingImageBufferSurface::RecordingImageBufferSurface(
21 const IntSize& size, 20 const IntSize& size,
22 std::unique_ptr<RecordingImageBufferFallbackSurfaceFactory> fallbackFactory, 21 std::unique_ptr<RecordingImageBufferFallbackSurfaceFactory> fallbackFactory,
23 OpacityMode opacityMode, 22 OpacityMode opacityMode,
24 sk_sp<SkColorSpace> colorSpace, 23 sk_sp<SkColorSpace> colorSpace,
25 SkColorType colorType) 24 SkColorType colorType)
26 : ImageBufferSurface(size, opacityMode, std::move(colorSpace), colorType), 25 : ImageBufferSurface(size, opacityMode, std::move(colorSpace), colorType),
27 m_imageBuffer(0), 26 m_imageBuffer(0),
28 m_currentFramePixelCount(0), 27 m_currentFramePixelCount(0),
29 m_previousFramePixelCount(0), 28 m_previousFramePixelCount(0),
30 m_frameWasCleared(true), 29 m_frameWasCleared(true),
31 m_didRecordDrawCommandsInCurrentFrame(false), 30 m_didRecordDrawCommandsInCurrentFrame(false),
32 m_currentFrameHasExpensiveOp(false), 31 m_currentFrameHasExpensiveOp(false),
33 m_previousFrameHasExpensiveOp(false), 32 m_previousFrameHasExpensiveOp(false),
34 m_fallbackFactory(std::move(fallbackFactory)) { 33 m_fallbackFactory(std::move(fallbackFactory)) {
35 initializeCurrentFrame(); 34 initializeCurrentFrame();
36 } 35 }
37 36
38 RecordingImageBufferSurface::~RecordingImageBufferSurface() {} 37 RecordingImageBufferSurface::~RecordingImageBufferSurface() {}
39 38
40 void RecordingImageBufferSurface::initializeCurrentFrame() { 39 void RecordingImageBufferSurface::initializeCurrentFrame() {
41 static SkRTreeFactory rTreeFactory; 40 static SkRTreeFactory rTreeFactory;
42 m_currentFrame = WTF::wrapUnique(new SkPictureRecorder); 41 m_currentFrame = WTF::wrapUnique(new PaintRecorder);
43 SkCanvas* canvas = m_currentFrame->beginRecording( 42 PaintCanvas* canvas = m_currentFrame->beginRecording(
44 size().width(), size().height(), &rTreeFactory); 43 size().width(), size().height(), &rTreeFactory);
45 // Always save an initial frame, to support resetting the top level matrix 44 // Always save an initial frame, to support resetting the top level matrix
46 // and clip. 45 // and clip.
47 canvas->save(); 46 canvas->save();
48 47
49 if (m_imageBuffer) { 48 if (m_imageBuffer) {
50 m_imageBuffer->resetCanvas(canvas); 49 m_imageBuffer->resetCanvas(canvas);
51 } 50 }
52 m_didRecordDrawCommandsInCurrentFrame = false; 51 m_didRecordDrawCommandsInCurrentFrame = false;
53 m_currentFrameHasExpensiveOp = false; 52 m_currentFrameHasExpensiveOp = false;
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 } 172 }
174 173
175 sk_sp<SkImage> RecordingImageBufferSurface::newImageSnapshot( 174 sk_sp<SkImage> RecordingImageBufferSurface::newImageSnapshot(
176 AccelerationHint hint, 175 AccelerationHint hint,
177 SnapshotReason reason) { 176 SnapshotReason reason) {
178 if (!m_fallbackSurface) 177 if (!m_fallbackSurface)
179 fallBackToRasterCanvas(snapshotReasonToFallbackReason(reason)); 178 fallBackToRasterCanvas(snapshotReasonToFallbackReason(reason));
180 return m_fallbackSurface->newImageSnapshot(hint, reason); 179 return m_fallbackSurface->newImageSnapshot(hint, reason);
181 } 180 }
182 181
183 SkCanvas* RecordingImageBufferSurface::canvas() { 182 PaintCanvas* RecordingImageBufferSurface::canvas() {
184 if (m_fallbackSurface) 183 if (m_fallbackSurface)
185 return m_fallbackSurface->canvas(); 184 return m_fallbackSurface->canvas();
186 185
187 ASSERT(m_currentFrame->getRecordingCanvas()); 186 ASSERT(m_currentFrame->getRecordingCanvas());
188 return m_currentFrame->getRecordingCanvas(); 187 return m_currentFrame->getRecordingCanvas();
189 } 188 }
190 189
191 static RecordingImageBufferSurface::FallbackReason 190 static RecordingImageBufferSurface::FallbackReason
192 disableDeferralReasonToFallbackReason(DisableDeferralReason reason) { 191 disableDeferralReasonToFallbackReason(DisableDeferralReason reason) {
193 switch (reason) { 192 switch (reason) {
(...skipping 22 matching lines...) Expand all
216 ASSERT_NOT_REACHED(); 215 ASSERT_NOT_REACHED();
217 return RecordingImageBufferSurface::FallbackReasonUnknown; 216 return RecordingImageBufferSurface::FallbackReasonUnknown;
218 } 217 }
219 218
220 void RecordingImageBufferSurface::disableDeferral( 219 void RecordingImageBufferSurface::disableDeferral(
221 DisableDeferralReason reason) { 220 DisableDeferralReason reason) {
222 if (!m_fallbackSurface) 221 if (!m_fallbackSurface)
223 fallBackToRasterCanvas(disableDeferralReasonToFallbackReason(reason)); 222 fallBackToRasterCanvas(disableDeferralReasonToFallbackReason(reason));
224 } 223 }
225 224
226 sk_sp<SkPicture> RecordingImageBufferSurface::getPicture() { 225 sk_sp<PaintRecord> RecordingImageBufferSurface::getPicture() {
227 if (m_fallbackSurface) 226 if (m_fallbackSurface)
228 return nullptr; 227 return nullptr;
229 228
230 FallbackReason fallbackReason = FallbackReasonUnknown; 229 FallbackReason fallbackReason = FallbackReasonUnknown;
231 bool canUsePicture = finalizeFrameInternal(&fallbackReason); 230 bool canUsePicture = finalizeFrameInternal(&fallbackReason);
232 m_imageBuffer->didFinalizeFrame(); 231 m_imageBuffer->didFinalizeFrame();
233 232
234 ASSERT(canUsePicture || m_fallbackFactory); 233 ASSERT(canUsePicture || m_fallbackFactory);
235 234
236 if (canUsePicture) { 235 if (canUsePicture) {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 334
336 void RecordingImageBufferSurface::draw(GraphicsContext& context, 335 void RecordingImageBufferSurface::draw(GraphicsContext& context,
337 const FloatRect& destRect, 336 const FloatRect& destRect,
338 const FloatRect& srcRect, 337 const FloatRect& srcRect,
339 SkBlendMode op) { 338 SkBlendMode op) {
340 if (m_fallbackSurface) { 339 if (m_fallbackSurface) {
341 m_fallbackSurface->draw(context, destRect, srcRect, op); 340 m_fallbackSurface->draw(context, destRect, srcRect, op);
342 return; 341 return;
343 } 342 }
344 343
345 sk_sp<SkPicture> picture = getPicture(); 344 sk_sp<PaintRecord> picture = getPicture();
346 if (picture) { 345 if (picture) {
347 context.compositePicture(std::move(picture), destRect, srcRect, op); 346 context.compositePicture(std::move(picture), destRect, srcRect, op);
348 } else { 347 } else {
349 ImageBufferSurface::draw(context, destRect, srcRect, op); 348 ImageBufferSurface::draw(context, destRect, srcRect, op);
350 } 349 }
351 } 350 }
352 351
353 bool RecordingImageBufferSurface::isExpensiveToPaint() { 352 bool RecordingImageBufferSurface::isExpensiveToPaint() {
354 if (m_fallbackSurface) 353 if (m_fallbackSurface)
355 return m_fallbackSurface->isExpensiveToPaint(); 354 return m_fallbackSurface->isExpensiveToPaint();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 } 400 }
402 401
403 void RecordingImageBufferSurface::setIsHidden(bool hidden) { 402 void RecordingImageBufferSurface::setIsHidden(bool hidden) {
404 if (m_fallbackSurface) 403 if (m_fallbackSurface)
405 m_fallbackSurface->setIsHidden(hidden); 404 m_fallbackSurface->setIsHidden(hidden);
406 else 405 else
407 ImageBufferSurface::setIsHidden(hidden); 406 ImageBufferSurface::setIsHidden(hidden);
408 } 407 }
409 408
410 } // namespace blink 409 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698