blob: 3ad07ae41a5c7480c8770862b1ee85b0f6932217 [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;
Yiwei Zhang5434a782018-12-05 18:06:32 -080057using android::base::StringAppendF;
Peiyong Linfd997e02018-03-28 15:29:00 -070058using android::ui::ColorMode;
Chia-I Wube02ec02018-05-18 10:59:36 -070059using android::ui::Dataspace;
Peiyong Lin62665892018-04-16 11:07:44 -070060using android::ui::Hdr;
Peiyong Lindd9b2ae2018-03-01 16:22:45 -080061using android::ui::RenderIntent;
Jaesoo Lee720a7242017-01-31 15:26:18 +090062
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080063/*
64 * Initialize the display to the specified values.
65 *
66 */
67
Pablo Ceballos021623b2016-04-15 17:31:51 -070068uint32_t DisplayDevice::sPrimaryDisplayOrientation = 0;
69
Chia-I Wube02ec02018-05-18 10:59:36 -070070namespace {
71
72// ordered list of known SDR color modes
Valerie Hau9758ae02018-10-09 16:05:09 -070073const std::array<ColorMode, 3> sSdrColorModes = {
74 ColorMode::DISPLAY_BT2020,
Chia-I Wube02ec02018-05-18 10:59:36 -070075 ColorMode::DISPLAY_P3,
76 ColorMode::SRGB,
77};
78
79// ordered list of known HDR color modes
80const std::array<ColorMode, 2> sHdrColorModes = {
81 ColorMode::BT2100_PQ,
82 ColorMode::BT2100_HLG,
83};
84
85// ordered list of known SDR render intents
86const std::array<RenderIntent, 2> sSdrRenderIntents = {
87 RenderIntent::ENHANCE,
88 RenderIntent::COLORIMETRIC,
89};
90
91// ordered list of known HDR render intents
92const std::array<RenderIntent, 2> sHdrRenderIntents = {
93 RenderIntent::TONE_MAP_ENHANCE,
94 RenderIntent::TONE_MAP_COLORIMETRIC,
95};
96
97// map known color mode to dataspace
98Dataspace colorModeToDataspace(ColorMode mode) {
99 switch (mode) {
100 case ColorMode::SRGB:
Peiyong Lin14724e62018-12-05 07:27:30 -0800101 return Dataspace::V0_SRGB;
Chia-I Wube02ec02018-05-18 10:59:36 -0700102 case ColorMode::DISPLAY_P3:
103 return Dataspace::DISPLAY_P3;
Valerie Hau9758ae02018-10-09 16:05:09 -0700104 case ColorMode::DISPLAY_BT2020:
105 return Dataspace::DISPLAY_BT2020;
Chia-I Wube02ec02018-05-18 10:59:36 -0700106 case ColorMode::BT2100_HLG:
107 return Dataspace::BT2020_HLG;
108 case ColorMode::BT2100_PQ:
109 return Dataspace::BT2020_PQ;
110 default:
111 return Dataspace::UNKNOWN;
112 }
113}
114
115// Return a list of candidate color modes.
116std::vector<ColorMode> getColorModeCandidates(ColorMode mode) {
117 std::vector<ColorMode> candidates;
118
119 // add mode itself
120 candidates.push_back(mode);
121
122 // check if mode is HDR
123 bool isHdr = false;
124 for (auto hdrMode : sHdrColorModes) {
125 if (hdrMode == mode) {
126 isHdr = true;
127 break;
128 }
129 }
130
131 // add other HDR candidates when mode is HDR
132 if (isHdr) {
133 for (auto hdrMode : sHdrColorModes) {
134 if (hdrMode != mode) {
135 candidates.push_back(hdrMode);
136 }
137 }
138 }
139
140 // add other SDR candidates
141 for (auto sdrMode : sSdrColorModes) {
142 if (sdrMode != mode) {
143 candidates.push_back(sdrMode);
144 }
145 }
146
147 return candidates;
148}
149
150// Return a list of candidate render intents.
151std::vector<RenderIntent> getRenderIntentCandidates(RenderIntent intent) {
152 std::vector<RenderIntent> candidates;
153
154 // add intent itself
155 candidates.push_back(intent);
156
157 // check if intent is HDR
158 bool isHdr = false;
159 for (auto hdrIntent : sHdrRenderIntents) {
160 if (hdrIntent == intent) {
161 isHdr = true;
162 break;
163 }
164 }
165
Chia-I Wube02ec02018-05-18 10:59:36 -0700166 if (isHdr) {
Chia-I Wuc4b08bd2018-05-29 12:57:23 -0700167 // add other HDR candidates when intent is HDR
Chia-I Wube02ec02018-05-18 10:59:36 -0700168 for (auto hdrIntent : sHdrRenderIntents) {
169 if (hdrIntent != intent) {
170 candidates.push_back(hdrIntent);
171 }
172 }
Chia-I Wuc4b08bd2018-05-29 12:57:23 -0700173 } else {
174 // add other SDR candidates when intent is SDR
175 for (auto sdrIntent : sSdrRenderIntents) {
176 if (sdrIntent != intent) {
177 candidates.push_back(sdrIntent);
178 }
179 }
Chia-I Wube02ec02018-05-18 10:59:36 -0700180 }
181
182 return candidates;
183}
184
185// Return the best color mode supported by HWC.
186ColorMode getHwcColorMode(
187 const std::unordered_map<ColorMode, std::vector<RenderIntent>>& hwcColorModes,
188 ColorMode mode) {
189 std::vector<ColorMode> candidates = getColorModeCandidates(mode);
190 for (auto candidate : candidates) {
191 auto iter = hwcColorModes.find(candidate);
192 if (iter != hwcColorModes.end()) {
193 return candidate;
194 }
195 }
196
197 return ColorMode::NATIVE;
198}
199
200// Return the best render intent supported by HWC.
201RenderIntent getHwcRenderIntent(const std::vector<RenderIntent>& hwcIntents, RenderIntent intent) {
202 std::vector<RenderIntent> candidates = getRenderIntentCandidates(intent);
203 for (auto candidate : candidates) {
204 for (auto hwcIntent : hwcIntents) {
205 if (candidate == hwcIntent) {
206 return candidate;
207 }
208 }
209 }
210
211 return RenderIntent::COLORIMETRIC;
212}
213
214} // anonymous namespace
215
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700216DisplayDeviceCreationArgs::DisplayDeviceCreationArgs(const sp<SurfaceFlinger>& flinger,
217 const wp<IBinder>& displayToken,
Dominik Laskowski075d3172018-05-24 15:50:06 -0700218 const std::optional<DisplayId>& displayId)
219 : flinger(flinger), displayToken(displayToken), displayId(displayId) {}
Chia-I Wube02ec02018-05-18 10:59:36 -0700220
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700221DisplayDevice::DisplayDevice(DisplayDeviceCreationArgs&& args)
222 : lastCompositionHadVisibleLayers(false),
223 mFlinger(args.flinger),
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700224 mDisplayToken(args.displayToken),
Dominik Laskowskie9774092018-12-11 10:04:24 -0800225 mSequenceId(args.sequenceId),
Dominik Laskowski075d3172018-05-24 15:50:06 -0700226 mId(args.displayId),
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700227 mNativeWindow(args.nativeWindow),
Alec Mouri0a9c7b82018-11-16 13:05:25 -0800228 mGraphicBuffer(nullptr),
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700229 mDisplaySurface(args.displaySurface),
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700230 mDisplayInstallOrientation(args.displayInstallOrientation),
231 mPageFlipCount(0),
Dominik Laskowski075d3172018-05-24 15:50:06 -0700232 mIsVirtual(args.isVirtual),
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700233 mIsSecure(args.isSecure),
234 mLayerStack(NO_LAYER_STACK),
235 mOrientation(),
236 mViewport(Rect::INVALID_RECT),
237 mFrame(Rect::INVALID_RECT),
238 mPowerMode(args.initialPowerMode),
239 mActiveConfig(0),
240 mColorTransform(HAL_COLOR_TRANSFORM_IDENTITY),
241 mHasWideColorGamut(args.hasWideColorGamut),
242 mHasHdr10(false),
243 mHasHLG(false),
244 mHasDolbyVision(false),
Dominik Laskowski075d3172018-05-24 15:50:06 -0700245 mSupportedPerFrameMetadata(args.supportedPerFrameMetadata),
246 mIsPrimary(args.isPrimary) {
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700247 populateColorModes(args.hwcColorModes);
248
249 ALOGE_IF(!mNativeWindow, "No native window was set for display");
250 ALOGE_IF(!mDisplaySurface, "No display surface was set for display");
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700251
252 std::vector<Hdr> types = args.hdrCapabilities.getSupportedHdrTypes();
Peiyong Linfb069302018-04-25 14:34:31 -0700253 for (Hdr hdrType : types) {
Peiyong Lin62665892018-04-16 11:07:44 -0700254 switch (hdrType) {
255 case Hdr::HDR10:
256 mHasHdr10 = true;
257 break;
258 case Hdr::HLG:
259 mHasHLG = true;
260 break;
261 case Hdr::DOLBY_VISION:
262 mHasDolbyVision = true;
263 break;
264 default:
265 ALOGE("UNKNOWN HDR capability: %d", static_cast<int32_t>(hdrType));
266 }
267 }
Jesse Hallffe1f192013-03-22 15:13:48 -0700268
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700269 float minLuminance = args.hdrCapabilities.getDesiredMinLuminance();
270 float maxLuminance = args.hdrCapabilities.getDesiredMaxLuminance();
271 float maxAverageLuminance = args.hdrCapabilities.getDesiredMaxAverageLuminance();
Peiyong Linfb069302018-04-25 14:34:31 -0700272
273 minLuminance = minLuminance <= 0.0 ? sDefaultMinLumiance : minLuminance;
274 maxLuminance = maxLuminance <= 0.0 ? sDefaultMaxLumiance : maxLuminance;
275 maxAverageLuminance = maxAverageLuminance <= 0.0 ? sDefaultMaxLumiance : maxAverageLuminance;
276 if (this->hasWideColorGamut()) {
277 // insert HDR10/HLG as we will force client composition for HDR10/HLG
278 // layers
279 if (!hasHDR10Support()) {
280 types.push_back(Hdr::HDR10);
281 }
282
283 if (!hasHLGSupport()) {
284 types.push_back(Hdr::HLG);
285 }
286 }
287 mHdrCapabilities = HdrCapabilities(types, maxLuminance, maxAverageLuminance, minLuminance);
288
Alec Mouriba013fa2018-10-16 12:43:11 -0700289 ANativeWindow* const window = mNativeWindow.get();
Alec Mouri0a9c7b82018-11-16 13:05:25 -0800290
Alec Mouri4efb6c22018-11-16 13:07:47 -0800291 int status = native_window_api_connect(window, NATIVE_WINDOW_API_EGL);
Alec Mouri0a9c7b82018-11-16 13:05:25 -0800292 ALOGE_IF(status != NO_ERROR, "Unable to connect BQ producer: %d", status);
Alec Mouri4efb6c22018-11-16 13:07:47 -0800293 status = native_window_set_buffers_format(window, HAL_PIXEL_FORMAT_RGBA_8888);
294 ALOGE_IF(status != NO_ERROR, "Unable to set BQ format to RGBA888: %d", status);
295 status = native_window_set_usage(window, GRALLOC_USAGE_HW_RENDER);
296 ALOGE_IF(status != NO_ERROR, "Unable to set BQ usage bits for GPU rendering: %d", status);
Alec Mouri0a9c7b82018-11-16 13:05:25 -0800297
Alec Mouriba013fa2018-10-16 12:43:11 -0700298 mDisplayWidth = ANativeWindow_getWidth(window);
299 mDisplayHeight = ANativeWindow_getHeight(window);
300
Jesse Hallffe1f192013-03-22 15:13:48 -0700301 // initialize the display orientation transform.
302 setProjection(DisplayState::eOrientationDefault, mViewport, mFrame);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800303}
304
Lloyd Pique09594832018-01-22 17:48:03 -0800305DisplayDevice::~DisplayDevice() = default;
Mathias Agopian92a979a2012-08-02 18:32:23 -0700306
Jesse Hall02d86562013-03-25 14:43:23 -0700307void DisplayDevice::disconnect(HWComposer& hwc) {
Dominik Laskowski075d3172018-05-24 15:50:06 -0700308 if (mId) {
309 hwc.disconnectDisplay(*mId);
310 mId.reset();
Jesse Hall02d86562013-03-25 14:43:23 -0700311 }
312}
313
Mathias Agopian0f2f5ff2012-07-31 23:09:07 -0700314int DisplayDevice::getWidth() const {
Mathias Agopiana4912602012-07-12 14:25:33 -0700315 return mDisplayWidth;
316}
317
Mathias Agopian0f2f5ff2012-07-31 23:09:07 -0700318int DisplayDevice::getHeight() const {
Mathias Agopiana4912602012-07-12 14:25:33 -0700319 return mDisplayHeight;
320}
321
Dominik Laskowskibf170d92018-04-19 15:08:05 -0700322void DisplayDevice::setDisplayName(const std::string& displayName) {
323 if (!displayName.empty()) {
Mathias Agopian9e2463e2012-09-21 18:26:16 -0700324 // never override the name with an empty name
325 mDisplayName = displayName;
326 }
327}
328
Mathias Agopian0f2f5ff2012-07-31 23:09:07 -0700329uint32_t DisplayDevice::getPageFlipCount() const {
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700330 return mPageFlipCount;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800331}
332
Chia-I Wub02087d2017-11-09 10:19:54 -0800333void DisplayDevice::flip() const
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800334{
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700335 mPageFlipCount++;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800336}
337
Dan Stoza71433162014-02-04 16:22:36 -0800338status_t DisplayDevice::beginFrame(bool mustRecompose) const {
339 return mDisplaySurface->beginFrame(mustRecompose);
Jesse Hall028dc8f2013-08-20 16:35:32 -0700340}
341
David Sodmanfb95bcc2017-12-22 15:45:30 -0800342status_t DisplayDevice::prepareFrame(HWComposer& hwc,
343 std::vector<CompositionInfo>& compositionData) {
Dominik Laskowski075d3172018-05-24 15:50:06 -0700344 if (mId) {
345 status_t error = hwc.prepare(*mId, compositionData);
346 if (error != NO_ERROR) {
347 return error;
348 }
Dan Stoza9e56aa02015-11-02 13:00:03 -0800349 }
350
351 DisplaySurface::CompositionType compositionType;
Dominik Laskowski7e045462018-05-30 13:02:02 -0700352 bool hasClient = hwc.hasClientComposition(mId);
353 bool hasDevice = hwc.hasDeviceComposition(mId);
Dan Stoza9e56aa02015-11-02 13:00:03 -0800354 if (hasClient && hasDevice) {
355 compositionType = DisplaySurface::COMPOSITION_MIXED;
356 } else if (hasClient) {
357 compositionType = DisplaySurface::COMPOSITION_GLES;
358 } else if (hasDevice) {
359 compositionType = DisplaySurface::COMPOSITION_HWC;
360 } else {
361 // Nothing to do -- when turning the screen off we get a frame like
362 // this. Call it a HWC frame since we won't be doing any GLES work but
363 // will do a prepare/set cycle.
364 compositionType = DisplaySurface::COMPOSITION_HWC;
365 }
366 return mDisplaySurface->prepareFrame(compositionType);
367}
Jesse Hall38efe862013-04-06 23:12:29 -0700368
Alec Mouri0a9c7b82018-11-16 13:05:25 -0800369sp<GraphicBuffer> DisplayDevice::dequeueBuffer() {
370 int fd;
371 ANativeWindowBuffer* buffer;
372
373 status_t res = mNativeWindow->dequeueBuffer(mNativeWindow.get(), &buffer, &fd);
374
375 if (res != NO_ERROR) {
376 ALOGE("ANativeWindow::dequeueBuffer failed for display [%s] with error: %d",
377 getDisplayName().c_str(), res);
378 // Return fast here as we can't do much more - any rendering we do
379 // now will just be wrong.
380 return mGraphicBuffer;
381 }
382
383 ALOGW_IF(mGraphicBuffer != nullptr, "Clobbering a non-null pointer to a buffer [%p].",
384 mGraphicBuffer->getNativeBuffer()->handle);
385 mGraphicBuffer = GraphicBuffer::from(buffer);
386
387 // Block until the buffer is ready
388 // TODO(alecmouri): it's perhaps more appropriate to block renderengine so
389 // that the gl driver can block instead.
390 if (fd >= 0) {
391 sync_wait(fd, -1);
392 close(fd);
393 }
394
395 return mGraphicBuffer;
396}
397
398void DisplayDevice::queueBuffer(HWComposer& hwc) {
Dominik Laskowski7e045462018-05-30 13:02:02 -0700399 if (hwc.hasClientComposition(mId) || hwc.hasFlipClientTargetRequest(mId)) {
Alec Mouri0a9c7b82018-11-16 13:05:25 -0800400 // hasFlipClientTargetRequest could return true even if we haven't
401 // dequeued a buffer before. Try dequeueing one if we don't have a
402 // buffer ready.
403 if (mGraphicBuffer == nullptr) {
404 ALOGI("Attempting to queue a client composited buffer without one "
405 "previously dequeued for display [%s]. Attempting to dequeue "
406 "a scratch buffer now",
407 mDisplayName.c_str());
408 // We shouldn't deadlock here, since mGraphicBuffer == nullptr only
409 // after a successful call to queueBuffer, or if dequeueBuffer has
410 // never been called.
411 dequeueBuffer();
412 }
413
414 if (mGraphicBuffer == nullptr) {
415 ALOGE("No buffer is ready for display [%s]", mDisplayName.c_str());
416 } else {
Alec Mouri0a9c7b82018-11-16 13:05:25 -0800417 status_t res = mNativeWindow->queueBuffer(mNativeWindow.get(),
Alec Mouri745163a2018-12-04 15:15:50 -0800418 mGraphicBuffer->getNativeBuffer(),
419 dup(mBufferReady));
Alec Mouri0a9c7b82018-11-16 13:05:25 -0800420 if (res != NO_ERROR) {
421 ALOGE("Error when queueing buffer for display [%s]: %d", mDisplayName.c_str(), res);
422 // We risk blocking on dequeueBuffer if the primary display failed
423 // to queue up its buffer, so crash here.
424 if (isPrimary()) {
425 LOG_ALWAYS_FATAL("ANativeWindow::queueBuffer failed with error: %d", res);
426 } else {
427 mNativeWindow->cancelBuffer(mNativeWindow.get(),
Alec Mouri745163a2018-12-04 15:15:50 -0800428 mGraphicBuffer->getNativeBuffer(),
429 dup(mBufferReady));
Alec Mouri0a9c7b82018-11-16 13:05:25 -0800430 }
431 }
Alec Mouri745163a2018-12-04 15:15:50 -0800432
433 mBufferReady.reset();
Alec Mouri0a9c7b82018-11-16 13:05:25 -0800434 mGraphicBuffer = nullptr;
435 }
Mathias Agopianda27af92012-09-13 18:17:13 -0700436 }
Mathias Agopian52e21482012-09-24 18:07:21 -0700437
Jesse Hall99c7dbb2013-03-14 14:29:29 -0700438 status_t result = mDisplaySurface->advanceFrame();
439 if (result != NO_ERROR) {
Dominik Laskowskibf170d92018-04-19 15:08:05 -0700440 ALOGE("[%s] failed pushing new frame to HWC: %d", mDisplayName.c_str(), result);
Mathias Agopian32341382012-09-25 19:16:28 -0700441 }
Mathias Agopianda27af92012-09-13 18:17:13 -0700442}
443
Alec Mouri0a9c7b82018-11-16 13:05:25 -0800444void DisplayDevice::onPresentDisplayCompleted() {
Dan Stoza9e56aa02015-11-02 13:00:03 -0800445 mDisplaySurface->onFrameCommitted();
446}
Mathias Agopianda27af92012-09-13 18:17:13 -0700447
Mathias Agopian875d8e12013-06-07 15:35:48 -0700448void DisplayDevice::setViewportAndProjection() const {
449 size_t w = mDisplayWidth;
450 size_t h = mDisplayHeight;
Dan Stozac1879002014-05-22 15:59:05 -0700451 Rect sourceCrop(0, 0, w, h);
Chia-I Wu1be50b52018-08-29 10:44:48 -0700452 mFlinger->getRenderEngine().setViewportAndProjection(w, h, sourceCrop, ui::Transform::ROT_0);
Mathias Agopianbae92d02012-09-28 01:00:47 -0700453}
454
Alec Mouri0a9c7b82018-11-16 13:05:25 -0800455void DisplayDevice::finishBuffer() {
456 mBufferReady = mFlinger->getRenderEngine().flush();
457 if (mBufferReady.get() < 0) {
458 mFlinger->getRenderEngine().finish();
459 }
460}
461
Dan Stoza9e56aa02015-11-02 13:00:03 -0800462const sp<Fence>& DisplayDevice::getClientTargetAcquireFence() const {
463 return mDisplaySurface->getClientTargetAcquireFence();
464}
Dan Stoza9e56aa02015-11-02 13:00:03 -0800465
Mathias Agopian1b031492012-06-20 17:51:20 -0700466// ----------------------------------------------------------------------------
467
Mathias Agopian13127d82013-03-05 17:47:11 -0800468void DisplayDevice::setVisibleLayersSortedByZ(const Vector< sp<Layer> >& layers) {
Mathias Agopian3b1d2b62012-07-11 13:48:17 -0700469 mVisibleLayersSortedByZ = layers;
Mathias Agopian3b1d2b62012-07-11 13:48:17 -0700470}
471
Mathias Agopian13127d82013-03-05 17:47:11 -0800472const Vector< sp<Layer> >& DisplayDevice::getVisibleLayersSortedByZ() const {
Mathias Agopian3b1d2b62012-07-11 13:48:17 -0700473 return mVisibleLayersSortedByZ;
474}
475
Chia-I Wu83806892017-11-16 10:50:20 -0800476void DisplayDevice::setLayersNeedingFences(const Vector< sp<Layer> >& layers) {
477 mLayersNeedingFences = layers;
478}
479
480const Vector< sp<Layer> >& DisplayDevice::getLayersNeedingFences() const {
481 return mLayersNeedingFences;
482}
483
Mathias Agopiancd60f992012-08-16 16:28:27 -0700484Region DisplayDevice::getDirtyRegion(bool repaintEverything) const {
485 Region dirty;
Mathias Agopiancd60f992012-08-16 16:28:27 -0700486 if (repaintEverything) {
487 dirty.set(getBounds());
488 } else {
Peiyong Linefefaac2018-08-17 12:27:51 -0700489 const ui::Transform& planeTransform(mGlobalTransform);
Mathias Agopiancd60f992012-08-16 16:28:27 -0700490 dirty = planeTransform.transform(this->dirtyRegion);
491 dirty.andSelf(getBounds());
492 }
493 return dirty;
494}
495
Mathias Agopian3b1d2b62012-07-11 13:48:17 -0700496// ----------------------------------------------------------------------------
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700497void DisplayDevice::setPowerMode(int mode) {
498 mPowerMode = mode;
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700499}
500
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700501int DisplayDevice::getPowerMode() const {
502 return mPowerMode;
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700503}
504
Dominik Laskowskieecd6592018-05-29 10:25:41 -0700505bool DisplayDevice::isPoweredOn() const {
506 return mPowerMode != HWC_POWER_MODE_OFF;
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700507}
508
509// ----------------------------------------------------------------------------
Michael Lentine6c9e34a2014-07-14 13:48:55 -0700510void DisplayDevice::setActiveConfig(int mode) {
511 mActiveConfig = mode;
512}
513
514int DisplayDevice::getActiveConfig() const {
515 return mActiveConfig;
516}
517
518// ----------------------------------------------------------------------------
Peiyong Lina52f0292018-03-14 17:26:31 -0700519void DisplayDevice::setActiveColorMode(ColorMode mode) {
Michael Wright28f24d02016-07-12 13:30:53 -0700520 mActiveColorMode = mode;
521}
522
Peiyong Lina52f0292018-03-14 17:26:31 -0700523ColorMode DisplayDevice::getActiveColorMode() const {
Michael Wright28f24d02016-07-12 13:30:53 -0700524 return mActiveColorMode;
525}
Courtney Goeltzenleuchter79d27242017-07-13 17:54:01 -0600526
Peiyong Lindd9b2ae2018-03-01 16:22:45 -0800527RenderIntent DisplayDevice::getActiveRenderIntent() const {
528 return mActiveRenderIntent;
529}
530
531void DisplayDevice::setActiveRenderIntent(RenderIntent renderIntent) {
532 mActiveRenderIntent = renderIntent;
533}
534
Yiwei Zhang7c64f172018-03-07 14:52:28 -0800535void DisplayDevice::setColorTransform(const mat4& transform) {
536 const bool isIdentity = (transform == mat4());
537 mColorTransform =
538 isIdentity ? HAL_COLOR_TRANSFORM_IDENTITY : HAL_COLOR_TRANSFORM_ARBITRARY_MATRIX;
539}
540
541android_color_transform_t DisplayDevice::getColorTransform() const {
542 return mColorTransform;
543}
544
Peiyong Lin34beb7a2018-03-28 11:57:12 -0700545void DisplayDevice::setCompositionDataSpace(ui::Dataspace dataspace) {
Peiyong Lindd9b2ae2018-03-01 16:22:45 -0800546 mCompositionDataSpace = dataspace;
Courtney Goeltzenleuchter79d27242017-07-13 17:54:01 -0600547 ANativeWindow* const window = mNativeWindow.get();
Peiyong Lin34beb7a2018-03-28 11:57:12 -0700548 native_window_set_buffers_data_space(window, static_cast<android_dataspace>(dataspace));
Courtney Goeltzenleuchter79d27242017-07-13 17:54:01 -0600549}
Michael Wright28f24d02016-07-12 13:30:53 -0700550
Peiyong Lindd9b2ae2018-03-01 16:22:45 -0800551ui::Dataspace DisplayDevice::getCompositionDataSpace() const {
552 return mCompositionDataSpace;
553}
554
Michael Wright28f24d02016-07-12 13:30:53 -0700555// ----------------------------------------------------------------------------
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700556
Mathias Agopian28947d72012-08-08 18:51:15 -0700557void DisplayDevice::setLayerStack(uint32_t stack) {
558 mLayerStack = stack;
559 dirtyRegion.set(bounds());
560}
561
562// ----------------------------------------------------------------------------
563
Mathias Agopianc1c05de2013-09-17 23:45:22 -0700564uint32_t DisplayDevice::getOrientationTransform() const {
565 uint32_t transform = 0;
566 switch (mOrientation) {
567 case DisplayState::eOrientationDefault:
Peiyong Linefefaac2018-08-17 12:27:51 -0700568 transform = ui::Transform::ROT_0;
Mathias Agopianc1c05de2013-09-17 23:45:22 -0700569 break;
570 case DisplayState::eOrientation90:
Peiyong Linefefaac2018-08-17 12:27:51 -0700571 transform = ui::Transform::ROT_90;
Mathias Agopianc1c05de2013-09-17 23:45:22 -0700572 break;
573 case DisplayState::eOrientation180:
Peiyong Linefefaac2018-08-17 12:27:51 -0700574 transform = ui::Transform::ROT_180;
Mathias Agopianc1c05de2013-09-17 23:45:22 -0700575 break;
576 case DisplayState::eOrientation270:
Peiyong Linefefaac2018-08-17 12:27:51 -0700577 transform = ui::Transform::ROT_270;
Mathias Agopianc1c05de2013-09-17 23:45:22 -0700578 break;
579 }
580 return transform;
581}
582
Mathias Agopian0f2f5ff2012-07-31 23:09:07 -0700583status_t DisplayDevice::orientationToTransfrom(
Peiyong Linefefaac2018-08-17 12:27:51 -0700584 int orientation, int w, int h, ui::Transform* tr)
Mathias Agopian1b031492012-06-20 17:51:20 -0700585{
586 uint32_t flags = 0;
587 switch (orientation) {
Mathias Agopian3165cc22012-08-08 19:42:09 -0700588 case DisplayState::eOrientationDefault:
Peiyong Linefefaac2018-08-17 12:27:51 -0700589 flags = ui::Transform::ROT_0;
Mathias Agopian1b031492012-06-20 17:51:20 -0700590 break;
Mathias Agopian3165cc22012-08-08 19:42:09 -0700591 case DisplayState::eOrientation90:
Peiyong Linefefaac2018-08-17 12:27:51 -0700592 flags = ui::Transform::ROT_90;
Mathias Agopian1b031492012-06-20 17:51:20 -0700593 break;
Mathias Agopian3165cc22012-08-08 19:42:09 -0700594 case DisplayState::eOrientation180:
Peiyong Linefefaac2018-08-17 12:27:51 -0700595 flags = ui::Transform::ROT_180;
Mathias Agopian1b031492012-06-20 17:51:20 -0700596 break;
Mathias Agopian3165cc22012-08-08 19:42:09 -0700597 case DisplayState::eOrientation270:
Peiyong Linefefaac2018-08-17 12:27:51 -0700598 flags = ui::Transform::ROT_270;
Mathias Agopian1b031492012-06-20 17:51:20 -0700599 break;
600 default:
601 return BAD_VALUE;
602 }
603 tr->set(flags, w, h);
604 return NO_ERROR;
605}
606
Michael Lentine47e45402014-07-18 15:34:25 -0700607void DisplayDevice::setDisplaySize(const int newWidth, const int newHeight) {
608 dirtyRegion.set(getBounds());
609
610 mDisplaySurface->resizeBuffers(newWidth, newHeight);
611
Alec Mouriba013fa2018-10-16 12:43:11 -0700612 mDisplayWidth = newWidth;
613 mDisplayHeight = newHeight;
Michael Lentine47e45402014-07-18 15:34:25 -0700614}
615
Mathias Agopian00e8c7a2012-09-04 19:30:46 -0700616void DisplayDevice::setProjection(int orientation,
Mathias Agopianf5f714a2013-02-26 16:54:05 -0800617 const Rect& newViewport, const Rect& newFrame) {
618 Rect viewport(newViewport);
619 Rect frame(newFrame);
620
621 const int w = mDisplayWidth;
622 const int h = mDisplayHeight;
623
Peiyong Linefefaac2018-08-17 12:27:51 -0700624 ui::Transform R;
Mathias Agopianf5f714a2013-02-26 16:54:05 -0800625 DisplayDevice::orientationToTransfrom(orientation, w, h, &R);
626
627 if (!frame.isValid()) {
628 // the destination frame can be invalid if it has never been set,
629 // in that case we assume the whole display frame.
630 frame = Rect(w, h);
631 }
632
633 if (viewport.isEmpty()) {
634 // viewport can be invalid if it has never been set, in that case
635 // we assume the whole display size.
636 // it's also invalid to have an empty viewport, so we handle that
637 // case in the same way.
638 viewport = Rect(w, h);
Peiyong Linefefaac2018-08-17 12:27:51 -0700639 if (R.getOrientation() & ui::Transform::ROT_90) {
Mathias Agopianf5f714a2013-02-26 16:54:05 -0800640 // viewport is always specified in the logical orientation
641 // of the display (ie: post-rotation).
Peiyong Lin3db42342018-08-16 09:15:59 -0700642 std::swap(viewport.right, viewport.bottom);
Mathias Agopianf5f714a2013-02-26 16:54:05 -0800643 }
644 }
645
646 dirtyRegion.set(getBounds());
647
Peiyong Linefefaac2018-08-17 12:27:51 -0700648 ui::Transform TL, TP, S;
Mathias Agopianf5f714a2013-02-26 16:54:05 -0800649 float src_width = viewport.width();
650 float src_height = viewport.height();
651 float dst_width = frame.width();
652 float dst_height = frame.height();
653 if (src_width != dst_width || src_height != dst_height) {
654 float sx = dst_width / src_width;
655 float sy = dst_height / src_height;
656 S.set(sx, 0, 0, sy);
657 }
658
659 float src_x = viewport.left;
660 float src_y = viewport.top;
661 float dst_x = frame.left;
662 float dst_y = frame.top;
663 TL.set(-src_x, -src_y);
664 TP.set(dst_x, dst_y);
665
Iris Chang7501ed62018-04-30 14:45:42 +0800666 // need to take care of primary display rotation for mGlobalTransform
667 // for case if the panel is not installed aligned with device orientation
Dominik Laskowski075d3172018-05-24 15:50:06 -0700668 if (isPrimary()) {
Iris Chang7501ed62018-04-30 14:45:42 +0800669 DisplayDevice::orientationToTransfrom(
Chia-I Wua02871c2018-08-27 14:38:23 -0700670 (orientation + mDisplayInstallOrientation) % (DisplayState::eOrientation270 + 1),
Iris Chang7501ed62018-04-30 14:45:42 +0800671 w, h, &R);
672 }
673
Mathias Agopianf5f714a2013-02-26 16:54:05 -0800674 // The viewport and frame are both in the logical orientation.
675 // Apply the logical translation, scale to physical size, apply the
676 // physical translation and finally rotate to the physical orientation.
677 mGlobalTransform = R * TP * S * TL;
678
679 const uint8_t type = mGlobalTransform.getType();
680 mNeedsFiltering = (!mGlobalTransform.preserveRects() ||
Peiyong Linefefaac2018-08-17 12:27:51 -0700681 (type >= ui::Transform::SCALE));
Mathias Agopianf5f714a2013-02-26 16:54:05 -0800682
683 mScissor = mGlobalTransform.transform(viewport);
684 if (mScissor.isEmpty()) {
Mathias Agopian6c7f25a2013-05-09 20:37:10 -0700685 mScissor = getBounds();
Mathias Agopianf5f714a2013-02-26 16:54:05 -0800686 }
687
Mathias Agopianda8d0a52012-09-04 15:05:38 -0700688 mOrientation = orientation;
Dominik Laskowski281644e2018-04-19 15:47:35 -0700689 if (isPrimary()) {
Pablo Ceballos021623b2016-04-15 17:31:51 -0700690 uint32_t transform = 0;
691 switch (mOrientation) {
692 case DisplayState::eOrientationDefault:
Peiyong Linefefaac2018-08-17 12:27:51 -0700693 transform = ui::Transform::ROT_0;
Pablo Ceballos021623b2016-04-15 17:31:51 -0700694 break;
695 case DisplayState::eOrientation90:
Peiyong Linefefaac2018-08-17 12:27:51 -0700696 transform = ui::Transform::ROT_90;
Pablo Ceballos021623b2016-04-15 17:31:51 -0700697 break;
698 case DisplayState::eOrientation180:
Peiyong Linefefaac2018-08-17 12:27:51 -0700699 transform = ui::Transform::ROT_180;
Pablo Ceballos021623b2016-04-15 17:31:51 -0700700 break;
701 case DisplayState::eOrientation270:
Peiyong Linefefaac2018-08-17 12:27:51 -0700702 transform = ui::Transform::ROT_270;
Pablo Ceballos021623b2016-04-15 17:31:51 -0700703 break;
704 }
705 sPrimaryDisplayOrientation = transform;
706 }
Mathias Agopian00e8c7a2012-09-04 19:30:46 -0700707 mViewport = viewport;
708 mFrame = frame;
Mathias Agopian1b031492012-06-20 17:51:20 -0700709}
Mathias Agopian1d12d8a2012-09-18 01:38:00 -0700710
Pablo Ceballos021623b2016-04-15 17:31:51 -0700711uint32_t DisplayDevice::getPrimaryDisplayOrientationTransform() {
712 return sPrimaryDisplayOrientation;
713}
714
Dominik Laskowski9b17b2c22018-11-01 14:49:03 -0700715std::string DisplayDevice::getDebugName() const {
Dominik Laskowski34157762018-10-31 13:07:19 -0700716 const auto id = mId ? to_string(*mId) + ", " : std::string();
Dominik Laskowski9b17b2c22018-11-01 14:49:03 -0700717 return base::StringPrintf("DisplayDevice{%s%s%s\"%s\"}", id.c_str(),
718 isPrimary() ? "primary, " : "", isVirtual() ? "virtual, " : "",
719 mDisplayName.c_str());
720}
721
Yiwei Zhang5434a782018-12-05 18:06:32 -0800722void DisplayDevice::dump(std::string& result) const {
Peiyong Linefefaac2018-08-17 12:27:51 -0700723 const ui::Transform& tr(mGlobalTransform);
Courtney Goeltzenleuchter152279d2017-08-14 18:18:30 -0600724 ANativeWindow* const window = mNativeWindow.get();
Yiwei Zhang5434a782018-12-05 18:06:32 -0800725 StringAppendF(&result, "+ %s\n", getDebugName().c_str());
726 StringAppendF(&result,
727 " layerStack=%u, (%4dx%4d), ANativeWindow=%p "
728 "format=%d, orient=%2d (type=%08x), flips=%u, isSecure=%d, "
729 "powerMode=%d, activeConfig=%d, numLayers=%zu\n",
730 mLayerStack, mDisplayWidth, mDisplayHeight, window,
731 ANativeWindow_getFormat(window), mOrientation, tr.getType(), getPageFlipCount(),
732 mIsSecure, mPowerMode, mActiveConfig, mVisibleLayersSortedByZ.size());
733 StringAppendF(&result,
734 " v:[%d,%d,%d,%d], f:[%d,%d,%d,%d], s:[%d,%d,%d,%d],"
735 "transform:[[%0.3f,%0.3f,%0.3f][%0.3f,%0.3f,%0.3f][%0.3f,%0.3f,%0.3f]]\n",
736 mViewport.left, mViewport.top, mViewport.right, mViewport.bottom, mFrame.left,
737 mFrame.top, mFrame.right, mFrame.bottom, mScissor.left, mScissor.top,
738 mScissor.right, mScissor.bottom, tr[0][0], tr[1][0], tr[2][0], tr[0][1], tr[1][1],
739 tr[2][1], tr[0][2], tr[1][2], tr[2][2]);
Courtney Goeltzenleuchter152279d2017-08-14 18:18:30 -0600740 auto const surface = static_cast<Surface*>(window);
Peiyong Lin34beb7a2018-03-28 11:57:12 -0700741 ui::Dataspace dataspace = surface->getBuffersDataSpace();
Yiwei Zhang5434a782018-12-05 18:06:32 -0800742 StringAppendF(&result, " wideColorGamut=%d, hdr10=%d, colorMode=%s, dataspace: %s (%d)\n",
743 mHasWideColorGamut, mHasHdr10, decodeColorMode(mActiveColorMode).c_str(),
744 dataspaceDetails(static_cast<android_dataspace>(dataspace)).c_str(), dataspace);
Mathias Agopian1d12d8a2012-09-18 01:38:00 -0700745
Jesse Hall99c7dbb2013-03-14 14:29:29 -0700746 String8 surfaceDump;
Dan Stozaf10c46e2014-11-11 10:32:31 -0800747 mDisplaySurface->dumpAsString(surfaceDump);
Yiwei Zhang5434a782018-12-05 18:06:32 -0800748 result.append(surfaceDump.string(), surfaceDump.size());
Mathias Agopian1d12d8a2012-09-18 01:38:00 -0700749}
Irvelffc9efc2016-07-27 15:16:37 -0700750
Chia-I Wube02ec02018-05-18 10:59:36 -0700751// Map dataspace/intent to the best matched dataspace/colorMode/renderIntent
752// supported by HWC.
753void DisplayDevice::addColorMode(
754 const std::unordered_map<ColorMode, std::vector<RenderIntent>>& hwcColorModes,
755 const ColorMode mode, const RenderIntent intent) {
756 // find the best color mode
757 const ColorMode hwcColorMode = getHwcColorMode(hwcColorModes, mode);
758
759 // find the best render intent
760 auto iter = hwcColorModes.find(hwcColorMode);
761 const auto& hwcIntents =
762 iter != hwcColorModes.end() ? iter->second : std::vector<RenderIntent>();
763 const RenderIntent hwcIntent = getHwcRenderIntent(hwcIntents, intent);
764
765 const Dataspace dataspace = colorModeToDataspace(mode);
766 const Dataspace hwcDataspace = colorModeToDataspace(hwcColorMode);
767
Dominik Laskowski9b17b2c22018-11-01 14:49:03 -0700768 ALOGV("%s: map (%s, %s) to (%s, %s, %s)", getDebugName().c_str(),
Chia-I Wube02ec02018-05-18 10:59:36 -0700769 dataspaceDetails(static_cast<android_dataspace_t>(dataspace)).c_str(),
770 decodeRenderIntent(intent).c_str(),
771 dataspaceDetails(static_cast<android_dataspace_t>(hwcDataspace)).c_str(),
772 decodeColorMode(hwcColorMode).c_str(), decodeRenderIntent(hwcIntent).c_str());
773
774 mColorModes[getColorModeKey(dataspace, intent)] = {hwcDataspace, hwcColorMode, hwcIntent};
775}
776
777void DisplayDevice::populateColorModes(
778 const std::unordered_map<ColorMode, std::vector<RenderIntent>>& hwcColorModes) {
779 if (!hasWideColorGamut()) {
780 return;
781 }
782
Chia-I Wu0d711262018-05-21 15:19:35 -0700783 // collect all known SDR render intents
784 std::unordered_set<RenderIntent> sdrRenderIntents(sSdrRenderIntents.begin(),
785 sSdrRenderIntents.end());
786 auto iter = hwcColorModes.find(ColorMode::SRGB);
787 if (iter != hwcColorModes.end()) {
788 for (auto intent : iter->second) {
789 sdrRenderIntents.insert(intent);
790 }
791 }
792
Chia-I Wuc4b08bd2018-05-29 12:57:23 -0700793 // add all known SDR combinations
Chia-I Wu0d711262018-05-21 15:19:35 -0700794 for (auto intent : sdrRenderIntents) {
Chia-I Wube02ec02018-05-18 10:59:36 -0700795 for (auto mode : sSdrColorModes) {
796 addColorMode(hwcColorModes, mode, intent);
Peiyong Lin136fbbc2018-04-17 15:09:44 -0700797 }
798 }
Chia-I Wube02ec02018-05-18 10:59:36 -0700799
Chia-I Wuc4b08bd2018-05-29 12:57:23 -0700800 // collect all known HDR render intents
801 std::unordered_set<RenderIntent> hdrRenderIntents(sHdrRenderIntents.begin(),
802 sHdrRenderIntents.end());
803 iter = hwcColorModes.find(ColorMode::BT2100_PQ);
804 if (iter != hwcColorModes.end()) {
805 for (auto intent : iter->second) {
806 hdrRenderIntents.insert(intent);
807 }
808 }
809
810 // add all known HDR combinations
Chia-I Wube02ec02018-05-18 10:59:36 -0700811 for (auto intent : sHdrRenderIntents) {
812 for (auto mode : sHdrColorModes) {
813 addColorMode(hwcColorModes, mode, intent);
814 }
815 }
816}
817
818bool DisplayDevice::hasRenderIntent(RenderIntent intent) const {
819 // assume a render intent is supported when SRGB supports it; we should
820 // get rid of that assumption.
Peiyong Lin14724e62018-12-05 07:27:30 -0800821 auto iter = mColorModes.find(getColorModeKey(Dataspace::V0_SRGB, intent));
Chia-I Wube02ec02018-05-18 10:59:36 -0700822 return iter != mColorModes.end() && iter->second.renderIntent == intent;
823}
824
Peiyong Lindfde5112018-06-05 10:58:41 -0700825bool DisplayDevice::hasLegacyHdrSupport(Dataspace dataspace) const {
Chia-I Wube02ec02018-05-18 10:59:36 -0700826 if ((dataspace == Dataspace::BT2020_PQ && hasHDR10Support()) ||
827 (dataspace == Dataspace::BT2020_HLG && hasHLGSupport())) {
828 auto iter =
829 mColorModes.find(getColorModeKey(dataspace, RenderIntent::TONE_MAP_COLORIMETRIC));
Peiyong Lindfde5112018-06-05 10:58:41 -0700830 return iter == mColorModes.end() || iter->second.dataspace != dataspace;
Chia-I Wube02ec02018-05-18 10:59:36 -0700831 }
832
833 return false;
834}
835
836void DisplayDevice::getBestColorMode(Dataspace dataspace, RenderIntent intent,
837 Dataspace* outDataspace, ColorMode* outMode,
838 RenderIntent* outIntent) const {
839 auto iter = mColorModes.find(getColorModeKey(dataspace, intent));
840 if (iter != mColorModes.end()) {
841 *outDataspace = iter->second.dataspace;
842 *outMode = iter->second.colorMode;
843 *outIntent = iter->second.renderIntent;
844 } else {
Chia-I Wu6333af52018-10-16 13:46:36 -0700845 // this is unexpected on a WCG display
846 if (hasWideColorGamut()) {
847 ALOGE("map unknown (%s)/(%s) to default color mode",
848 dataspaceDetails(static_cast<android_dataspace_t>(dataspace)).c_str(),
849 decodeRenderIntent(intent).c_str());
850 }
Chia-I Wube02ec02018-05-18 10:59:36 -0700851
852 *outDataspace = Dataspace::UNKNOWN;
853 *outMode = ColorMode::NATIVE;
854 *outIntent = RenderIntent::COLORIMETRIC;
855 }
Peiyong Lin136fbbc2018-04-17 15:09:44 -0700856}
857
Dominik Laskowski663bd282018-04-19 15:26:54 -0700858std::atomic<int32_t> DisplayDeviceState::sNextSequenceId(1);
Peiyong Linfd997e02018-03-28 15:29:00 -0700859
860} // namespace android