OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "ui/gfx/canvas_direct2d.h" | 5 #include "ui/gfx/canvas_direct2d.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "ui/gfx/brush.h" | 8 #include "ui/gfx/brush.h" |
9 #include "ui/gfx/rect.h" | 9 #include "ui/gfx/rect.h" |
10 | 10 |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 void CanvasDirect2D::Scale(int x_scale, int y_scale) { | 195 void CanvasDirect2D::Scale(int x_scale, int y_scale) { |
196 D2D1_MATRIX_3X2_F raw; | 196 D2D1_MATRIX_3X2_F raw; |
197 rt_->GetTransform(&raw); | 197 rt_->GetTransform(&raw); |
198 D2D1::Matrix3x2F transform(raw._11, raw._12, raw._21, raw._22, raw._31, | 198 D2D1::Matrix3x2F transform(raw._11, raw._12, raw._21, raw._22, raw._31, |
199 raw._32); | 199 raw._32); |
200 transform = D2D1::Matrix3x2F::Scale(static_cast<float>(x_scale), | 200 transform = D2D1::Matrix3x2F::Scale(static_cast<float>(x_scale), |
201 static_cast<float>(y_scale)) * transform; | 201 static_cast<float>(y_scale)) * transform; |
202 rt_->SetTransform(transform); | 202 rt_->SetTransform(transform); |
203 } | 203 } |
204 | 204 |
205 void CanvasDirect2D::FillRectInt(const SkColor& color, | 205 void CanvasDirect2D::FillRect(const SkColor& color, const gfx::Rect& rect) { |
206 int x, int y, int w, int h) { | |
207 base::win::ScopedComPtr<ID2D1SolidColorBrush> solid_brush; | 206 base::win::ScopedComPtr<ID2D1SolidColorBrush> solid_brush; |
208 rt_->CreateSolidColorBrush(SkColorToColorF(color), solid_brush.Receive()); | 207 rt_->CreateSolidColorBrush(SkColorToColorF(color), solid_brush.Receive()); |
209 rt_->FillRectangle(RectToRectF(x, y, w, h), solid_brush); | 208 rt_->FillRectangle(RectToRectF(rect), solid_brush); |
210 } | 209 } |
211 | 210 |
212 void CanvasDirect2D::FillRectInt(const SkColor& color, | 211 void CanvasDirect2D::FillRect(const SkColor& color, |
213 int x, int y, int w, int h, | 212 const gfx::Rect& rect, |
214 SkXfermode::Mode mode) { | 213 SkXfermode::Mode mode) { |
215 NOTIMPLEMENTED(); | 214 NOTIMPLEMENTED(); |
216 } | 215 } |
217 | 216 |
218 void CanvasDirect2D::FillRectInt(const gfx::Brush* brush, | 217 void CanvasDirect2D::FillRect(const gfx::Brush* brush, const gfx::Rect& rect) { |
219 int x, int y, int w, int h) { | |
220 const Direct2DBrush* d2d_brush = static_cast<const Direct2DBrush*>(brush); | 218 const Direct2DBrush* d2d_brush = static_cast<const Direct2DBrush*>(brush); |
221 rt_->FillRectangle(RectToRectF(x, y, w, h), d2d_brush->brush()); | 219 rt_->FillRectangle(RectToRectF(rect), d2d_brush->brush()); |
222 } | 220 } |
223 | 221 |
224 void CanvasDirect2D::DrawRectInt(const SkColor& color, | 222 void CanvasDirect2D::DrawRectInt(const SkColor& color, |
225 int x, int y, int w, int h) { | 223 int x, int y, int w, int h) { |
226 base::win::ScopedComPtr<ID2D1SolidColorBrush> solid_brush; | 224 base::win::ScopedComPtr<ID2D1SolidColorBrush> solid_brush; |
227 rt_->CreateSolidColorBrush(SkColorToColorF(color), solid_brush.Receive()); | 225 rt_->CreateSolidColorBrush(SkColorToColorF(color), solid_brush.Receive()); |
228 rt_->DrawRectangle(RectToRectF(x, y, w, h), solid_brush); | 226 rt_->DrawRectangle(RectToRectF(x, y, w, h), solid_brush); |
229 } | 227 } |
230 | 228 |
231 void CanvasDirect2D::DrawRectInt(const SkColor& color, | 229 void CanvasDirect2D::DrawRectInt(const SkColor& color, |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 // CanvasDirect2D, private: | 360 // CanvasDirect2D, private: |
363 | 361 |
364 void CanvasDirect2D::SaveInternal(ID2D1Layer* layer) { | 362 void CanvasDirect2D::SaveInternal(ID2D1Layer* layer) { |
365 if (!drawing_state_block_) | 363 if (!drawing_state_block_) |
366 GetD2D1Factory()->CreateDrawingStateBlock(drawing_state_block_.Receive()); | 364 GetD2D1Factory()->CreateDrawingStateBlock(drawing_state_block_.Receive()); |
367 rt_->SaveDrawingState(drawing_state_block_.get()); | 365 rt_->SaveDrawingState(drawing_state_block_.get()); |
368 state_.push(RenderState(layer)); | 366 state_.push(RenderState(layer)); |
369 } | 367 } |
370 | 368 |
371 } // namespace gfx | 369 } // namespace gfx |
OLD | NEW |