Chromium Code Reviews| 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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 166 rt_->PopAxisAlignedClip(); | 166 rt_->PopAxisAlignedClip(); |
| 167 | 167 |
| 168 state_.pop(); | 168 state_.pop(); |
| 169 // The state_ stack should never be empty - we should always have at least one | 169 // The state_ stack should never be empty - we should always have at least one |
| 170 // entry to hold a clip count when there is no active save/restore entry. | 170 // entry to hold a clip count when there is no active save/restore entry. |
| 171 CHECK(!state_.empty()) << "Called Restore() once too often!"; | 171 CHECK(!state_.empty()) << "Called Restore() once too often!"; |
| 172 | 172 |
| 173 rt_->RestoreDrawingState(drawing_state_block_); | 173 rt_->RestoreDrawingState(drawing_state_block_); |
| 174 } | 174 } |
| 175 | 175 |
| 176 bool CanvasDirect2D::ClipRectInt(int x, int y, int w, int h) { | 176 bool CanvasDirect2D::ClipRectInt(const gfx::Rect& rect) { |
| 177 rt_->PushAxisAlignedClip(RectToRectF(x, y, w, h), | 177 rt_->PushAxisAlignedClip( |
| 178 D2D1_ANTIALIAS_MODE_PER_PRIMITIVE); | 178 RectToRectF(rect.x(), rect.y(), rect.width(), rect.height()), |
|
Peter Kasting
2011/10/25 20:24:47
Nit: Just RectToRectF(rect) should work.
tfarina
2011/10/25 23:52:41
Done.
| |
| 179 D2D1_ANTIALIAS_MODE_PER_PRIMITIVE); | |
| 179 // Increment the clip count so the call to PushAxisAlignedClip() can be | 180 // Increment the clip count so the call to PushAxisAlignedClip() can be |
| 180 // balanced with a call to PopAxisAlignedClip in the next Restore(). | 181 // balanced with a call to PopAxisAlignedClip in the next Restore(). |
| 181 ++state_.top().clip_count; | 182 ++state_.top().clip_count; |
| 182 return w > 0 && h > 0; | 183 return rect.width() > 0 && rect.height() > 0; |
|
Peter Kasting
2011/10/25 20:24:47
Nit: Simpler:
return !rect.IsEmpty();
tfarina
2011/10/25 23:52:41
Done.
| |
| 183 } | 184 } |
| 184 | 185 |
| 185 void CanvasDirect2D::TranslateInt(int x, int y) { | 186 void CanvasDirect2D::TranslateInt(int x, int y) { |
| 186 D2D1_MATRIX_3X2_F raw; | 187 D2D1_MATRIX_3X2_F raw; |
| 187 rt_->GetTransform(&raw); | 188 rt_->GetTransform(&raw); |
| 188 D2D1::Matrix3x2F transform(raw._11, raw._12, raw._21, raw._22, raw._31, | 189 D2D1::Matrix3x2F transform(raw._11, raw._12, raw._21, raw._22, raw._31, |
| 189 raw._32); | 190 raw._32); |
| 190 transform = D2D1::Matrix3x2F::Translation(static_cast<float>(x), | 191 transform = D2D1::Matrix3x2F::Translation(static_cast<float>(x), |
| 191 static_cast<float>(y)) * transform; | 192 static_cast<float>(y)) * transform; |
| 192 rt_->SetTransform(transform); | 193 rt_->SetTransform(transform); |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 362 // CanvasDirect2D, private: | 363 // CanvasDirect2D, private: |
| 363 | 364 |
| 364 void CanvasDirect2D::SaveInternal(ID2D1Layer* layer) { | 365 void CanvasDirect2D::SaveInternal(ID2D1Layer* layer) { |
| 365 if (!drawing_state_block_) | 366 if (!drawing_state_block_) |
| 366 GetD2D1Factory()->CreateDrawingStateBlock(drawing_state_block_.Receive()); | 367 GetD2D1Factory()->CreateDrawingStateBlock(drawing_state_block_.Receive()); |
| 367 rt_->SaveDrawingState(drawing_state_block_.get()); | 368 rt_->SaveDrawingState(drawing_state_block_.get()); |
| 368 state_.push(RenderState(layer)); | 369 state_.push(RenderState(layer)); |
| 369 } | 370 } |
| 370 | 371 |
| 371 } // namespace gfx | 372 } // namespace gfx |
| OLD | NEW |