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 3 // found in the LICENSE file. 4 5 #ifndef CC_OUTPUT_FILTER_OPERATIONS_H_ 6 #define CC_OUTPUT_FILTER_OPERATIONS_H_ 7 8 #include <vector> 9 10 #include "base/logging.h" 11 #include "base/memory/scoped_ptr.h" 12 #include "cc/output/filter_operation.h" 13 14 namespace base { 15 class Value; 16 } 17 18 namespace cc { 19 20 // An ordered list of filter operations. 21 class CC_EXPORT FilterOperations { 22 public: 23 FilterOperations(); 24 25 FilterOperations(const FilterOperations& other); 26 27 ~FilterOperations(); 28 29 FilterOperations& operator=(const FilterOperations& other); 30 31 bool operator==(const FilterOperations& other) const; 32 33 bool operator!=(const FilterOperations& other) const { 34 return !(*this == other); 35 } 36 37 void Append(const FilterOperation& filter); 38 39 // Removes all filter operations. 40 void Clear(); 41 42 bool IsEmpty() const; 43 44 void GetOutsets(int* top, int* right, int* bottom, int* left) const; 45 bool HasFilterThatMovesPixels() const; 46 bool HasFilterThatAffectsOpacity() const; 47 bool HasReferenceFilter() const; 48 49 size_t size() const { 50 return operations_.size(); 51 } 52 53 const FilterOperation& at(size_t index) const { 54 DCHECK_LT(index, size()); 55 return operations_[index]; 56 } 57 58 // If |from| is of the same size as this, where in each position, the filter 59 // in |from| is of the same type as the filter in this, and if this doesn't 60 // contain any reference filters, returns a FilterOperations formed by 61 // linearly interpolating at each position a |progress| fraction of the way 62 // from the filter in |from| to the filter in this. If |from| and this are of 63 // different lengths, they are treated as having the same length by padding 64 // the shorter sequence with no-op filters of the same type as the filters in 65 // the corresponding positions in the longer sequence. If either sequence has 66 // a reference filter or if there is a type mismatch at some position, returns 67 // a copy of this. 68 FilterOperations Blend(const FilterOperations& from, double progress) const; 69 70 71 scoped_ptr<base::Value> AsValue() const; 72 73 private: 74 std::vector<FilterOperation> operations_; 75 }; 76 77 } // namespace cc 78 79 #endif // CC_OUTPUT_FILTER_OPERATIONS_H_ 80