1 /*
2  * Copyright 2020 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 package android.graphics;
18 
19 import android.annotation.NonNull;
20 import android.util.proto.ProtoOutputStream;
21 
22 /**
23  * Utility class for creating protos from parcelable Graphics classes.
24  *
25  * @hide
26  */
27 public final class GraphicsProtos {
28     /** GraphicsProtos can never be an instance */
GraphicsProtos()29     private GraphicsProtos() {}
30 
31     /**
32      * Write to a protocol buffer output stream.
33      * Protocol buffer message definition at {@link android.graphics.PointProto}
34      *
35      * @param point             Point to serialize into a protocol buffer
36      * @param protoOutputStream Stream to write the Point object to.
37      * @param fieldId           Field Id of the Point as defined in the parent message
38      * @hide
39      */
dumpPointProto( @onNull Point point, @NonNull ProtoOutputStream protoOutputStream, long fieldId)40     public static void dumpPointProto(
41             @NonNull Point point, @NonNull ProtoOutputStream protoOutputStream, long fieldId) {
42         final long token = protoOutputStream.start(fieldId);
43         protoOutputStream.write(PointProto.X, point.x);
44         protoOutputStream.write(PointProto.Y, point.y);
45         protoOutputStream.end(token);
46     }
47 }
48 
49