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

Side by Side Diff: cc/output/filter_operation.cc

Issue 2593583005: cc: Prevent float-cast-overflow in MapRectInternal. (Closed)
Patch Set: . Created 4 years 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
« no previous file with comments | « no previous file | cc/output/filter_operations_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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/trace_event/trace_event_argument.h" 9 #include "base/trace_event/trace_event_argument.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 329
330 gfx::Rect MapRectInternal(const FilterOperation& op, 330 gfx::Rect MapRectInternal(const FilterOperation& op,
331 const gfx::Rect& rect, 331 const gfx::Rect& rect,
332 const SkMatrix& matrix, 332 const SkMatrix& matrix,
333 SkImageFilter::MapDirection direction) { 333 SkImageFilter::MapDirection direction) {
334 switch (op.type()) { 334 switch (op.type()) {
335 case FilterOperation::BLUR: { 335 case FilterOperation::BLUR: {
336 SkVector spread = MapStdDeviation(op.amount(), matrix); 336 SkVector spread = MapStdDeviation(op.amount(), matrix);
337 float spread_x = std::abs(spread.x()); 337 float spread_x = std::abs(spread.x());
338 float spread_y = std::abs(spread.y()); 338 float spread_y = std::abs(spread.y());
339 gfx::Rect result = rect; 339 gfx::RectF result(rect);
340 result.Inset(-spread_x, -spread_y, -spread_x, -spread_y); 340 result.Inset(-spread_x, -spread_y, -spread_x, -spread_y);
341 return result; 341 return gfx::ToEnclosingRect(result);
342 } 342 }
343 case FilterOperation::DROP_SHADOW: { 343 case FilterOperation::DROP_SHADOW: {
344 SkVector spread = MapStdDeviation(op.amount(), matrix); 344 SkVector spread = MapStdDeviation(op.amount(), matrix);
345 float spread_x = std::abs(spread.x()); 345 float spread_x = std::abs(spread.x());
346 float spread_y = std::abs(spread.y()); 346 float spread_y = std::abs(spread.y());
347 gfx::RectF result(rect); 347 gfx::RectF result(rect);
348 result.Inset(-spread_x, -spread_y, -spread_x, -spread_y); 348 result.Inset(-spread_x, -spread_y, -spread_x, -spread_y);
349 349
350 gfx::Point drop_shadow_offset = op.drop_shadow_offset(); 350 gfx::Point drop_shadow_offset = op.drop_shadow_offset();
351 SkVector mapped_drop_shadow_offset; 351 SkVector mapped_drop_shadow_offset;
(...skipping 25 matching lines...) Expand all
377 SkImageFilter::kForward_MapDirection); 377 SkImageFilter::kForward_MapDirection);
378 } 378 }
379 379
380 gfx::Rect FilterOperation::MapRectReverse(const gfx::Rect& rect, 380 gfx::Rect FilterOperation::MapRectReverse(const gfx::Rect& rect,
381 const SkMatrix& matrix) const { 381 const SkMatrix& matrix) const {
382 return MapRectInternal(*this, rect, matrix, 382 return MapRectInternal(*this, rect, matrix,
383 SkImageFilter::kReverse_MapDirection); 383 SkImageFilter::kReverse_MapDirection);
384 } 384 }
385 385
386 } // namespace cc 386 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/output/filter_operations_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698