• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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 #pragma once
18 
19 #include <stdint.h>
20 #include <sys/types.h>
21 
22 #include <binder/IBinder.h>
23 #include <binder/Parcel.h>
24 #include <binder/Parcelable.h>
25 #include <ui/GraphicTypes.h>
26 #include <ui/PixelFormat.h>
27 
28 namespace android::gui {
29 
30 struct CaptureArgs : public Parcelable {
31     const static int32_t UNSET_UID = -1;
32     virtual ~CaptureArgs() = default;
33 
34     ui::PixelFormat pixelFormat{ui::PixelFormat::RGBA_8888};
35     Rect sourceCrop;
36     float frameScaleX{1};
37     float frameScaleY{1};
38     bool captureSecureLayers{false};
39     int32_t uid{UNSET_UID};
40     // Force capture to be in a color space. If the value is ui::Dataspace::UNKNOWN, the captured
41     // result will be in the display's colorspace.
42     // The display may use non-RGB dataspace (ex. displayP3) that could cause pixel data could be
43     // different from SRGB (byte per color), and failed when checking colors in tests.
44     // NOTE: In normal cases, we want the screen to be captured in display's colorspace.
45     ui::Dataspace dataspace = ui::Dataspace::UNKNOWN;
46 
47     // The receiver of the capture can handle protected buffer. A protected buffer has
48     // GRALLOC_USAGE_PROTECTED usage bit and must not be accessed unprotected behaviour.
49     // Any read/write access from unprotected context will result in undefined behaviour.
50     // Protected contents are typically DRM contents. This has no direct implication to the
51     // secure property of the surface, which is specified by the application explicitly to avoid
52     // the contents being accessed/captured by screenshot or unsecure display.
53     bool allowProtected = false;
54 
55     bool grayscale = false;
56 
57     virtual status_t writeToParcel(Parcel* output) const;
58     virtual status_t readFromParcel(const Parcel* input);
59 };
60 
61 struct DisplayCaptureArgs : CaptureArgs {
62     sp<IBinder> displayToken;
63     uint32_t width{0};
64     uint32_t height{0};
65     bool useIdentityTransform{false};
66 
67     status_t writeToParcel(Parcel* output) const override;
68     status_t readFromParcel(const Parcel* input) override;
69 };
70 
71 }; // namespace android::gui
72