blob: 79b6689c8017ef196c0b5340bfb196b1bd3d2a1a [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
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080017#include <stdlib.h>
18#include <stdio.h>
19#include <string.h>
20#include <math.h>
21
22#include <cutils/properties.h>
23
Mathias Agopian076b1cc2009-04-10 14:24:30 -070024#include <utils/RefBase.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080025#include <utils/Log.h>
26
Mathias Agopianc666cae2012-07-25 18:56:13 -070027#include <ui/DisplayInfo.h>
Mathias Agopian076b1cc2009-04-10 14:24:30 -070028#include <ui/PixelFormat.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080029
Mathias Agopiane3c697f2013-02-14 17:11:02 -080030#include <gui/Surface.h>
Jamie Gennis1a4d8832012-08-02 20:11:05 -070031
Mathias Agopian076b1cc2009-04-10 14:24:30 -070032#include <hardware/gralloc.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080033
Jesse Hall99c7dbb2013-03-14 14:29:29 -070034#include "DisplayHardware/DisplaySurface.h"
Mathias Agopian1b031492012-06-20 17:51:20 -070035#include "DisplayHardware/HWComposer.h"
Mathias Agopian875d8e12013-06-07 15:35:48 -070036#include "RenderEngine/RenderEngine.h"
Mathias Agopian1b031492012-06-20 17:51:20 -070037
Mathias Agopianda8d0a52012-09-04 15:05:38 -070038#include "clz.h"
Mathias Agopian0f2f5ff2012-07-31 23:09:07 -070039#include "DisplayDevice.h"
Mathias Agopianc7d14e22011-08-01 16:32:21 -070040#include "SurfaceFlinger.h"
Mathias Agopian13127d82013-03-05 17:47:11 -080041#include "Layer.h"
Mathias Agopian1f7bec62010-06-25 18:02:21 -070042
Mathias Agopiana4912602012-07-12 14:25:33 -070043// ----------------------------------------------------------------------------
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080044using namespace android;
Mathias Agopiana4912602012-07-12 14:25:33 -070045// ----------------------------------------------------------------------------
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080046
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080047/*
48 * Initialize the display to the specified values.
49 *
50 */
51
Mathias Agopian0f2f5ff2012-07-31 23:09:07 -070052DisplayDevice::DisplayDevice(
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080053 const sp<SurfaceFlinger>& flinger,
Jamie Gennisdd3cb842012-10-19 18:19:11 -070054 DisplayType type,
Jesse Hallffe1f192013-03-22 15:13:48 -070055 int32_t hwcId,
Jamie Gennisdd3cb842012-10-19 18:19:11 -070056 bool isSecure,
57 const wp<IBinder>& displayToken,
Jesse Hall99c7dbb2013-03-14 14:29:29 -070058 const sp<DisplaySurface>& displaySurface,
Mathias Agopiandb89edc2013-08-02 01:40:18 -070059 const sp<IGraphicBufferProducer>& producer,
Mathias Agopiana4912602012-07-12 14:25:33 -070060 EGLConfig config)
Mathias Agopian92a979a2012-08-02 18:32:23 -070061 : mFlinger(flinger),
Jesse Hallffe1f192013-03-22 15:13:48 -070062 mType(type), mHwcDisplayId(hwcId),
Chih-Wei Huang27e25622013-01-07 17:33:56 +080063 mDisplayToken(displayToken),
Jesse Hall99c7dbb2013-03-14 14:29:29 -070064 mDisplaySurface(displaySurface),
Mathias Agopian92a979a2012-08-02 18:32:23 -070065 mDisplay(EGL_NO_DISPLAY),
66 mSurface(EGL_NO_SURFACE),
Mathias Agopian92a979a2012-08-02 18:32:23 -070067 mDisplayWidth(), mDisplayHeight(), mFormat(),
68 mFlags(),
69 mPageFlipCount(),
Jamie Gennisdd3cb842012-10-19 18:19:11 -070070 mIsSecure(isSecure),
Mathias Agopian92a979a2012-08-02 18:32:23 -070071 mSecureLayerVisible(false),
72 mScreenAcquired(false),
Jesse Hall01e29052013-02-19 16:13:35 -080073 mLayerStack(NO_LAYER_STACK),
Mathias Agopianda8d0a52012-09-04 15:05:38 -070074 mOrientation()
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080075{
Mathias Agopiandb89edc2013-08-02 01:40:18 -070076 mNativeWindow = new Surface(producer);
Jesse Hallffe1f192013-03-22 15:13:48 -070077 ANativeWindow* const window = mNativeWindow.get();
78
79 int format;
80 window->query(window, NATIVE_WINDOW_FORMAT, &format);
81
Jesse Hallf460f552013-08-06 17:08:53 -070082 // Make sure that composition can never be stalled by a virtual display
83 // consumer that isn't processing buffers fast enough. We have to do this
84 // in two places:
85 // * Here, in case the display is composed entirely by HWC.
86 // * In makeCurrent(), using eglSwapInterval. Some EGL drivers set the
87 // window's swap interval in eglMakeCurrent, so they'll override the
88 // interval we set here.
89 if (mType >= DisplayDevice::DISPLAY_VIRTUAL)
90 window->setSwapInterval(window, 0);
91
Jesse Hallffe1f192013-03-22 15:13:48 -070092 /*
93 * Create our display's surface
94 */
95
96 EGLSurface surface;
97 EGLint w, h;
98 EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
99 surface = eglCreateWindowSurface(display, config, window, NULL);
100 eglQuerySurface(display, surface, EGL_WIDTH, &mDisplayWidth);
101 eglQuerySurface(display, surface, EGL_HEIGHT, &mDisplayHeight);
102
103 mDisplay = display;
104 mSurface = surface;
105 mFormat = format;
106 mPageFlipCount = 0;
107 mViewport.makeInvalid();
108 mFrame.makeInvalid();
109
110 // virtual displays are always considered enabled
111 mScreenAcquired = (mType >= DisplayDevice::DISPLAY_VIRTUAL);
112
113 // Name the display. The name will be replaced shortly if the display
114 // was created with createDisplay().
115 switch (mType) {
116 case DISPLAY_PRIMARY:
117 mDisplayName = "Built-in Screen";
118 break;
119 case DISPLAY_EXTERNAL:
120 mDisplayName = "HDMI Screen";
121 break;
122 default:
123 mDisplayName = "Virtual Screen"; // e.g. Overlay #n
124 break;
125 }
126
127 // initialize the display orientation transform.
128 setProjection(DisplayState::eOrientationDefault, mViewport, mFrame);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800129}
130
Mathias Agopian0f2f5ff2012-07-31 23:09:07 -0700131DisplayDevice::~DisplayDevice() {
Mathias Agopian92a979a2012-08-02 18:32:23 -0700132 if (mSurface != EGL_NO_SURFACE) {
133 eglDestroySurface(mDisplay, mSurface);
134 mSurface = EGL_NO_SURFACE;
135 }
136}
137
Jesse Hall02d86562013-03-25 14:43:23 -0700138void DisplayDevice::disconnect(HWComposer& hwc) {
139 if (mHwcDisplayId >= 0) {
140 hwc.disconnectDisplay(mHwcDisplayId);
141 if (mHwcDisplayId >= DISPLAY_VIRTUAL)
142 hwc.freeDisplayId(mHwcDisplayId);
143 mHwcDisplayId = -1;
144 }
145}
146
Mathias Agopian92a979a2012-08-02 18:32:23 -0700147bool DisplayDevice::isValid() const {
148 return mFlinger != NULL;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800149}
150
Mathias Agopian0f2f5ff2012-07-31 23:09:07 -0700151int DisplayDevice::getWidth() const {
Mathias Agopiana4912602012-07-12 14:25:33 -0700152 return mDisplayWidth;
153}
154
Mathias Agopian0f2f5ff2012-07-31 23:09:07 -0700155int DisplayDevice::getHeight() const {
Mathias Agopiana4912602012-07-12 14:25:33 -0700156 return mDisplayHeight;
157}
158
Mathias Agopian0f2f5ff2012-07-31 23:09:07 -0700159PixelFormat DisplayDevice::getFormat() const {
Mathias Agopiana4912602012-07-12 14:25:33 -0700160 return mFormat;
161}
162
Mathias Agopian0f2f5ff2012-07-31 23:09:07 -0700163EGLSurface DisplayDevice::getEGLSurface() const {
Mathias Agopiana4912602012-07-12 14:25:33 -0700164 return mSurface;
165}
166
Mathias Agopian9e2463e2012-09-21 18:26:16 -0700167void DisplayDevice::setDisplayName(const String8& displayName) {
168 if (!displayName.isEmpty()) {
169 // never override the name with an empty name
170 mDisplayName = displayName;
171 }
172}
173
Mathias Agopian0f2f5ff2012-07-31 23:09:07 -0700174uint32_t DisplayDevice::getPageFlipCount() const {
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700175 return mPageFlipCount;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800176}
177
Mathias Agopian0f2f5ff2012-07-31 23:09:07 -0700178status_t DisplayDevice::compositionComplete() const {
Jesse Hall99c7dbb2013-03-14 14:29:29 -0700179 return mDisplaySurface->compositionComplete();
Mathias Agopian74faca22009-09-17 16:18:16 -0700180}
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800181
Mathias Agopian0f2f5ff2012-07-31 23:09:07 -0700182void DisplayDevice::flip(const Region& dirty) const
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800183{
Mathias Agopian875d8e12013-06-07 15:35:48 -0700184 mFlinger->getRenderEngine().checkErrors();
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800185
186 EGLDisplay dpy = mDisplay;
187 EGLSurface surface = mSurface;
188
Jesse Hall01e29052013-02-19 16:13:35 -0800189#ifdef EGL_ANDROID_swap_rectangle
Mathias Agopiandf3ca302009-05-04 19:29:25 -0700190 if (mFlags & SWAP_RECTANGLE) {
Mathias Agopianb8a55602009-06-26 19:06:36 -0700191 const Region newDirty(dirty.intersect(bounds()));
192 const Rect b(newDirty.getBounds());
Mathias Agopiandf3ca302009-05-04 19:29:25 -0700193 eglSetSwapRectangleANDROID(dpy, surface,
194 b.left, b.top, b.width(), b.height());
Jesse Hall01e29052013-02-19 16:13:35 -0800195 }
Mathias Agopian5e78e092009-06-11 17:19:54 -0700196#endif
Mathias Agopiand8707032012-09-18 01:21:55 -0700197
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700198 mPageFlipCount++;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800199}
200
Jesse Hall38efe862013-04-06 23:12:29 -0700201status_t DisplayDevice::prepareFrame(const HWComposer& hwc) const {
202 DisplaySurface::CompositionType compositionType;
203 bool haveGles = hwc.hasGlesComposition(mHwcDisplayId);
204 bool haveHwc = hwc.hasHwcComposition(mHwcDisplayId);
205 if (haveGles && haveHwc) {
206 compositionType = DisplaySurface::COMPOSITION_MIXED;
207 } else if (haveGles) {
208 compositionType = DisplaySurface::COMPOSITION_GLES;
209 } else if (haveHwc) {
210 compositionType = DisplaySurface::COMPOSITION_HWC;
211 } else {
212 // Nothing to do -- when turning the screen off we get a frame like
213 // this. Call it a HWC frame since we won't be doing any GLES work but
214 // will do a prepare/set cycle.
215 compositionType = DisplaySurface::COMPOSITION_HWC;
216 }
217 return mDisplaySurface->prepareFrame(compositionType);
218}
219
Mathias Agopianda27af92012-09-13 18:17:13 -0700220void DisplayDevice::swapBuffers(HWComposer& hwc) const {
Jesse Hall99c7dbb2013-03-14 14:29:29 -0700221 // We need to call eglSwapBuffers() unless:
222 // (a) there was no GLES composition this frame, or
223 // (b) we're using a legacy HWC with no framebuffer target support (in
224 // which case HWComposer::commit() handles things).
225 if (hwc.initCheck() != NO_ERROR ||
226 (hwc.hasGlesComposition(mHwcDisplayId) &&
227 hwc.supportsFramebufferTarget())) {
228 EGLBoolean success = eglSwapBuffers(mDisplay, mSurface);
229 if (!success) {
230 EGLint error = eglGetError();
231 if (error == EGL_CONTEXT_LOST ||
232 mType == DisplayDevice::DISPLAY_PRIMARY) {
233 LOG_ALWAYS_FATAL("eglSwapBuffers(%p, %p) failed with 0x%08x",
234 mDisplay, mSurface, error);
235 } else {
236 ALOGE("eglSwapBuffers(%p, %p) failed with 0x%08x",
237 mDisplay, mSurface, error);
Mathias Agopianda27af92012-09-13 18:17:13 -0700238 }
239 }
240 }
Mathias Agopian52e21482012-09-24 18:07:21 -0700241
Jesse Hall99c7dbb2013-03-14 14:29:29 -0700242 status_t result = mDisplaySurface->advanceFrame();
243 if (result != NO_ERROR) {
244 ALOGE("[%s] failed pushing new frame to HWC: %d",
245 mDisplayName.string(), result);
Mathias Agopian32341382012-09-25 19:16:28 -0700246 }
Mathias Agopianda27af92012-09-13 18:17:13 -0700247}
248
249void DisplayDevice::onSwapBuffersCompleted(HWComposer& hwc) const {
250 if (hwc.initCheck() == NO_ERROR) {
Jesse Hall851cfe82013-03-20 13:44:00 -0700251 mDisplaySurface->onFrameCommitted();
Mathias Agopianda27af92012-09-13 18:17:13 -0700252 }
253}
254
Mathias Agopian0f2f5ff2012-07-31 23:09:07 -0700255uint32_t DisplayDevice::getFlags() const
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800256{
257 return mFlags;
258}
259
Mathias Agopian875d8e12013-06-07 15:35:48 -0700260EGLBoolean DisplayDevice::makeCurrent(EGLDisplay dpy, EGLContext ctx) const {
Mathias Agopianda8d0a52012-09-04 15:05:38 -0700261 EGLBoolean result = EGL_TRUE;
Mathias Agopian52bbb1a2012-07-31 19:01:53 -0700262 EGLSurface sur = eglGetCurrentSurface(EGL_DRAW);
Mathias Agopian875d8e12013-06-07 15:35:48 -0700263 if (sur != mSurface) {
264 result = eglMakeCurrent(dpy, mSurface, mSurface, ctx);
Mathias Agopianda8d0a52012-09-04 15:05:38 -0700265 if (result == EGL_TRUE) {
Jesse Hallf460f552013-08-06 17:08:53 -0700266 if (mType >= DisplayDevice::DISPLAY_VIRTUAL)
267 eglSwapInterval(dpy, 0);
Mathias Agopian875d8e12013-06-07 15:35:48 -0700268 setViewportAndProjection();
Mathias Agopianda8d0a52012-09-04 15:05:38 -0700269 }
Mathias Agopian52bbb1a2012-07-31 19:01:53 -0700270 }
Mathias Agopianda8d0a52012-09-04 15:05:38 -0700271 return result;
Mathias Agopian52bbb1a2012-07-31 19:01:53 -0700272}
273
Mathias Agopian875d8e12013-06-07 15:35:48 -0700274void DisplayDevice::setViewportAndProjection() const {
275 size_t w = mDisplayWidth;
276 size_t h = mDisplayHeight;
Mathias Agopian3f844832013-08-07 21:24:32 -0700277 mFlinger->getRenderEngine().setViewportAndProjection(w, h, w, h, false);
Mathias Agopianbae92d02012-09-28 01:00:47 -0700278}
279
Mathias Agopian1b031492012-06-20 17:51:20 -0700280// ----------------------------------------------------------------------------
281
Mathias Agopian13127d82013-03-05 17:47:11 -0800282void DisplayDevice::setVisibleLayersSortedByZ(const Vector< sp<Layer> >& layers) {
Mathias Agopian3b1d2b62012-07-11 13:48:17 -0700283 mVisibleLayersSortedByZ = layers;
Mathias Agopianef7b9c72012-08-10 15:22:19 -0700284 mSecureLayerVisible = false;
Mathias Agopian3b1d2b62012-07-11 13:48:17 -0700285 size_t count = layers.size();
286 for (size_t i=0 ; i<count ; i++) {
Mathias Agopian13127d82013-03-05 17:47:11 -0800287 const sp<Layer>& layer(layers[i]);
Mathias Agopianf5f714a2013-02-26 16:54:05 -0800288 if (layer->isSecure()) {
Mathias Agopian3b1d2b62012-07-11 13:48:17 -0700289 mSecureLayerVisible = true;
290 }
291 }
292}
293
Mathias Agopian13127d82013-03-05 17:47:11 -0800294const Vector< sp<Layer> >& DisplayDevice::getVisibleLayersSortedByZ() const {
Mathias Agopian3b1d2b62012-07-11 13:48:17 -0700295 return mVisibleLayersSortedByZ;
296}
297
Mathias Agopian0f2f5ff2012-07-31 23:09:07 -0700298bool DisplayDevice::getSecureLayerVisible() const {
Mathias Agopian3b1d2b62012-07-11 13:48:17 -0700299 return mSecureLayerVisible;
300}
301
Mathias Agopiancd60f992012-08-16 16:28:27 -0700302Region DisplayDevice::getDirtyRegion(bool repaintEverything) const {
303 Region dirty;
Mathias Agopiancd60f992012-08-16 16:28:27 -0700304 if (repaintEverything) {
305 dirty.set(getBounds());
306 } else {
Mathias Agopianda8d0a52012-09-04 15:05:38 -0700307 const Transform& planeTransform(mGlobalTransform);
Mathias Agopiancd60f992012-08-16 16:28:27 -0700308 dirty = planeTransform.transform(this->dirtyRegion);
309 dirty.andSelf(getBounds());
310 }
311 return dirty;
312}
313
Mathias Agopian3b1d2b62012-07-11 13:48:17 -0700314// ----------------------------------------------------------------------------
315
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700316bool DisplayDevice::canDraw() const {
317 return mScreenAcquired;
318}
319
320void DisplayDevice::releaseScreen() const {
321 mScreenAcquired = false;
322}
323
324void DisplayDevice::acquireScreen() const {
325 mScreenAcquired = true;
326}
327
328bool DisplayDevice::isScreenAcquired() const {
329 return mScreenAcquired;
330}
331
332// ----------------------------------------------------------------------------
333
Mathias Agopian28947d72012-08-08 18:51:15 -0700334void DisplayDevice::setLayerStack(uint32_t stack) {
335 mLayerStack = stack;
336 dirtyRegion.set(bounds());
337}
338
339// ----------------------------------------------------------------------------
340
Mathias Agopian0f2f5ff2012-07-31 23:09:07 -0700341status_t DisplayDevice::orientationToTransfrom(
Mathias Agopian1b031492012-06-20 17:51:20 -0700342 int orientation, int w, int h, Transform* tr)
343{
344 uint32_t flags = 0;
345 switch (orientation) {
Mathias Agopian3165cc22012-08-08 19:42:09 -0700346 case DisplayState::eOrientationDefault:
Mathias Agopian1b031492012-06-20 17:51:20 -0700347 flags = Transform::ROT_0;
348 break;
Mathias Agopian3165cc22012-08-08 19:42:09 -0700349 case DisplayState::eOrientation90:
Mathias Agopian1b031492012-06-20 17:51:20 -0700350 flags = Transform::ROT_90;
351 break;
Mathias Agopian3165cc22012-08-08 19:42:09 -0700352 case DisplayState::eOrientation180:
Mathias Agopian1b031492012-06-20 17:51:20 -0700353 flags = Transform::ROT_180;
354 break;
Mathias Agopian3165cc22012-08-08 19:42:09 -0700355 case DisplayState::eOrientation270:
Mathias Agopian1b031492012-06-20 17:51:20 -0700356 flags = Transform::ROT_270;
357 break;
358 default:
359 return BAD_VALUE;
360 }
361 tr->set(flags, w, h);
362 return NO_ERROR;
363}
364
Mathias Agopian00e8c7a2012-09-04 19:30:46 -0700365void DisplayDevice::setProjection(int orientation,
Mathias Agopianf5f714a2013-02-26 16:54:05 -0800366 const Rect& newViewport, const Rect& newFrame) {
367 Rect viewport(newViewport);
368 Rect frame(newFrame);
369
370 const int w = mDisplayWidth;
371 const int h = mDisplayHeight;
372
373 Transform R;
374 DisplayDevice::orientationToTransfrom(orientation, w, h, &R);
375
376 if (!frame.isValid()) {
377 // the destination frame can be invalid if it has never been set,
378 // in that case we assume the whole display frame.
379 frame = Rect(w, h);
380 }
381
382 if (viewport.isEmpty()) {
383 // viewport can be invalid if it has never been set, in that case
384 // we assume the whole display size.
385 // it's also invalid to have an empty viewport, so we handle that
386 // case in the same way.
387 viewport = Rect(w, h);
388 if (R.getOrientation() & Transform::ROT_90) {
389 // viewport is always specified in the logical orientation
390 // of the display (ie: post-rotation).
391 swap(viewport.right, viewport.bottom);
392 }
393 }
394
395 dirtyRegion.set(getBounds());
396
397 Transform TL, TP, S;
398 float src_width = viewport.width();
399 float src_height = viewport.height();
400 float dst_width = frame.width();
401 float dst_height = frame.height();
402 if (src_width != dst_width || src_height != dst_height) {
403 float sx = dst_width / src_width;
404 float sy = dst_height / src_height;
405 S.set(sx, 0, 0, sy);
406 }
407
408 float src_x = viewport.left;
409 float src_y = viewport.top;
410 float dst_x = frame.left;
411 float dst_y = frame.top;
412 TL.set(-src_x, -src_y);
413 TP.set(dst_x, dst_y);
414
415 // The viewport and frame are both in the logical orientation.
416 // Apply the logical translation, scale to physical size, apply the
417 // physical translation and finally rotate to the physical orientation.
418 mGlobalTransform = R * TP * S * TL;
419
420 const uint8_t type = mGlobalTransform.getType();
421 mNeedsFiltering = (!mGlobalTransform.preserveRects() ||
422 (type >= Transform::SCALE));
423
424 mScissor = mGlobalTransform.transform(viewport);
425 if (mScissor.isEmpty()) {
Mathias Agopian6c7f25a2013-05-09 20:37:10 -0700426 mScissor = getBounds();
Mathias Agopianf5f714a2013-02-26 16:54:05 -0800427 }
428
Mathias Agopianda8d0a52012-09-04 15:05:38 -0700429 mOrientation = orientation;
Mathias Agopian00e8c7a2012-09-04 19:30:46 -0700430 mViewport = viewport;
431 mFrame = frame;
Mathias Agopian1b031492012-06-20 17:51:20 -0700432}
Mathias Agopian1d12d8a2012-09-18 01:38:00 -0700433
Mathias Agopian74d211a2013-04-22 16:55:35 +0200434void DisplayDevice::dump(String8& result) const {
Mathias Agopian1d12d8a2012-09-18 01:38:00 -0700435 const Transform& tr(mGlobalTransform);
Mathias Agopian74d211a2013-04-22 16:55:35 +0200436 result.appendFormat(
Mathias Agopian1d12d8a2012-09-18 01:38:00 -0700437 "+ DisplayDevice: %s\n"
Jesse Hall02d86562013-03-25 14:43:23 -0700438 " type=%x, hwcId=%d, layerStack=%u, (%4dx%4d), ANativeWindow=%p, orient=%2d (type=%08x), "
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700439 "flips=%u, isSecure=%d, secureVis=%d, acquired=%d, numLayers=%u\n"
Mathias Agopian766dc492012-10-30 18:08:06 -0700440 " v:[%d,%d,%d,%d], f:[%d,%d,%d,%d], s:[%d,%d,%d,%d],"
Mathias Agopian1d12d8a2012-09-18 01:38:00 -0700441 "transform:[[%0.3f,%0.3f,%0.3f][%0.3f,%0.3f,%0.3f][%0.3f,%0.3f,%0.3f]]\n",
Jesse Hall02d86562013-03-25 14:43:23 -0700442 mDisplayName.string(), mType, mHwcDisplayId,
Mathias Agopian1d12d8a2012-09-18 01:38:00 -0700443 mLayerStack, mDisplayWidth, mDisplayHeight, mNativeWindow.get(),
444 mOrientation, tr.getType(), getPageFlipCount(),
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700445 mIsSecure, mSecureLayerVisible, mScreenAcquired, mVisibleLayersSortedByZ.size(),
Mathias Agopian1d12d8a2012-09-18 01:38:00 -0700446 mViewport.left, mViewport.top, mViewport.right, mViewport.bottom,
447 mFrame.left, mFrame.top, mFrame.right, mFrame.bottom,
Mathias Agopian766dc492012-10-30 18:08:06 -0700448 mScissor.left, mScissor.top, mScissor.right, mScissor.bottom,
Mathias Agopian1d12d8a2012-09-18 01:38:00 -0700449 tr[0][0], tr[1][0], tr[2][0],
450 tr[0][1], tr[1][1], tr[2][1],
451 tr[0][2], tr[1][2], tr[2][2]);
452
Jesse Hall99c7dbb2013-03-14 14:29:29 -0700453 String8 surfaceDump;
454 mDisplaySurface->dump(surfaceDump);
455 result.append(surfaceDump);
Mathias Agopian1d12d8a2012-09-18 01:38:00 -0700456}