Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(104)

Side by Side Diff: ui/gfx/canvas_direct2d.cc

Issue 8383028: ui/gfx: Convert Canvas::ClipRectInt() to use gfx::Rect. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix typo Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/gfx/canvas_direct2d.h ('k') | ui/gfx/canvas_direct2d_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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(RectToRectF(rect),
178 D2D1_ANTIALIAS_MODE_PER_PRIMITIVE); 178 D2D1_ANTIALIAS_MODE_PER_PRIMITIVE);
179 // Increment the clip count so the call to PushAxisAlignedClip() can be 179 // Increment the clip count so the call to PushAxisAlignedClip() can be
180 // balanced with a call to PopAxisAlignedClip in the next Restore(). 180 // balanced with a call to PopAxisAlignedClip in the next Restore().
181 ++state_.top().clip_count; 181 ++state_.top().clip_count;
182 return w > 0 && h > 0; 182 return !rect.IsEmpty();
183 } 183 }
184 184
185 void CanvasDirect2D::TranslateInt(int x, int y) { 185 void CanvasDirect2D::TranslateInt(int x, int y) {
186 D2D1_MATRIX_3X2_F raw; 186 D2D1_MATRIX_3X2_F raw;
187 rt_->GetTransform(&raw); 187 rt_->GetTransform(&raw);
188 D2D1::Matrix3x2F transform(raw._11, raw._12, raw._21, raw._22, raw._31, 188 D2D1::Matrix3x2F transform(raw._11, raw._12, raw._21, raw._22, raw._31,
189 raw._32); 189 raw._32);
190 transform = D2D1::Matrix3x2F::Translation(static_cast<float>(x), 190 transform = D2D1::Matrix3x2F::Translation(static_cast<float>(x),
191 static_cast<float>(y)) * transform; 191 static_cast<float>(y)) * transform;
192 rt_->SetTransform(transform); 192 rt_->SetTransform(transform);
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 // CanvasDirect2D, private: 362 // CanvasDirect2D, private:
363 363
364 void CanvasDirect2D::SaveInternal(ID2D1Layer* layer) { 364 void CanvasDirect2D::SaveInternal(ID2D1Layer* layer) {
365 if (!drawing_state_block_) 365 if (!drawing_state_block_)
366 GetD2D1Factory()->CreateDrawingStateBlock(drawing_state_block_.Receive()); 366 GetD2D1Factory()->CreateDrawingStateBlock(drawing_state_block_.Receive());
367 rt_->SaveDrawingState(drawing_state_block_.get()); 367 rt_->SaveDrawingState(drawing_state_block_.get());
368 state_.push(RenderState(layer)); 368 state_.push(RenderState(layer));
369 } 369 }
370 370
371 } // namespace gfx 371 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/canvas_direct2d.h ('k') | ui/gfx/canvas_direct2d_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698