| chaviw | 1d04428 | 2017-09-27 12:19:28 -0700 | [diff] [blame] | 1 | /* | 
|  | 2 | * Copyright (C) 2017 The Android Open Source Project | 
|  | 3 | * | 
|  | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | 
|  | 5 | * you may not use this file except in compliance with the License. | 
|  | 6 | * You may obtain a copy of the License at | 
|  | 7 | * | 
|  | 8 | *      http://www.apache.org/licenses/LICENSE-2.0 | 
|  | 9 | * | 
|  | 10 | * Unless required by applicable law or agreed to in writing, software | 
|  | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | 
|  | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
|  | 13 | * See the License for the specific language governing permissions and | 
|  | 14 | * limitations under the License. | 
|  | 15 | */ | 
|  | 16 |  | 
|  | 17 | #include "LayerProtoHelper.h" | 
|  | 18 |  | 
|  | 19 | namespace android { | 
|  | 20 | namespace surfaceflinger { | 
|  | 21 | void LayerProtoHelper::writeToProto(const Region& region, RegionProto* regionProto) { | 
|  | 22 | Region::const_iterator head = region.begin(); | 
|  | 23 | Region::const_iterator const tail = region.end(); | 
|  | 24 | uint64_t address = reinterpret_cast<uint64_t>(®ion); | 
|  | 25 | regionProto->set_id(address); | 
|  | 26 | while (head != tail) { | 
|  | 27 | RectProto* rectProto = regionProto->add_rect(); | 
|  | 28 | writeToProto(*head, rectProto); | 
|  | 29 | head++; | 
|  | 30 | } | 
|  | 31 | } | 
|  | 32 |  | 
|  | 33 | void LayerProtoHelper::writeToProto(const Rect& rect, RectProto* rectProto) { | 
|  | 34 | rectProto->set_left(rect.left); | 
|  | 35 | rectProto->set_top(rect.top); | 
|  | 36 | rectProto->set_bottom(rect.bottom); | 
|  | 37 | rectProto->set_right(rect.right); | 
|  | 38 | } | 
|  | 39 |  | 
| Yiwei Zhang | 7124ad3 | 2018-02-21 13:02:45 -0800 | [diff] [blame] | 40 | void LayerProtoHelper::writeToProto(const FloatRect& rect, FloatRectProto* rectProto) { | 
|  | 41 | rectProto->set_left(rect.left); | 
|  | 42 | rectProto->set_top(rect.top); | 
|  | 43 | rectProto->set_bottom(rect.bottom); | 
|  | 44 | rectProto->set_right(rect.right); | 
|  | 45 | } | 
|  | 46 |  | 
| chaviw | 1d04428 | 2017-09-27 12:19:28 -0700 | [diff] [blame] | 47 | void LayerProtoHelper::writeToProto(const half4 color, ColorProto* colorProto) { | 
|  | 48 | colorProto->set_r(color.r); | 
|  | 49 | colorProto->set_g(color.g); | 
|  | 50 | colorProto->set_b(color.b); | 
|  | 51 | colorProto->set_a(color.a); | 
|  | 52 | } | 
|  | 53 |  | 
| Peiyong Lin | efefaac | 2018-08-17 12:27:51 -0700 | [diff] [blame] | 54 | void LayerProtoHelper::writeToProto(const ui::Transform& transform, | 
|  | 55 | TransformProto* transformProto) { | 
| chaviw | 1d04428 | 2017-09-27 12:19:28 -0700 | [diff] [blame] | 56 | transformProto->set_dsdx(transform[0][0]); | 
|  | 57 | transformProto->set_dtdx(transform[0][1]); | 
|  | 58 | transformProto->set_dsdy(transform[1][0]); | 
|  | 59 | transformProto->set_dtdy(transform[1][1]); | 
|  | 60 | } | 
|  | 61 |  | 
|  | 62 | void LayerProtoHelper::writeToProto(const sp<GraphicBuffer>& buffer, | 
|  | 63 | ActiveBufferProto* activeBufferProto) { | 
|  | 64 | activeBufferProto->set_width(buffer->getWidth()); | 
|  | 65 | activeBufferProto->set_height(buffer->getHeight()); | 
|  | 66 | activeBufferProto->set_stride(buffer->getStride()); | 
|  | 67 | activeBufferProto->set_format(buffer->format); | 
|  | 68 | } | 
|  | 69 |  | 
|  | 70 | } // namespace surfaceflinger | 
|  | 71 | } // namespace android |