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

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

Issue 2820133005: Revert of Back PaintRecord with PaintOpBuffer instead of SkPicture (Closed)
Patch Set: 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 // 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/paint/CompositingRecorder.h" 5 #include "platform/graphics/paint/CompositingRecorder.h"
6 6
7 #include "platform/graphics/GraphicsContext.h" 7 #include "platform/graphics/GraphicsContext.h"
8 #include "platform/graphics/GraphicsLayer.h" 8 #include "platform/graphics/GraphicsLayer.h"
9 #include "platform/graphics/paint/CompositingDisplayItem.h" 9 #include "platform/graphics/paint/CompositingDisplayItem.h"
10 #include "platform/graphics/paint/DrawingRecorder.h" 10 #include "platform/graphics/paint/DrawingRecorder.h"
(...skipping 11 matching lines...) Expand all
22 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) 22 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled())
23 return; 23 return;
24 graphics_context.GetPaintController() 24 graphics_context.GetPaintController()
25 .CreateAndAppend<BeginCompositingDisplayItem>(client_, xfer_mode, opacity, 25 .CreateAndAppend<BeginCompositingDisplayItem>(client_, xfer_mode, opacity,
26 bounds, color_filter); 26 bounds, color_filter);
27 } 27 }
28 28
29 CompositingRecorder::~CompositingRecorder() { 29 CompositingRecorder::~CompositingRecorder() {
30 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) 30 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled())
31 return; 31 return;
32 graphics_context_.GetPaintController().EndItem<EndCompositingDisplayItem>( 32 // If the end of the current display list is of the form
33 client_); 33 // [BeginCompositingDisplayItem] [DrawingDisplayItem], then fold the
34 // BeginCompositingDisplayItem into a new DrawingDisplayItem that replaces
35 // them both. This allows Skia to optimize for the case when the
36 // BeginCompositingDisplayItem represents a simple opacity/color that can be
37 // merged into the opacity/color of the drawing. See crbug.com/628831 for more
38 // details.
39 PaintController& paint_controller = graphics_context_.GetPaintController();
40 const DisplayItem* last_display_item = paint_controller.LastDisplayItem(0);
41 const DisplayItem* second_to_last_display_item =
42 paint_controller.LastDisplayItem(1);
43 // TODO(chrishtr): remove the call to LastDisplayItemIsSubsequenceEnd when
44 // https://codereview.chromium.org/2768143002 lands.
45 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled() && last_display_item &&
46 second_to_last_display_item && last_display_item->DrawsContent() &&
47 second_to_last_display_item->GetType() ==
48 DisplayItem::kBeginCompositing &&
49 !paint_controller.LastDisplayItemIsSubsequenceEnd()) {
50 FloatRect cull_rect(
51 ((DrawingDisplayItem*)last_display_item)->GetPaintRecord()->cullRect());
52 const DisplayItemClient& display_item_client = last_display_item->Client();
53 DisplayItem::Type display_item_type = last_display_item->GetType();
54
55 // Re-record the last two DisplayItems into a new drawing. The new item
56 // cannot be cached, because it is a mutation of the DisplayItem the client
57 // thought it was painting.
58 paint_controller.BeginSkippingCache();
59 {
60 #if DCHECK_IS_ON()
61 // In the recorder's scope we remove the last two display items which
62 // are combined into a new drawing.
63 DisableListModificationCheck disabler;
64 #endif
65 DrawingRecorder new_recorder(graphics_context_, display_item_client,
66 display_item_type, cull_rect);
67 DCHECK(!DrawingRecorder::UseCachedDrawingIfPossible(
68 graphics_context_, display_item_client, display_item_type));
69
70 second_to_last_display_item->Replay(graphics_context_);
71 last_display_item->Replay(graphics_context_);
72 EndCompositingDisplayItem(client_).Replay(graphics_context_);
73
74 // Remove the DrawingDisplayItem.
75 paint_controller.RemoveLastDisplayItem();
76 // Remove the BeginCompositingDisplayItem.
77 paint_controller.RemoveLastDisplayItem();
78 }
79 paint_controller.EndSkippingCache();
80 } else {
81 graphics_context_.GetPaintController().EndItem<EndCompositingDisplayItem>(
82 client_);
83 }
34 } 84 }
35 85
36 } // namespace blink 86 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698