blob: f3849bcdcd8bc07f30a8f5310e75a0417cce429e [file] [log] [blame]
chaviw0ef7caa2021-01-05 11:04:50 -08001/*
2 * Copyright 2021 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 <gui/ScreenCaptureResults.h>
18
19namespace android::gui {
20
21status_t ScreenCaptureResults::writeToParcel(android::Parcel* parcel) const {
22 if (buffer != nullptr) {
23 SAFE_PARCEL(parcel->writeBool, true);
24 SAFE_PARCEL(parcel->write, *buffer);
25 } else {
26 SAFE_PARCEL(parcel->writeBool, false);
27 }
Ady Abraham99599942021-01-27 20:27:23 -080028
29 if (fence != Fence::NO_FENCE) {
30 SAFE_PARCEL(parcel->writeBool, true);
31 SAFE_PARCEL(parcel->write, *fence);
32 } else {
33 SAFE_PARCEL(parcel->writeBool, false);
34 }
35
chaviw0ef7caa2021-01-05 11:04:50 -080036 SAFE_PARCEL(parcel->writeBool, capturedSecureLayers);
37 SAFE_PARCEL(parcel->writeUint32, static_cast<uint32_t>(capturedDataspace));
38 SAFE_PARCEL(parcel->writeInt32, result);
39 return NO_ERROR;
40}
41
42status_t ScreenCaptureResults::readFromParcel(const android::Parcel* parcel) {
43 bool hasGraphicBuffer;
44 SAFE_PARCEL(parcel->readBool, &hasGraphicBuffer);
45 if (hasGraphicBuffer) {
46 buffer = new GraphicBuffer();
47 SAFE_PARCEL(parcel->read, *buffer);
48 }
49
Ady Abraham99599942021-01-27 20:27:23 -080050 bool hasFence;
51 SAFE_PARCEL(parcel->readBool, &hasFence);
52 if (hasFence) {
53 fence = new Fence();
54 SAFE_PARCEL(parcel->read, *fence);
55 }
56
chaviw0ef7caa2021-01-05 11:04:50 -080057 SAFE_PARCEL(parcel->readBool, &capturedSecureLayers);
58 uint32_t dataspace = 0;
59 SAFE_PARCEL(parcel->readUint32, &dataspace);
60 capturedDataspace = static_cast<ui::Dataspace>(dataspace);
61 SAFE_PARCEL(parcel->readInt32, &result);
62 return NO_ERROR;
63}
64
65} // namespace android::gui