blob: cdc16edb97f21c21539cbdef1e1acbf5bc1622bf [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
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080032#include <GLES/gl.h>
Mathias Agopian076b1cc2009-04-10 14:24:30 -070033#include <EGL/egl.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080034#include <EGL/eglext.h>
35
Mathias Agopian076b1cc2009-04-10 14:24:30 -070036#include <hardware/gralloc.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080037
Jesse Hall99c7dbb2013-03-14 14:29:29 -070038#include "DisplayHardware/DisplaySurface.h"
Mathias Agopian1b031492012-06-20 17:51:20 -070039#include "DisplayHardware/HWComposer.h"
40
Mathias Agopianda8d0a52012-09-04 15:05:38 -070041#include "clz.h"
Mathias Agopian0f2f5ff2012-07-31 23:09:07 -070042#include "DisplayDevice.h"
Mathias Agopian1f7bec62010-06-25 18:02:21 -070043#include "GLExtensions.h"
Mathias Agopianc7d14e22011-08-01 16:32:21 -070044#include "SurfaceFlinger.h"
Mathias Agopian13127d82013-03-05 17:47:11 -080045#include "Layer.h"
Mathias Agopian1f7bec62010-06-25 18:02:21 -070046
Mathias Agopiana4912602012-07-12 14:25:33 -070047// ----------------------------------------------------------------------------
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080048using namespace android;
Mathias Agopiana4912602012-07-12 14:25:33 -070049// ----------------------------------------------------------------------------
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080050
51static __attribute__((noinline))
52void checkGLErrors()
53{
Mathias Agopiancbb288b2009-09-07 16:32:45 -070054 do {
55 // there could be more than one error flag
56 GLenum error = glGetError();
57 if (error == GL_NO_ERROR)
58 break;
Steve Blocke6f43dd2012-01-06 19:20:56 +000059 ALOGE("GL error 0x%04x", int(error));
Mathias Agopiancbb288b2009-09-07 16:32:45 -070060 } while(true);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080061}
62
Mathias Agopiana4912602012-07-12 14:25:33 -070063// ----------------------------------------------------------------------------
64
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080065/*
66 * Initialize the display to the specified values.
67 *
68 */
69
Mathias Agopian0f2f5ff2012-07-31 23:09:07 -070070DisplayDevice::DisplayDevice(
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080071 const sp<SurfaceFlinger>& flinger,
Jamie Gennisdd3cb842012-10-19 18:19:11 -070072 DisplayType type,
73 bool isSecure,
74 const wp<IBinder>& displayToken,
Jesse Hall99c7dbb2013-03-14 14:29:29 -070075 const sp<DisplaySurface>& displaySurface,
Mathias Agopiana4912602012-07-12 14:25:33 -070076 EGLConfig config)
Mathias Agopian92a979a2012-08-02 18:32:23 -070077 : mFlinger(flinger),
Mathias Agopian3ee454a2012-08-27 16:28:24 -070078 mType(type), mHwcDisplayId(-1),
Chih-Wei Huang27e25622013-01-07 17:33:56 +080079 mDisplayToken(displayToken),
Jesse Hall99c7dbb2013-03-14 14:29:29 -070080 mDisplaySurface(displaySurface),
Mathias Agopian92a979a2012-08-02 18:32:23 -070081 mDisplay(EGL_NO_DISPLAY),
82 mSurface(EGL_NO_SURFACE),
83 mContext(EGL_NO_CONTEXT),
Mathias Agopian92a979a2012-08-02 18:32:23 -070084 mDisplayWidth(), mDisplayHeight(), mFormat(),
85 mFlags(),
86 mPageFlipCount(),
Jamie Gennisdd3cb842012-10-19 18:19:11 -070087 mIsSecure(isSecure),
Mathias Agopian92a979a2012-08-02 18:32:23 -070088 mSecureLayerVisible(false),
89 mScreenAcquired(false),
Jesse Hall01e29052013-02-19 16:13:35 -080090 mLayerStack(NO_LAYER_STACK),
Mathias Agopianda8d0a52012-09-04 15:05:38 -070091 mOrientation()
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080092{
Jesse Hall99c7dbb2013-03-14 14:29:29 -070093 mNativeWindow = new Surface(mDisplaySurface->getIGraphicBufferProducer());
Mathias Agopiana4912602012-07-12 14:25:33 -070094 init(config);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080095}
96
Mathias Agopian0f2f5ff2012-07-31 23:09:07 -070097DisplayDevice::~DisplayDevice() {
Mathias Agopian92a979a2012-08-02 18:32:23 -070098 if (mSurface != EGL_NO_SURFACE) {
99 eglDestroySurface(mDisplay, mSurface);
100 mSurface = EGL_NO_SURFACE;
101 }
102}
103
104bool DisplayDevice::isValid() const {
105 return mFlinger != NULL;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800106}
107
Mathias Agopian0f2f5ff2012-07-31 23:09:07 -0700108int DisplayDevice::getWidth() const {
Mathias Agopiana4912602012-07-12 14:25:33 -0700109 return mDisplayWidth;
110}
111
Mathias Agopian0f2f5ff2012-07-31 23:09:07 -0700112int DisplayDevice::getHeight() const {
Mathias Agopiana4912602012-07-12 14:25:33 -0700113 return mDisplayHeight;
114}
115
Mathias Agopian0f2f5ff2012-07-31 23:09:07 -0700116PixelFormat DisplayDevice::getFormat() const {
Mathias Agopiana4912602012-07-12 14:25:33 -0700117 return mFormat;
118}
119
Mathias Agopian0f2f5ff2012-07-31 23:09:07 -0700120EGLSurface DisplayDevice::getEGLSurface() const {
Mathias Agopiana4912602012-07-12 14:25:33 -0700121 return mSurface;
122}
123
Mathias Agopian0f2f5ff2012-07-31 23:09:07 -0700124void DisplayDevice::init(EGLConfig config)
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800125{
Mathias Agopiana4912602012-07-12 14:25:33 -0700126 ANativeWindow* const window = mNativeWindow.get();
127
Mathias Agopian61630912011-07-06 16:35:30 -0700128 int format;
Mathias Agopian61630912011-07-06 16:35:30 -0700129 window->query(window, NATIVE_WINDOW_FORMAT, &format);
Mathias Agopianb5dd9c02012-03-22 12:15:54 -0700130
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800131 /*
Mathias Agopiana4912602012-07-12 14:25:33 -0700132 * Create our display's surface
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800133 */
134
Mathias Agopiana4912602012-07-12 14:25:33 -0700135 EGLSurface surface;
136 EGLint w, h;
137 EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
138 surface = eglCreateWindowSurface(display, config, window, NULL);
Mathias Agopian1b031492012-06-20 17:51:20 -0700139 eglQuerySurface(display, surface, EGL_WIDTH, &mDisplayWidth);
140 eglQuerySurface(display, surface, EGL_HEIGHT, &mDisplayHeight);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800141
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800142 mDisplay = display;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800143 mSurface = surface;
Mathias Agopiana4912602012-07-12 14:25:33 -0700144 mFormat = format;
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700145 mPageFlipCount = 0;
Mathias Agopianda8d0a52012-09-04 15:05:38 -0700146 mViewport.makeInvalid();
147 mFrame.makeInvalid();
Mathias Agopian1f7bec62010-06-25 18:02:21 -0700148
Mathias Agopian5f20e2d2012-08-10 18:50:38 -0700149 // external displays are always considered enabled
Mathias Agopian3ee454a2012-08-27 16:28:24 -0700150 mScreenAcquired = (mType >= DisplayDevice::NUM_DISPLAY_TYPES);
151
152 // get an h/w composer ID
153 mHwcDisplayId = mFlinger->allocateHwcDisplayId(mType);
Mathias Agopian5f20e2d2012-08-10 18:50:38 -0700154
Andy McFadden8dfa92f2012-09-17 18:27:17 -0700155 // Name the display. The name will be replaced shortly if the display
156 // was created with createDisplay().
157 switch (mType) {
158 case DISPLAY_PRIMARY:
159 mDisplayName = "Built-in Screen";
160 break;
161 case DISPLAY_EXTERNAL:
162 mDisplayName = "HDMI Screen";
163 break;
164 default:
165 mDisplayName = "Virtual Screen"; // e.g. Overlay #n
166 break;
167 }
168
Mathias Agopian98a121a2012-07-24 21:08:59 -0700169 // initialize the display orientation transform.
Mathias Agopian00e8c7a2012-09-04 19:30:46 -0700170 setProjection(DisplayState::eOrientationDefault, mViewport, mFrame);
Mathias Agopiana350ff92010-08-10 17:14:02 -0700171}
172
Mathias Agopian9e2463e2012-09-21 18:26:16 -0700173void DisplayDevice::setDisplayName(const String8& displayName) {
174 if (!displayName.isEmpty()) {
175 // never override the name with an empty name
176 mDisplayName = displayName;
177 }
178}
179
Mathias Agopian0f2f5ff2012-07-31 23:09:07 -0700180uint32_t DisplayDevice::getPageFlipCount() const {
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700181 return mPageFlipCount;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800182}
183
Mathias Agopian0f2f5ff2012-07-31 23:09:07 -0700184status_t DisplayDevice::compositionComplete() const {
Jesse Hall99c7dbb2013-03-14 14:29:29 -0700185 return mDisplaySurface->compositionComplete();
Mathias Agopian74faca22009-09-17 16:18:16 -0700186}
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800187
Mathias Agopian0f2f5ff2012-07-31 23:09:07 -0700188void DisplayDevice::flip(const Region& dirty) const
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800189{
190 checkGLErrors();
191
192 EGLDisplay dpy = mDisplay;
193 EGLSurface surface = mSurface;
194
Jesse Hall01e29052013-02-19 16:13:35 -0800195#ifdef EGL_ANDROID_swap_rectangle
Mathias Agopiandf3ca302009-05-04 19:29:25 -0700196 if (mFlags & SWAP_RECTANGLE) {
Mathias Agopianb8a55602009-06-26 19:06:36 -0700197 const Region newDirty(dirty.intersect(bounds()));
198 const Rect b(newDirty.getBounds());
Mathias Agopiandf3ca302009-05-04 19:29:25 -0700199 eglSetSwapRectangleANDROID(dpy, surface,
200 b.left, b.top, b.width(), b.height());
Jesse Hall01e29052013-02-19 16:13:35 -0800201 }
Mathias Agopian5e78e092009-06-11 17:19:54 -0700202#endif
Mathias Agopiand8707032012-09-18 01:21:55 -0700203
Mathias Agopian076b1cc2009-04-10 14:24:30 -0700204 mPageFlipCount++;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800205}
206
Mathias Agopianda27af92012-09-13 18:17:13 -0700207void DisplayDevice::swapBuffers(HWComposer& hwc) const {
Jesse Hall99c7dbb2013-03-14 14:29:29 -0700208 // We need to call eglSwapBuffers() unless:
209 // (a) there was no GLES composition this frame, or
210 // (b) we're using a legacy HWC with no framebuffer target support (in
211 // which case HWComposer::commit() handles things).
212 if (hwc.initCheck() != NO_ERROR ||
213 (hwc.hasGlesComposition(mHwcDisplayId) &&
214 hwc.supportsFramebufferTarget())) {
215 EGLBoolean success = eglSwapBuffers(mDisplay, mSurface);
216 if (!success) {
217 EGLint error = eglGetError();
218 if (error == EGL_CONTEXT_LOST ||
219 mType == DisplayDevice::DISPLAY_PRIMARY) {
220 LOG_ALWAYS_FATAL("eglSwapBuffers(%p, %p) failed with 0x%08x",
221 mDisplay, mSurface, error);
222 } else {
223 ALOGE("eglSwapBuffers(%p, %p) failed with 0x%08x",
224 mDisplay, mSurface, error);
Mathias Agopianda27af92012-09-13 18:17:13 -0700225 }
226 }
227 }
Mathias Agopian52e21482012-09-24 18:07:21 -0700228
Jesse Hall99c7dbb2013-03-14 14:29:29 -0700229 status_t result = mDisplaySurface->advanceFrame();
230 if (result != NO_ERROR) {
231 ALOGE("[%s] failed pushing new frame to HWC: %d",
232 mDisplayName.string(), result);
Mathias Agopian32341382012-09-25 19:16:28 -0700233 }
Mathias Agopianda27af92012-09-13 18:17:13 -0700234}
235
236void DisplayDevice::onSwapBuffersCompleted(HWComposer& hwc) const {
237 if (hwc.initCheck() == NO_ERROR) {
Jesse Hall851cfe82013-03-20 13:44:00 -0700238 mDisplaySurface->onFrameCommitted();
Mathias Agopianda27af92012-09-13 18:17:13 -0700239 }
240}
241
Mathias Agopian0f2f5ff2012-07-31 23:09:07 -0700242uint32_t DisplayDevice::getFlags() const
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800243{
244 return mFlags;
245}
246
Mathias Agopianda8d0a52012-09-04 15:05:38 -0700247EGLBoolean DisplayDevice::makeCurrent(EGLDisplay dpy,
248 const sp<const DisplayDevice>& hw, EGLContext ctx) {
249 EGLBoolean result = EGL_TRUE;
Mathias Agopian52bbb1a2012-07-31 19:01:53 -0700250 EGLSurface sur = eglGetCurrentSurface(EGL_DRAW);
Mathias Agopian42977342012-08-05 00:40:46 -0700251 if (sur != hw->mSurface) {
Mathias Agopianda8d0a52012-09-04 15:05:38 -0700252 result = eglMakeCurrent(dpy, hw->mSurface, hw->mSurface, ctx);
253 if (result == EGL_TRUE) {
Mathias Agopianbae92d02012-09-28 01:00:47 -0700254 setViewportAndProjection(hw);
Mathias Agopianda8d0a52012-09-04 15:05:38 -0700255 }
Mathias Agopian52bbb1a2012-07-31 19:01:53 -0700256 }
Mathias Agopianda8d0a52012-09-04 15:05:38 -0700257 return result;
Mathias Agopian52bbb1a2012-07-31 19:01:53 -0700258}
259
Mathias Agopianbae92d02012-09-28 01:00:47 -0700260void DisplayDevice::setViewportAndProjection(const sp<const DisplayDevice>& hw) {
261 GLsizei w = hw->mDisplayWidth;
262 GLsizei h = hw->mDisplayHeight;
263 glViewport(0, 0, w, h);
264 glMatrixMode(GL_PROJECTION);
265 glLoadIdentity();
266 // put the origin in the left-bottom corner
267 glOrthof(0, w, 0, h, 0, 1); // l=0, r=w ; b=0, t=h
Mathias Agopian135e5892012-09-30 16:43:20 -0700268 glMatrixMode(GL_MODELVIEW);
Mathias Agopianbae92d02012-09-28 01:00:47 -0700269}
270
Mathias Agopian1b031492012-06-20 17:51:20 -0700271// ----------------------------------------------------------------------------
272
Mathias Agopian13127d82013-03-05 17:47:11 -0800273void DisplayDevice::setVisibleLayersSortedByZ(const Vector< sp<Layer> >& layers) {
Mathias Agopian3b1d2b62012-07-11 13:48:17 -0700274 mVisibleLayersSortedByZ = layers;
Mathias Agopianef7b9c72012-08-10 15:22:19 -0700275 mSecureLayerVisible = false;
Mathias Agopian3b1d2b62012-07-11 13:48:17 -0700276 size_t count = layers.size();
277 for (size_t i=0 ; i<count ; i++) {
Mathias Agopian13127d82013-03-05 17:47:11 -0800278 const sp<Layer>& layer(layers[i]);
Mathias Agopianf5f714a2013-02-26 16:54:05 -0800279 if (layer->isSecure()) {
Mathias Agopian3b1d2b62012-07-11 13:48:17 -0700280 mSecureLayerVisible = true;
281 }
282 }
283}
284
Mathias Agopian13127d82013-03-05 17:47:11 -0800285const Vector< sp<Layer> >& DisplayDevice::getVisibleLayersSortedByZ() const {
Mathias Agopian3b1d2b62012-07-11 13:48:17 -0700286 return mVisibleLayersSortedByZ;
287}
288
Mathias Agopian0f2f5ff2012-07-31 23:09:07 -0700289bool DisplayDevice::getSecureLayerVisible() const {
Mathias Agopian3b1d2b62012-07-11 13:48:17 -0700290 return mSecureLayerVisible;
291}
292
Mathias Agopiancd60f992012-08-16 16:28:27 -0700293Region DisplayDevice::getDirtyRegion(bool repaintEverything) const {
294 Region dirty;
Mathias Agopiancd60f992012-08-16 16:28:27 -0700295 if (repaintEverything) {
296 dirty.set(getBounds());
297 } else {
Mathias Agopianda8d0a52012-09-04 15:05:38 -0700298 const Transform& planeTransform(mGlobalTransform);
Mathias Agopiancd60f992012-08-16 16:28:27 -0700299 dirty = planeTransform.transform(this->dirtyRegion);
300 dirty.andSelf(getBounds());
301 }
302 return dirty;
303}
304
Mathias Agopian3b1d2b62012-07-11 13:48:17 -0700305// ----------------------------------------------------------------------------
306
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700307bool DisplayDevice::canDraw() const {
308 return mScreenAcquired;
309}
310
311void DisplayDevice::releaseScreen() const {
312 mScreenAcquired = false;
313}
314
315void DisplayDevice::acquireScreen() const {
316 mScreenAcquired = true;
317}
318
319bool DisplayDevice::isScreenAcquired() const {
320 return mScreenAcquired;
321}
322
323// ----------------------------------------------------------------------------
324
Mathias Agopian28947d72012-08-08 18:51:15 -0700325void DisplayDevice::setLayerStack(uint32_t stack) {
326 mLayerStack = stack;
327 dirtyRegion.set(bounds());
328}
329
330// ----------------------------------------------------------------------------
331
Mathias Agopian0f2f5ff2012-07-31 23:09:07 -0700332status_t DisplayDevice::orientationToTransfrom(
Mathias Agopian1b031492012-06-20 17:51:20 -0700333 int orientation, int w, int h, Transform* tr)
334{
335 uint32_t flags = 0;
336 switch (orientation) {
Mathias Agopian3165cc22012-08-08 19:42:09 -0700337 case DisplayState::eOrientationDefault:
Mathias Agopian1b031492012-06-20 17:51:20 -0700338 flags = Transform::ROT_0;
339 break;
Mathias Agopian3165cc22012-08-08 19:42:09 -0700340 case DisplayState::eOrientation90:
Mathias Agopian1b031492012-06-20 17:51:20 -0700341 flags = Transform::ROT_90;
342 break;
Mathias Agopian3165cc22012-08-08 19:42:09 -0700343 case DisplayState::eOrientation180:
Mathias Agopian1b031492012-06-20 17:51:20 -0700344 flags = Transform::ROT_180;
345 break;
Mathias Agopian3165cc22012-08-08 19:42:09 -0700346 case DisplayState::eOrientation270:
Mathias Agopian1b031492012-06-20 17:51:20 -0700347 flags = Transform::ROT_270;
348 break;
349 default:
350 return BAD_VALUE;
351 }
352 tr->set(flags, w, h);
353 return NO_ERROR;
354}
355
Mathias Agopian00e8c7a2012-09-04 19:30:46 -0700356void DisplayDevice::setProjection(int orientation,
Mathias Agopianf5f714a2013-02-26 16:54:05 -0800357 const Rect& newViewport, const Rect& newFrame) {
358 Rect viewport(newViewport);
359 Rect frame(newFrame);
360
361 const int w = mDisplayWidth;
362 const int h = mDisplayHeight;
363
364 Transform R;
365 DisplayDevice::orientationToTransfrom(orientation, w, h, &R);
366
367 if (!frame.isValid()) {
368 // the destination frame can be invalid if it has never been set,
369 // in that case we assume the whole display frame.
370 frame = Rect(w, h);
371 }
372
373 if (viewport.isEmpty()) {
374 // viewport can be invalid if it has never been set, in that case
375 // we assume the whole display size.
376 // it's also invalid to have an empty viewport, so we handle that
377 // case in the same way.
378 viewport = Rect(w, h);
379 if (R.getOrientation() & Transform::ROT_90) {
380 // viewport is always specified in the logical orientation
381 // of the display (ie: post-rotation).
382 swap(viewport.right, viewport.bottom);
383 }
384 }
385
386 dirtyRegion.set(getBounds());
387
388 Transform TL, TP, S;
389 float src_width = viewport.width();
390 float src_height = viewport.height();
391 float dst_width = frame.width();
392 float dst_height = frame.height();
393 if (src_width != dst_width || src_height != dst_height) {
394 float sx = dst_width / src_width;
395 float sy = dst_height / src_height;
396 S.set(sx, 0, 0, sy);
397 }
398
399 float src_x = viewport.left;
400 float src_y = viewport.top;
401 float dst_x = frame.left;
402 float dst_y = frame.top;
403 TL.set(-src_x, -src_y);
404 TP.set(dst_x, dst_y);
405
406 // The viewport and frame are both in the logical orientation.
407 // Apply the logical translation, scale to physical size, apply the
408 // physical translation and finally rotate to the physical orientation.
409 mGlobalTransform = R * TP * S * TL;
410
411 const uint8_t type = mGlobalTransform.getType();
412 mNeedsFiltering = (!mGlobalTransform.preserveRects() ||
413 (type >= Transform::SCALE));
414
415 mScissor = mGlobalTransform.transform(viewport);
416 if (mScissor.isEmpty()) {
417 mScissor.set(getBounds());
418 }
419
Mathias Agopianda8d0a52012-09-04 15:05:38 -0700420 mOrientation = orientation;
Mathias Agopian00e8c7a2012-09-04 19:30:46 -0700421 mViewport = viewport;
422 mFrame = frame;
Mathias Agopian1b031492012-06-20 17:51:20 -0700423}
Mathias Agopian1d12d8a2012-09-18 01:38:00 -0700424
425void DisplayDevice::dump(String8& result, char* buffer, size_t SIZE) const {
426 const Transform& tr(mGlobalTransform);
427 snprintf(buffer, SIZE,
428 "+ DisplayDevice: %s\n"
429 " type=%x, layerStack=%u, (%4dx%4d), ANativeWindow=%p, orient=%2d (type=%08x), "
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700430 "flips=%u, isSecure=%d, secureVis=%d, acquired=%d, numLayers=%u\n"
Mathias Agopian766dc492012-10-30 18:08:06 -0700431 " v:[%d,%d,%d,%d], f:[%d,%d,%d,%d], s:[%d,%d,%d,%d],"
Mathias Agopian1d12d8a2012-09-18 01:38:00 -0700432 "transform:[[%0.3f,%0.3f,%0.3f][%0.3f,%0.3f,%0.3f][%0.3f,%0.3f,%0.3f]]\n",
Mathias Agopiand56eff22012-09-19 16:25:29 -0700433 mDisplayName.string(), mType,
Mathias Agopian1d12d8a2012-09-18 01:38:00 -0700434 mLayerStack, mDisplayWidth, mDisplayHeight, mNativeWindow.get(),
435 mOrientation, tr.getType(), getPageFlipCount(),
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700436 mIsSecure, mSecureLayerVisible, mScreenAcquired, mVisibleLayersSortedByZ.size(),
Mathias Agopian1d12d8a2012-09-18 01:38:00 -0700437 mViewport.left, mViewport.top, mViewport.right, mViewport.bottom,
438 mFrame.left, mFrame.top, mFrame.right, mFrame.bottom,
Mathias Agopian766dc492012-10-30 18:08:06 -0700439 mScissor.left, mScissor.top, mScissor.right, mScissor.bottom,
Mathias Agopian1d12d8a2012-09-18 01:38:00 -0700440 tr[0][0], tr[1][0], tr[2][0],
441 tr[0][1], tr[1][1], tr[2][1],
442 tr[0][2], tr[1][2], tr[2][2]);
443
444 result.append(buffer);
445
Jesse Hall99c7dbb2013-03-14 14:29:29 -0700446 String8 surfaceDump;
447 mDisplaySurface->dump(surfaceDump);
448 result.append(surfaceDump);
Mathias Agopian1d12d8a2012-09-18 01:38:00 -0700449}