OLD | NEW |
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 "modules/canvas2d/ClipList.h" | 5 #include "modules/canvas2d/ClipList.h" |
6 | 6 |
| 7 #include "platform/graphics/paint/PaintCanvas.h" |
7 #include "platform/transforms/AffineTransform.h" | 8 #include "platform/transforms/AffineTransform.h" |
8 #include "third_party/skia/include/core/SkCanvas.h" | |
9 #include "third_party/skia/include/pathops/SkPathOps.h" | 9 #include "third_party/skia/include/pathops/SkPathOps.h" |
10 | 10 |
11 namespace blink { | 11 namespace blink { |
12 | 12 |
13 ClipList::ClipList(const ClipList& other) : m_clipList(other.m_clipList) {} | 13 ClipList::ClipList(const ClipList& other) : m_clipList(other.m_clipList) {} |
14 | 14 |
15 void ClipList::clipPath(const SkPath& path, | 15 void ClipList::clipPath(const SkPath& path, |
16 AntiAliasingMode antiAliasingMode, | 16 AntiAliasingMode antiAliasingMode, |
17 const SkMatrix& ctm) { | 17 const SkMatrix& ctm) { |
18 ClipOp newClip; | 18 ClipOp newClip; |
19 newClip.m_antiAliasingMode = antiAliasingMode; | 19 newClip.m_antiAliasingMode = antiAliasingMode; |
20 newClip.m_path = path; | 20 newClip.m_path = path; |
21 newClip.m_path.transform(ctm); | 21 newClip.m_path.transform(ctm); |
22 if (m_clipList.isEmpty()) | 22 if (m_clipList.isEmpty()) |
23 m_currentClipPath = path; | 23 m_currentClipPath = path; |
24 else | 24 else |
25 Op(m_currentClipPath, path, SkPathOp::kIntersect_SkPathOp, | 25 Op(m_currentClipPath, path, SkPathOp::kIntersect_SkPathOp, |
26 &m_currentClipPath); | 26 &m_currentClipPath); |
27 m_clipList.push_back(newClip); | 27 m_clipList.push_back(newClip); |
28 } | 28 } |
29 | 29 |
30 void ClipList::playback(SkCanvas* canvas) const { | 30 void ClipList::playback(PaintCanvas* canvas) const { |
31 for (const ClipOp* it = m_clipList.begin(); it < m_clipList.end(); it++) { | 31 for (const ClipOp* it = m_clipList.begin(); it < m_clipList.end(); it++) { |
32 canvas->clipPath(it->m_path, SkClipOp::kIntersect, | 32 canvas->clipPath(it->m_path, SkClipOp::kIntersect, |
33 it->m_antiAliasingMode == AntiAliased); | 33 it->m_antiAliasingMode == AntiAliased); |
34 } | 34 } |
35 } | 35 } |
36 | 36 |
37 const SkPath& ClipList::getCurrentClipPath() const { | 37 const SkPath& ClipList::getCurrentClipPath() const { |
38 return m_currentClipPath; | 38 return m_currentClipPath; |
39 } | 39 } |
40 | 40 |
41 ClipList::ClipOp::ClipOp() : m_antiAliasingMode(AntiAliased) {} | 41 ClipList::ClipOp::ClipOp() : m_antiAliasingMode(AntiAliased) {} |
42 | 42 |
43 ClipList::ClipOp::ClipOp(const ClipOp& other) | 43 ClipList::ClipOp::ClipOp(const ClipOp& other) |
44 : m_path(other.m_path), m_antiAliasingMode(other.m_antiAliasingMode) {} | 44 : m_path(other.m_path), m_antiAliasingMode(other.m_antiAliasingMode) {} |
45 | 45 |
46 } // namespace blink | 46 } // namespace blink |
OLD | NEW |