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

Side by Side Diff: Source/platform/graphics/paint/ClipDisplayItem.cpp

Issue 1192363005: Move all clip display item parameters to the constructor (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 5 years, 6 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/platform/graphics/paint/ClipDisplayItem.h ('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 // 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 "config.h" 5 #include "config.h"
6 #include "platform/graphics/paint/ClipDisplayItem.h" 6 #include "platform/graphics/paint/ClipDisplayItem.h"
7 7
8 #include "platform/geometry/FloatRoundedRect.h" 8 #include "platform/geometry/FloatRoundedRect.h"
9 #include "platform/graphics/GraphicsContext.h" 9 #include "platform/graphics/GraphicsContext.h"
10 #include "public/platform/WebDisplayItemList.h" 10 #include "public/platform/WebDisplayItemList.h"
11 #include "third_party/skia/include/core/SkScalar.h" 11 #include "third_party/skia/include/core/SkScalar.h"
12 12
13 namespace blink { 13 namespace blink {
14 14
15 void ClipDisplayItem::replay(GraphicsContext& context) 15 void ClipDisplayItem::replay(GraphicsContext& context)
16 { 16 {
17 context.save(); 17 context.save();
18 context.clipRect(m_clipRect, NotAntiAliased, SkRegion::kIntersect_Op); 18 context.clipRect(m_clipRect, NotAntiAliased, SkRegion::kIntersect_Op);
19 for (FloatRoundedRect roundedRect : m_roundedRectClips) 19
20 if (!m_roundedRectClips)
21 return;
22
23 for (const FloatRoundedRect& roundedRect : *m_roundedRectClips)
20 context.clipRoundedRect(roundedRect, SkRegion::kIntersect_Op); 24 context.clipRoundedRect(roundedRect, SkRegion::kIntersect_Op);
21 } 25 }
22 26
23 void ClipDisplayItem::appendToWebDisplayItemList(WebDisplayItemList* list) const 27 void ClipDisplayItem::appendToWebDisplayItemList(WebDisplayItemList* list) const
24 { 28 {
25 WebVector<SkRRect> webRoundedRects(m_roundedRectClips.size()); 29 if (!m_roundedRectClips) {
26 for (size_t i = 0; i < m_roundedRectClips.size(); ++i) { 30 WebVector<SkRRect> webRoundedRects;
27 FloatRoundedRect::Radii rectRadii = m_roundedRectClips[i].radii(); 31 list->appendClipItem(m_clipRect, webRoundedRects);
32 return;
33 }
34
35 Vector<FloatRoundedRect>& roundedRects = *m_roundedRectClips;
36 WebVector<SkRRect> webRoundedRects(roundedRects.size());
37 for (size_t i = 0; i < roundedRects.size(); ++i) {
38 FloatRoundedRect::Radii rectRadii = roundedRects[i].radii();
28 SkVector skRadii[4]; 39 SkVector skRadii[4];
29 skRadii[SkRRect::kUpperLeft_Corner].set(SkIntToScalar(rectRadii.topLeft( ).width()), 40 skRadii[SkRRect::kUpperLeft_Corner].set(SkIntToScalar(rectRadii.topLeft( ).width()),
30 SkIntToScalar(rectRadii.topLeft().height())); 41 SkIntToScalar(rectRadii.topLeft().height()));
31 skRadii[SkRRect::kUpperRight_Corner].set(SkIntToScalar(rectRadii.topRigh t().width()), 42 skRadii[SkRRect::kUpperRight_Corner].set(SkIntToScalar(rectRadii.topRigh t().width()),
32 SkIntToScalar(rectRadii.topRight().height())); 43 SkIntToScalar(rectRadii.topRight().height()));
33 skRadii[SkRRect::kLowerRight_Corner].set(SkIntToScalar(rectRadii.bottomR ight().width()), 44 skRadii[SkRRect::kLowerRight_Corner].set(SkIntToScalar(rectRadii.bottomR ight().width()),
34 SkIntToScalar(rectRadii.bottomRight().height())); 45 SkIntToScalar(rectRadii.bottomRight().height()));
35 skRadii[SkRRect::kLowerLeft_Corner].set(SkIntToScalar(rectRadii.bottomLe ft().width()), 46 skRadii[SkRRect::kLowerLeft_Corner].set(SkIntToScalar(rectRadii.bottomLe ft().width()),
36 SkIntToScalar(rectRadii.bottomLeft().height())); 47 SkIntToScalar(rectRadii.bottomLeft().height()));
37 SkRRect skRoundedRect; 48 SkRRect skRoundedRect;
38 skRoundedRect.setRectRadii(m_roundedRectClips[i].rect(), skRadii); 49 skRoundedRect.setRectRadii(roundedRects[i].rect(), skRadii);
39 webRoundedRects[i] = skRoundedRect; 50 webRoundedRects[i] = skRoundedRect;
40 } 51 }
41 list->appendClipItem(m_clipRect, webRoundedRects); 52 list->appendClipItem(m_clipRect, webRoundedRects);
42 } 53 }
43 54
44 void EndClipDisplayItem::replay(GraphicsContext& context) 55 void EndClipDisplayItem::replay(GraphicsContext& context)
45 { 56 {
46 context.restore(); 57 context.restore();
47 } 58 }
48 59
49 void EndClipDisplayItem::appendToWebDisplayItemList(WebDisplayItemList* list) co nst 60 void EndClipDisplayItem::appendToWebDisplayItemList(WebDisplayItemList* list) co nst
50 { 61 {
51 list->appendEndClipItem(); 62 list->appendEndClipItem();
52 } 63 }
53 64
54 #ifndef NDEBUG 65 #ifndef NDEBUG
55 void ClipDisplayItem::dumpPropertiesAsDebugString(WTF::StringBuilder& stringBuil der) const 66 void ClipDisplayItem::dumpPropertiesAsDebugString(WTF::StringBuilder& stringBuil der) const
56 { 67 {
57 DisplayItem::dumpPropertiesAsDebugString(stringBuilder); 68 DisplayItem::dumpPropertiesAsDebugString(stringBuilder);
58 stringBuilder.append(WTF::String::format(", clipRect: [%d,%d,%d,%d]", 69 stringBuilder.append(WTF::String::format(", clipRect: [%d,%d,%d,%d]",
59 m_clipRect.x(), m_clipRect.y(), m_clipRect.width(), m_clipRect.height()) ); 70 m_clipRect.x(), m_clipRect.y(), m_clipRect.width(), m_clipRect.height()) );
60 } 71 }
61 #endif 72 #endif
62 73
63 } // namespace blink 74 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/graphics/paint/ClipDisplayItem.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698