blob: 2b2948726858ebbe25f72b66d1885939f2f231d6 [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 }
28 SAFE_PARCEL(parcel->writeBool, capturedSecureLayers);
29 SAFE_PARCEL(parcel->writeUint32, static_cast<uint32_t>(capturedDataspace));
30 SAFE_PARCEL(parcel->writeInt32, result);
31 return NO_ERROR;
32}
33
34status_t ScreenCaptureResults::readFromParcel(const android::Parcel* parcel) {
35 bool hasGraphicBuffer;
36 SAFE_PARCEL(parcel->readBool, &hasGraphicBuffer);
37 if (hasGraphicBuffer) {
38 buffer = new GraphicBuffer();
39 SAFE_PARCEL(parcel->read, *buffer);
40 }
41
42 SAFE_PARCEL(parcel->readBool, &capturedSecureLayers);
43 uint32_t dataspace = 0;
44 SAFE_PARCEL(parcel->readUint32, &dataspace);
45 capturedDataspace = static_cast<ui::Dataspace>(dataspace);
46 SAFE_PARCEL(parcel->readInt32, &result);
47 return NO_ERROR;
48}
49
50} // namespace android::gui