blob: 1a8edf3e7963fef04c126710f44f97c55cfd4d59 [file] [log] [blame]
chaviwa76b2712017-09-20 12:02:26 -07001#include "RenderArea.h"
2
Iris Chang7501ed62018-04-30 14:45:42 +08003#include <gui/LayerState.h>
4
chaviwa76b2712017-09-20 12:02:26 -07005namespace android {
6
chaviw50da5042018-04-09 13:49:37 -07007float RenderArea::getCaptureFillValue(CaptureFill captureFill) {
8 switch(captureFill) {
9 case CaptureFill::CLEAR:
10 return 0.0f;
11 case CaptureFill::OPAQUE:
12 default:
13 return 1.0f;
14 }
15}
chaviwa76b2712017-09-20 12:02:26 -070016/*
17 * Checks that the requested width and height are valid and updates them to the render area
18 * dimensions if they are set to 0
19 */
Iris Chang7501ed62018-04-30 14:45:42 +080020status_t RenderArea::updateDimensions(int displayRotation) {
chaviwa76b2712017-09-20 12:02:26 -070021 // get screen geometry
22
23 uint32_t width = getWidth();
24 uint32_t height = getHeight();
25
26 if (mRotationFlags & Transform::ROT_90) {
27 std::swap(width, height);
28 }
29
Iris Chang7501ed62018-04-30 14:45:42 +080030 if (displayRotation & DisplayState::eOrientationSwapMask) {
31 std::swap(width, height);
32 }
33
chaviwa76b2712017-09-20 12:02:26 -070034 if ((mReqWidth > width) || (mReqHeight > height)) {
35 ALOGE("size mismatch (%d, %d) > (%d, %d)", mReqWidth, mReqHeight, width, height);
36 return BAD_VALUE;
37 }
38
39 if (mReqWidth == 0) {
40 mReqWidth = width;
41 }
42 if (mReqHeight == 0) {
43 mReqHeight = height;
44 }
45
46 return NO_ERROR;
47}
48
Iris Chang7501ed62018-04-30 14:45:42 +080049} // namespace android