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