blob: e16abef3d7e03b811499b1f5f85b4e3e666cb25c [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 Hall13f01cb2013-03-20 11:37:21 -0700238 sp<Fence> fence = hwc.getAndResetReleaseFence(mType);
239 mDisplaySurface->onFrameCommitted(fence);
Mathias Agopianda27af92012-09-13 18:17:13 -0700240 }
241}
242
Mathias Agopian0f2f5ff2012-07-31 23:09:07 -0700243uint32_t DisplayDevice::getFlags() const
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800244{
245 return mFlags;
246}
247
Mathias Agopianda8d0a52012-09-04 15:05:38 -0700248EGLBoolean DisplayDevice::makeCurrent(EGLDisplay dpy,
249 const sp<const DisplayDevice>& hw, EGLContext ctx) {
250 EGLBoolean result = EGL_TRUE;
Mathias Agopian52bbb1a2012-07-31 19:01:53 -0700251 EGLSurface sur = eglGetCurrentSurface(EGL_DRAW);
Mathias Agopian42977342012-08-05 00:40:46 -0700252 if (sur != hw->mSurface) {
Mathias Agopianda8d0a52012-09-04 15:05:38 -0700253 result = eglMakeCurrent(dpy, hw->mSurface, hw->mSurface, ctx);
254 if (result == EGL_TRUE) {
Mathias Agopianbae92d02012-09-28 01:00:47 -0700255 setViewportAndProjection(hw);
Mathias Agopianda8d0a52012-09-04 15:05:38 -0700256 }
Mathias Agopian52bbb1a2012-07-31 19:01:53 -0700257 }
Mathias Agopianda8d0a52012-09-04 15:05:38 -0700258 return result;
Mathias Agopian52bbb1a2012-07-31 19:01:53 -0700259}
260
Mathias Agopianbae92d02012-09-28 01:00:47 -0700261void DisplayDevice::setViewportAndProjection(const sp<const DisplayDevice>& hw) {
262 GLsizei w = hw->mDisplayWidth;
263 GLsizei h = hw->mDisplayHeight;
264 glViewport(0, 0, w, h);
265 glMatrixMode(GL_PROJECTION);
266 glLoadIdentity();
267 // put the origin in the left-bottom corner
268 glOrthof(0, w, 0, h, 0, 1); // l=0, r=w ; b=0, t=h
Mathias Agopian135e5892012-09-30 16:43:20 -0700269 glMatrixMode(GL_MODELVIEW);
Mathias Agopianbae92d02012-09-28 01:00:47 -0700270}
271
Mathias Agopian1b031492012-06-20 17:51:20 -0700272// ----------------------------------------------------------------------------
273
Mathias Agopian13127d82013-03-05 17:47:11 -0800274void DisplayDevice::setVisibleLayersSortedByZ(const Vector< sp<Layer> >& layers) {
Mathias Agopian3b1d2b62012-07-11 13:48:17 -0700275 mVisibleLayersSortedByZ = layers;
Mathias Agopianef7b9c72012-08-10 15:22:19 -0700276 mSecureLayerVisible = false;
Mathias Agopian3b1d2b62012-07-11 13:48:17 -0700277 size_t count = layers.size();
278 for (size_t i=0 ; i<count ; i++) {
Mathias Agopian13127d82013-03-05 17:47:11 -0800279 const sp<Layer>& layer(layers[i]);
Mathias Agopianf5f714a2013-02-26 16:54:05 -0800280 if (layer->isSecure()) {
Mathias Agopian3b1d2b62012-07-11 13:48:17 -0700281 mSecureLayerVisible = true;
282 }
283 }
284}
285
Mathias Agopian13127d82013-03-05 17:47:11 -0800286const Vector< sp<Layer> >& DisplayDevice::getVisibleLayersSortedByZ() const {
Mathias Agopian3b1d2b62012-07-11 13:48:17 -0700287 return mVisibleLayersSortedByZ;
288}
289
Mathias Agopian0f2f5ff2012-07-31 23:09:07 -0700290bool DisplayDevice::getSecureLayerVisible() const {
Mathias Agopian3b1d2b62012-07-11 13:48:17 -0700291 return mSecureLayerVisible;
292}
293
Mathias Agopiancd60f992012-08-16 16:28:27 -0700294Region DisplayDevice::getDirtyRegion(bool repaintEverything) const {
295 Region dirty;
Mathias Agopiancd60f992012-08-16 16:28:27 -0700296 if (repaintEverything) {
297 dirty.set(getBounds());
298 } else {
Mathias Agopianda8d0a52012-09-04 15:05:38 -0700299 const Transform& planeTransform(mGlobalTransform);
Mathias Agopiancd60f992012-08-16 16:28:27 -0700300 dirty = planeTransform.transform(this->dirtyRegion);
301 dirty.andSelf(getBounds());
302 }
303 return dirty;
304}
305
Mathias Agopian3b1d2b62012-07-11 13:48:17 -0700306// ----------------------------------------------------------------------------
307
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700308bool DisplayDevice::canDraw() const {
309 return mScreenAcquired;
310}
311
312void DisplayDevice::releaseScreen() const {
313 mScreenAcquired = false;
314}
315
316void DisplayDevice::acquireScreen() const {
317 mScreenAcquired = true;
318}
319
320bool DisplayDevice::isScreenAcquired() const {
321 return mScreenAcquired;
322}
323
324// ----------------------------------------------------------------------------
325
Mathias Agopian28947d72012-08-08 18:51:15 -0700326void DisplayDevice::setLayerStack(uint32_t stack) {
327 mLayerStack = stack;
328 dirtyRegion.set(bounds());
329}
330
331// ----------------------------------------------------------------------------
332
Mathias Agopian0f2f5ff2012-07-31 23:09:07 -0700333status_t DisplayDevice::orientationToTransfrom(
Mathias Agopian1b031492012-06-20 17:51:20 -0700334 int orientation, int w, int h, Transform* tr)
335{
336 uint32_t flags = 0;
337 switch (orientation) {
Mathias Agopian3165cc22012-08-08 19:42:09 -0700338 case DisplayState::eOrientationDefault:
Mathias Agopian1b031492012-06-20 17:51:20 -0700339 flags = Transform::ROT_0;
340 break;
Mathias Agopian3165cc22012-08-08 19:42:09 -0700341 case DisplayState::eOrientation90:
Mathias Agopian1b031492012-06-20 17:51:20 -0700342 flags = Transform::ROT_90;
343 break;
Mathias Agopian3165cc22012-08-08 19:42:09 -0700344 case DisplayState::eOrientation180:
Mathias Agopian1b031492012-06-20 17:51:20 -0700345 flags = Transform::ROT_180;
346 break;
Mathias Agopian3165cc22012-08-08 19:42:09 -0700347 case DisplayState::eOrientation270:
Mathias Agopian1b031492012-06-20 17:51:20 -0700348 flags = Transform::ROT_270;
349 break;
350 default:
351 return BAD_VALUE;
352 }
353 tr->set(flags, w, h);
354 return NO_ERROR;
355}
356
Mathias Agopian00e8c7a2012-09-04 19:30:46 -0700357void DisplayDevice::setProjection(int orientation,
Mathias Agopianf5f714a2013-02-26 16:54:05 -0800358 const Rect& newViewport, const Rect& newFrame) {
359 Rect viewport(newViewport);
360 Rect frame(newFrame);
361
362 const int w = mDisplayWidth;
363 const int h = mDisplayHeight;
364
365 Transform R;
366 DisplayDevice::orientationToTransfrom(orientation, w, h, &R);
367
368 if (!frame.isValid()) {
369 // the destination frame can be invalid if it has never been set,
370 // in that case we assume the whole display frame.
371 frame = Rect(w, h);
372 }
373
374 if (viewport.isEmpty()) {
375 // viewport can be invalid if it has never been set, in that case
376 // we assume the whole display size.
377 // it's also invalid to have an empty viewport, so we handle that
378 // case in the same way.
379 viewport = Rect(w, h);
380 if (R.getOrientation() & Transform::ROT_90) {
381 // viewport is always specified in the logical orientation
382 // of the display (ie: post-rotation).
383 swap(viewport.right, viewport.bottom);
384 }
385 }
386
387 dirtyRegion.set(getBounds());
388
389 Transform TL, TP, S;
390 float src_width = viewport.width();
391 float src_height = viewport.height();
392 float dst_width = frame.width();
393 float dst_height = frame.height();
394 if (src_width != dst_width || src_height != dst_height) {
395 float sx = dst_width / src_width;
396 float sy = dst_height / src_height;
397 S.set(sx, 0, 0, sy);
398 }
399
400 float src_x = viewport.left;
401 float src_y = viewport.top;
402 float dst_x = frame.left;
403 float dst_y = frame.top;
404 TL.set(-src_x, -src_y);
405 TP.set(dst_x, dst_y);
406
407 // The viewport and frame are both in the logical orientation.
408 // Apply the logical translation, scale to physical size, apply the
409 // physical translation and finally rotate to the physical orientation.
410 mGlobalTransform = R * TP * S * TL;
411
412 const uint8_t type = mGlobalTransform.getType();
413 mNeedsFiltering = (!mGlobalTransform.preserveRects() ||
414 (type >= Transform::SCALE));
415
416 mScissor = mGlobalTransform.transform(viewport);
417 if (mScissor.isEmpty()) {
418 mScissor.set(getBounds());
419 }
420
Mathias Agopianda8d0a52012-09-04 15:05:38 -0700421 mOrientation = orientation;
Mathias Agopian00e8c7a2012-09-04 19:30:46 -0700422 mViewport = viewport;
423 mFrame = frame;
Mathias Agopian1b031492012-06-20 17:51:20 -0700424}
Mathias Agopian1d12d8a2012-09-18 01:38:00 -0700425
426void DisplayDevice::dump(String8& result, char* buffer, size_t SIZE) const {
427 const Transform& tr(mGlobalTransform);
428 snprintf(buffer, SIZE,
429 "+ DisplayDevice: %s\n"
430 " type=%x, layerStack=%u, (%4dx%4d), ANativeWindow=%p, orient=%2d (type=%08x), "
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700431 "flips=%u, isSecure=%d, secureVis=%d, acquired=%d, numLayers=%u\n"
Mathias Agopian766dc492012-10-30 18:08:06 -0700432 " v:[%d,%d,%d,%d], f:[%d,%d,%d,%d], s:[%d,%d,%d,%d],"
Mathias Agopian1d12d8a2012-09-18 01:38:00 -0700433 "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 -0700434 mDisplayName.string(), mType,
Mathias Agopian1d12d8a2012-09-18 01:38:00 -0700435 mLayerStack, mDisplayWidth, mDisplayHeight, mNativeWindow.get(),
436 mOrientation, tr.getType(), getPageFlipCount(),
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700437 mIsSecure, mSecureLayerVisible, mScreenAcquired, mVisibleLayersSortedByZ.size(),
Mathias Agopian1d12d8a2012-09-18 01:38:00 -0700438 mViewport.left, mViewport.top, mViewport.right, mViewport.bottom,
439 mFrame.left, mFrame.top, mFrame.right, mFrame.bottom,
Mathias Agopian766dc492012-10-30 18:08:06 -0700440 mScissor.left, mScissor.top, mScissor.right, mScissor.bottom,
Mathias Agopian1d12d8a2012-09-18 01:38:00 -0700441 tr[0][0], tr[1][0], tr[2][0],
442 tr[0][1], tr[1][1], tr[2][1],
443 tr[0][2], tr[1][2], tr[2][2]);
444
445 result.append(buffer);
446
Jesse Hall99c7dbb2013-03-14 14:29:29 -0700447 String8 surfaceDump;
448 mDisplaySurface->dump(surfaceDump);
449 result.append(surfaceDump);
Mathias Agopian1d12d8a2012-09-18 01:38:00 -0700450}