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