| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "sky/engine/config.h" | 5 #include "sky/engine/config.h" |
| 6 #include "sky/engine/core/painting/Canvas.h" | 6 #include "sky/engine/core/painting/Canvas.h" |
| 7 | 7 |
| 8 #include "sky/engine/core/dom/Document.h" | 8 #include "sky/engine/core/dom/Document.h" |
| 9 #include "sky/engine/core/dom/Element.h" | 9 #include "sky/engine/core/dom/Element.h" |
| 10 #include "sky/engine/core/painting/CanvasImage.h" | 10 #include "sky/engine/core/painting/CanvasImage.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 } | 76 } |
| 77 | 77 |
| 78 void Canvas::skew(float sx, float sy) | 78 void Canvas::skew(float sx, float sy) |
| 79 { | 79 { |
| 80 if (!m_canvas) | 80 if (!m_canvas) |
| 81 return; | 81 return; |
| 82 ASSERT(m_displayList->isRecording()); | 82 ASSERT(m_displayList->isRecording()); |
| 83 m_canvas->skew(sx, sy); | 83 m_canvas->skew(sx, sy); |
| 84 } | 84 } |
| 85 | 85 |
| 86 void Canvas::concat(const Vector<float>& matrix) | 86 void Canvas::concat(const Float32List& matrix4) |
| 87 { | 87 { |
| 88 if (!m_canvas) | 88 if (!m_canvas) |
| 89 return; | 89 return; |
| 90 ASSERT(m_displayList->isRecording()); | 90 ASSERT(m_displayList->isRecording()); |
| 91 ASSERT(matrix.size() == 9); | 91 ASSERT(matrix4.data); |
| 92 |
| 93 // TODO(mpcomplete): how can we raise an error in this case? |
| 94 if (matrix4.num_elements != 16) |
| 95 return; |
| 96 |
| 92 SkMatrix sk_matrix; | 97 SkMatrix sk_matrix; |
| 93 sk_matrix.set9(matrix.data()); | 98 // Mappings from SkMatrix-index to input-index. |
| 99 static const int kMappings[] = { |
| 100 0, 4, 12, |
| 101 1, 5, 13, |
| 102 3, 7, 15, |
| 103 }; |
| 104 for (intptr_t i = 0; i < 9; ++i) |
| 105 sk_matrix[i] = matrix4.data[kMappings[i]]; |
| 106 |
| 94 m_canvas->concat(sk_matrix); | 107 m_canvas->concat(sk_matrix); |
| 95 } | 108 } |
| 96 | 109 |
| 97 void Canvas::clipRect(const Rect& rect) | 110 void Canvas::clipRect(const Rect& rect) |
| 98 { | 111 { |
| 99 if (!m_canvas) | 112 if (!m_canvas) |
| 100 return; | 113 return; |
| 101 ASSERT(m_displayList->isRecording()); | 114 ASSERT(m_displayList->isRecording()); |
| 102 m_canvas->clipRect(rect.sk_rect); | 115 m_canvas->clipRect(rect.sk_rect); |
| 103 } | 116 } |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 PassRefPtr<DisplayList> Canvas::finishRecording() | 184 PassRefPtr<DisplayList> Canvas::finishRecording() |
| 172 { | 185 { |
| 173 if (!isRecording()) | 186 if (!isRecording()) |
| 174 return nullptr; | 187 return nullptr; |
| 175 m_canvas = nullptr; | 188 m_canvas = nullptr; |
| 176 m_displayList->endRecording(); | 189 m_displayList->endRecording(); |
| 177 return m_displayList.release(); | 190 return m_displayList.release(); |
| 178 } | 191 } |
| 179 | 192 |
| 180 } // namespace blink | 193 } // namespace blink |
| OLD | NEW |