blob: a1c8da0a2f6a919900381ff8d80a72ab806d5cf8 [file] [log] [blame]
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001/*
2 * Copyright (C) 2007 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
Dan Stoza9e56aa02015-11-02 13:00:03 -080017// #define LOG_NDEBUG 0
18#undef LOG_TAG
19#define LOG_TAG "DisplayDevice"
20
Peiyong Lincbc184f2018-08-22 13:24:10 -070021#include "DisplayDevice.h"
22
Chia-I Wube02ec02018-05-18 10:59:36 -070023#include <array>
24#include <unordered_set>
25
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080026#include <stdlib.h>
27#include <stdio.h>
28#include <string.h>
29#include <math.h>
30
Dominik Laskowski9b17b2c22018-11-01 14:49:03 -070031#include <android-base/stringprintf.h>
Peiyong Lincbc184f2018-08-22 13:24:10 -070032#include <android/hardware/configstore/1.0/ISurfaceFlingerConfigs.h>
33#include <configstore/Utils.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080034#include <cutils/properties.h>
Peiyong Lincbc184f2018-08-22 13:24:10 -070035#include <gui/Surface.h>
36#include <hardware/gralloc.h>
37#include <renderengine/RenderEngine.h>
Alec Mouri0a9c7b82018-11-16 13:05:25 -080038#include <sync/sync.h>
39#include <system/window.h>
Courtney Goeltzenleuchter152279d2017-08-14 18:18:30 -060040#include <ui/DebugUtils.h>
Mathias Agopianc666cae2012-07-25 18:56:13 -070041#include <ui/DisplayInfo.h>
Mathias Agopian076b1cc2009-04-10 14:24:30 -070042#include <ui/PixelFormat.h>
Peiyong Lincbc184f2018-08-22 13:24:10 -070043#include <utils/Log.h>
Valerie Hau9758ae02018-10-09 16:05:09 -070044#include <utils/RefBase.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080045
Jesse Hall99c7dbb2013-03-14 14:29:29 -070046#include "DisplayHardware/DisplaySurface.h"
Mathias Agopian1b031492012-06-20 17:51:20 -070047#include "DisplayHardware/HWComposer.h"
Dan Stoza9e56aa02015-11-02 13:00:03 -080048#include "DisplayHardware/HWC2.h"
Mathias Agopianc7d14e22011-08-01 16:32:21 -070049#include "SurfaceFlinger.h"
Mathias Agopian13127d82013-03-05 17:47:11 -080050#include "Layer.h"
Mathias Agopian1f7bec62010-06-25 18:02:21 -070051
Peiyong Linfd997e02018-03-28 15:29:00 -070052namespace android {
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080053
Jaesoo Lee720a7242017-01-31 15:26:18 +090054// retrieve triple buffer setting from configstore
55using namespace android::hardware::configstore;
56using namespace android::hardware::configstore::V1_0;
Peiyong Linfd997e02018-03-28 15:29:00 -070057using android::ui::ColorMode;
Chia-I Wube02ec02018-05-18 10:59:36 -070058using android::ui::Dataspace;
Peiyong Lin62665892018-04-16 11:07:44 -070059using android::ui::Hdr;
Peiyong Lindd9b2ae2018-03-01 16:22:45 -080060using android::ui::RenderIntent;
Jaesoo Lee720a7242017-01-31 15:26:18 +090061
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080062/*
63 * Initialize the display to the specified values.
64 *
65 */
66
Pablo Ceballos021623b2016-04-15 17:31:51 -070067uint32_t DisplayDevice::sPrimaryDisplayOrientation = 0;
68
Chia-I Wube02ec02018-05-18 10:59:36 -070069namespace {
70
71// ordered list of known SDR color modes
Valerie Hau9758ae02018-10-09 16:05:09 -070072const std::array<ColorMode, 3> sSdrColorModes = {
73 ColorMode::DISPLAY_BT2020,
Chia-I Wube02ec02018-05-18 10:59:36 -070074 ColorMode::DISPLAY_P3,
75 ColorMode::SRGB,
76};
77
78// ordered list of known HDR color modes
79const std::array<ColorMode, 2> sHdrColorModes = {
80 ColorMode::BT2100_PQ,
81 ColorMode::BT2100_HLG,
82};
83
84// ordered list of known SDR render intents
85const std::array<RenderIntent, 2> sSdrRenderIntents = {
86 RenderIntent::ENHANCE,
87 RenderIntent::COLORIMETRIC,
88};
89
90// ordered list of known HDR render intents
91const std::array<RenderIntent, 2> sHdrRenderIntents = {
92 RenderIntent::TONE_MAP_ENHANCE,
93 RenderIntent::TONE_MAP_COLORIMETRIC,
94};
95
96// map known color mode to dataspace
97Dataspace colorModeToDataspace(ColorMode mode) {
98 switch (mode) {
99 case ColorMode::SRGB:
100 return Dataspace::SRGB;
101 case ColorMode::DISPLAY_P3:
102 return Dataspace::DISPLAY_P3;
Valerie Hau9758ae02018-10-09 16:05:09 -0700103 case ColorMode::DISPLAY_BT2020:
104 return Dataspace::DISPLAY_BT2020;
Chia-I Wube02ec02018-05-18 10:59:36 -0700105 case ColorMode::BT2100_HLG:
106 return Dataspace::BT2020_HLG;
107 case ColorMode::BT2100_PQ:
108 return Dataspace::BT2020_PQ;
109 default:
110 return Dataspace::UNKNOWN;
111 }
112}
113
114// Return a list of candidate color modes.
115std::vector<ColorMode> getColorModeCandidates(ColorMode mode) {
116 std::vector<ColorMode> candidates;
117
118 // add mode itself
119 candidates.push_back(mode);
120
121 // check if mode is HDR
122 bool isHdr = false;
123 for (auto hdrMode : sHdrColorModes) {
124 if (hdrMode == mode) {
125 isHdr = true;
126 break;
127 }
128 }
129
130 // add other HDR candidates when mode is HDR
131 if (isHdr) {
132 for (auto hdrMode : sHdrColorModes) {
133 if (hdrMode != mode) {
134 candidates.push_back(hdrMode);
135 }
136 }
137 }
138
139 // add other SDR candidates
140 for (auto sdrMode : sSdrColorModes) {
141 if (sdrMode != mode) {
142 candidates.push_back(sdrMode);
143 }
144 }
145
146 return candidates;
147}
148
149// Return a list of candidate render intents.
150std::vector<RenderIntent> getRenderIntentCandidates(RenderIntent intent) {
151 std::vector<RenderIntent> candidates;
152
153 // add intent itself
154 candidates.push_back(intent);
155
156 // check if intent is HDR
157 bool isHdr = false;
158 for (auto hdrIntent : sHdrRenderIntents) {
159 if (hdrIntent == intent) {
160 isHdr = true;
161 break;
162 }
163 }
164
Chia-I Wube02ec02018-05-18 10:59:36 -0700165 if (isHdr) {
Chia-I Wuc4b08bd2018-05-29 12:57:23 -0700166 // add other HDR candidates when intent is HDR
Chia-I Wube02ec02018-05-18 10:59:36 -0700167 for (auto hdrIntent : sHdrRenderIntents) {
168 if (hdrIntent != intent) {
169 candidates.push_back(hdrIntent);
170 }
171 }
Chia-I Wuc4b08bd2018-05-29 12:57:23 -0700172 } else {
173 // add other SDR candidates when intent is SDR
174 for (auto sdrIntent : sSdrRenderIntents) {
175 if (sdrIntent != intent) {
176 candidates.push_back(sdrIntent);
177 }
178 }
Chia-I Wube02ec02018-05-18 10:59:36 -0700179 }
180
181 return candidates;
182}
183
184// Return the best color mode supported by HWC.
185ColorMode getHwcColorMode(
186 const std::unordered_map<ColorMode, std::vector<RenderIntent>>& hwcColorModes,
187 ColorMode mode) {
188 std::vector<ColorMode> candidates = getColorModeCandidates(mode);
189 for (auto candidate : candidates) {
190 auto iter = hwcColorModes.find(candidate);
191 if (iter != hwcColorModes.end()) {
192 return candidate;
193 }
194 }
195
196 return ColorMode::NATIVE;
197}
198
199// Return the best render intent supported by HWC.
200RenderIntent getHwcRenderIntent(const std::vector<RenderIntent>& hwcIntents, RenderIntent intent) {
201 std::vector<RenderIntent> candidates = getRenderIntentCandidates(intent);
202 for (auto candidate : candidates) {
203 for (auto hwcIntent : hwcIntents) {
204 if (candidate == hwcIntent) {
205 return candidate;
206 }
207 }
208 }
209
210 return RenderIntent::COLORIMETRIC;
211}
212
213} // anonymous namespace
214
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700215DisplayDeviceCreationArgs::DisplayDeviceCreationArgs(const sp<SurfaceFlinger>& flinger,
216 const wp<IBinder>& displayToken,
Dominik Laskowski075d3172018-05-24 15:50:06 -0700217 const std::optional<DisplayId>& displayId)
218 : flinger(flinger), displayToken(displayToken), displayId(displayId) {}
Chia-I Wube02ec02018-05-18 10:59:36 -0700219
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700220DisplayDevice::DisplayDevice(DisplayDeviceCreationArgs&& args)
221 : lastCompositionHadVisibleLayers(false),
222 mFlinger(args.flinger),
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700223 mDisplayToken(args.displayToken),
Dominik Laskowski075d3172018-05-24 15:50:06 -0700224 mId(args.displayId),
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700225 mNativeWindow(args.nativeWindow),
Alec Mouri0a9c7b82018-11-16 13:05:25 -0800226 mGraphicBuffer(nullptr),
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700227 mDisplaySurface(args.displaySurface),
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700228 mDisplayInstallOrientation(args.displayInstallOrientation),
229 mPageFlipCount(0),
Dominik Laskowski075d3172018-05-24 15:50:06 -0700230 mIsVirtual(args.isVirtual),
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700231 mIsSecure(args.isSecure),
232 mLayerStack(NO_LAYER_STACK),
233 mOrientation(),
234 mViewport(Rect::INVALID_RECT),
235 mFrame(Rect::INVALID_RECT),
236 mPowerMode(args.initialPowerMode),
237 mActiveConfig(0),
238 mColorTransform(HAL_COLOR_TRANSFORM_IDENTITY),
239 mHasWideColorGamut(args.hasWideColorGamut),
240 mHasHdr10(false),
241 mHasHLG(false),
242 mHasDolbyVision(false),
Dominik Laskowski075d3172018-05-24 15:50:06 -0700243 mSupportedPerFrameMetadata(args.supportedPerFrameMetadata),
244 mIsPrimary(args.isPrimary) {
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700245 populateColorModes(args.hwcColorModes);
246
247 ALOGE_IF(!mNativeWindow, "No native window was set for display");
248 ALOGE_IF(!mDisplaySurface, "No display surface was set for display");
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700249
250 std::vector<Hdr> types = args.hdrCapabilities.getSupportedHdrTypes();
Peiyong Linfb069302018-04-25 14:34:31 -0700251 for (Hdr hdrType : types) {
Peiyong Lin62665892018-04-16 11:07:44 -0700252 switch (hdrType) {
253 case Hdr::HDR10:
254 mHasHdr10 = true;
255 break;
256 case Hdr::HLG:
257 mHasHLG = true;
258 break;
259 case Hdr::DOLBY_VISION:
260 mHasDolbyVision = true;
261 break;
262 default:
263 ALOGE("UNKNOWN HDR capability: %d", static_cast<int32_t>(hdrType));
264 }
265 }
Jesse Hallffe1f192013-03-22 15:13:48 -0700266
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700267 float minLuminance = args.hdrCapabilities.getDesiredMinLuminance();
268 float maxLuminance = args.hdrCapabilities.getDesiredMaxLuminance();
269 float maxAverageLuminance = args.hdrCapabilities.getDesiredMaxAverageLuminance();
Peiyong Linfb069302018-04-25 14:34:31 -0700270
271 minLuminance = minLuminance <= 0.0 ? sDefaultMinLumiance : minLuminance;
272 maxLuminance = maxLuminance <= 0.0 ? sDefaultMaxLumiance : maxLuminance;
273 maxAverageLuminance = maxAverageLuminance <= 0.0 ? sDefaultMaxLumiance : maxAverageLuminance;
274 if (this->hasWideColorGamut()) {
275 // insert HDR10/HLG as we will force client composition for HDR10/HLG
276 // layers
277 if (!hasHDR10Support()) {
278 types.push_back(Hdr::HDR10);
279 }
280
281 if (!hasHLGSupport()) {
282 types.push_back(Hdr::HLG);
283 }
284 }
285 mHdrCapabilities = HdrCapabilities(types, maxLuminance, maxAverageLuminance, minLuminance);
286
Alec Mouriba013fa2018-10-16 12:43:11 -0700287 ANativeWindow* const window = mNativeWindow.get();
Alec Mouri0a9c7b82018-11-16 13:05:25 -0800288
Alec Mouri4efb6c22018-11-16 13:07:47 -0800289 int status = native_window_api_connect(window, NATIVE_WINDOW_API_EGL);
Alec Mouri0a9c7b82018-11-16 13:05:25 -0800290 ALOGE_IF(status != NO_ERROR, "Unable to connect BQ producer: %d", status);
Alec Mouri4efb6c22018-11-16 13:07:47 -0800291 status = native_window_set_buffers_format(window, HAL_PIXEL_FORMAT_RGBA_8888);
292 ALOGE_IF(status != NO_ERROR, "Unable to set BQ format to RGBA888: %d", status);
293 status = native_window_set_usage(window, GRALLOC_USAGE_HW_RENDER);
294 ALOGE_IF(status != NO_ERROR, "Unable to set BQ usage bits for GPU rendering: %d", status);
Alec Mouri0a9c7b82018-11-16 13:05:25 -0800295
Alec Mouriba013fa2018-10-16 12:43:11 -0700296 mDisplayWidth = ANativeWindow_getWidth(window);
297 mDisplayHeight = ANativeWindow_getHeight(window);
298
Jesse Hallffe1f192013-03-22 15:13:48 -0700299 // initialize the display orientation transform.
300 setProjection(DisplayState::eOrientationDefault, mViewport, mFrame);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800301}
302
Lloyd Pique09594832018-01-22 17:48:03 -0800303DisplayDevice::~DisplayDevice() = default;
Mathias Agopian92a979a2012-08-02 18:32:23 -0700304
Jesse Hall02d86562013-03-25 14:43:23 -0700305void DisplayDevice::disconnect(HWComposer& hwc) {
Dominik Laskowski075d3172018-05-24 15:50:06 -0700306 if (mId) {
307 hwc.disconnectDisplay(*mId);
308 mId.reset();
Jesse Hall02d86562013-03-25 14:43:23 -0700309 }
310}
311
Mathias Agopian0f2f5ff2012-07-31 23:09:07 -0700312int DisplayDevice::getWidth() const {
Mathias Agopiana4912602012-07-12 14:25:33 -0700313 return mDisplayWidth;
314}
315
Mathias Agopian0f2f5ff2012-07-31 23:09:07 -0700316int DisplayDevice::getHeight() const {
Mathias Agopiana4912602012-07-12 14:25:33 -0700317 return mDisplayHeight;
318}
319
Dominik Laskowskibf170d92018-04-19 15:08:05 -0700320void DisplayDevice::setDisplayName(const std::string& displayName) {
321 if (!displayName.empty()) {
Mathias Agopian9e2463e2012-09-21 18:26:16 -0700322 // never override the name with an empty name
323 mDisplayName = displayName;
324 }
325}
326
Mathias Agopian0f2f5ff2012-07-31 23:09:07 -0700327uint32_t DisplayDevice::getPageFlipCount() const {
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700328 return mPageFlipCount;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800329}
330
Chia-I Wub02087d2017-11-09 10:19:54 -0800331void DisplayDevice::flip() const
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800332{
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700333 mPageFlipCount++;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800334}
335
Dan Stoza71433162014-02-04 16:22:36 -0800336status_t DisplayDevice::beginFrame(bool mustRecompose) const {
337 return mDisplaySurface->beginFrame(mustRecompose);
Jesse Hall028dc8f2013-08-20 16:35:32 -0700338}
339
David Sodmanfb95bcc2017-12-22 15:45:30 -0800340status_t DisplayDevice::prepareFrame(HWComposer& hwc,
341 std::vector<CompositionInfo>& compositionData) {
Dominik Laskowski075d3172018-05-24 15:50:06 -0700342 if (mId) {
343 status_t error = hwc.prepare(*mId, compositionData);
344 if (error != NO_ERROR) {
345 return error;
346 }
Dan Stoza9e56aa02015-11-02 13:00:03 -0800347 }
348
349 DisplaySurface::CompositionType compositionType;
Dominik Laskowski7e045462018-05-30 13:02:02 -0700350 bool hasClient = hwc.hasClientComposition(mId);
351 bool hasDevice = hwc.hasDeviceComposition(mId);
Dan Stoza9e56aa02015-11-02 13:00:03 -0800352 if (hasClient && hasDevice) {
353 compositionType = DisplaySurface::COMPOSITION_MIXED;
354 } else if (hasClient) {
355 compositionType = DisplaySurface::COMPOSITION_GLES;
356 } else if (hasDevice) {
357 compositionType = DisplaySurface::COMPOSITION_HWC;
358 } else {
359 // Nothing to do -- when turning the screen off we get a frame like
360 // this. Call it a HWC frame since we won't be doing any GLES work but
361 // will do a prepare/set cycle.
362 compositionType = DisplaySurface::COMPOSITION_HWC;
363 }
364 return mDisplaySurface->prepareFrame(compositionType);
365}
Jesse Hall38efe862013-04-06 23:12:29 -0700366
Alec Mouri0a9c7b82018-11-16 13:05:25 -0800367sp<GraphicBuffer> DisplayDevice::dequeueBuffer() {
368 int fd;
369 ANativeWindowBuffer* buffer;
370
371 status_t res = mNativeWindow->dequeueBuffer(mNativeWindow.get(), &buffer, &fd);
372
373 if (res != NO_ERROR) {
374 ALOGE("ANativeWindow::dequeueBuffer failed for display [%s] with error: %d",
375 getDisplayName().c_str(), res);
376 // Return fast here as we can't do much more - any rendering we do
377 // now will just be wrong.
378 return mGraphicBuffer;
379 }
380
381 ALOGW_IF(mGraphicBuffer != nullptr, "Clobbering a non-null pointer to a buffer [%p].",
382 mGraphicBuffer->getNativeBuffer()->handle);
383 mGraphicBuffer = GraphicBuffer::from(buffer);
384
385 // Block until the buffer is ready
386 // TODO(alecmouri): it's perhaps more appropriate to block renderengine so
387 // that the gl driver can block instead.
388 if (fd >= 0) {
389 sync_wait(fd, -1);
390 close(fd);
391 }
392
393 return mGraphicBuffer;
394}
395
396void DisplayDevice::queueBuffer(HWComposer& hwc) {
Dominik Laskowski7e045462018-05-30 13:02:02 -0700397 if (hwc.hasClientComposition(mId) || hwc.hasFlipClientTargetRequest(mId)) {
Alec Mouri0a9c7b82018-11-16 13:05:25 -0800398 // hasFlipClientTargetRequest could return true even if we haven't
399 // dequeued a buffer before. Try dequeueing one if we don't have a
400 // buffer ready.
401 if (mGraphicBuffer == nullptr) {
402 ALOGI("Attempting to queue a client composited buffer without one "
403 "previously dequeued for display [%s]. Attempting to dequeue "
404 "a scratch buffer now",
405 mDisplayName.c_str());
406 // We shouldn't deadlock here, since mGraphicBuffer == nullptr only
407 // after a successful call to queueBuffer, or if dequeueBuffer has
408 // never been called.
409 dequeueBuffer();
410 }
411
412 if (mGraphicBuffer == nullptr) {
413 ALOGE("No buffer is ready for display [%s]", mDisplayName.c_str());
414 } else {
Alec Mouri0a9c7b82018-11-16 13:05:25 -0800415 status_t res = mNativeWindow->queueBuffer(mNativeWindow.get(),
Alec Mouri745163a2018-12-04 15:15:50 -0800416 mGraphicBuffer->getNativeBuffer(),
417 dup(mBufferReady));
Alec Mouri0a9c7b82018-11-16 13:05:25 -0800418 if (res != NO_ERROR) {
419 ALOGE("Error when queueing buffer for display [%s]: %d", mDisplayName.c_str(), res);
420 // We risk blocking on dequeueBuffer if the primary display failed
421 // to queue up its buffer, so crash here.
422 if (isPrimary()) {
423 LOG_ALWAYS_FATAL("ANativeWindow::queueBuffer failed with error: %d", res);
424 } else {
425 mNativeWindow->cancelBuffer(mNativeWindow.get(),
Alec Mouri745163a2018-12-04 15:15:50 -0800426 mGraphicBuffer->getNativeBuffer(),
427 dup(mBufferReady));
Alec Mouri0a9c7b82018-11-16 13:05:25 -0800428 }
429 }
Alec Mouri745163a2018-12-04 15:15:50 -0800430
431 mBufferReady.reset();
Alec Mouri0a9c7b82018-11-16 13:05:25 -0800432 mGraphicBuffer = nullptr;
433 }
Mathias Agopianda27af92012-09-13 18:17:13 -0700434 }
Mathias Agopian52e21482012-09-24 18:07:21 -0700435
Jesse Hall99c7dbb2013-03-14 14:29:29 -0700436 status_t result = mDisplaySurface->advanceFrame();
437 if (result != NO_ERROR) {
Dominik Laskowskibf170d92018-04-19 15:08:05 -0700438 ALOGE("[%s] failed pushing new frame to HWC: %d", mDisplayName.c_str(), result);
Mathias Agopian32341382012-09-25 19:16:28 -0700439 }
Mathias Agopianda27af92012-09-13 18:17:13 -0700440}
441
Alec Mouri0a9c7b82018-11-16 13:05:25 -0800442void DisplayDevice::onPresentDisplayCompleted() {
Dan Stoza9e56aa02015-11-02 13:00:03 -0800443 mDisplaySurface->onFrameCommitted();
444}
Mathias Agopianda27af92012-09-13 18:17:13 -0700445
Mathias Agopian875d8e12013-06-07 15:35:48 -0700446void DisplayDevice::setViewportAndProjection() const {
447 size_t w = mDisplayWidth;
448 size_t h = mDisplayHeight;
Dan Stozac1879002014-05-22 15:59:05 -0700449 Rect sourceCrop(0, 0, w, h);
Chia-I Wu1be50b52018-08-29 10:44:48 -0700450 mFlinger->getRenderEngine().setViewportAndProjection(w, h, sourceCrop, ui::Transform::ROT_0);
Mathias Agopianbae92d02012-09-28 01:00:47 -0700451}
452
Alec Mouri0a9c7b82018-11-16 13:05:25 -0800453void DisplayDevice::finishBuffer() {
454 mBufferReady = mFlinger->getRenderEngine().flush();
455 if (mBufferReady.get() < 0) {
456 mFlinger->getRenderEngine().finish();
457 }
458}
459
Dan Stoza9e56aa02015-11-02 13:00:03 -0800460const sp<Fence>& DisplayDevice::getClientTargetAcquireFence() const {
461 return mDisplaySurface->getClientTargetAcquireFence();
462}
Dan Stoza9e56aa02015-11-02 13:00:03 -0800463
Mathias Agopian1b031492012-06-20 17:51:20 -0700464// ----------------------------------------------------------------------------
465
Mathias Agopian13127d82013-03-05 17:47:11 -0800466void DisplayDevice::setVisibleLayersSortedByZ(const Vector< sp<Layer> >& layers) {
Mathias Agopian3b1d2b62012-07-11 13:48:17 -0700467 mVisibleLayersSortedByZ = layers;
Mathias Agopian3b1d2b62012-07-11 13:48:17 -0700468}
469
Mathias Agopian13127d82013-03-05 17:47:11 -0800470const Vector< sp<Layer> >& DisplayDevice::getVisibleLayersSortedByZ() const {
Mathias Agopian3b1d2b62012-07-11 13:48:17 -0700471 return mVisibleLayersSortedByZ;
472}
473
Chia-I Wu83806892017-11-16 10:50:20 -0800474void DisplayDevice::setLayersNeedingFences(const Vector< sp<Layer> >& layers) {
475 mLayersNeedingFences = layers;
476}
477
478const Vector< sp<Layer> >& DisplayDevice::getLayersNeedingFences() const {
479 return mLayersNeedingFences;
480}
481
Mathias Agopiancd60f992012-08-16 16:28:27 -0700482Region DisplayDevice::getDirtyRegion(bool repaintEverything) const {
483 Region dirty;
Mathias Agopiancd60f992012-08-16 16:28:27 -0700484 if (repaintEverything) {
485 dirty.set(getBounds());
486 } else {
Peiyong Linefefaac2018-08-17 12:27:51 -0700487 const ui::Transform& planeTransform(mGlobalTransform);
Mathias Agopiancd60f992012-08-16 16:28:27 -0700488 dirty = planeTransform.transform(this->dirtyRegion);
489 dirty.andSelf(getBounds());
490 }
491 return dirty;
492}
493
Mathias Agopian3b1d2b62012-07-11 13:48:17 -0700494// ----------------------------------------------------------------------------
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700495void DisplayDevice::setPowerMode(int mode) {
496 mPowerMode = mode;
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700497}
498
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700499int DisplayDevice::getPowerMode() const {
500 return mPowerMode;
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700501}
502
Dominik Laskowskieecd6592018-05-29 10:25:41 -0700503bool DisplayDevice::isPoweredOn() const {
504 return mPowerMode != HWC_POWER_MODE_OFF;
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700505}
506
507// ----------------------------------------------------------------------------
Michael Lentine6c9e34a2014-07-14 13:48:55 -0700508void DisplayDevice::setActiveConfig(int mode) {
509 mActiveConfig = mode;
510}
511
512int DisplayDevice::getActiveConfig() const {
513 return mActiveConfig;
514}
515
516// ----------------------------------------------------------------------------
Peiyong Lina52f0292018-03-14 17:26:31 -0700517void DisplayDevice::setActiveColorMode(ColorMode mode) {
Michael Wright28f24d02016-07-12 13:30:53 -0700518 mActiveColorMode = mode;
519}
520
Peiyong Lina52f0292018-03-14 17:26:31 -0700521ColorMode DisplayDevice::getActiveColorMode() const {
Michael Wright28f24d02016-07-12 13:30:53 -0700522 return mActiveColorMode;
523}
Courtney Goeltzenleuchter79d27242017-07-13 17:54:01 -0600524
Peiyong Lindd9b2ae2018-03-01 16:22:45 -0800525RenderIntent DisplayDevice::getActiveRenderIntent() const {
526 return mActiveRenderIntent;
527}
528
529void DisplayDevice::setActiveRenderIntent(RenderIntent renderIntent) {
530 mActiveRenderIntent = renderIntent;
531}
532
Yiwei Zhang7c64f172018-03-07 14:52:28 -0800533void DisplayDevice::setColorTransform(const mat4& transform) {
534 const bool isIdentity = (transform == mat4());
535 mColorTransform =
536 isIdentity ? HAL_COLOR_TRANSFORM_IDENTITY : HAL_COLOR_TRANSFORM_ARBITRARY_MATRIX;
537}
538
539android_color_transform_t DisplayDevice::getColorTransform() const {
540 return mColorTransform;
541}
542
Peiyong Lin34beb7a2018-03-28 11:57:12 -0700543void DisplayDevice::setCompositionDataSpace(ui::Dataspace dataspace) {
Peiyong Lindd9b2ae2018-03-01 16:22:45 -0800544 mCompositionDataSpace = dataspace;
Courtney Goeltzenleuchter79d27242017-07-13 17:54:01 -0600545 ANativeWindow* const window = mNativeWindow.get();
Peiyong Lin34beb7a2018-03-28 11:57:12 -0700546 native_window_set_buffers_data_space(window, static_cast<android_dataspace>(dataspace));
Courtney Goeltzenleuchter79d27242017-07-13 17:54:01 -0600547}
Michael Wright28f24d02016-07-12 13:30:53 -0700548
Peiyong Lindd9b2ae2018-03-01 16:22:45 -0800549ui::Dataspace DisplayDevice::getCompositionDataSpace() const {
550 return mCompositionDataSpace;
551}
552
Michael Wright28f24d02016-07-12 13:30:53 -0700553// ----------------------------------------------------------------------------
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700554
Mathias Agopian28947d72012-08-08 18:51:15 -0700555void DisplayDevice::setLayerStack(uint32_t stack) {
556 mLayerStack = stack;
557 dirtyRegion.set(bounds());
558}
559
560// ----------------------------------------------------------------------------
561
Mathias Agopianc1c05de2013-09-17 23:45:22 -0700562uint32_t DisplayDevice::getOrientationTransform() const {
563 uint32_t transform = 0;
564 switch (mOrientation) {
565 case DisplayState::eOrientationDefault:
Peiyong Linefefaac2018-08-17 12:27:51 -0700566 transform = ui::Transform::ROT_0;
Mathias Agopianc1c05de2013-09-17 23:45:22 -0700567 break;
568 case DisplayState::eOrientation90:
Peiyong Linefefaac2018-08-17 12:27:51 -0700569 transform = ui::Transform::ROT_90;
Mathias Agopianc1c05de2013-09-17 23:45:22 -0700570 break;
571 case DisplayState::eOrientation180:
Peiyong Linefefaac2018-08-17 12:27:51 -0700572 transform = ui::Transform::ROT_180;
Mathias Agopianc1c05de2013-09-17 23:45:22 -0700573 break;
574 case DisplayState::eOrientation270:
Peiyong Linefefaac2018-08-17 12:27:51 -0700575 transform = ui::Transform::ROT_270;
Mathias Agopianc1c05de2013-09-17 23:45:22 -0700576 break;
577 }
578 return transform;
579}
580
Mathias Agopian0f2f5ff2012-07-31 23:09:07 -0700581status_t DisplayDevice::orientationToTransfrom(
Peiyong Linefefaac2018-08-17 12:27:51 -0700582 int orientation, int w, int h, ui::Transform* tr)
Mathias Agopian1b031492012-06-20 17:51:20 -0700583{
584 uint32_t flags = 0;
585 switch (orientation) {
Mathias Agopian3165cc22012-08-08 19:42:09 -0700586 case DisplayState::eOrientationDefault:
Peiyong Linefefaac2018-08-17 12:27:51 -0700587 flags = ui::Transform::ROT_0;
Mathias Agopian1b031492012-06-20 17:51:20 -0700588 break;
Mathias Agopian3165cc22012-08-08 19:42:09 -0700589 case DisplayState::eOrientation90:
Peiyong Linefefaac2018-08-17 12:27:51 -0700590 flags = ui::Transform::ROT_90;
Mathias Agopian1b031492012-06-20 17:51:20 -0700591 break;
Mathias Agopian3165cc22012-08-08 19:42:09 -0700592 case DisplayState::eOrientation180:
Peiyong Linefefaac2018-08-17 12:27:51 -0700593 flags = ui::Transform::ROT_180;
Mathias Agopian1b031492012-06-20 17:51:20 -0700594 break;
Mathias Agopian3165cc22012-08-08 19:42:09 -0700595 case DisplayState::eOrientation270:
Peiyong Linefefaac2018-08-17 12:27:51 -0700596 flags = ui::Transform::ROT_270;
Mathias Agopian1b031492012-06-20 17:51:20 -0700597 break;
598 default:
599 return BAD_VALUE;
600 }
601 tr->set(flags, w, h);
602 return NO_ERROR;
603}
604
Michael Lentine47e45402014-07-18 15:34:25 -0700605void DisplayDevice::setDisplaySize(const int newWidth, const int newHeight) {
606 dirtyRegion.set(getBounds());
607
608 mDisplaySurface->resizeBuffers(newWidth, newHeight);
609
Alec Mouriba013fa2018-10-16 12:43:11 -0700610 mDisplayWidth = newWidth;
611 mDisplayHeight = newHeight;
Michael Lentine47e45402014-07-18 15:34:25 -0700612}
613
Mathias Agopian00e8c7a2012-09-04 19:30:46 -0700614void DisplayDevice::setProjection(int orientation,
Mathias Agopianf5f714a2013-02-26 16:54:05 -0800615 const Rect& newViewport, const Rect& newFrame) {
616 Rect viewport(newViewport);
617 Rect frame(newFrame);
618
619 const int w = mDisplayWidth;
620 const int h = mDisplayHeight;
621
Peiyong Linefefaac2018-08-17 12:27:51 -0700622 ui::Transform R;
Mathias Agopianf5f714a2013-02-26 16:54:05 -0800623 DisplayDevice::orientationToTransfrom(orientation, w, h, &R);
624
625 if (!frame.isValid()) {
626 // the destination frame can be invalid if it has never been set,
627 // in that case we assume the whole display frame.
628 frame = Rect(w, h);
629 }
630
631 if (viewport.isEmpty()) {
632 // viewport can be invalid if it has never been set, in that case
633 // we assume the whole display size.
634 // it's also invalid to have an empty viewport, so we handle that
635 // case in the same way.
636 viewport = Rect(w, h);
Peiyong Linefefaac2018-08-17 12:27:51 -0700637 if (R.getOrientation() & ui::Transform::ROT_90) {
Mathias Agopianf5f714a2013-02-26 16:54:05 -0800638 // viewport is always specified in the logical orientation
639 // of the display (ie: post-rotation).
Peiyong Lin3db42342018-08-16 09:15:59 -0700640 std::swap(viewport.right, viewport.bottom);
Mathias Agopianf5f714a2013-02-26 16:54:05 -0800641 }
642 }
643
644 dirtyRegion.set(getBounds());
645
Peiyong Linefefaac2018-08-17 12:27:51 -0700646 ui::Transform TL, TP, S;
Mathias Agopianf5f714a2013-02-26 16:54:05 -0800647 float src_width = viewport.width();
648 float src_height = viewport.height();
649 float dst_width = frame.width();
650 float dst_height = frame.height();
651 if (src_width != dst_width || src_height != dst_height) {
652 float sx = dst_width / src_width;
653 float sy = dst_height / src_height;
654 S.set(sx, 0, 0, sy);
655 }
656
657 float src_x = viewport.left;
658 float src_y = viewport.top;
659 float dst_x = frame.left;
660 float dst_y = frame.top;
661 TL.set(-src_x, -src_y);
662 TP.set(dst_x, dst_y);
663
Iris Chang7501ed62018-04-30 14:45:42 +0800664 // need to take care of primary display rotation for mGlobalTransform
665 // for case if the panel is not installed aligned with device orientation
Dominik Laskowski075d3172018-05-24 15:50:06 -0700666 if (isPrimary()) {
Iris Chang7501ed62018-04-30 14:45:42 +0800667 DisplayDevice::orientationToTransfrom(
Chia-I Wua02871c2018-08-27 14:38:23 -0700668 (orientation + mDisplayInstallOrientation) % (DisplayState::eOrientation270 + 1),
Iris Chang7501ed62018-04-30 14:45:42 +0800669 w, h, &R);
670 }
671
Mathias Agopianf5f714a2013-02-26 16:54:05 -0800672 // The viewport and frame are both in the logical orientation.
673 // Apply the logical translation, scale to physical size, apply the
674 // physical translation and finally rotate to the physical orientation.
675 mGlobalTransform = R * TP * S * TL;
676
677 const uint8_t type = mGlobalTransform.getType();
678 mNeedsFiltering = (!mGlobalTransform.preserveRects() ||
Peiyong Linefefaac2018-08-17 12:27:51 -0700679 (type >= ui::Transform::SCALE));
Mathias Agopianf5f714a2013-02-26 16:54:05 -0800680
681 mScissor = mGlobalTransform.transform(viewport);
682 if (mScissor.isEmpty()) {
Mathias Agopian6c7f25a2013-05-09 20:37:10 -0700683 mScissor = getBounds();
Mathias Agopianf5f714a2013-02-26 16:54:05 -0800684 }
685
Mathias Agopianda8d0a52012-09-04 15:05:38 -0700686 mOrientation = orientation;
Dominik Laskowski281644e2018-04-19 15:47:35 -0700687 if (isPrimary()) {
Pablo Ceballos021623b2016-04-15 17:31:51 -0700688 uint32_t transform = 0;
689 switch (mOrientation) {
690 case DisplayState::eOrientationDefault:
Peiyong Linefefaac2018-08-17 12:27:51 -0700691 transform = ui::Transform::ROT_0;
Pablo Ceballos021623b2016-04-15 17:31:51 -0700692 break;
693 case DisplayState::eOrientation90:
Peiyong Linefefaac2018-08-17 12:27:51 -0700694 transform = ui::Transform::ROT_90;
Pablo Ceballos021623b2016-04-15 17:31:51 -0700695 break;
696 case DisplayState::eOrientation180:
Peiyong Linefefaac2018-08-17 12:27:51 -0700697 transform = ui::Transform::ROT_180;
Pablo Ceballos021623b2016-04-15 17:31:51 -0700698 break;
699 case DisplayState::eOrientation270:
Peiyong Linefefaac2018-08-17 12:27:51 -0700700 transform = ui::Transform::ROT_270;
Pablo Ceballos021623b2016-04-15 17:31:51 -0700701 break;
702 }
703 sPrimaryDisplayOrientation = transform;
704 }
Mathias Agopian00e8c7a2012-09-04 19:30:46 -0700705 mViewport = viewport;
706 mFrame = frame;
Mathias Agopian1b031492012-06-20 17:51:20 -0700707}
Mathias Agopian1d12d8a2012-09-18 01:38:00 -0700708
Pablo Ceballos021623b2016-04-15 17:31:51 -0700709uint32_t DisplayDevice::getPrimaryDisplayOrientationTransform() {
710 return sPrimaryDisplayOrientation;
711}
712
Dominik Laskowski9b17b2c22018-11-01 14:49:03 -0700713std::string DisplayDevice::getDebugName() const {
Dominik Laskowski34157762018-10-31 13:07:19 -0700714 const auto id = mId ? to_string(*mId) + ", " : std::string();
Dominik Laskowski9b17b2c22018-11-01 14:49:03 -0700715 return base::StringPrintf("DisplayDevice{%s%s%s\"%s\"}", id.c_str(),
716 isPrimary() ? "primary, " : "", isVirtual() ? "virtual, " : "",
717 mDisplayName.c_str());
718}
719
Mathias Agopian74d211a2013-04-22 16:55:35 +0200720void DisplayDevice::dump(String8& result) const {
Peiyong Linefefaac2018-08-17 12:27:51 -0700721 const ui::Transform& tr(mGlobalTransform);
Courtney Goeltzenleuchter152279d2017-08-14 18:18:30 -0600722 ANativeWindow* const window = mNativeWindow.get();
Dominik Laskowski9b17b2c22018-11-01 14:49:03 -0700723 result.appendFormat("+ %s\n", getDebugName().c_str());
724 result.appendFormat(" layerStack=%u, (%4dx%4d), ANativeWindow=%p "
Alec Mourif6fd29e2018-11-17 04:56:41 +0000725 "format=%d, orient=%2d (type=%08x), flips=%u, isSecure=%d, "
726 "powerMode=%d, activeConfig=%d, numLayers=%zu\n",
Dominik Laskowski9b17b2c22018-11-01 14:49:03 -0700727 mLayerStack, mDisplayWidth, mDisplayHeight, window,
Alec Mourif6fd29e2018-11-17 04:56:41 +0000728 ANativeWindow_getFormat(window), mOrientation, tr.getType(),
729 getPageFlipCount(), mIsSecure, mPowerMode, mActiveConfig,
Courtney Goeltzenleuchter0ebaac32017-04-13 12:17:03 -0600730 mVisibleLayersSortedByZ.size());
731 result.appendFormat(" v:[%d,%d,%d,%d], f:[%d,%d,%d,%d], s:[%d,%d,%d,%d],"
732 "transform:[[%0.3f,%0.3f,%0.3f][%0.3f,%0.3f,%0.3f][%0.3f,%0.3f,%0.3f]]\n",
733 mViewport.left, mViewport.top, mViewport.right, mViewport.bottom,
734 mFrame.left, mFrame.top, mFrame.right, mFrame.bottom, mScissor.left,
735 mScissor.top, mScissor.right, mScissor.bottom, tr[0][0], tr[1][0], tr[2][0],
736 tr[0][1], tr[1][1], tr[2][1], tr[0][2], tr[1][2], tr[2][2]);
Courtney Goeltzenleuchter152279d2017-08-14 18:18:30 -0600737 auto const surface = static_cast<Surface*>(window);
Peiyong Lin34beb7a2018-03-28 11:57:12 -0700738 ui::Dataspace dataspace = surface->getBuffersDataSpace();
Peiyong Lindd9b2ae2018-03-01 16:22:45 -0800739 result.appendFormat(" wideColorGamut=%d, hdr10=%d, colorMode=%s, dataspace: %s (%d)\n",
Alec Mourif6fd29e2018-11-17 04:56:41 +0000740 mHasWideColorGamut, mHasHdr10, decodeColorMode(mActiveColorMode).c_str(),
741 dataspaceDetails(static_cast<android_dataspace>(dataspace)).c_str(),
742 dataspace);
Mathias Agopian1d12d8a2012-09-18 01:38:00 -0700743
Jesse Hall99c7dbb2013-03-14 14:29:29 -0700744 String8 surfaceDump;
Dan Stozaf10c46e2014-11-11 10:32:31 -0800745 mDisplaySurface->dumpAsString(surfaceDump);
Jesse Hall99c7dbb2013-03-14 14:29:29 -0700746 result.append(surfaceDump);
Mathias Agopian1d12d8a2012-09-18 01:38:00 -0700747}
Irvelffc9efc2016-07-27 15:16:37 -0700748
Chia-I Wube02ec02018-05-18 10:59:36 -0700749// Map dataspace/intent to the best matched dataspace/colorMode/renderIntent
750// supported by HWC.
751void DisplayDevice::addColorMode(
752 const std::unordered_map<ColorMode, std::vector<RenderIntent>>& hwcColorModes,
753 const ColorMode mode, const RenderIntent intent) {
754 // find the best color mode
755 const ColorMode hwcColorMode = getHwcColorMode(hwcColorModes, mode);
756
757 // find the best render intent
758 auto iter = hwcColorModes.find(hwcColorMode);
759 const auto& hwcIntents =
760 iter != hwcColorModes.end() ? iter->second : std::vector<RenderIntent>();
761 const RenderIntent hwcIntent = getHwcRenderIntent(hwcIntents, intent);
762
763 const Dataspace dataspace = colorModeToDataspace(mode);
764 const Dataspace hwcDataspace = colorModeToDataspace(hwcColorMode);
765
Dominik Laskowski9b17b2c22018-11-01 14:49:03 -0700766 ALOGV("%s: map (%s, %s) to (%s, %s, %s)", getDebugName().c_str(),
Chia-I Wube02ec02018-05-18 10:59:36 -0700767 dataspaceDetails(static_cast<android_dataspace_t>(dataspace)).c_str(),
768 decodeRenderIntent(intent).c_str(),
769 dataspaceDetails(static_cast<android_dataspace_t>(hwcDataspace)).c_str(),
770 decodeColorMode(hwcColorMode).c_str(), decodeRenderIntent(hwcIntent).c_str());
771
772 mColorModes[getColorModeKey(dataspace, intent)] = {hwcDataspace, hwcColorMode, hwcIntent};
773}
774
775void DisplayDevice::populateColorModes(
776 const std::unordered_map<ColorMode, std::vector<RenderIntent>>& hwcColorModes) {
777 if (!hasWideColorGamut()) {
778 return;
779 }
780
Chia-I Wu0d711262018-05-21 15:19:35 -0700781 // collect all known SDR render intents
782 std::unordered_set<RenderIntent> sdrRenderIntents(sSdrRenderIntents.begin(),
783 sSdrRenderIntents.end());
784 auto iter = hwcColorModes.find(ColorMode::SRGB);
785 if (iter != hwcColorModes.end()) {
786 for (auto intent : iter->second) {
787 sdrRenderIntents.insert(intent);
788 }
789 }
790
Chia-I Wuc4b08bd2018-05-29 12:57:23 -0700791 // add all known SDR combinations
Chia-I Wu0d711262018-05-21 15:19:35 -0700792 for (auto intent : sdrRenderIntents) {
Chia-I Wube02ec02018-05-18 10:59:36 -0700793 for (auto mode : sSdrColorModes) {
794 addColorMode(hwcColorModes, mode, intent);
Peiyong Lin136fbbc2018-04-17 15:09:44 -0700795 }
796 }
Chia-I Wube02ec02018-05-18 10:59:36 -0700797
Chia-I Wuc4b08bd2018-05-29 12:57:23 -0700798 // collect all known HDR render intents
799 std::unordered_set<RenderIntent> hdrRenderIntents(sHdrRenderIntents.begin(),
800 sHdrRenderIntents.end());
801 iter = hwcColorModes.find(ColorMode::BT2100_PQ);
802 if (iter != hwcColorModes.end()) {
803 for (auto intent : iter->second) {
804 hdrRenderIntents.insert(intent);
805 }
806 }
807
808 // add all known HDR combinations
Chia-I Wube02ec02018-05-18 10:59:36 -0700809 for (auto intent : sHdrRenderIntents) {
810 for (auto mode : sHdrColorModes) {
811 addColorMode(hwcColorModes, mode, intent);
812 }
813 }
814}
815
816bool DisplayDevice::hasRenderIntent(RenderIntent intent) const {
817 // assume a render intent is supported when SRGB supports it; we should
818 // get rid of that assumption.
819 auto iter = mColorModes.find(getColorModeKey(Dataspace::SRGB, intent));
820 return iter != mColorModes.end() && iter->second.renderIntent == intent;
821}
822
Peiyong Lindfde5112018-06-05 10:58:41 -0700823bool DisplayDevice::hasLegacyHdrSupport(Dataspace dataspace) const {
Chia-I Wube02ec02018-05-18 10:59:36 -0700824 if ((dataspace == Dataspace::BT2020_PQ && hasHDR10Support()) ||
825 (dataspace == Dataspace::BT2020_HLG && hasHLGSupport())) {
826 auto iter =
827 mColorModes.find(getColorModeKey(dataspace, RenderIntent::TONE_MAP_COLORIMETRIC));
Peiyong Lindfde5112018-06-05 10:58:41 -0700828 return iter == mColorModes.end() || iter->second.dataspace != dataspace;
Chia-I Wube02ec02018-05-18 10:59:36 -0700829 }
830
831 return false;
832}
833
834void DisplayDevice::getBestColorMode(Dataspace dataspace, RenderIntent intent,
835 Dataspace* outDataspace, ColorMode* outMode,
836 RenderIntent* outIntent) const {
837 auto iter = mColorModes.find(getColorModeKey(dataspace, intent));
838 if (iter != mColorModes.end()) {
839 *outDataspace = iter->second.dataspace;
840 *outMode = iter->second.colorMode;
841 *outIntent = iter->second.renderIntent;
842 } else {
Chia-I Wu6333af52018-10-16 13:46:36 -0700843 // this is unexpected on a WCG display
844 if (hasWideColorGamut()) {
845 ALOGE("map unknown (%s)/(%s) to default color mode",
846 dataspaceDetails(static_cast<android_dataspace_t>(dataspace)).c_str(),
847 decodeRenderIntent(intent).c_str());
848 }
Chia-I Wube02ec02018-05-18 10:59:36 -0700849
850 *outDataspace = Dataspace::UNKNOWN;
851 *outMode = ColorMode::NATIVE;
852 *outIntent = RenderIntent::COLORIMETRIC;
853 }
Peiyong Lin136fbbc2018-04-17 15:09:44 -0700854}
855
Dominik Laskowski663bd282018-04-19 15:26:54 -0700856std::atomic<int32_t> DisplayDeviceState::sNextSequenceId(1);
Peiyong Linfd997e02018-03-28 15:29:00 -0700857
858} // namespace android