| 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/transforms/AffineTransform.h" | 7 #include "platform/transforms/AffineTransform.h" |
| 8 #include "third_party/skia/include/core/SkCanvas.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, AntiAliasingMode antiAliasingMode, c
onst SkMatrix& ctm) | 15 void ClipList::clipPath(const SkPath& path, AntiAliasingMode antiAliasingMode, c
onst SkMatrix& ctm) |
| 16 { | 16 { |
| 17 ClipOp newClip; | 17 ClipOp newClip; |
| 18 newClip.m_antiAliasingMode = antiAliasingMode; | 18 newClip.m_antiAliasingMode = antiAliasingMode; |
| 19 newClip.m_path = path; | 19 newClip.m_path = path; |
| 20 newClip.m_path.transform(ctm); | 20 newClip.m_path.transform(ctm); |
| 21 if (m_clipList.isEmpty()) |
| 22 m_currentClipPath = path; |
| 23 else |
| 24 Op(m_currentClipPath, path, SkPathOp::kIntersect_SkPathOp, &m_currentCli
pPath); |
| 21 m_clipList.append(newClip); | 25 m_clipList.append(newClip); |
| 22 } | 26 } |
| 23 | 27 |
| 24 void ClipList::playback(SkCanvas* canvas) const | 28 void ClipList::playback(SkCanvas* canvas) const |
| 25 { | 29 { |
| 26 for (const ClipOp* it = m_clipList.begin(); it < m_clipList.end(); it++) { | 30 for (const ClipOp* it = m_clipList.begin(); it < m_clipList.end(); it++) { |
| 27 canvas->clipPath(it->m_path, SkRegion::kIntersect_Op, it->m_antiAliasing
Mode == AntiAliased); | 31 canvas->clipPath(it->m_path, SkRegion::kIntersect_Op, it->m_antiAliasing
Mode == AntiAliased); |
| 28 } | 32 } |
| 29 } | 33 } |
| 30 | 34 |
| 31 SkPath ClipList::intersectPathWithClip(const SkPath& path) const | 35 const SkPath& ClipList::getCurrentClipPath() const |
| 32 { | 36 { |
| 33 SkPath total = path; | 37 return m_currentClipPath; |
| 34 for (const ClipOp* it = m_clipList.begin(); it < m_clipList.end(); it++) { | |
| 35 Op(total, it->m_path, SkPathOp::kIntersect_SkPathOp, &total); | |
| 36 } | |
| 37 return total; | |
| 38 } | 38 } |
| 39 | 39 |
| 40 ClipList::ClipOp::ClipOp() | 40 ClipList::ClipOp::ClipOp() |
| 41 : m_antiAliasingMode(AntiAliased) | 41 : m_antiAliasingMode(AntiAliased) |
| 42 { } | 42 { } |
| 43 | 43 |
| 44 ClipList::ClipOp::ClipOp(const ClipOp& other) | 44 ClipList::ClipOp::ClipOp(const ClipOp& other) |
| 45 : m_path(other.m_path) | 45 : m_path(other.m_path) |
| 46 , m_antiAliasingMode(other.m_antiAliasingMode) | 46 , m_antiAliasingMode(other.m_antiAliasingMode) |
| 47 { } | 47 { } |
| 48 | 48 |
| 49 } // namespace blink | 49 } // namespace blink |
| OLD | NEW |