blob: f96614fc964ac067c3392f576ba6fabf74dd5a0c [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
40namespace android {
Kevin DuBois1d4249a2018-08-29 10:45:14 -070041 struct DisplayedFrameStats;
Dan Stoza651bf312015-10-23 17:03:17 -070042 class Fence;
Dan Stoza5a423ea2017-02-16 14:10:39 -080043 class FloatRect;
Dan Stoza651bf312015-10-23 17:03:17 -070044 class GraphicBuffer;
45 class Rect;
46 class Region;
Chia-I Wuaab99f52016-10-05 12:59:58 +080047 namespace Hwc2 {
48 class Composer;
Dan Stoza71bded52016-10-19 11:10:33 -070049 }
Lloyd Piquebc792092018-01-17 11:52:30 -080050
51 class TestableSurfaceFlinger;
Dan Stoza651bf312015-10-23 17:03:17 -070052}
53
54namespace HWC2 {
55
56class Display;
57class Layer;
58
Steven Thomas94e35b92017-07-26 18:48:28 -070059// Implement this interface to receive hardware composer events.
60//
61// These callback functions will generally be called on a hwbinder thread, but
62// when first registering the callback the onHotplugReceived() function will
63// immediately be called on the thread calling registerCallback().
64//
65// All calls receive a sequenceId, which will be the value that was supplied to
66// HWC2::Device::registerCallback(). It's used to help differentiate callbacks
67// from different hardware composer instances.
68class ComposerCallback {
69 public:
70 virtual void onHotplugReceived(int32_t sequenceId, hwc2_display_t display,
Lloyd Pique715a2c12017-12-14 17:18:08 -080071 Connection connection) = 0;
Steven Thomas94e35b92017-07-26 18:48:28 -070072 virtual void onRefreshReceived(int32_t sequenceId,
73 hwc2_display_t display) = 0;
74 virtual void onVsyncReceived(int32_t sequenceId, hwc2_display_t display,
75 int64_t timestamp) = 0;
76 virtual ~ComposerCallback() = default;
77};
Dan Stoza651bf312015-10-23 17:03:17 -070078
Fabien Sanglard33960702016-11-29 17:58:21 -080079// C++ Wrapper around hwc2_device_t. Load all functions pointers
80// and handle callback registration.
Dan Stoza651bf312015-10-23 17:03:17 -070081class Device
82{
83public:
Lloyd Piquea822d522017-12-20 16:42:57 -080084 explicit Device(std::unique_ptr<android::Hwc2::Composer> composer);
Dan Stoza651bf312015-10-23 17:03:17 -070085
Steven Thomas94e35b92017-07-26 18:48:28 -070086 void registerCallback(ComposerCallback* callback, int32_t sequenceId);
Dan Stoza651bf312015-10-23 17:03:17 -070087
88 // Required by HWC2
89
90 std::string dump() const;
91
Dan Stoza9f26a9c2016-06-22 14:51:09 -070092 const std::unordered_set<Capability>& getCapabilities() const {
Dan Stoza651bf312015-10-23 17:03:17 -070093 return mCapabilities;
94 };
95
96 uint32_t getMaxVirtualDisplayCount() const;
Dominik Laskowski0954b1d2018-06-13 14:58:49 -070097 Error getDisplayIdentificationData(hwc2_display_t hwcDisplayId, uint8_t* outPort,
98 std::vector<uint8_t>* outData) const;
99
Dan Stoza651bf312015-10-23 17:03:17 -0700100 Error createVirtualDisplay(uint32_t width, uint32_t height,
Peiyong Lin34beb7a2018-03-28 11:57:12 -0700101 android::ui::PixelFormat* format, Display** outDisplay);
Steven Thomas94e35b92017-07-26 18:48:28 -0700102 void destroyDisplay(hwc2_display_t displayId);
Dan Stoza651bf312015-10-23 17:03:17 -0700103
Steven Thomas94e35b92017-07-26 18:48:28 -0700104 void onHotplug(hwc2_display_t displayId, Connection connection);
Dan Stoza651bf312015-10-23 17:03:17 -0700105
106 // Other Device methods
107
Steven Thomas94e35b92017-07-26 18:48:28 -0700108 Display* getDisplayById(hwc2_display_t id);
Dan Stoza09e7a272016-04-14 12:31:01 -0700109
Hendrik Wagenaar87670ff2017-02-01 12:10:46 -0800110 android::Hwc2::Composer* getComposer() { return mComposer.get(); }
Hendrik Wagenaar87670ff2017-02-01 12:10:46 -0800111
Chia-I Wuae5a6b82017-10-10 09:09:22 -0700112 // We buffer most state changes and flush them implicitly with
113 // Display::validate, Display::present, and Display::presentOrValidate.
114 // This method provides an explicit way to flush state changes to HWC.
115 Error flushCommands();
116
Dan Stoza651bf312015-10-23 17:03:17 -0700117private:
118 // Initialization methods
119
Dan Stoza651bf312015-10-23 17:03:17 -0700120 void loadCapabilities();
Dan Stoza651bf312015-10-23 17:03:17 -0700121
122 // Member variables
Chia-I Wuaab99f52016-10-05 12:59:58 +0800123 std::unique_ptr<android::Hwc2::Composer> mComposer;
Dan Stoza9f26a9c2016-06-22 14:51:09 -0700124 std::unordered_set<Capability> mCapabilities;
Steven Thomas94e35b92017-07-26 18:48:28 -0700125 std::unordered_map<hwc2_display_t, std::unique_ptr<Display>> mDisplays;
Lloyd Piquea822d522017-12-20 16:42:57 -0800126 bool mRegisteredCallback = false;
Dan Stoza651bf312015-10-23 17:03:17 -0700127};
128
Fabien Sanglard33960702016-11-29 17:58:21 -0800129// Convenience C++ class to access hwc2_device_t Display functions directly.
Ana Krulec4593b692019-01-11 22:07:25 -0800130class Display {
Dan Stoza651bf312015-10-23 17:03:17 -0700131public:
Ana Krulec4593b692019-01-11 22:07:25 -0800132 virtual ~Display();
Dan Stoza651bf312015-10-23 17:03:17 -0700133
Ana Krulec4593b692019-01-11 22:07:25 -0800134 class Config {
Dan Stoza651bf312015-10-23 17:03:17 -0700135 public:
136 class Builder
137 {
138 public:
139 Builder(Display& display, hwc2_config_t id);
140
141 std::shared_ptr<const Config> build() {
142 return std::const_pointer_cast<const Config>(
143 std::move(mConfig));
144 }
145
146 Builder& setWidth(int32_t width) {
147 mConfig->mWidth = width;
148 return *this;
149 }
150 Builder& setHeight(int32_t height) {
151 mConfig->mHeight = height;
152 return *this;
153 }
154 Builder& setVsyncPeriod(int32_t vsyncPeriod) {
155 mConfig->mVsyncPeriod = vsyncPeriod;
156 return *this;
157 }
158 Builder& setDpiX(int32_t dpiX) {
159 if (dpiX == -1) {
160 mConfig->mDpiX = getDefaultDensity();
161 } else {
162 mConfig->mDpiX = dpiX / 1000.0f;
163 }
164 return *this;
165 }
166 Builder& setDpiY(int32_t dpiY) {
167 if (dpiY == -1) {
168 mConfig->mDpiY = getDefaultDensity();
169 } else {
170 mConfig->mDpiY = dpiY / 1000.0f;
171 }
172 return *this;
173 }
174
175 private:
176 float getDefaultDensity();
177 std::shared_ptr<Config> mConfig;
178 };
179
180 hwc2_display_t getDisplayId() const { return mDisplay.getId(); }
181 hwc2_config_t getId() const { return mId; }
182
183 int32_t getWidth() const { return mWidth; }
184 int32_t getHeight() const { return mHeight; }
David Sodman1afa8b02018-10-15 11:20:48 -0700185 nsecs_t getVsyncPeriod() const { return mVsyncPeriod; }
Dan Stoza651bf312015-10-23 17:03:17 -0700186 float getDpiX() const { return mDpiX; }
187 float getDpiY() const { return mDpiY; }
188
189 private:
190 Config(Display& display, hwc2_config_t id);
191
192 Display& mDisplay;
193 hwc2_config_t mId;
194
195 int32_t mWidth;
196 int32_t mHeight;
197 nsecs_t mVsyncPeriod;
198 float mDpiX;
199 float mDpiY;
200 };
201
Ana Krulec4593b692019-01-11 22:07:25 -0800202 virtual hwc2_display_t getId() const = 0;
203 virtual bool isConnected() const = 0;
204 virtual void setConnected(bool connected) = 0; // For use by Device only
205 virtual const std::unordered_set<DisplayCapability>& getCapabilities() const = 0;
Dan Stoza651bf312015-10-23 17:03:17 -0700206
Ana Krulec4593b692019-01-11 22:07:25 -0800207 [[clang::warn_unused_result]] virtual Error acceptChanges() = 0;
208 [[clang::warn_unused_result]] virtual Error createLayer(Layer** outLayer) = 0;
209 [[clang::warn_unused_result]] virtual Error destroyLayer(Layer* layer) = 0;
210 [[clang::warn_unused_result]] virtual Error getActiveConfig(
211 std::shared_ptr<const Config>* outConfig) const = 0;
212 [[clang::warn_unused_result]] virtual Error getActiveConfigIndex(int* outIndex) const = 0;
213 [[clang::warn_unused_result]] virtual Error getChangedCompositionTypes(
214 std::unordered_map<Layer*, Composition>* outTypes) = 0;
215 [[clang::warn_unused_result]] virtual Error getColorModes(
216 std::vector<android::ui::ColorMode>* outModes) const = 0;
Chia-I Wud7e01d72018-06-21 13:39:09 +0800217 // Returns a bitmask which contains HdrMetadata::Type::*.
Ana Krulec4593b692019-01-11 22:07:25 -0800218 [[clang::warn_unused_result]] virtual int32_t getSupportedPerFrameMetadata() const = 0;
219 [[clang::warn_unused_result]] virtual Error getRenderIntents(
Peiyong Lin0e7a7912018-04-05 14:36:36 -0700220 android::ui::ColorMode colorMode,
Ana Krulec4593b692019-01-11 22:07:25 -0800221 std::vector<android::ui::RenderIntent>* outRenderIntents) const = 0;
222 [[clang::warn_unused_result]] virtual Error getDataspaceSaturationMatrix(
223 android::ui::Dataspace dataspace, android::mat4* outMatrix) = 0;
224
225 // Doesn't call into the HWC2 device, so no Errors are possible
226 virtual std::vector<std::shared_ptr<const Config>> getConfigs() const = 0;
227
228 [[clang::warn_unused_result]] virtual Error getName(std::string* outName) const = 0;
229 [[clang::warn_unused_result]] virtual Error getRequests(
230 DisplayRequest* outDisplayRequests,
231 std::unordered_map<Layer*, LayerRequest>* outLayerRequests) = 0;
232 [[clang::warn_unused_result]] virtual Error getType(DisplayType* outType) const = 0;
233 [[clang::warn_unused_result]] virtual Error supportsDoze(bool* outSupport) const = 0;
234 [[clang::warn_unused_result]] virtual Error getHdrCapabilities(
235 android::HdrCapabilities* outCapabilities) const = 0;
236 [[clang::warn_unused_result]] virtual Error getDisplayedContentSamplingAttributes(
237 android::ui::PixelFormat* outFormat, android::ui::Dataspace* outDataspace,
238 uint8_t* outComponentMask) const = 0;
239 [[clang::warn_unused_result]] virtual Error setDisplayContentSamplingEnabled(
240 bool enabled, uint8_t componentMask, uint64_t maxFrames) const = 0;
241 [[clang::warn_unused_result]] virtual Error getDisplayedContentSample(
242 uint64_t maxFrames, uint64_t timestamp,
243 android::DisplayedFrameStats* outStats) const = 0;
244 [[clang::warn_unused_result]] virtual Error getReleaseFences(
245 std::unordered_map<Layer*, android::sp<android::Fence>>* outFences) const = 0;
246 [[clang::warn_unused_result]] virtual Error present(
247 android::sp<android::Fence>* outPresentFence) = 0;
248 [[clang::warn_unused_result]] virtual Error setActiveConfig(
249 const std::shared_ptr<const Config>& config) = 0;
250 [[clang::warn_unused_result]] virtual Error setClientTarget(
251 uint32_t slot, const android::sp<android::GraphicBuffer>& target,
252 const android::sp<android::Fence>& acquireFence, android::ui::Dataspace dataspace) = 0;
253 [[clang::warn_unused_result]] virtual Error setColorMode(
254 android::ui::ColorMode mode, android::ui::RenderIntent renderIntent) = 0;
255 [[clang::warn_unused_result]] virtual Error setColorTransform(
256 const android::mat4& matrix, android_color_transform_t hint) = 0;
257 [[clang::warn_unused_result]] virtual Error setOutputBuffer(
258 const android::sp<android::GraphicBuffer>& buffer,
259 const android::sp<android::Fence>& releaseFence) = 0;
260 [[clang::warn_unused_result]] virtual Error setPowerMode(PowerMode mode) = 0;
261 [[clang::warn_unused_result]] virtual Error setVsyncEnabled(Vsync enabled) = 0;
262 [[clang::warn_unused_result]] virtual Error validate(uint32_t* outNumTypes,
263 uint32_t* outNumRequests) = 0;
264 [[clang::warn_unused_result]] virtual Error presentOrValidate(
265 uint32_t* outNumTypes, uint32_t* outNumRequests,
266 android::sp<android::Fence>* outPresentFence, uint32_t* state) = 0;
267};
268
269namespace impl {
270
271class Display : public HWC2::Display {
272public:
Peiyong Lin74ca2f42019-01-14 19:36:57 -0800273 Display(android::Hwc2::Composer& composer, const std::unordered_set<Capability>& capabilities,
274 hwc2_display_t id, DisplayType type);
Ana Krulec4593b692019-01-11 22:07:25 -0800275 ~Display() override;
276
277 // Required by HWC2
278 Error acceptChanges() override;
279 Error createLayer(Layer** outLayer) override;
280 Error destroyLayer(Layer* layer) override;
281 Error getActiveConfig(std::shared_ptr<const Config>* outConfig) const override;
282 Error getActiveConfigIndex(int* outIndex) const override;
283 Error getChangedCompositionTypes(std::unordered_map<Layer*, Composition>* outTypes) override;
284 Error getColorModes(std::vector<android::ui::ColorMode>* outModes) const override;
285 // Returns a bitmask which contains HdrMetadata::Type::*.
286 int32_t getSupportedPerFrameMetadata() const override;
287 Error getRenderIntents(android::ui::ColorMode colorMode,
288 std::vector<android::ui::RenderIntent>* outRenderIntents) const override;
289 Error getDataspaceSaturationMatrix(android::ui::Dataspace dataspace,
290 android::mat4* outMatrix) override;
Dan Stoza651bf312015-10-23 17:03:17 -0700291
292 // Doesn't call into the HWC2 device, so no errors are possible
Ana Krulec4593b692019-01-11 22:07:25 -0800293 std::vector<std::shared_ptr<const Config>> getConfigs() const override;
Dan Stoza651bf312015-10-23 17:03:17 -0700294
Ana Krulec4593b692019-01-11 22:07:25 -0800295 Error getName(std::string* outName) const override;
296 Error getRequests(DisplayRequest* outDisplayRequests,
297 std::unordered_map<Layer*, LayerRequest>* outLayerRequests) override;
298 Error getType(DisplayType* outType) const override;
299 Error supportsDoze(bool* outSupport) const override;
300 Error getHdrCapabilities(android::HdrCapabilities* outCapabilities) const override;
301 Error getDisplayedContentSamplingAttributes(android::ui::PixelFormat* outFormat,
302 android::ui::Dataspace* outDataspace,
303 uint8_t* outComponentMask) const override;
304 Error setDisplayContentSamplingEnabled(bool enabled, uint8_t componentMask,
305 uint64_t maxFrames) const override;
306 Error getDisplayedContentSample(uint64_t maxFrames, uint64_t timestamp,
307 android::DisplayedFrameStats* outStats) const override;
308 Error getReleaseFences(
309 std::unordered_map<Layer*, android::sp<android::Fence>>* outFences) const override;
310 Error present(android::sp<android::Fence>* outPresentFence) override;
311 Error setActiveConfig(const std::shared_ptr<const HWC2::Display::Config>& config) override;
312 Error setClientTarget(uint32_t slot, const android::sp<android::GraphicBuffer>& target,
313 const android::sp<android::Fence>& acquireFence,
314 android::ui::Dataspace dataspace) override;
315 Error setColorMode(android::ui::ColorMode mode,
316 android::ui::RenderIntent renderIntent) override;
317 Error setColorTransform(const android::mat4& matrix, android_color_transform_t hint) override;
318 Error setOutputBuffer(const android::sp<android::GraphicBuffer>& buffer,
319 const android::sp<android::Fence>& releaseFence) override;
320 Error setPowerMode(PowerMode mode) override;
321 Error setVsyncEnabled(Vsync enabled) override;
322 Error validate(uint32_t* outNumTypes, uint32_t* outNumRequests) override;
323 Error presentOrValidate(uint32_t* outNumTypes, uint32_t* outNumRequests,
324 android::sp<android::Fence>* outPresentFence, uint32_t* state) override;
Dan Stoza651bf312015-10-23 17:03:17 -0700325
326 // Other Display methods
Ana Krulec4593b692019-01-11 22:07:25 -0800327 hwc2_display_t getId() const override { return mId; }
328 bool isConnected() const override { return mIsConnected; }
329 void setConnected(bool connected) override; // For use by Device only
330 const std::unordered_set<DisplayCapability>& getCapabilities() const override {
Peiyong Lined531a32018-10-26 18:27:56 -0700331 return mDisplayCapabilities;
332 };
Dan Stoza651bf312015-10-23 17:03:17 -0700333
334private:
Dan Stoza651bf312015-10-23 17:03:17 -0700335 int32_t getAttribute(hwc2_config_t configId, Attribute attribute);
336 void loadConfig(hwc2_config_t configId);
337 void loadConfigs();
338
Dan Stoza651bf312015-10-23 17:03:17 -0700339 // This may fail (and return a null pointer) if no layer with this ID exists
340 // on this display
Steven Thomas94e35b92017-07-26 18:48:28 -0700341 Layer* getLayerById(hwc2_layer_t id) const;
Dan Stoza651bf312015-10-23 17:03:17 -0700342
Lloyd Piquebc792092018-01-17 11:52:30 -0800343 friend android::TestableSurfaceFlinger;
344
Dan Stoza651bf312015-10-23 17:03:17 -0700345 // Member variables
346
Steven Thomas94e35b92017-07-26 18:48:28 -0700347 // These are references to data owned by HWC2::Device, which will outlive
348 // this HWC2::Display, so these references are guaranteed to be valid for
349 // the lifetime of this object.
350 android::Hwc2::Composer& mComposer;
351 const std::unordered_set<Capability>& mCapabilities;
352
Dan Stoza651bf312015-10-23 17:03:17 -0700353 hwc2_display_t mId;
354 bool mIsConnected;
Chris Forbes016d73c2017-04-11 10:04:31 -0700355 DisplayType mType;
Steven Thomas94e35b92017-07-26 18:48:28 -0700356 std::unordered_map<hwc2_layer_t, std::unique_ptr<Layer>> mLayers;
Lloyd Pique3c085a02018-05-09 19:38:32 -0700357 std::unordered_map<hwc2_config_t, std::shared_ptr<const Config>> mConfigs;
Peiyong Lined531a32018-10-26 18:27:56 -0700358 std::unordered_set<DisplayCapability> mDisplayCapabilities;
Dan Stoza651bf312015-10-23 17:03:17 -0700359};
Ana Krulec4593b692019-01-11 22:07:25 -0800360} // namespace impl
Dan Stoza651bf312015-10-23 17:03:17 -0700361
Lloyd Pique35d58242018-12-18 16:33:25 -0800362class Layer {
363public:
364 virtual ~Layer();
365
366 virtual hwc2_layer_t getId() const = 0;
367
368 [[clang::warn_unused_result]] virtual Error setCursorPosition(int32_t x, int32_t y) = 0;
369 [[clang::warn_unused_result]] virtual Error setBuffer(
370 uint32_t slot, const android::sp<android::GraphicBuffer>& buffer,
371 const android::sp<android::Fence>& acquireFence) = 0;
372 [[clang::warn_unused_result]] virtual Error setSurfaceDamage(const android::Region& damage) = 0;
373
374 [[clang::warn_unused_result]] virtual Error setBlendMode(BlendMode mode) = 0;
375 [[clang::warn_unused_result]] virtual Error setColor(hwc_color_t color) = 0;
376 [[clang::warn_unused_result]] virtual Error setCompositionType(Composition type) = 0;
377 [[clang::warn_unused_result]] virtual Error setDataspace(android::ui::Dataspace dataspace) = 0;
378 [[clang::warn_unused_result]] virtual Error setPerFrameMetadata(
379 const int32_t supportedPerFrameMetadata, const android::HdrMetadata& metadata) = 0;
380 [[clang::warn_unused_result]] virtual Error setDisplayFrame(const android::Rect& frame) = 0;
381 [[clang::warn_unused_result]] virtual Error setPlaneAlpha(float alpha) = 0;
382 [[clang::warn_unused_result]] virtual Error setSidebandStream(
383 const native_handle_t* stream) = 0;
384 [[clang::warn_unused_result]] virtual Error setSourceCrop(const android::FloatRect& crop) = 0;
385 [[clang::warn_unused_result]] virtual Error setTransform(Transform transform) = 0;
386 [[clang::warn_unused_result]] virtual Error setVisibleRegion(const android::Region& region) = 0;
387 [[clang::warn_unused_result]] virtual Error setZOrder(uint32_t z) = 0;
388 [[clang::warn_unused_result]] virtual Error setInfo(uint32_t type, uint32_t appId) = 0;
389
390 // Composer HAL 2.3
391 [[clang::warn_unused_result]] virtual Error setColorTransform(const android::mat4& matrix) = 0;
392};
393
394namespace impl {
395
Fabien Sanglard33960702016-11-29 17:58:21 -0800396// Convenience C++ class to access hwc2_device_t Layer functions directly.
Lloyd Pique35d58242018-12-18 16:33:25 -0800397
398class Layer : public HWC2::Layer {
Dan Stoza651bf312015-10-23 17:03:17 -0700399public:
Steven Thomas94e35b92017-07-26 18:48:28 -0700400 Layer(android::Hwc2::Composer& composer,
401 const std::unordered_set<Capability>& capabilities,
402 hwc2_display_t displayId, hwc2_layer_t layerId);
Lloyd Pique35d58242018-12-18 16:33:25 -0800403 ~Layer() override;
Dan Stoza651bf312015-10-23 17:03:17 -0700404
Lloyd Pique35d58242018-12-18 16:33:25 -0800405 hwc2_layer_t getId() const override { return mId; }
Dan Stoza651bf312015-10-23 17:03:17 -0700406
Lloyd Pique35d58242018-12-18 16:33:25 -0800407 Error setCursorPosition(int32_t x, int32_t y) override;
408 Error setBuffer(uint32_t slot, const android::sp<android::GraphicBuffer>& buffer,
409 const android::sp<android::Fence>& acquireFence) override;
410 Error setSurfaceDamage(const android::Region& damage) override;
Steven Thomas94e35b92017-07-26 18:48:28 -0700411
Lloyd Pique35d58242018-12-18 16:33:25 -0800412 Error setBlendMode(BlendMode mode) override;
413 Error setColor(hwc_color_t color) override;
414 Error setCompositionType(Composition type) override;
415 Error setDataspace(android::ui::Dataspace dataspace) override;
416 Error setPerFrameMetadata(const int32_t supportedPerFrameMetadata,
417 const android::HdrMetadata& metadata) override;
418 Error setDisplayFrame(const android::Rect& frame) override;
419 Error setPlaneAlpha(float alpha) override;
420 Error setSidebandStream(const native_handle_t* stream) override;
421 Error setSourceCrop(const android::FloatRect& crop) override;
422 Error setTransform(Transform transform) override;
423 Error setVisibleRegion(const android::Region& region) override;
424 Error setZOrder(uint32_t z) override;
425 Error setInfo(uint32_t type, uint32_t appId) override;
Dan Stoza651bf312015-10-23 17:03:17 -0700426
Peiyong Lin698147a2018-09-14 13:27:18 -0700427 // Composer HAL 2.3
Lloyd Pique35d58242018-12-18 16:33:25 -0800428 Error setColorTransform(const android::mat4& matrix) override;
Peiyong Lin698147a2018-09-14 13:27:18 -0700429
Dan Stoza651bf312015-10-23 17:03:17 -0700430private:
Steven Thomas94e35b92017-07-26 18:48:28 -0700431 // These are references to data owned by HWC2::Device, which will outlive
432 // this HWC2::Layer, so these references are guaranteed to be valid for
433 // the lifetime of this object.
434 android::Hwc2::Composer& mComposer;
435 const std::unordered_set<Capability>& mCapabilities;
436
Dan Stoza651bf312015-10-23 17:03:17 -0700437 hwc2_display_t mDisplayId;
Dan Stoza651bf312015-10-23 17:03:17 -0700438 hwc2_layer_t mId;
Peiyong Lin34beb7a2018-03-28 11:57:12 -0700439 android::ui::Dataspace mDataSpace = android::ui::Dataspace::UNKNOWN;
Courtney Goeltzenleuchterf9c98e52018-02-12 07:23:17 -0700440 android::HdrMetadata mHdrMetadata;
Peiyong Lin698147a2018-09-14 13:27:18 -0700441 android::mat4 mColorMatrix;
Dan Stoza651bf312015-10-23 17:03:17 -0700442};
443
Lloyd Pique35d58242018-12-18 16:33:25 -0800444} // namespace impl
445
Dan Stoza651bf312015-10-23 17:03:17 -0700446} // namespace HWC2
447
448#endif // ANDROID_SF_HWC2_H