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

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

Issue 1998233002: cc: Implement and use FilterOperations::MapRectReverse for mapping backdrop bounding box. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months 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
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 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 SkIRect in_rect = gfx::RectToSkIRect(rect); 345 SkIRect in_rect = gfx::RectToSkIRect(rect);
346 SkIRect out_rect = image_filter()->filterBounds( 346 SkIRect out_rect = image_filter()->filterBounds(
347 in_rect, matrix, SkImageFilter::kForward_MapDirection); 347 in_rect, matrix, SkImageFilter::kForward_MapDirection);
348 return gfx::SkIRectToRect(out_rect); 348 return gfx::SkIRectToRect(out_rect);
349 } 349 }
350 default: 350 default:
351 return rect; 351 return rect;
352 } 352 }
353 } 353 }
354 354
355 gfx::Rect FilterOperation::MapRectReverse(const gfx::Rect& rect,
356 const SkMatrix& matrix) const {
357 switch (type_) {
358 case FilterOperation::BLUR: {
359 SkVector spread = MapStdDeviation(amount(), matrix);
360 gfx::Rect result = rect;
361 result.Inset(-spread.x(), -spread.y(), -spread.x(), -spread.y());
362 return result;
363 }
364 case FilterOperation::DROP_SHADOW: {
365 SkVector spread = MapStdDeviation(amount(), matrix);
366 gfx::Rect result = rect;
367 result.Inset(-spread.x(), -spread.y(), -spread.x(), -spread.y());
368 result -= drop_shadow_offset().OffsetFromOrigin();
369 result.Union(rect);
370 return result;
371 }
372 case FilterOperation::REFERENCE: {
373 if (!image_filter())
374 return rect;
375 SkIRect in_rect = gfx::RectToSkIRect(rect);
376 SkIRect out_rect = image_filter()->filterBounds(
377 in_rect, matrix, SkImageFilter::kReverse_MapDirection);
378 return gfx::SkIRectToRect(out_rect);
379 }
380 default:
381 return rect;
382 }
383 }
384
355 } // namespace cc 385 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698