blob: c1f481ade94610278ac717fe6ebda7ed3a9fc953 [file] [log] [blame]
Dan Stoza651bf312015-10-23 17:03:17 -07001/*
2 * Copyright 2015 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#ifndef ANDROID_SF_HWC2_H
18#define ANDROID_SF_HWC2_H
19
20#define HWC2_INCLUDE_STRINGIFICATION
21#define HWC2_USE_CPP11
22#include <hardware/hwcomposer2.h>
23#undef HWC2_INCLUDE_STRINGIFICATION
24#undef HWC2_USE_CPP11
25
Courtney Goeltzenleuchterf9c98e52018-02-12 07:23:17 -070026#include <gui/HdrMetadata.h>
Mathias Agopian1d77b712017-02-17 15:46:13 -080027#include <math/mat4.h>
Peiyong Linfd997e02018-03-28 15:29:00 -070028#include <ui/GraphicTypes.h>
Courtney Goeltzenleuchterf9c98e52018-02-12 07:23:17 -070029#include <ui/HdrCapabilities.h>
Dan Stoza651bf312015-10-23 17:03:17 -070030#include <utils/Log.h>
31#include <utils/StrongPointer.h>
32#include <utils/Timers.h>
33
34#include <functional>
35#include <string>
36#include <unordered_map>
Dan Stoza9f26a9c2016-06-22 14:51:09 -070037#include <unordered_set>
Dan Stoza651bf312015-10-23 17:03:17 -070038#include <vector>
39
Michael Wright5d22d4f2018-06-21 02:50:34 +010040#include "PowerAdvisor.h"
41
Dan Stoza651bf312015-10-23 17:03:17 -070042namespace android {
Kevin DuBois1d4249a2018-08-29 10:45:14 -070043 struct DisplayedFrameStats;
Dan Stoza651bf312015-10-23 17:03:17 -070044 class Fence;
Dan Stoza5a423ea2017-02-16 14:10:39 -080045 class FloatRect;
Dan Stoza651bf312015-10-23 17:03:17 -070046 class GraphicBuffer;
47 class Rect;
48 class Region;
Chia-I Wuaab99f52016-10-05 12:59:58 +080049 namespace Hwc2 {
50 class Composer;
Dan Stoza71bded52016-10-19 11:10:33 -070051 }
Lloyd Piquebc792092018-01-17 11:52:30 -080052
53 class TestableSurfaceFlinger;
Dan Stoza651bf312015-10-23 17:03:17 -070054}
55
56namespace HWC2 {
57
58class Display;
59class Layer;
60
Steven Thomas94e35b92017-07-26 18:48:28 -070061// Implement this interface to receive hardware composer events.
62//
63// These callback functions will generally be called on a hwbinder thread, but
64// when first registering the callback the onHotplugReceived() function will
65// immediately be called on the thread calling registerCallback().
66//
67// All calls receive a sequenceId, which will be the value that was supplied to
68// HWC2::Device::registerCallback(). It's used to help differentiate callbacks
69// from different hardware composer instances.
70class ComposerCallback {
71 public:
72 virtual void onHotplugReceived(int32_t sequenceId, hwc2_display_t display,
Lloyd Pique715a2c12017-12-14 17:18:08 -080073 Connection connection) = 0;
Steven Thomas94e35b92017-07-26 18:48:28 -070074 virtual void onRefreshReceived(int32_t sequenceId,
75 hwc2_display_t display) = 0;
76 virtual void onVsyncReceived(int32_t sequenceId, hwc2_display_t display,
77 int64_t timestamp) = 0;
78 virtual ~ComposerCallback() = default;
79};
Dan Stoza651bf312015-10-23 17:03:17 -070080
Fabien Sanglard33960702016-11-29 17:58:21 -080081// C++ Wrapper around hwc2_device_t. Load all functions pointers
82// and handle callback registration.
Dan Stoza651bf312015-10-23 17:03:17 -070083class Device
84{
85public:
Lloyd Piquea822d522017-12-20 16:42:57 -080086 explicit Device(std::unique_ptr<android::Hwc2::Composer> composer);
Dan Stoza651bf312015-10-23 17:03:17 -070087
Steven Thomas94e35b92017-07-26 18:48:28 -070088 void registerCallback(ComposerCallback* callback, int32_t sequenceId);
Dan Stoza651bf312015-10-23 17:03:17 -070089
90 // Required by HWC2
91
92 std::string dump() const;
93
Dan Stoza9f26a9c2016-06-22 14:51:09 -070094 const std::unordered_set<Capability>& getCapabilities() const {
Dan Stoza651bf312015-10-23 17:03:17 -070095 return mCapabilities;
96 };
97
98 uint32_t getMaxVirtualDisplayCount() const;
Dominik Laskowski0954b1d2018-06-13 14:58:49 -070099 Error getDisplayIdentificationData(hwc2_display_t hwcDisplayId, uint8_t* outPort,
100 std::vector<uint8_t>* outData) const;
101
Dan Stoza651bf312015-10-23 17:03:17 -0700102 Error createVirtualDisplay(uint32_t width, uint32_t height,
Peiyong Lin34beb7a2018-03-28 11:57:12 -0700103 android::ui::PixelFormat* format, Display** outDisplay);
Steven Thomas94e35b92017-07-26 18:48:28 -0700104 void destroyDisplay(hwc2_display_t displayId);
Dan Stoza651bf312015-10-23 17:03:17 -0700105
Steven Thomas94e35b92017-07-26 18:48:28 -0700106 void onHotplug(hwc2_display_t displayId, Connection connection);
Dan Stoza651bf312015-10-23 17:03:17 -0700107
108 // Other Device methods
109
Steven Thomas94e35b92017-07-26 18:48:28 -0700110 Display* getDisplayById(hwc2_display_t id);
Dan Stoza09e7a272016-04-14 12:31:01 -0700111
Hendrik Wagenaar87670ff2017-02-01 12:10:46 -0800112 android::Hwc2::Composer* getComposer() { return mComposer.get(); }
Hendrik Wagenaar87670ff2017-02-01 12:10:46 -0800113
Chia-I Wuae5a6b82017-10-10 09:09:22 -0700114 // We buffer most state changes and flush them implicitly with
115 // Display::validate, Display::present, and Display::presentOrValidate.
116 // This method provides an explicit way to flush state changes to HWC.
117 Error flushCommands();
118
Dan Stoza651bf312015-10-23 17:03:17 -0700119private:
120 // Initialization methods
121
Dan Stoza651bf312015-10-23 17:03:17 -0700122 void loadCapabilities();
Dan Stoza651bf312015-10-23 17:03:17 -0700123
124 // Member variables
Chia-I Wuaab99f52016-10-05 12:59:58 +0800125 std::unique_ptr<android::Hwc2::Composer> mComposer;
Dan Stoza9f26a9c2016-06-22 14:51:09 -0700126 std::unordered_set<Capability> mCapabilities;
Steven Thomas94e35b92017-07-26 18:48:28 -0700127 std::unordered_map<hwc2_display_t, std::unique_ptr<Display>> mDisplays;
Michael Wright5d22d4f2018-06-21 02:50:34 +0100128 android::Hwc2::impl::PowerAdvisor mPowerAdvisor;
Lloyd Piquea822d522017-12-20 16:42:57 -0800129 bool mRegisteredCallback = false;
Dan Stoza651bf312015-10-23 17:03:17 -0700130};
131
Fabien Sanglard33960702016-11-29 17:58:21 -0800132// Convenience C++ class to access hwc2_device_t Display functions directly.
Ana Krulec4593b692019-01-11 22:07:25 -0800133class Display {
Dan Stoza651bf312015-10-23 17:03:17 -0700134public:
Ana Krulec4593b692019-01-11 22:07:25 -0800135 virtual ~Display();
Dan Stoza651bf312015-10-23 17:03:17 -0700136
Ana Krulec4593b692019-01-11 22:07:25 -0800137 class Config {
Dan Stoza651bf312015-10-23 17:03:17 -0700138 public:
139 class Builder
140 {
141 public:
142 Builder(Display& display, hwc2_config_t id);
143
144 std::shared_ptr<const Config> build() {
145 return std::const_pointer_cast<const Config>(
146 std::move(mConfig));
147 }
148
149 Builder& setWidth(int32_t width) {
150 mConfig->mWidth = width;
151 return *this;
152 }
153 Builder& setHeight(int32_t height) {
154 mConfig->mHeight = height;
155 return *this;
156 }
157 Builder& setVsyncPeriod(int32_t vsyncPeriod) {
158 mConfig->mVsyncPeriod = vsyncPeriod;
159 return *this;
160 }
161 Builder& setDpiX(int32_t dpiX) {
162 if (dpiX == -1) {
163 mConfig->mDpiX = getDefaultDensity();
164 } else {
165 mConfig->mDpiX = dpiX / 1000.0f;
166 }
167 return *this;
168 }
169 Builder& setDpiY(int32_t dpiY) {
170 if (dpiY == -1) {
171 mConfig->mDpiY = getDefaultDensity();
172 } else {
173 mConfig->mDpiY = dpiY / 1000.0f;
174 }
175 return *this;
176 }
177
178 private:
179 float getDefaultDensity();
180 std::shared_ptr<Config> mConfig;
181 };
182
183 hwc2_display_t getDisplayId() const { return mDisplay.getId(); }
184 hwc2_config_t getId() const { return mId; }
185
186 int32_t getWidth() const { return mWidth; }
187 int32_t getHeight() const { return mHeight; }
David Sodman1afa8b02018-10-15 11:20:48 -0700188 nsecs_t getVsyncPeriod() const { return mVsyncPeriod; }
Dan Stoza651bf312015-10-23 17:03:17 -0700189 float getDpiX() const { return mDpiX; }
190 float getDpiY() const { return mDpiY; }
191
192 private:
193 Config(Display& display, hwc2_config_t id);
194
195 Display& mDisplay;
196 hwc2_config_t mId;
197
198 int32_t mWidth;
199 int32_t mHeight;
200 nsecs_t mVsyncPeriod;
201 float mDpiX;
202 float mDpiY;
203 };
204
Ana Krulec4593b692019-01-11 22:07:25 -0800205 virtual hwc2_display_t getId() const = 0;
206 virtual bool isConnected() const = 0;
207 virtual void setConnected(bool connected) = 0; // For use by Device only
208 virtual const std::unordered_set<DisplayCapability>& getCapabilities() const = 0;
Dan Stoza651bf312015-10-23 17:03:17 -0700209
Ana Krulec4593b692019-01-11 22:07:25 -0800210 [[clang::warn_unused_result]] virtual Error acceptChanges() = 0;
211 [[clang::warn_unused_result]] virtual Error createLayer(Layer** outLayer) = 0;
212 [[clang::warn_unused_result]] virtual Error destroyLayer(Layer* layer) = 0;
213 [[clang::warn_unused_result]] virtual Error getActiveConfig(
214 std::shared_ptr<const Config>* outConfig) const = 0;
215 [[clang::warn_unused_result]] virtual Error getActiveConfigIndex(int* outIndex) const = 0;
216 [[clang::warn_unused_result]] virtual Error getChangedCompositionTypes(
217 std::unordered_map<Layer*, Composition>* outTypes) = 0;
218 [[clang::warn_unused_result]] virtual Error getColorModes(
219 std::vector<android::ui::ColorMode>* outModes) const = 0;
Chia-I Wud7e01d72018-06-21 13:39:09 +0800220 // Returns a bitmask which contains HdrMetadata::Type::*.
Ana Krulec4593b692019-01-11 22:07:25 -0800221 [[clang::warn_unused_result]] virtual int32_t getSupportedPerFrameMetadata() const = 0;
222 [[clang::warn_unused_result]] virtual Error getRenderIntents(
Peiyong Lin0e7a7912018-04-05 14:36:36 -0700223 android::ui::ColorMode colorMode,
Ana Krulec4593b692019-01-11 22:07:25 -0800224 std::vector<android::ui::RenderIntent>* outRenderIntents) const = 0;
225 [[clang::warn_unused_result]] virtual Error getDataspaceSaturationMatrix(
226 android::ui::Dataspace dataspace, android::mat4* outMatrix) = 0;
227
228 // Doesn't call into the HWC2 device, so no Errors are possible
229 virtual std::vector<std::shared_ptr<const Config>> getConfigs() const = 0;
230
231 [[clang::warn_unused_result]] virtual Error getName(std::string* outName) const = 0;
232 [[clang::warn_unused_result]] virtual Error getRequests(
233 DisplayRequest* outDisplayRequests,
234 std::unordered_map<Layer*, LayerRequest>* outLayerRequests) = 0;
235 [[clang::warn_unused_result]] virtual Error getType(DisplayType* outType) const = 0;
236 [[clang::warn_unused_result]] virtual Error supportsDoze(bool* outSupport) const = 0;
237 [[clang::warn_unused_result]] virtual Error getHdrCapabilities(
238 android::HdrCapabilities* outCapabilities) const = 0;
239 [[clang::warn_unused_result]] virtual Error getDisplayedContentSamplingAttributes(
240 android::ui::PixelFormat* outFormat, android::ui::Dataspace* outDataspace,
241 uint8_t* outComponentMask) const = 0;
242 [[clang::warn_unused_result]] virtual Error setDisplayContentSamplingEnabled(
243 bool enabled, uint8_t componentMask, uint64_t maxFrames) const = 0;
244 [[clang::warn_unused_result]] virtual Error getDisplayedContentSample(
245 uint64_t maxFrames, uint64_t timestamp,
246 android::DisplayedFrameStats* outStats) const = 0;
247 [[clang::warn_unused_result]] virtual Error getReleaseFences(
248 std::unordered_map<Layer*, android::sp<android::Fence>>* outFences) const = 0;
249 [[clang::warn_unused_result]] virtual Error present(
250 android::sp<android::Fence>* outPresentFence) = 0;
251 [[clang::warn_unused_result]] virtual Error setActiveConfig(
252 const std::shared_ptr<const Config>& config) = 0;
253 [[clang::warn_unused_result]] virtual Error setClientTarget(
254 uint32_t slot, const android::sp<android::GraphicBuffer>& target,
255 const android::sp<android::Fence>& acquireFence, android::ui::Dataspace dataspace) = 0;
256 [[clang::warn_unused_result]] virtual Error setColorMode(
257 android::ui::ColorMode mode, android::ui::RenderIntent renderIntent) = 0;
258 [[clang::warn_unused_result]] virtual Error setColorTransform(
259 const android::mat4& matrix, android_color_transform_t hint) = 0;
260 [[clang::warn_unused_result]] virtual Error setOutputBuffer(
261 const android::sp<android::GraphicBuffer>& buffer,
262 const android::sp<android::Fence>& releaseFence) = 0;
263 [[clang::warn_unused_result]] virtual Error setPowerMode(PowerMode mode) = 0;
264 [[clang::warn_unused_result]] virtual Error setVsyncEnabled(Vsync enabled) = 0;
265 [[clang::warn_unused_result]] virtual Error validate(uint32_t* outNumTypes,
266 uint32_t* outNumRequests) = 0;
267 [[clang::warn_unused_result]] virtual Error presentOrValidate(
268 uint32_t* outNumTypes, uint32_t* outNumRequests,
269 android::sp<android::Fence>* outPresentFence, uint32_t* state) = 0;
270};
271
272namespace impl {
273
274class Display : public HWC2::Display {
275public:
276 Display(android::Hwc2::Composer& composer, android::Hwc2::PowerAdvisor& advisor,
277 const std::unordered_set<Capability>& capabilities, hwc2_display_t id,
278 DisplayType type);
279 ~Display() override;
280
281 // Required by HWC2
282 Error acceptChanges() override;
283 Error createLayer(Layer** outLayer) override;
284 Error destroyLayer(Layer* layer) override;
285 Error getActiveConfig(std::shared_ptr<const Config>* outConfig) const override;
286 Error getActiveConfigIndex(int* outIndex) const override;
287 Error getChangedCompositionTypes(std::unordered_map<Layer*, Composition>* outTypes) override;
288 Error getColorModes(std::vector<android::ui::ColorMode>* outModes) const override;
289 // Returns a bitmask which contains HdrMetadata::Type::*.
290 int32_t getSupportedPerFrameMetadata() const override;
291 Error getRenderIntents(android::ui::ColorMode colorMode,
292 std::vector<android::ui::RenderIntent>* outRenderIntents) const override;
293 Error getDataspaceSaturationMatrix(android::ui::Dataspace dataspace,
294 android::mat4* outMatrix) override;
Dan Stoza651bf312015-10-23 17:03:17 -0700295
296 // Doesn't call into the HWC2 device, so no errors are possible
Ana Krulec4593b692019-01-11 22:07:25 -0800297 std::vector<std::shared_ptr<const Config>> getConfigs() const override;
Dan Stoza651bf312015-10-23 17:03:17 -0700298
Ana Krulec4593b692019-01-11 22:07:25 -0800299 Error getName(std::string* outName) const override;
300 Error getRequests(DisplayRequest* outDisplayRequests,
301 std::unordered_map<Layer*, LayerRequest>* outLayerRequests) override;
302 Error getType(DisplayType* outType) const override;
303 Error supportsDoze(bool* outSupport) const override;
304 Error getHdrCapabilities(android::HdrCapabilities* outCapabilities) const override;
305 Error getDisplayedContentSamplingAttributes(android::ui::PixelFormat* outFormat,
306 android::ui::Dataspace* outDataspace,
307 uint8_t* outComponentMask) const override;
308 Error setDisplayContentSamplingEnabled(bool enabled, uint8_t componentMask,
309 uint64_t maxFrames) const override;
310 Error getDisplayedContentSample(uint64_t maxFrames, uint64_t timestamp,
311 android::DisplayedFrameStats* outStats) const override;
312 Error getReleaseFences(
313 std::unordered_map<Layer*, android::sp<android::Fence>>* outFences) const override;
314 Error present(android::sp<android::Fence>* outPresentFence) override;
315 Error setActiveConfig(const std::shared_ptr<const HWC2::Display::Config>& config) override;
316 Error setClientTarget(uint32_t slot, const android::sp<android::GraphicBuffer>& target,
317 const android::sp<android::Fence>& acquireFence,
318 android::ui::Dataspace dataspace) override;
319 Error setColorMode(android::ui::ColorMode mode,
320 android::ui::RenderIntent renderIntent) override;
321 Error setColorTransform(const android::mat4& matrix, android_color_transform_t hint) override;
322 Error setOutputBuffer(const android::sp<android::GraphicBuffer>& buffer,
323 const android::sp<android::Fence>& releaseFence) override;
324 Error setPowerMode(PowerMode mode) override;
325 Error setVsyncEnabled(Vsync enabled) override;
326 Error validate(uint32_t* outNumTypes, uint32_t* outNumRequests) override;
327 Error presentOrValidate(uint32_t* outNumTypes, uint32_t* outNumRequests,
328 android::sp<android::Fence>* outPresentFence, uint32_t* state) override;
Dan Stoza651bf312015-10-23 17:03:17 -0700329
330 // Other Display methods
Ana Krulec4593b692019-01-11 22:07:25 -0800331 hwc2_display_t getId() const override { return mId; }
332 bool isConnected() const override { return mIsConnected; }
333 void setConnected(bool connected) override; // For use by Device only
334 const std::unordered_set<DisplayCapability>& getCapabilities() const override {
Peiyong Lined531a32018-10-26 18:27:56 -0700335 return mDisplayCapabilities;
336 };
Dan Stoza651bf312015-10-23 17:03:17 -0700337
338private:
Dan Stoza651bf312015-10-23 17:03:17 -0700339 int32_t getAttribute(hwc2_config_t configId, Attribute attribute);
340 void loadConfig(hwc2_config_t configId);
341 void loadConfigs();
342
Dan Stoza651bf312015-10-23 17:03:17 -0700343 // This may fail (and return a null pointer) if no layer with this ID exists
344 // on this display
Steven Thomas94e35b92017-07-26 18:48:28 -0700345 Layer* getLayerById(hwc2_layer_t id) const;
Dan Stoza651bf312015-10-23 17:03:17 -0700346
Lloyd Piquebc792092018-01-17 11:52:30 -0800347 friend android::TestableSurfaceFlinger;
348
Dan Stoza651bf312015-10-23 17:03:17 -0700349 // Member variables
350
Steven Thomas94e35b92017-07-26 18:48:28 -0700351 // These are references to data owned by HWC2::Device, which will outlive
352 // this HWC2::Display, so these references are guaranteed to be valid for
353 // the lifetime of this object.
354 android::Hwc2::Composer& mComposer;
Michael Wright5d22d4f2018-06-21 02:50:34 +0100355 android::Hwc2::PowerAdvisor& mPowerAdvisor;
Steven Thomas94e35b92017-07-26 18:48:28 -0700356 const std::unordered_set<Capability>& mCapabilities;
357
Dan Stoza651bf312015-10-23 17:03:17 -0700358 hwc2_display_t mId;
359 bool mIsConnected;
Chris Forbes016d73c2017-04-11 10:04:31 -0700360 DisplayType mType;
Steven Thomas94e35b92017-07-26 18:48:28 -0700361 std::unordered_map<hwc2_layer_t, std::unique_ptr<Layer>> mLayers;
Lloyd Pique3c085a02018-05-09 19:38:32 -0700362 std::unordered_map<hwc2_config_t, std::shared_ptr<const Config>> mConfigs;
Peiyong Lined531a32018-10-26 18:27:56 -0700363 std::unordered_set<DisplayCapability> mDisplayCapabilities;
Dan Stoza651bf312015-10-23 17:03:17 -0700364};
Ana Krulec4593b692019-01-11 22:07:25 -0800365} // namespace impl
Dan Stoza651bf312015-10-23 17:03:17 -0700366
Fabien Sanglard33960702016-11-29 17:58:21 -0800367// Convenience C++ class to access hwc2_device_t Layer functions directly.
Dan Stoza651bf312015-10-23 17:03:17 -0700368class Layer
369{
370public:
Steven Thomas94e35b92017-07-26 18:48:28 -0700371 Layer(android::Hwc2::Composer& composer,
372 const std::unordered_set<Capability>& capabilities,
373 hwc2_display_t displayId, hwc2_layer_t layerId);
Dan Stoza651bf312015-10-23 17:03:17 -0700374 ~Layer();
375
Dan Stoza651bf312015-10-23 17:03:17 -0700376 hwc2_layer_t getId() const { return mId; }
377
Steven Thomas94e35b92017-07-26 18:48:28 -0700378 // Register a listener to be notified when the layer is destroyed. When the
379 // listener function is called, the Layer will be in the process of being
380 // destroyed, so it's not safe to call methods on it.
381 void setLayerDestroyedListener(std::function<void(Layer*)> listener);
382
Dan Stoza651bf312015-10-23 17:03:17 -0700383 [[clang::warn_unused_result]] Error setCursorPosition(int32_t x, int32_t y);
Chia-I Wu06d63de2017-01-04 14:58:51 +0800384 [[clang::warn_unused_result]] Error setBuffer(uint32_t slot,
Daniel Nicoara1f42e3a2017-04-10 13:27:32 -0400385 const android::sp<android::GraphicBuffer>& buffer,
Dan Stoza651bf312015-10-23 17:03:17 -0700386 const android::sp<android::Fence>& acquireFence);
387 [[clang::warn_unused_result]] Error setSurfaceDamage(
388 const android::Region& damage);
389
390 [[clang::warn_unused_result]] Error setBlendMode(BlendMode mode);
391 [[clang::warn_unused_result]] Error setColor(hwc_color_t color);
392 [[clang::warn_unused_result]] Error setCompositionType(Composition type);
Dan Stoza5df2a862016-03-24 16:19:37 -0700393 [[clang::warn_unused_result]] Error setDataspace(
Peiyong Lin34beb7a2018-03-28 11:57:12 -0700394 android::ui::Dataspace dataspace);
Peiyong Lin0ac5f4e2018-04-19 22:06:34 -0700395 [[clang::warn_unused_result]] Error setPerFrameMetadata(
396 const int32_t supportedPerFrameMetadata,
397 const android::HdrMetadata& metadata);
Dan Stoza651bf312015-10-23 17:03:17 -0700398 [[clang::warn_unused_result]] Error setDisplayFrame(
399 const android::Rect& frame);
400 [[clang::warn_unused_result]] Error setPlaneAlpha(float alpha);
401 [[clang::warn_unused_result]] Error setSidebandStream(
402 const native_handle_t* stream);
403 [[clang::warn_unused_result]] Error setSourceCrop(
Dan Stoza5a423ea2017-02-16 14:10:39 -0800404 const android::FloatRect& crop);
Dan Stoza651bf312015-10-23 17:03:17 -0700405 [[clang::warn_unused_result]] Error setTransform(Transform transform);
406 [[clang::warn_unused_result]] Error setVisibleRegion(
407 const android::Region& region);
408 [[clang::warn_unused_result]] Error setZOrder(uint32_t z);
Daniel Nicoara2f5f8a52016-12-20 16:11:58 -0500409 [[clang::warn_unused_result]] Error setInfo(uint32_t type, uint32_t appId);
Dan Stoza651bf312015-10-23 17:03:17 -0700410
Peiyong Lin698147a2018-09-14 13:27:18 -0700411 // Composer HAL 2.3
412 [[clang::warn_unused_result]] Error setColorTransform(const android::mat4& matrix);
413
Dan Stoza651bf312015-10-23 17:03:17 -0700414private:
Steven Thomas94e35b92017-07-26 18:48:28 -0700415 // These are references to data owned by HWC2::Device, which will outlive
416 // this HWC2::Layer, so these references are guaranteed to be valid for
417 // the lifetime of this object.
418 android::Hwc2::Composer& mComposer;
419 const std::unordered_set<Capability>& mCapabilities;
420
Dan Stoza651bf312015-10-23 17:03:17 -0700421 hwc2_display_t mDisplayId;
Dan Stoza651bf312015-10-23 17:03:17 -0700422 hwc2_layer_t mId;
Peiyong Lin34beb7a2018-03-28 11:57:12 -0700423 android::ui::Dataspace mDataSpace = android::ui::Dataspace::UNKNOWN;
Courtney Goeltzenleuchterf9c98e52018-02-12 07:23:17 -0700424 android::HdrMetadata mHdrMetadata;
Steven Thomas94e35b92017-07-26 18:48:28 -0700425 std::function<void(Layer*)> mLayerDestroyedListener;
Peiyong Lin698147a2018-09-14 13:27:18 -0700426 android::mat4 mColorMatrix;
Dan Stoza651bf312015-10-23 17:03:17 -0700427};
428
429} // namespace HWC2
430
431#endif // ANDROID_SF_HWC2_H