Wed, 31 Dec 2014 07:22:50 +0100
Correct previous dual key logic pending first delivery installment.
1 /*
2 * Copyright (c) 2013, The Linux Foundation. All rights reserved.
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 */
17 #ifndef mozilla_HwcUtils
18 #define mozilla_HwcUtils
20 #include "Layers.h"
21 #include <vector>
22 #include "hardware/hwcomposer.h"
24 namespace mozilla {
26 class HwcUtils {
27 public:
29 enum {
30 HWC_USE_GPU = HWC_FRAMEBUFFER,
31 HWC_USE_OVERLAY = HWC_OVERLAY,
32 HWC_USE_COPYBIT
33 };
35 // HWC layer flags
36 enum {
37 // Draw a solid color rectangle
38 // The color should be set on the transform member of the hwc_layer_t struct
39 // The expected format is a 32 bit ABGR with 8 bits per component
40 HWC_COLOR_FILL = 0x8,
41 // Swap the RB pixels of gralloc buffer, like RGBA<->BGRA or RGBX<->BGRX
42 // The flag will be set inside LayerRenderState
43 HWC_FORMAT_RB_SWAP = 0x40
44 };
46 typedef std::vector<hwc_rect_t> RectVector;
48 /* Utility functions - implemented in HwcUtils.cpp */
50 /**
51 * Calculates the layer's clipping rectangle
52 *
53 * @param aTransform Input. A transformation matrix
54 * It transforms the clip rect to screen space
55 * @param aLayerClip Input. The layer's internal clipping rectangle.
56 * This may be NULL which means the layer has no internal clipping
57 * The origin is the top-left corner of the layer
58 * @param aParentClip Input. The parent layer's rendering clipping rectangle
59 * The origin is the top-left corner of the screen
60 * @param aRenderClip Output. The layer's rendering clipping rectangle
61 * The origin is the top-left corner of the screen
62 * @return true if the layer should be rendered.
63 * false if the layer can be skipped
64 */
65 static bool CalculateClipRect(const gfxMatrix& aTransform,
66 const nsIntRect* aLayerClip,
67 nsIntRect aParentClip, nsIntRect* aRenderClip);
70 /**
71 * Prepares hwc layer visible region required for hwc composition
72 *
73 * @param aVisible Input. Layer's unclipped visible region
74 * The origin is the top-left corner of the layer
75 * @param aTransform Input. Layer's transformation matrix
76 * It transforms from layer space to screen space
77 * @param aClip Input. A clipping rectangle.
78 * The origin is the top-left corner of the screen
79 * @param aBufferRect Input. The layer's buffer bounds
80 * The origin is the top-left corner of the layer
81 * @param aVisibleRegionScreen Output. Visible region in screen space.
82 * The origin is the top-left corner of the screen
83 * @return true if the layer should be rendered.
84 * false if the layer can be skipped
85 */
86 static bool PrepareVisibleRegion(const nsIntRegion& aVisible,
87 const gfxMatrix& aTransform,
88 nsIntRect aClip, nsIntRect aBufferRect,
89 RectVector* aVisibleRegionScreen);
92 /**
93 * Sets hwc layer rectangles required for hwc composition
94 *
95 * @param aVisible Input. Layer's unclipped visible rectangle
96 * The origin is the top-left corner of the layer
97 * @param aTransform Input. Layer's transformation matrix
98 * It transforms from layer space to screen space
99 * @param aClip Input. A clipping rectangle.
100 * The origin is the top-left corner of the screen
101 * @param aBufferRect Input. The layer's buffer bounds
102 * The origin is the top-left corner of the layer
103 * @param aYFlipped Input. true if the buffer is rendered as Y flipped
104 * @param aSurceCrop Output. Area of the source to consider,
105 * the origin is the top-left corner of the buffer
106 * @param aVisibleRegionScreen Output. Visible region in screen space.
107 * The origin is the top-left corner of the screen
108 * @return true if the layer should be rendered.
109 * false if the layer can be skipped
110 */
111 static bool PrepareLayerRects(nsIntRect aVisible, const gfxMatrix& aTransform,
112 nsIntRect aClip, nsIntRect aBufferRect,
113 bool aYFlipped,
114 hwc_rect_t* aSourceCrop,
115 hwc_rect_t* aVisibleRegionScreen);
117 };
119 } // namespace mozilla
121 #endif // mozilla_HwcUtils