Chromium Code Reviews| Index: cc/base/region.cc |
| diff --git a/cc/base/region.cc b/cc/base/region.cc |
| index c048c89e5710ba0412910008c9eabb2fdaa37abc..0a7ee5d6b62fbd591e549ea448a3b7d0591110c3 100644 |
| --- a/cc/base/region.cc |
| +++ b/cc/base/region.cc |
| @@ -7,6 +7,7 @@ |
| #include "base/trace_event/trace_event_argument.h" |
| #include "base/values.h" |
| #include "cc/base/simple_enclosed_region.h" |
| +#include "cc/proto/region.pb.h" |
| namespace cc { |
| @@ -140,6 +141,25 @@ void Region::AsValueInto(base::trace_event::TracedValue* result) const { |
| } |
| } |
| +void Region::ToProtobuf(proto::Region* proto) const { |
| + size_t region_size = skregion_.writeToMemory(nullptr); |
| + if (region_size > 0) { |
| + scoped_ptr<char[]> buffer(new char[region_size]); |
|
David Trainor- moved to gerrit
2015/11/19 19:14:01
uint8_t? Again same for the DisplayItem protos :(
nyquist
2015/11/20 01:11:43
Done.
|
| + skregion_.writeToMemory(buffer.get()); |
| + proto->set_skregion(std::string(buffer.get(), region_size)); |
| + } |
| +} |
| + |
| +void Region::FromProtobuf(const proto::Region& proto) { |
| + SkRegion region; |
| + if (proto.has_skregion()) { |
| + size_t bytes_read = region.readFromMemory(proto.skregion().c_str(), |
|
David Trainor- moved to gerrit
2015/11/19 19:14:01
.data? Could you also do this for the DisplayItem
nyquist
2015/11/20 01:11:43
Done.
|
| + proto.skregion().size()); |
| + DCHECK_EQ(proto.skregion().size(), bytes_read); |
| + } |
| + skregion_ = region; |
| +} |
| + |
| Region::Iterator::Iterator() { |
| } |