blob: 2963a97608400c61664eaf4bf9c459373c1797e8 [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 Laskowski075d3172018-05-24 15:50:06 -0700225 mId(args.displayId),
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700226 mNativeWindow(args.nativeWindow),
Alec Mouri0a9c7b82018-11-16 13:05:25 -0800227 mGraphicBuffer(nullptr),
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700228 mDisplaySurface(args.displaySurface),
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700229 mDisplayInstallOrientation(args.displayInstallOrientation),
230 mPageFlipCount(0),
Dominik Laskowski075d3172018-05-24 15:50:06 -0700231 mIsVirtual(args.isVirtual),
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700232 mIsSecure(args.isSecure),
233 mLayerStack(NO_LAYER_STACK),
234 mOrientation(),
235 mViewport(Rect::INVALID_RECT),
236 mFrame(Rect::INVALID_RECT),
237 mPowerMode(args.initialPowerMode),
238 mActiveConfig(0),
239 mColorTransform(HAL_COLOR_TRANSFORM_IDENTITY),
240 mHasWideColorGamut(args.hasWideColorGamut),
241 mHasHdr10(false),
242 mHasHLG(false),
243 mHasDolbyVision(false),
Dominik Laskowski075d3172018-05-24 15:50:06 -0700244 mSupportedPerFrameMetadata(args.supportedPerFrameMetadata),
245 mIsPrimary(args.isPrimary) {
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700246 populateColorModes(args.hwcColorModes);
247
248 ALOGE_IF(!mNativeWindow, "No native window was set for display");
249 ALOGE_IF(!mDisplaySurface, "No display surface was set for display");
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700250
251 std::vector<Hdr> types = args.hdrCapabilities.getSupportedHdrTypes();
Peiyong Linfb069302018-04-25 14:34:31 -0700252 for (Hdr hdrType : types) {
Peiyong Lin62665892018-04-16 11:07:44 -0700253 switch (hdrType) {
254 case Hdr::HDR10:
255 mHasHdr10 = true;
256 break;
257 case Hdr::HLG:
258 mHasHLG = true;
259 break;
260 case Hdr::DOLBY_VISION:
261 mHasDolbyVision = true;
262 break;
263 default:
264 ALOGE("UNKNOWN HDR capability: %d", static_cast<int32_t>(hdrType));
265 }
266 }
Jesse Hallffe1f192013-03-22 15:13:48 -0700267
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700268 float minLuminance = args.hdrCapabilities.getDesiredMinLuminance();
269 float maxLuminance = args.hdrCapabilities.getDesiredMaxLuminance();
270 float maxAverageLuminance = args.hdrCapabilities.getDesiredMaxAverageLuminance();
Peiyong Linfb069302018-04-25 14:34:31 -0700271
272 minLuminance = minLuminance <= 0.0 ? sDefaultMinLumiance : minLuminance;
273 maxLuminance = maxLuminance <= 0.0 ? sDefaultMaxLumiance : maxLuminance;
274 maxAverageLuminance = maxAverageLuminance <= 0.0 ? sDefaultMaxLumiance : maxAverageLuminance;
275 if (this->hasWideColorGamut()) {
276 // insert HDR10/HLG as we will force client composition for HDR10/HLG
277 // layers
278 if (!hasHDR10Support()) {
279 types.push_back(Hdr::HDR10);
280 }
281
282 if (!hasHLGSupport()) {
283 types.push_back(Hdr::HLG);
284 }
285 }
286 mHdrCapabilities = HdrCapabilities(types, maxLuminance, maxAverageLuminance, minLuminance);
287
Alec Mouriba013fa2018-10-16 12:43:11 -0700288 ANativeWindow* const window = mNativeWindow.get();
Alec Mouri0a9c7b82018-11-16 13:05:25 -0800289
Alec Mouri4efb6c22018-11-16 13:07:47 -0800290 int status = native_window_api_connect(window, NATIVE_WINDOW_API_EGL);
Alec Mouri0a9c7b82018-11-16 13:05:25 -0800291 ALOGE_IF(status != NO_ERROR, "Unable to connect BQ producer: %d", status);
Alec Mouri4efb6c22018-11-16 13:07:47 -0800292 status = native_window_set_buffers_format(window, HAL_PIXEL_FORMAT_RGBA_8888);
293 ALOGE_IF(status != NO_ERROR, "Unable to set BQ format to RGBA888: %d", status);
294 status = native_window_set_usage(window, GRALLOC_USAGE_HW_RENDER);
295 ALOGE_IF(status != NO_ERROR, "Unable to set BQ usage bits for GPU rendering: %d", status);
Alec Mouri0a9c7b82018-11-16 13:05:25 -0800296
Alec Mouriba013fa2018-10-16 12:43:11 -0700297 mDisplayWidth = ANativeWindow_getWidth(window);
298 mDisplayHeight = ANativeWindow_getHeight(window);
299
Jesse Hallffe1f192013-03-22 15:13:48 -0700300 // initialize the display orientation transform.
301 setProjection(DisplayState::eOrientationDefault, mViewport, mFrame);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800302}
303
Lloyd Pique09594832018-01-22 17:48:03 -0800304DisplayDevice::~DisplayDevice() = default;
Mathias Agopian92a979a2012-08-02 18:32:23 -0700305
Jesse Hall02d86562013-03-25 14:43:23 -0700306void DisplayDevice::disconnect(HWComposer& hwc) {
Dominik Laskowski075d3172018-05-24 15:50:06 -0700307 if (mId) {
308 hwc.disconnectDisplay(*mId);
309 mId.reset();
Jesse Hall02d86562013-03-25 14:43:23 -0700310 }
311}
312
Mathias Agopian0f2f5ff2012-07-31 23:09:07 -0700313int DisplayDevice::getWidth() const {
Mathias Agopiana4912602012-07-12 14:25:33 -0700314 return mDisplayWidth;
315}
316
Mathias Agopian0f2f5ff2012-07-31 23:09:07 -0700317int DisplayDevice::getHeight() const {
Mathias Agopiana4912602012-07-12 14:25:33 -0700318 return mDisplayHeight;
319}
320
Dominik Laskowskibf170d92018-04-19 15:08:05 -0700321void DisplayDevice::setDisplayName(const std::string& displayName) {
322 if (!displayName.empty()) {
Mathias Agopian9e2463e2012-09-21 18:26:16 -0700323 // never override the name with an empty name
324 mDisplayName = displayName;
325 }
326}
327
Mathias Agopian0f2f5ff2012-07-31 23:09:07 -0700328uint32_t DisplayDevice::getPageFlipCount() const {
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700329 return mPageFlipCount;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800330}
331
Chia-I Wub02087d2017-11-09 10:19:54 -0800332void DisplayDevice::flip() const
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800333{
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700334 mPageFlipCount++;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800335}
336
Dan Stoza71433162014-02-04 16:22:36 -0800337status_t DisplayDevice::beginFrame(bool mustRecompose) const {
338 return mDisplaySurface->beginFrame(mustRecompose);
Jesse Hall028dc8f2013-08-20 16:35:32 -0700339}
340
David Sodmanfb95bcc2017-12-22 15:45:30 -0800341status_t DisplayDevice::prepareFrame(HWComposer& hwc,
342 std::vector<CompositionInfo>& compositionData) {
Dominik Laskowski075d3172018-05-24 15:50:06 -0700343 if (mId) {
344 status_t error = hwc.prepare(*mId, compositionData);
345 if (error != NO_ERROR) {
346 return error;
347 }
Dan Stoza9e56aa02015-11-02 13:00:03 -0800348 }
349
350 DisplaySurface::CompositionType compositionType;
Dominik Laskowski7e045462018-05-30 13:02:02 -0700351 bool hasClient = hwc.hasClientComposition(mId);
352 bool hasDevice = hwc.hasDeviceComposition(mId);
Dan Stoza9e56aa02015-11-02 13:00:03 -0800353 if (hasClient && hasDevice) {
354 compositionType = DisplaySurface::COMPOSITION_MIXED;
355 } else if (hasClient) {
356 compositionType = DisplaySurface::COMPOSITION_GLES;
357 } else if (hasDevice) {
358 compositionType = DisplaySurface::COMPOSITION_HWC;
359 } else {
360 // Nothing to do -- when turning the screen off we get a frame like
361 // this. Call it a HWC frame since we won't be doing any GLES work but
362 // will do a prepare/set cycle.
363 compositionType = DisplaySurface::COMPOSITION_HWC;
364 }
365 return mDisplaySurface->prepareFrame(compositionType);
366}
Jesse Hall38efe862013-04-06 23:12:29 -0700367
Alec Mouri0a9c7b82018-11-16 13:05:25 -0800368sp<GraphicBuffer> DisplayDevice::dequeueBuffer() {
369 int fd;
370 ANativeWindowBuffer* buffer;
371
372 status_t res = mNativeWindow->dequeueBuffer(mNativeWindow.get(), &buffer, &fd);
373
374 if (res != NO_ERROR) {
375 ALOGE("ANativeWindow::dequeueBuffer failed for display [%s] with error: %d",
376 getDisplayName().c_str(), res);
377 // Return fast here as we can't do much more - any rendering we do
378 // now will just be wrong.
379 return mGraphicBuffer;
380 }
381
382 ALOGW_IF(mGraphicBuffer != nullptr, "Clobbering a non-null pointer to a buffer [%p].",
383 mGraphicBuffer->getNativeBuffer()->handle);
384 mGraphicBuffer = GraphicBuffer::from(buffer);
385
386 // Block until the buffer is ready
387 // TODO(alecmouri): it's perhaps more appropriate to block renderengine so
388 // that the gl driver can block instead.
389 if (fd >= 0) {
390 sync_wait(fd, -1);
391 close(fd);
392 }
393
394 return mGraphicBuffer;
395}
396
397void DisplayDevice::queueBuffer(HWComposer& hwc) {
Dominik Laskowski7e045462018-05-30 13:02:02 -0700398 if (hwc.hasClientComposition(mId) || hwc.hasFlipClientTargetRequest(mId)) {
Alec Mouri0a9c7b82018-11-16 13:05:25 -0800399 // hasFlipClientTargetRequest could return true even if we haven't
400 // dequeued a buffer before. Try dequeueing one if we don't have a
401 // buffer ready.
402 if (mGraphicBuffer == nullptr) {
403 ALOGI("Attempting to queue a client composited buffer without one "
404 "previously dequeued for display [%s]. Attempting to dequeue "
405 "a scratch buffer now",
406 mDisplayName.c_str());
407 // We shouldn't deadlock here, since mGraphicBuffer == nullptr only
408 // after a successful call to queueBuffer, or if dequeueBuffer has
409 // never been called.
410 dequeueBuffer();
411 }
412
413 if (mGraphicBuffer == nullptr) {
414 ALOGE("No buffer is ready for display [%s]", mDisplayName.c_str());
415 } else {
Alec Mouri0a9c7b82018-11-16 13:05:25 -0800416 status_t res = mNativeWindow->queueBuffer(mNativeWindow.get(),
Alec Mouri745163a2018-12-04 15:15:50 -0800417 mGraphicBuffer->getNativeBuffer(),
418 dup(mBufferReady));
Alec Mouri0a9c7b82018-11-16 13:05:25 -0800419 if (res != NO_ERROR) {
420 ALOGE("Error when queueing buffer for display [%s]: %d", mDisplayName.c_str(), res);
421 // We risk blocking on dequeueBuffer if the primary display failed
422 // to queue up its buffer, so crash here.
423 if (isPrimary()) {
424 LOG_ALWAYS_FATAL("ANativeWindow::queueBuffer failed with error: %d", res);
425 } else {
426 mNativeWindow->cancelBuffer(mNativeWindow.get(),
Alec Mouri745163a2018-12-04 15:15:50 -0800427 mGraphicBuffer->getNativeBuffer(),
428 dup(mBufferReady));
Alec Mouri0a9c7b82018-11-16 13:05:25 -0800429 }
430 }
Alec Mouri745163a2018-12-04 15:15:50 -0800431
432 mBufferReady.reset();
Alec Mouri0a9c7b82018-11-16 13:05:25 -0800433 mGraphicBuffer = nullptr;
434 }
Mathias Agopianda27af92012-09-13 18:17:13 -0700435 }
Mathias Agopian52e21482012-09-24 18:07:21 -0700436
Jesse Hall99c7dbb2013-03-14 14:29:29 -0700437 status_t result = mDisplaySurface->advanceFrame();
438 if (result != NO_ERROR) {
Dominik Laskowskibf170d92018-04-19 15:08:05 -0700439 ALOGE("[%s] failed pushing new frame to HWC: %d", mDisplayName.c_str(), result);
Mathias Agopian32341382012-09-25 19:16:28 -0700440 }
Mathias Agopianda27af92012-09-13 18:17:13 -0700441}
442
Alec Mouri0a9c7b82018-11-16 13:05:25 -0800443void DisplayDevice::onPresentDisplayCompleted() {
Dan Stoza9e56aa02015-11-02 13:00:03 -0800444 mDisplaySurface->onFrameCommitted();
445}
Mathias Agopianda27af92012-09-13 18:17:13 -0700446
Mathias Agopian875d8e12013-06-07 15:35:48 -0700447void DisplayDevice::setViewportAndProjection() const {
448 size_t w = mDisplayWidth;
449 size_t h = mDisplayHeight;
Dan Stozac1879002014-05-22 15:59:05 -0700450 Rect sourceCrop(0, 0, w, h);
Chia-I Wu1be50b52018-08-29 10:44:48 -0700451 mFlinger->getRenderEngine().setViewportAndProjection(w, h, sourceCrop, ui::Transform::ROT_0);
Mathias Agopianbae92d02012-09-28 01:00:47 -0700452}
453
Alec Mouri0a9c7b82018-11-16 13:05:25 -0800454void DisplayDevice::finishBuffer() {
455 mBufferReady = mFlinger->getRenderEngine().flush();
456 if (mBufferReady.get() < 0) {
457 mFlinger->getRenderEngine().finish();
458 }
459}
460
Dan Stoza9e56aa02015-11-02 13:00:03 -0800461const sp<Fence>& DisplayDevice::getClientTargetAcquireFence() const {
462 return mDisplaySurface->getClientTargetAcquireFence();
463}
Dan Stoza9e56aa02015-11-02 13:00:03 -0800464
Mathias Agopian1b031492012-06-20 17:51:20 -0700465// ----------------------------------------------------------------------------
466
Mathias Agopian13127d82013-03-05 17:47:11 -0800467void DisplayDevice::setVisibleLayersSortedByZ(const Vector< sp<Layer> >& layers) {
Mathias Agopian3b1d2b62012-07-11 13:48:17 -0700468 mVisibleLayersSortedByZ = layers;
Mathias Agopian3b1d2b62012-07-11 13:48:17 -0700469}
470
Mathias Agopian13127d82013-03-05 17:47:11 -0800471const Vector< sp<Layer> >& DisplayDevice::getVisibleLayersSortedByZ() const {
Mathias Agopian3b1d2b62012-07-11 13:48:17 -0700472 return mVisibleLayersSortedByZ;
473}
474
Chia-I Wu83806892017-11-16 10:50:20 -0800475void DisplayDevice::setLayersNeedingFences(const Vector< sp<Layer> >& layers) {
476 mLayersNeedingFences = layers;
477}
478
479const Vector< sp<Layer> >& DisplayDevice::getLayersNeedingFences() const {
480 return mLayersNeedingFences;
481}
482
Mathias Agopiancd60f992012-08-16 16:28:27 -0700483Region DisplayDevice::getDirtyRegion(bool repaintEverything) const {
484 Region dirty;
Mathias Agopiancd60f992012-08-16 16:28:27 -0700485 if (repaintEverything) {
486 dirty.set(getBounds());
487 } else {
Peiyong Linefefaac2018-08-17 12:27:51 -0700488 const ui::Transform& planeTransform(mGlobalTransform);
Mathias Agopiancd60f992012-08-16 16:28:27 -0700489 dirty = planeTransform.transform(this->dirtyRegion);
490 dirty.andSelf(getBounds());
491 }
492 return dirty;
493}
494
Mathias Agopian3b1d2b62012-07-11 13:48:17 -0700495// ----------------------------------------------------------------------------
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700496void DisplayDevice::setPowerMode(int mode) {
497 mPowerMode = mode;
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700498}
499
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700500int DisplayDevice::getPowerMode() const {
501 return mPowerMode;
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700502}
503
Dominik Laskowskieecd6592018-05-29 10:25:41 -0700504bool DisplayDevice::isPoweredOn() const {
505 return mPowerMode != HWC_POWER_MODE_OFF;
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700506}
507
508// ----------------------------------------------------------------------------
Michael Lentine6c9e34a2014-07-14 13:48:55 -0700509void DisplayDevice::setActiveConfig(int mode) {
510 mActiveConfig = mode;
511}
512
513int DisplayDevice::getActiveConfig() const {
514 return mActiveConfig;
515}
516
517// ----------------------------------------------------------------------------
Peiyong Lina52f0292018-03-14 17:26:31 -0700518void DisplayDevice::setActiveColorMode(ColorMode mode) {
Michael Wright28f24d02016-07-12 13:30:53 -0700519 mActiveColorMode = mode;
520}
521
Peiyong Lina52f0292018-03-14 17:26:31 -0700522ColorMode DisplayDevice::getActiveColorMode() const {
Michael Wright28f24d02016-07-12 13:30:53 -0700523 return mActiveColorMode;
524}
Courtney Goeltzenleuchter79d27242017-07-13 17:54:01 -0600525
Peiyong Lindd9b2ae2018-03-01 16:22:45 -0800526RenderIntent DisplayDevice::getActiveRenderIntent() const {
527 return mActiveRenderIntent;
528}
529
530void DisplayDevice::setActiveRenderIntent(RenderIntent renderIntent) {
531 mActiveRenderIntent = renderIntent;
532}
533
Yiwei Zhang7c64f172018-03-07 14:52:28 -0800534void DisplayDevice::setColorTransform(const mat4& transform) {
535 const bool isIdentity = (transform == mat4());
536 mColorTransform =
537 isIdentity ? HAL_COLOR_TRANSFORM_IDENTITY : HAL_COLOR_TRANSFORM_ARBITRARY_MATRIX;
538}
539
540android_color_transform_t DisplayDevice::getColorTransform() const {
541 return mColorTransform;
542}
543
Peiyong Lin34beb7a2018-03-28 11:57:12 -0700544void DisplayDevice::setCompositionDataSpace(ui::Dataspace dataspace) {
Peiyong Lindd9b2ae2018-03-01 16:22:45 -0800545 mCompositionDataSpace = dataspace;
Courtney Goeltzenleuchter79d27242017-07-13 17:54:01 -0600546 ANativeWindow* const window = mNativeWindow.get();
Peiyong Lin34beb7a2018-03-28 11:57:12 -0700547 native_window_set_buffers_data_space(window, static_cast<android_dataspace>(dataspace));
Courtney Goeltzenleuchter79d27242017-07-13 17:54:01 -0600548}
Michael Wright28f24d02016-07-12 13:30:53 -0700549
Peiyong Lindd9b2ae2018-03-01 16:22:45 -0800550ui::Dataspace DisplayDevice::getCompositionDataSpace() const {
551 return mCompositionDataSpace;
552}
553
Michael Wright28f24d02016-07-12 13:30:53 -0700554// ----------------------------------------------------------------------------
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700555
Mathias Agopian28947d72012-08-08 18:51:15 -0700556void DisplayDevice::setLayerStack(uint32_t stack) {
557 mLayerStack = stack;
558 dirtyRegion.set(bounds());
559}
560
561// ----------------------------------------------------------------------------
562
Mathias Agopianc1c05de2013-09-17 23:45:22 -0700563uint32_t DisplayDevice::getOrientationTransform() const {
564 uint32_t transform = 0;
565 switch (mOrientation) {
566 case DisplayState::eOrientationDefault:
Peiyong Linefefaac2018-08-17 12:27:51 -0700567 transform = ui::Transform::ROT_0;
Mathias Agopianc1c05de2013-09-17 23:45:22 -0700568 break;
569 case DisplayState::eOrientation90:
Peiyong Linefefaac2018-08-17 12:27:51 -0700570 transform = ui::Transform::ROT_90;
Mathias Agopianc1c05de2013-09-17 23:45:22 -0700571 break;
572 case DisplayState::eOrientation180:
Peiyong Linefefaac2018-08-17 12:27:51 -0700573 transform = ui::Transform::ROT_180;
Mathias Agopianc1c05de2013-09-17 23:45:22 -0700574 break;
575 case DisplayState::eOrientation270:
Peiyong Linefefaac2018-08-17 12:27:51 -0700576 transform = ui::Transform::ROT_270;
Mathias Agopianc1c05de2013-09-17 23:45:22 -0700577 break;
578 }
579 return transform;
580}
581
Mathias Agopian0f2f5ff2012-07-31 23:09:07 -0700582status_t DisplayDevice::orientationToTransfrom(
Peiyong Linefefaac2018-08-17 12:27:51 -0700583 int orientation, int w, int h, ui::Transform* tr)
Mathias Agopian1b031492012-06-20 17:51:20 -0700584{
585 uint32_t flags = 0;
586 switch (orientation) {
Mathias Agopian3165cc22012-08-08 19:42:09 -0700587 case DisplayState::eOrientationDefault:
Peiyong Linefefaac2018-08-17 12:27:51 -0700588 flags = ui::Transform::ROT_0;
Mathias Agopian1b031492012-06-20 17:51:20 -0700589 break;
Mathias Agopian3165cc22012-08-08 19:42:09 -0700590 case DisplayState::eOrientation90:
Peiyong Linefefaac2018-08-17 12:27:51 -0700591 flags = ui::Transform::ROT_90;
Mathias Agopian1b031492012-06-20 17:51:20 -0700592 break;
Mathias Agopian3165cc22012-08-08 19:42:09 -0700593 case DisplayState::eOrientation180:
Peiyong Linefefaac2018-08-17 12:27:51 -0700594 flags = ui::Transform::ROT_180;
Mathias Agopian1b031492012-06-20 17:51:20 -0700595 break;
Mathias Agopian3165cc22012-08-08 19:42:09 -0700596 case DisplayState::eOrientation270:
Peiyong Linefefaac2018-08-17 12:27:51 -0700597 flags = ui::Transform::ROT_270;
Mathias Agopian1b031492012-06-20 17:51:20 -0700598 break;
599 default:
600 return BAD_VALUE;
601 }
602 tr->set(flags, w, h);
603 return NO_ERROR;
604}
605
Michael Lentine47e45402014-07-18 15:34:25 -0700606void DisplayDevice::setDisplaySize(const int newWidth, const int newHeight) {
607 dirtyRegion.set(getBounds());
608
609 mDisplaySurface->resizeBuffers(newWidth, newHeight);
610
Alec Mouriba013fa2018-10-16 12:43:11 -0700611 mDisplayWidth = newWidth;
612 mDisplayHeight = newHeight;
Michael Lentine47e45402014-07-18 15:34:25 -0700613}
614
Mathias Agopian00e8c7a2012-09-04 19:30:46 -0700615void DisplayDevice::setProjection(int orientation,
Mathias Agopianf5f714a2013-02-26 16:54:05 -0800616 const Rect& newViewport, const Rect& newFrame) {
617 Rect viewport(newViewport);
618 Rect frame(newFrame);
619
620 const int w = mDisplayWidth;
621 const int h = mDisplayHeight;
622
Peiyong Linefefaac2018-08-17 12:27:51 -0700623 ui::Transform R;
Mathias Agopianf5f714a2013-02-26 16:54:05 -0800624 DisplayDevice::orientationToTransfrom(orientation, w, h, &R);
625
626 if (!frame.isValid()) {
627 // the destination frame can be invalid if it has never been set,
628 // in that case we assume the whole display frame.
629 frame = Rect(w, h);
630 }
631
632 if (viewport.isEmpty()) {
633 // viewport can be invalid if it has never been set, in that case
634 // we assume the whole display size.
635 // it's also invalid to have an empty viewport, so we handle that
636 // case in the same way.
637 viewport = Rect(w, h);
Peiyong Linefefaac2018-08-17 12:27:51 -0700638 if (R.getOrientation() & ui::Transform::ROT_90) {
Mathias Agopianf5f714a2013-02-26 16:54:05 -0800639 // viewport is always specified in the logical orientation
640 // of the display (ie: post-rotation).
Peiyong Lin3db42342018-08-16 09:15:59 -0700641 std::swap(viewport.right, viewport.bottom);
Mathias Agopianf5f714a2013-02-26 16:54:05 -0800642 }
643 }
644
645 dirtyRegion.set(getBounds());
646
Peiyong Linefefaac2018-08-17 12:27:51 -0700647 ui::Transform TL, TP, S;
Mathias Agopianf5f714a2013-02-26 16:54:05 -0800648 float src_width = viewport.width();
649 float src_height = viewport.height();
650 float dst_width = frame.width();
651 float dst_height = frame.height();
652 if (src_width != dst_width || src_height != dst_height) {
653 float sx = dst_width / src_width;
654 float sy = dst_height / src_height;
655 S.set(sx, 0, 0, sy);
656 }
657
658 float src_x = viewport.left;
659 float src_y = viewport.top;
660 float dst_x = frame.left;
661 float dst_y = frame.top;
662 TL.set(-src_x, -src_y);
663 TP.set(dst_x, dst_y);
664
Iris Chang7501ed62018-04-30 14:45:42 +0800665 // need to take care of primary display rotation for mGlobalTransform
666 // for case if the panel is not installed aligned with device orientation
Dominik Laskowski075d3172018-05-24 15:50:06 -0700667 if (isPrimary()) {
Iris Chang7501ed62018-04-30 14:45:42 +0800668 DisplayDevice::orientationToTransfrom(
Chia-I Wua02871c2018-08-27 14:38:23 -0700669 (orientation + mDisplayInstallOrientation) % (DisplayState::eOrientation270 + 1),
Iris Chang7501ed62018-04-30 14:45:42 +0800670 w, h, &R);
671 }
672
Mathias Agopianf5f714a2013-02-26 16:54:05 -0800673 // The viewport and frame are both in the logical orientation.
674 // Apply the logical translation, scale to physical size, apply the
675 // physical translation and finally rotate to the physical orientation.
676 mGlobalTransform = R * TP * S * TL;
677
678 const uint8_t type = mGlobalTransform.getType();
679 mNeedsFiltering = (!mGlobalTransform.preserveRects() ||
Peiyong Linefefaac2018-08-17 12:27:51 -0700680 (type >= ui::Transform::SCALE));
Mathias Agopianf5f714a2013-02-26 16:54:05 -0800681
682 mScissor = mGlobalTransform.transform(viewport);
683 if (mScissor.isEmpty()) {
Mathias Agopian6c7f25a2013-05-09 20:37:10 -0700684 mScissor = getBounds();
Mathias Agopianf5f714a2013-02-26 16:54:05 -0800685 }
686
Mathias Agopianda8d0a52012-09-04 15:05:38 -0700687 mOrientation = orientation;
Dominik Laskowski281644e2018-04-19 15:47:35 -0700688 if (isPrimary()) {
Pablo Ceballos021623b2016-04-15 17:31:51 -0700689 uint32_t transform = 0;
690 switch (mOrientation) {
691 case DisplayState::eOrientationDefault:
Peiyong Linefefaac2018-08-17 12:27:51 -0700692 transform = ui::Transform::ROT_0;
Pablo Ceballos021623b2016-04-15 17:31:51 -0700693 break;
694 case DisplayState::eOrientation90:
Peiyong Linefefaac2018-08-17 12:27:51 -0700695 transform = ui::Transform::ROT_90;
Pablo Ceballos021623b2016-04-15 17:31:51 -0700696 break;
697 case DisplayState::eOrientation180:
Peiyong Linefefaac2018-08-17 12:27:51 -0700698 transform = ui::Transform::ROT_180;
Pablo Ceballos021623b2016-04-15 17:31:51 -0700699 break;
700 case DisplayState::eOrientation270:
Peiyong Linefefaac2018-08-17 12:27:51 -0700701 transform = ui::Transform::ROT_270;
Pablo Ceballos021623b2016-04-15 17:31:51 -0700702 break;
703 }
704 sPrimaryDisplayOrientation = transform;
705 }
Mathias Agopian00e8c7a2012-09-04 19:30:46 -0700706 mViewport = viewport;
707 mFrame = frame;
Mathias Agopian1b031492012-06-20 17:51:20 -0700708}
Mathias Agopian1d12d8a2012-09-18 01:38:00 -0700709
Pablo Ceballos021623b2016-04-15 17:31:51 -0700710uint32_t DisplayDevice::getPrimaryDisplayOrientationTransform() {
711 return sPrimaryDisplayOrientation;
712}
713
Dominik Laskowski9b17b2c22018-11-01 14:49:03 -0700714std::string DisplayDevice::getDebugName() const {
Dominik Laskowski34157762018-10-31 13:07:19 -0700715 const auto id = mId ? to_string(*mId) + ", " : std::string();
Dominik Laskowski9b17b2c22018-11-01 14:49:03 -0700716 return base::StringPrintf("DisplayDevice{%s%s%s\"%s\"}", id.c_str(),
717 isPrimary() ? "primary, " : "", isVirtual() ? "virtual, " : "",
718 mDisplayName.c_str());
719}
720
Yiwei Zhang5434a782018-12-05 18:06:32 -0800721void DisplayDevice::dump(std::string& result) const {
Peiyong Linefefaac2018-08-17 12:27:51 -0700722 const ui::Transform& tr(mGlobalTransform);
Courtney Goeltzenleuchter152279d2017-08-14 18:18:30 -0600723 ANativeWindow* const window = mNativeWindow.get();
Yiwei Zhang5434a782018-12-05 18:06:32 -0800724 StringAppendF(&result, "+ %s\n", getDebugName().c_str());
725 StringAppendF(&result,
726 " layerStack=%u, (%4dx%4d), ANativeWindow=%p "
727 "format=%d, orient=%2d (type=%08x), flips=%u, isSecure=%d, "
728 "powerMode=%d, activeConfig=%d, numLayers=%zu\n",
729 mLayerStack, mDisplayWidth, mDisplayHeight, window,
730 ANativeWindow_getFormat(window), mOrientation, tr.getType(), getPageFlipCount(),
731 mIsSecure, mPowerMode, mActiveConfig, mVisibleLayersSortedByZ.size());
732 StringAppendF(&result,
733 " v:[%d,%d,%d,%d], f:[%d,%d,%d,%d], s:[%d,%d,%d,%d],"
734 "transform:[[%0.3f,%0.3f,%0.3f][%0.3f,%0.3f,%0.3f][%0.3f,%0.3f,%0.3f]]\n",
735 mViewport.left, mViewport.top, mViewport.right, mViewport.bottom, mFrame.left,
736 mFrame.top, mFrame.right, mFrame.bottom, mScissor.left, mScissor.top,
737 mScissor.right, mScissor.bottom, tr[0][0], tr[1][0], tr[2][0], tr[0][1], tr[1][1],
738 tr[2][1], tr[0][2], tr[1][2], tr[2][2]);
Courtney Goeltzenleuchter152279d2017-08-14 18:18:30 -0600739 auto const surface = static_cast<Surface*>(window);
Peiyong Lin34beb7a2018-03-28 11:57:12 -0700740 ui::Dataspace dataspace = surface->getBuffersDataSpace();
Yiwei Zhang5434a782018-12-05 18:06:32 -0800741 StringAppendF(&result, " wideColorGamut=%d, hdr10=%d, colorMode=%s, dataspace: %s (%d)\n",
742 mHasWideColorGamut, mHasHdr10, decodeColorMode(mActiveColorMode).c_str(),
743 dataspaceDetails(static_cast<android_dataspace>(dataspace)).c_str(), dataspace);
Mathias Agopian1d12d8a2012-09-18 01:38:00 -0700744
Jesse Hall99c7dbb2013-03-14 14:29:29 -0700745 String8 surfaceDump;
Dan Stozaf10c46e2014-11-11 10:32:31 -0800746 mDisplaySurface->dumpAsString(surfaceDump);
Yiwei Zhang5434a782018-12-05 18:06:32 -0800747 result.append(surfaceDump.string(), surfaceDump.size());
Mathias Agopian1d12d8a2012-09-18 01:38:00 -0700748}
Irvelffc9efc2016-07-27 15:16:37 -0700749
Chia-I Wube02ec02018-05-18 10:59:36 -0700750// Map dataspace/intent to the best matched dataspace/colorMode/renderIntent
751// supported by HWC.
752void DisplayDevice::addColorMode(
753 const std::unordered_map<ColorMode, std::vector<RenderIntent>>& hwcColorModes,
754 const ColorMode mode, const RenderIntent intent) {
755 // find the best color mode
756 const ColorMode hwcColorMode = getHwcColorMode(hwcColorModes, mode);
757
758 // find the best render intent
759 auto iter = hwcColorModes.find(hwcColorMode);
760 const auto& hwcIntents =
761 iter != hwcColorModes.end() ? iter->second : std::vector<RenderIntent>();
762 const RenderIntent hwcIntent = getHwcRenderIntent(hwcIntents, intent);
763
764 const Dataspace dataspace = colorModeToDataspace(mode);
765 const Dataspace hwcDataspace = colorModeToDataspace(hwcColorMode);
766
Dominik Laskowski9b17b2c22018-11-01 14:49:03 -0700767 ALOGV("%s: map (%s, %s) to (%s, %s, %s)", getDebugName().c_str(),
Chia-I Wube02ec02018-05-18 10:59:36 -0700768 dataspaceDetails(static_cast<android_dataspace_t>(dataspace)).c_str(),
769 decodeRenderIntent(intent).c_str(),
770 dataspaceDetails(static_cast<android_dataspace_t>(hwcDataspace)).c_str(),
771 decodeColorMode(hwcColorMode).c_str(), decodeRenderIntent(hwcIntent).c_str());
772
773 mColorModes[getColorModeKey(dataspace, intent)] = {hwcDataspace, hwcColorMode, hwcIntent};
774}
775
776void DisplayDevice::populateColorModes(
777 const std::unordered_map<ColorMode, std::vector<RenderIntent>>& hwcColorModes) {
778 if (!hasWideColorGamut()) {
779 return;
780 }
781
Chia-I Wu0d711262018-05-21 15:19:35 -0700782 // collect all known SDR render intents
783 std::unordered_set<RenderIntent> sdrRenderIntents(sSdrRenderIntents.begin(),
784 sSdrRenderIntents.end());
785 auto iter = hwcColorModes.find(ColorMode::SRGB);
786 if (iter != hwcColorModes.end()) {
787 for (auto intent : iter->second) {
788 sdrRenderIntents.insert(intent);
789 }
790 }
791
Chia-I Wuc4b08bd2018-05-29 12:57:23 -0700792 // add all known SDR combinations
Chia-I Wu0d711262018-05-21 15:19:35 -0700793 for (auto intent : sdrRenderIntents) {
Chia-I Wube02ec02018-05-18 10:59:36 -0700794 for (auto mode : sSdrColorModes) {
795 addColorMode(hwcColorModes, mode, intent);
Peiyong Lin136fbbc2018-04-17 15:09:44 -0700796 }
797 }
Chia-I Wube02ec02018-05-18 10:59:36 -0700798
Chia-I Wuc4b08bd2018-05-29 12:57:23 -0700799 // collect all known HDR render intents
800 std::unordered_set<RenderIntent> hdrRenderIntents(sHdrRenderIntents.begin(),
801 sHdrRenderIntents.end());
802 iter = hwcColorModes.find(ColorMode::BT2100_PQ);
803 if (iter != hwcColorModes.end()) {
804 for (auto intent : iter->second) {
805 hdrRenderIntents.insert(intent);
806 }
807 }
808
809 // add all known HDR combinations
Chia-I Wube02ec02018-05-18 10:59:36 -0700810 for (auto intent : sHdrRenderIntents) {
811 for (auto mode : sHdrColorModes) {
812 addColorMode(hwcColorModes, mode, intent);
813 }
814 }
815}
816
817bool DisplayDevice::hasRenderIntent(RenderIntent intent) const {
818 // assume a render intent is supported when SRGB supports it; we should
819 // get rid of that assumption.
Peiyong Lin14724e62018-12-05 07:27:30 -0800820 auto iter = mColorModes.find(getColorModeKey(Dataspace::V0_SRGB, intent));
Chia-I Wube02ec02018-05-18 10:59:36 -0700821 return iter != mColorModes.end() && iter->second.renderIntent == intent;
822}
823
Peiyong Lindfde5112018-06-05 10:58:41 -0700824bool DisplayDevice::hasLegacyHdrSupport(Dataspace dataspace) const {
Chia-I Wube02ec02018-05-18 10:59:36 -0700825 if ((dataspace == Dataspace::BT2020_PQ && hasHDR10Support()) ||
826 (dataspace == Dataspace::BT2020_HLG && hasHLGSupport())) {
827 auto iter =
828 mColorModes.find(getColorModeKey(dataspace, RenderIntent::TONE_MAP_COLORIMETRIC));
Peiyong Lindfde5112018-06-05 10:58:41 -0700829 return iter == mColorModes.end() || iter->second.dataspace != dataspace;
Chia-I Wube02ec02018-05-18 10:59:36 -0700830 }
831
832 return false;
833}
834
835void DisplayDevice::getBestColorMode(Dataspace dataspace, RenderIntent intent,
836 Dataspace* outDataspace, ColorMode* outMode,
837 RenderIntent* outIntent) const {
838 auto iter = mColorModes.find(getColorModeKey(dataspace, intent));
839 if (iter != mColorModes.end()) {
840 *outDataspace = iter->second.dataspace;
841 *outMode = iter->second.colorMode;
842 *outIntent = iter->second.renderIntent;
843 } else {
Chia-I Wu6333af52018-10-16 13:46:36 -0700844 // this is unexpected on a WCG display
845 if (hasWideColorGamut()) {
846 ALOGE("map unknown (%s)/(%s) to default color mode",
847 dataspaceDetails(static_cast<android_dataspace_t>(dataspace)).c_str(),
848 decodeRenderIntent(intent).c_str());
849 }
Chia-I Wube02ec02018-05-18 10:59:36 -0700850
851 *outDataspace = Dataspace::UNKNOWN;
852 *outMode = ColorMode::NATIVE;
853 *outIntent = RenderIntent::COLORIMETRIC;
854 }
Peiyong Lin136fbbc2018-04-17 15:09:44 -0700855}
856
Dominik Laskowski663bd282018-04-19 15:26:54 -0700857std::atomic<int32_t> DisplayDeviceState::sNextSequenceId(1);
Peiyong Linfd997e02018-03-28 15:29:00 -0700858
859} // namespace android