OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "gfx/canvas_direct2d.h" | 5 #include "gfx/canvas_direct2d.h" |
6 | 6 |
7 #include "gfx/rect.h" | 7 #include "gfx/rect.h" |
8 | 8 |
9 namespace { | 9 namespace { |
10 | 10 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 bool CanvasDirect2D::ClipRectInt(int x, int y, int w, int h) { | 110 bool CanvasDirect2D::ClipRectInt(int x, int y, int w, int h) { |
111 rt_->PushAxisAlignedClip(RectToRectF(x, y, w, h), | 111 rt_->PushAxisAlignedClip(RectToRectF(x, y, w, h), |
112 D2D1_ANTIALIAS_MODE_PER_PRIMITIVE); | 112 D2D1_ANTIALIAS_MODE_PER_PRIMITIVE); |
113 // Increment the clip count so the call to PushAxisAlignedClip() can be | 113 // Increment the clip count so the call to PushAxisAlignedClip() can be |
114 // balanced with a call to PopAxisAlignedClip in the next Restore(). | 114 // balanced with a call to PopAxisAlignedClip in the next Restore(). |
115 ++state_.top().clip_count; | 115 ++state_.top().clip_count; |
116 return w > 0 && h > 0; | 116 return w > 0 && h > 0; |
117 } | 117 } |
118 | 118 |
119 void CanvasDirect2D::TranslateInt(int x, int y) { | 119 void CanvasDirect2D::TranslateInt(int x, int y) { |
120 rt_->SetTransform(D2D1::Matrix3x2F::Translation(static_cast<float>(x), | 120 D2D1_MATRIX_3X2_F raw; |
121 static_cast<float>(y))); | 121 rt_->GetTransform(&raw); |
| 122 D2D1::Matrix3x2F transform(raw._11, raw._12, raw._21, raw._22, raw._31, |
| 123 raw._32); |
| 124 transform = D2D1::Matrix3x2F::Translation(static_cast<float>(x), |
| 125 static_cast<float>(y)) * transform; |
| 126 rt_->SetTransform(transform); |
122 } | 127 } |
123 | 128 |
124 void CanvasDirect2D::ScaleInt(int x, int y) { | 129 void CanvasDirect2D::ScaleInt(int x, int y) { |
125 rt_->SetTransform(D2D1::Matrix3x2F::Scale(static_cast<float>(x), | 130 D2D1_MATRIX_3X2_F raw; |
126 static_cast<float>(y))); | 131 rt_->GetTransform(&raw); |
| 132 D2D1::Matrix3x2F transform(raw._11, raw._12, raw._21, raw._22, raw._31, |
| 133 raw._32); |
| 134 transform = D2D1::Matrix3x2F::Scale(static_cast<float>(x), |
| 135 static_cast<float>(y)) * transform; |
| 136 rt_->SetTransform(transform); |
127 } | 137 } |
128 | 138 |
129 void CanvasDirect2D::FillRectInt(int x, int y, int w, int h, | 139 void CanvasDirect2D::FillRectInt(int x, int y, int w, int h, |
130 const SkPaint& paint) { | 140 const SkPaint& paint) { |
131 } | 141 } |
132 | 142 |
133 void CanvasDirect2D::FillRectInt(const SkColor& color, int x, int y, int w, | 143 void CanvasDirect2D::FillRectInt(const SkColor& color, int x, int y, int w, |
134 int h) { | 144 int h) { |
135 ScopedComPtr<ID2D1SolidColorBrush> solid_brush; | 145 ScopedComPtr<ID2D1SolidColorBrush> solid_brush; |
136 rt_->CreateSolidColorBrush(SkColorToColorF(color), solid_brush.Receive()); | 146 rt_->CreateSolidColorBrush(SkColorToColorF(color), solid_brush.Receive()); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 // CanvasDirect2D, private: | 244 // CanvasDirect2D, private: |
235 | 245 |
236 void CanvasDirect2D::SaveInternal(ID2D1Layer* layer) { | 246 void CanvasDirect2D::SaveInternal(ID2D1Layer* layer) { |
237 if (!drawing_state_block_) | 247 if (!drawing_state_block_) |
238 GetD2D1Factory()->CreateDrawingStateBlock(drawing_state_block_.Receive()); | 248 GetD2D1Factory()->CreateDrawingStateBlock(drawing_state_block_.Receive()); |
239 rt_->SaveDrawingState(drawing_state_block_.get()); | 249 rt_->SaveDrawingState(drawing_state_block_.get()); |
240 state_.push(RenderState(layer)); | 250 state_.push(RenderState(layer)); |
241 } | 251 } |
242 | 252 |
243 } // namespace gfx | 253 } // namespace gfx |
OLD | NEW |