blob: fe387064bc5b74e90e845c92f263ea089b547226 [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);
Alec Mouri14d5b862022-04-27 21:20:04 +000039 SAFE_PARCEL(parcel->writeBool, capturedHdrLayers);
chaviw0ef7caa2021-01-05 11:04:50 -080040 SAFE_PARCEL(parcel->writeUint32, static_cast<uint32_t>(capturedDataspace));
41 SAFE_PARCEL(parcel->writeInt32, result);
42 return NO_ERROR;
43}
44
45status_t ScreenCaptureResults::readFromParcel(const android::Parcel* parcel) {
46 bool hasGraphicBuffer;
47 SAFE_PARCEL(parcel->readBool, &hasGraphicBuffer);
48 if (hasGraphicBuffer) {
49 buffer = new GraphicBuffer();
50 SAFE_PARCEL(parcel->read, *buffer);
51 }
52
Ady Abraham99599942021-01-27 20:27:23 -080053 bool hasFence;
54 SAFE_PARCEL(parcel->readBool, &hasFence);
55 if (hasFence) {
56 fence = new Fence();
57 SAFE_PARCEL(parcel->read, *fence);
58 }
59
chaviw0ef7caa2021-01-05 11:04:50 -080060 SAFE_PARCEL(parcel->readBool, &capturedSecureLayers);
Alec Mouri14d5b862022-04-27 21:20:04 +000061 SAFE_PARCEL(parcel->readBool, &capturedHdrLayers);
chaviw0ef7caa2021-01-05 11:04:50 -080062 uint32_t dataspace = 0;
63 SAFE_PARCEL(parcel->readUint32, &dataspace);
64 capturedDataspace = static_cast<ui::Dataspace>(dataspace);
65 SAFE_PARCEL(parcel->readInt32, &result);
66 return NO_ERROR;
67}
68
69} // namespace android::gui