blob: e91f74f3d3d516039903aba56aa4f52ea354d7ea [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
Marin Shalamanov3b1f7bc2021-03-16 15:51:53 +010019#include <private/gui/ParcelUtils.h>
20
chaviw0ef7caa2021-01-05 11:04:50 -080021namespace android::gui {
22
23status_t ScreenCaptureResults::writeToParcel(android::Parcel* parcel) const {
24 if (buffer != nullptr) {
25 SAFE_PARCEL(parcel->writeBool, true);
26 SAFE_PARCEL(parcel->write, *buffer);
27 } else {
28 SAFE_PARCEL(parcel->writeBool, false);
29 }
Ady Abraham99599942021-01-27 20:27:23 -080030
31 if (fence != Fence::NO_FENCE) {
32 SAFE_PARCEL(parcel->writeBool, true);
33 SAFE_PARCEL(parcel->write, *fence);
34 } else {
35 SAFE_PARCEL(parcel->writeBool, false);
36 }
37
chaviw0ef7caa2021-01-05 11:04:50 -080038 SAFE_PARCEL(parcel->writeBool, capturedSecureLayers);
39 SAFE_PARCEL(parcel->writeUint32, static_cast<uint32_t>(capturedDataspace));
40 SAFE_PARCEL(parcel->writeInt32, result);
41 return NO_ERROR;
42}
43
44status_t ScreenCaptureResults::readFromParcel(const android::Parcel* parcel) {
45 bool hasGraphicBuffer;
46 SAFE_PARCEL(parcel->readBool, &hasGraphicBuffer);
47 if (hasGraphicBuffer) {
48 buffer = new GraphicBuffer();
49 SAFE_PARCEL(parcel->read, *buffer);
50 }
51
Ady Abraham99599942021-01-27 20:27:23 -080052 bool hasFence;
53 SAFE_PARCEL(parcel->readBool, &hasFence);
54 if (hasFence) {
55 fence = new Fence();
56 SAFE_PARCEL(parcel->read, *fence);
57 }
58
chaviw0ef7caa2021-01-05 11:04:50 -080059 SAFE_PARCEL(parcel->readBool, &capturedSecureLayers);
60 uint32_t dataspace = 0;
61 SAFE_PARCEL(parcel->readUint32, &dataspace);
62 capturedDataspace = static_cast<ui::Dataspace>(dataspace);
63 SAFE_PARCEL(parcel->readInt32, &result);
64 return NO_ERROR;
65}
66
67} // namespace android::gui