Chromium Code Reviews| OLD | NEW | 
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/common/cc_messages.h" | 5 #include "content/common/cc_messages.h" | 
| 6 | 6 | 
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" | 
| 8 #include "cc/output/compositor_frame.h" | 8 #include "cc/output/compositor_frame.h" | 
| 9 #include "cc/output/filter_operations.h" | 9 #include "cc/output/filter_operations.h" | 
| 10 #include "content/public/common/common_param_traits.h" | 10 #include "content/public/common/common_param_traits.h" | 
| (...skipping 26 matching lines...) Expand all Loading... | |
| 37 WriteParam(m, p.drop_shadow_color()); | 37 WriteParam(m, p.drop_shadow_color()); | 
| 38 break; | 38 break; | 
| 39 case cc::FilterOperation::COLOR_MATRIX: | 39 case cc::FilterOperation::COLOR_MATRIX: | 
| 40 for (int i = 0; i < 20; ++i) | 40 for (int i = 0; i < 20; ++i) | 
| 41 WriteParam(m, p.matrix()[i]); | 41 WriteParam(m, p.matrix()[i]); | 
| 42 break; | 42 break; | 
| 43 case cc::FilterOperation::ZOOM: | 43 case cc::FilterOperation::ZOOM: | 
| 44 WriteParam(m, p.amount()); | 44 WriteParam(m, p.amount()); | 
| 45 WriteParam(m, p.zoom_inset()); | 45 WriteParam(m, p.zoom_inset()); | 
| 46 break; | 46 break; | 
| 47 case cc::FilterOperation::REFERENCE: | |
| 48 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
| 49 switches::kAllowFiltersOverIPC)) | |
| 
 
piman
2013/09/09 23:29:15
nit: we already test the flag in ParamTraits<SkIma
 
ajuma
2013/09/10 21:17:58
Done. In fact, we don't even need to do any specia
 
 | |
| 50 WriteParam(m, p.image_filter()); | |
| 51 break; | |
| 47 } | 52 } | 
| 48 } | 53 } | 
| 49 | 54 | 
| 50 bool ParamTraits<cc::FilterOperation>::Read( | 55 bool ParamTraits<cc::FilterOperation>::Read( | 
| 51 const Message* m, PickleIterator* iter, param_type* r) { | 56 const Message* m, PickleIterator* iter, param_type* r) { | 
| 52 cc::FilterOperation::FilterType type; | 57 cc::FilterOperation::FilterType type; | 
| 53 float amount; | 58 float amount; | 
| 54 gfx::Point drop_shadow_offset; | 59 gfx::Point drop_shadow_offset; | 
| 55 SkColor drop_shadow_color; | 60 SkColor drop_shadow_color; | 
| 56 SkScalar matrix[20]; | 61 SkScalar matrix[20]; | 
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 102 case cc::FilterOperation::ZOOM: | 107 case cc::FilterOperation::ZOOM: | 
| 103 if (ReadParam(m, iter, &amount) && | 108 if (ReadParam(m, iter, &amount) && | 
| 104 ReadParam(m, iter, &zoom_inset) && | 109 ReadParam(m, iter, &zoom_inset) && | 
| 105 amount >= 0.f && | 110 amount >= 0.f && | 
| 106 zoom_inset >= 0) { | 111 zoom_inset >= 0) { | 
| 107 r->set_amount(amount); | 112 r->set_amount(amount); | 
| 108 r->set_zoom_inset(zoom_inset); | 113 r->set_zoom_inset(zoom_inset); | 
| 109 success = true; | 114 success = true; | 
| 110 } | 115 } | 
| 111 break; | 116 break; | 
| 117 case cc::FilterOperation::REFERENCE: { | |
| 118 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
| 119 switches::kAllowFiltersOverIPC)) { | |
| 120 skia::RefPtr<SkImageFilter> filter; | |
| 121 if (!ReadParam(m, iter, &filter)) { | |
| 122 success = false; | |
| 123 break; | |
| 124 } | |
| 125 if (!filter) { | |
| 126 success = false; | |
| 127 break; | |
| 128 } | |
| 129 r->set_image_filter(filter); | |
| 130 success = true; | |
| 131 break; | |
| 132 } | |
| 133 // When reference filters cannot be serialized, just use a noop filter. | |
| 134 *r = cc::FilterOperation::CreateEmptyFilter(); | |
| 135 success = true; | |
| 136 break; | |
| 137 } | |
| 112 } | 138 } | 
| 113 return success; | 139 return success; | 
| 114 } | 140 } | 
| 115 | 141 | 
| 116 void ParamTraits<cc::FilterOperation>::Log( | 142 void ParamTraits<cc::FilterOperation>::Log( | 
| 117 const param_type& p, std::string* l) { | 143 const param_type& p, std::string* l) { | 
| 118 l->append("("); | 144 l->append("("); | 
| 119 LogParam(static_cast<unsigned>(p.type()), l); | 145 LogParam(static_cast<unsigned>(p.type()), l); | 
| 120 l->append(", "); | 146 l->append(", "); | 
| 121 | 147 | 
| (...skipping 22 matching lines...) Expand all Loading... | |
| 144 if (i) | 170 if (i) | 
| 145 l->append(", "); | 171 l->append(", "); | 
| 146 LogParam(p.matrix()[i], l); | 172 LogParam(p.matrix()[i], l); | 
| 147 } | 173 } | 
| 148 break; | 174 break; | 
| 149 case cc::FilterOperation::ZOOM: | 175 case cc::FilterOperation::ZOOM: | 
| 150 LogParam(p.amount(), l); | 176 LogParam(p.amount(), l); | 
| 151 l->append(", "); | 177 l->append(", "); | 
| 152 LogParam(p.zoom_inset(), l); | 178 LogParam(p.zoom_inset(), l); | 
| 153 break; | 179 break; | 
| 180 case cc::FilterOperation::REFERENCE: | |
| 181 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
| 182 switches::kAllowFiltersOverIPC)) | |
| 183 LogParam(p.image_filter(), l); | |
| 184 break; | |
| 154 } | 185 } | 
| 155 l->append(")"); | 186 l->append(")"); | 
| 156 } | 187 } | 
| 157 | 188 | 
| 158 void ParamTraits<cc::FilterOperations>::Write( | 189 void ParamTraits<cc::FilterOperations>::Write( | 
| 159 Message* m, const param_type& p) { | 190 Message* m, const param_type& p) { | 
| 160 WriteParam(m, p.size()); | 191 WriteParam(m, p.size()); | 
| 161 for (std::size_t i = 0; i < p.size(); ++i) { | 192 for (std::size_t i = 0; i < p.size(); ++i) { | 
| 162 WriteParam(m, p.at(i)); | 193 WriteParam(m, p.at(i)); | 
| 163 } | 194 } | 
| (...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 746 l->append(", ["); | 777 l->append(", ["); | 
| 747 for (size_t i = 0; i < p.render_pass_list.size(); ++i) { | 778 for (size_t i = 0; i < p.render_pass_list.size(); ++i) { | 
| 748 if (i) | 779 if (i) | 
| 749 l->append(", "); | 780 l->append(", "); | 
| 750 LogParam(*p.render_pass_list[i], l); | 781 LogParam(*p.render_pass_list[i], l); | 
| 751 } | 782 } | 
| 752 l->append("])"); | 783 l->append("])"); | 
| 753 } | 784 } | 
| 754 | 785 | 
| 755 } // namespace IPC | 786 } // namespace IPC | 
| OLD | NEW |