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

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

Issue 2042413003: Implement cc::FilterOperation StructTraits (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased + Addressed Enne's comment Created 4 years, 6 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
« no previous file with comments | « cc/output/filter_operation.h ('k') | skia/public/interfaces/image_filter_struct_traits.h » ('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"
11 #include "cc/base/math_util.h" 11 #include "cc/base/math_util.h"
12 #include "cc/output/filter_operation.h" 12 #include "cc/output/filter_operation.h"
13 #include "ui/gfx/animation/tween.h" 13 #include "ui/gfx/animation/tween.h"
14 #include "ui/gfx/geometry/rect.h" 14 #include "ui/gfx/geometry/rect.h"
15 #include "ui/gfx/geometry/rect_conversions.h" 15 #include "ui/gfx/geometry/rect_conversions.h"
16 #include "ui/gfx/skia_util.h" 16 #include "ui/gfx/skia_util.h"
17 17
18 namespace cc { 18 namespace cc {
19 19
20 bool FilterOperation::operator==(const FilterOperation& other) const { 20 bool FilterOperation::operator==(const FilterOperation& other) const {
21 if (type_ != other.type_) 21 if (type_ != other.type_)
22 return false; 22 return false;
23 if (type_ == COLOR_MATRIX) 23 if (type_ == COLOR_MATRIX)
24 return !memcmp(matrix_, other.matrix_, sizeof(matrix_)); 24 return !memcmp(matrix_, other.matrix_, sizeof(matrix_));
25 if (type_ == DROP_SHADOW) { 25 if (type_ == DROP_SHADOW) {
26 return amount_ == other.amount_ && 26 return amount_ == other.amount_ &&
27 drop_shadow_offset_ == other.drop_shadow_offset_ && 27 drop_shadow_offset_ == other.drop_shadow_offset_ &&
28 drop_shadow_color_ == other.drop_shadow_color_; 28 drop_shadow_color_ == other.drop_shadow_color_;
29 } 29 }
30 if (type_ == REFERENCE) 30 if (type_ == REFERENCE) {
31 return image_filter_.get() == other.image_filter_.get(); 31 return image_filter_.get() == other.image_filter_.get();
32 }
32 if (type_ == ALPHA_THRESHOLD) { 33 if (type_ == ALPHA_THRESHOLD) {
33 return region_ == other.region_ && 34 return region_ == other.region_ &&
34 amount_ == other.amount_ && 35 amount_ == other.amount_ &&
35 outer_threshold_ == other.outer_threshold_; 36 outer_threshold_ == other.outer_threshold_;
36 } 37 }
37 return amount_ == other.amount_; 38 return amount_ == other.amount_;
38 } 39 }
39 40
41 FilterOperation::FilterOperation() : FilterOperation(GRAYSCALE, 0.f) {}
42
40 FilterOperation::FilterOperation(FilterType type, float amount) 43 FilterOperation::FilterOperation(FilterType type, float amount)
41 : type_(type), 44 : type_(type),
42 amount_(amount), 45 amount_(amount),
43 outer_threshold_(0), 46 outer_threshold_(0),
44 drop_shadow_offset_(0, 0), 47 drop_shadow_offset_(0, 0),
45 drop_shadow_color_(0), 48 drop_shadow_color_(0),
46 zoom_inset_(0) { 49 zoom_inset_(0) {
47 DCHECK_NE(type_, DROP_SHADOW); 50 DCHECK_NE(type_, DROP_SHADOW);
48 DCHECK_NE(type_, COLOR_MATRIX); 51 DCHECK_NE(type_, COLOR_MATRIX);
49 DCHECK_NE(type_, REFERENCE); 52 DCHECK_NE(type_, REFERENCE);
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 SkIRect out_rect = image_filter()->filterBounds( 349 SkIRect out_rect = image_filter()->filterBounds(
347 in_rect, matrix, SkImageFilter::kForward_MapDirection); 350 in_rect, matrix, SkImageFilter::kForward_MapDirection);
348 return gfx::SkIRectToRect(out_rect); 351 return gfx::SkIRectToRect(out_rect);
349 } 352 }
350 default: 353 default:
351 return rect; 354 return rect;
352 } 355 }
353 } 356 }
354 357
355 } // namespace cc 358 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/filter_operation.h ('k') | skia/public/interfaces/image_filter_struct_traits.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698