ProtoHelpers.h revision e248bd1b2c3fcf8088429507e73b31f45ee2544b
1e248bd1b2c3fcf8088429507e73b31f45ee2544bJohn Reck/*
2e248bd1b2c3fcf8088429507e73b31f45ee2544bJohn Reck * Copyright (C) 2015 The Android Open Source Project
3e248bd1b2c3fcf8088429507e73b31f45ee2544bJohn Reck *
4e248bd1b2c3fcf8088429507e73b31f45ee2544bJohn Reck * Licensed under the Apache License, Version 2.0 (the "License");
5e248bd1b2c3fcf8088429507e73b31f45ee2544bJohn Reck * you may not use this file except in compliance with the License.
6e248bd1b2c3fcf8088429507e73b31f45ee2544bJohn Reck * You may obtain a copy of the License at
7e248bd1b2c3fcf8088429507e73b31f45ee2544bJohn Reck *
8e248bd1b2c3fcf8088429507e73b31f45ee2544bJohn Reck *      http://www.apache.org/licenses/LICENSE-2.0
9e248bd1b2c3fcf8088429507e73b31f45ee2544bJohn Reck *
10e248bd1b2c3fcf8088429507e73b31f45ee2544bJohn Reck * Unless required by applicable law or agreed to in writing, software
11e248bd1b2c3fcf8088429507e73b31f45ee2544bJohn Reck * distributed under the License is distributed on an "AS IS" BASIS,
12e248bd1b2c3fcf8088429507e73b31f45ee2544bJohn Reck * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13e248bd1b2c3fcf8088429507e73b31f45ee2544bJohn Reck * See the License for the specific language governing permissions and
14e248bd1b2c3fcf8088429507e73b31f45ee2544bJohn Reck * limitations under the License.
15e248bd1b2c3fcf8088429507e73b31f45ee2544bJohn Reck */
16e248bd1b2c3fcf8088429507e73b31f45ee2544bJohn Reck#ifndef PROTOHELPERS_H
17e248bd1b2c3fcf8088429507e73b31f45ee2544bJohn Reck#define PROTOHELPERS_H
18e248bd1b2c3fcf8088429507e73b31f45ee2544bJohn Reck
19e248bd1b2c3fcf8088429507e73b31f45ee2544bJohn Reck#include "Rect.h"
20e248bd1b2c3fcf8088429507e73b31f45ee2544bJohn Reck#include "protos/hwui.pb.h"
21e248bd1b2c3fcf8088429507e73b31f45ee2544bJohn Reck
22e248bd1b2c3fcf8088429507e73b31f45ee2544bJohn Recknamespace android {
23e248bd1b2c3fcf8088429507e73b31f45ee2544bJohn Recknamespace uirenderer {
24e248bd1b2c3fcf8088429507e73b31f45ee2544bJohn Reck
25e248bd1b2c3fcf8088429507e73b31f45ee2544bJohn Reckvoid set(proto::RectF* dest, const Rect& src) {
26e248bd1b2c3fcf8088429507e73b31f45ee2544bJohn Reck    dest->set_left(src.left);
27e248bd1b2c3fcf8088429507e73b31f45ee2544bJohn Reck    dest->set_top(src.top);
28e248bd1b2c3fcf8088429507e73b31f45ee2544bJohn Reck    dest->set_right(src.right);
29e248bd1b2c3fcf8088429507e73b31f45ee2544bJohn Reck    dest->set_bottom(src.bottom);
30e248bd1b2c3fcf8088429507e73b31f45ee2544bJohn Reck}
31e248bd1b2c3fcf8088429507e73b31f45ee2544bJohn Reck
32e248bd1b2c3fcf8088429507e73b31f45ee2544bJohn Reckvoid set(std::string* dest, const SkPath& src) {
33e248bd1b2c3fcf8088429507e73b31f45ee2544bJohn Reck    size_t size = src.writeToMemory(nullptr);
34e248bd1b2c3fcf8088429507e73b31f45ee2544bJohn Reck    dest->resize(size);
35e248bd1b2c3fcf8088429507e73b31f45ee2544bJohn Reck    src.writeToMemory(&*dest->begin());
36e248bd1b2c3fcf8088429507e73b31f45ee2544bJohn Reck}
37e248bd1b2c3fcf8088429507e73b31f45ee2544bJohn Reck
38e248bd1b2c3fcf8088429507e73b31f45ee2544bJohn Reck} // namespace uirenderer
39e248bd1b2c3fcf8088429507e73b31f45ee2544bJohn Reck} // namespace android
40e248bd1b2c3fcf8088429507e73b31f45ee2544bJohn Reck
41e248bd1b2c3fcf8088429507e73b31f45ee2544bJohn Reck#endif // PROTOHELPERS_H
42