The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 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 Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 17 | #include <stdlib.h> |
| 18 | #include <stdint.h> |
| 19 | #include <sys/types.h> |
| 20 | |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 21 | #include <cutils/compiler.h> |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 22 | #include <cutils/native_handle.h> |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 23 | #include <cutils/properties.h> |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 24 | |
| 25 | #include <utils/Errors.h> |
| 26 | #include <utils/Log.h> |
| 27 | #include <utils/StopWatch.h> |
| 28 | |
Mathias Agopian | 3330b20 | 2009-10-05 17:07:12 -0700 | [diff] [blame] | 29 | #include <ui/GraphicBuffer.h> |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 30 | #include <ui/PixelFormat.h> |
Mathias Agopian | 9cce325 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 31 | |
| 32 | #include <surfaceflinger/Surface.h> |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 33 | |
| 34 | #include "clz.h" |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 35 | #include "DisplayHardware/DisplayHardware.h" |
| 36 | #include "DisplayHardware/HWComposer.h" |
Mathias Agopian | 1f7bec6 | 2010-06-25 18:02:21 -0700 | [diff] [blame] | 37 | #include "GLExtensions.h" |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 38 | #include "Layer.h" |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 39 | #include "SurfaceFlinger.h" |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 40 | #include "SurfaceTextureLayer.h" |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 41 | |
| 42 | #define DEBUG_RESIZE 0 |
| 43 | |
| 44 | |
| 45 | namespace android { |
| 46 | |
| 47 | // --------------------------------------------------------------------------- |
| 48 | |
Mathias Agopian | 96f0819 | 2010-06-02 23:28:45 -0700 | [diff] [blame] | 49 | Layer::Layer(SurfaceFlinger* flinger, |
| 50 | DisplayID display, const sp<Client>& client) |
| 51 | : LayerBaseClient(flinger, display, client), |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 52 | mTextureName(-1U), |
| 53 | mQueuedFrames(0), |
| 54 | mCurrentTransform(0), |
Mathias Agopian | 933389f | 2011-07-18 16:15:08 -0700 | [diff] [blame] | 55 | mCurrentScalingMode(NATIVE_WINDOW_SCALING_MODE_FREEZE), |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 56 | mCurrentOpacity(true), |
Mathias Agopian | 5bf3abe | 2011-03-11 17:01:07 -0800 | [diff] [blame] | 57 | mFormat(PIXEL_FORMAT_NONE), |
Mathias Agopian | 1f7bec6 | 2010-06-25 18:02:21 -0700 | [diff] [blame] | 58 | mGLExtensions(GLExtensions::getInstance()), |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 59 | mOpaqueLayer(true), |
Mathias Agopian | d606de6 | 2010-05-10 20:06:11 -0700 | [diff] [blame] | 60 | mNeedsDithering(false), |
Mathias Agopian | b7e930d | 2010-06-01 15:12:58 -0700 | [diff] [blame] | 61 | mSecure(false), |
Mathias Agopian | 933389f | 2011-07-18 16:15:08 -0700 | [diff] [blame] | 62 | mProtectedByApp(false) |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 63 | { |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 64 | mCurrentCrop.makeInvalid(); |
| 65 | glGenTextures(1, &mTextureName); |
Mathias Agopian | d606de6 | 2010-05-10 20:06:11 -0700 | [diff] [blame] | 66 | } |
| 67 | |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 68 | void Layer::onFirstRef() |
Mathias Agopian | 96f0819 | 2010-06-02 23:28:45 -0700 | [diff] [blame] | 69 | { |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 70 | LayerBaseClient::onFirstRef(); |
Mathias Agopian | ddc31c3 | 2011-06-12 18:05:53 -0700 | [diff] [blame] | 71 | |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 72 | struct FrameQueuedListener : public SurfaceTexture::FrameAvailableListener { |
| 73 | FrameQueuedListener(Layer* layer) : mLayer(layer) { } |
| 74 | private: |
| 75 | wp<Layer> mLayer; |
| 76 | virtual void onFrameAvailable() { |
| 77 | sp<Layer> that(mLayer.promote()); |
| 78 | if (that != 0) { |
| 79 | that->onFrameQueued(); |
| 80 | } |
| 81 | } |
| 82 | }; |
| 83 | mSurfaceTexture = new SurfaceTextureLayer(mTextureName, this); |
| 84 | mSurfaceTexture->setFrameAvailableListener(new FrameQueuedListener(this)); |
| 85 | mSurfaceTexture->setSynchronousMode(true); |
| 86 | mSurfaceTexture->setBufferCountServer(2); |
Mathias Agopian | b7e930d | 2010-06-01 15:12:58 -0700 | [diff] [blame] | 87 | } |
| 88 | |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 89 | Layer::~Layer() |
Mathias Agopian | b7e930d | 2010-06-01 15:12:58 -0700 | [diff] [blame] | 90 | { |
Mathias Agopian | 118d024 | 2011-10-13 16:02:48 -0700 | [diff] [blame] | 91 | mFlinger->postMessageAsync( |
| 92 | new SurfaceFlinger::MessageDestroyGLTexture(mTextureName) ); |
Mathias Agopian | 96f0819 | 2010-06-02 23:28:45 -0700 | [diff] [blame] | 93 | } |
| 94 | |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 95 | void Layer::onFrameQueued() { |
Jamie Gennis | 3d8063b | 2011-06-26 18:27:47 -0700 | [diff] [blame] | 96 | android_atomic_inc(&mQueuedFrames); |
| 97 | mFlinger->signalEvent(); |
Mathias Agopian | 579b3f8 | 2010-06-08 19:54:15 -0700 | [diff] [blame] | 98 | } |
| 99 | |
Mathias Agopian | d606de6 | 2010-05-10 20:06:11 -0700 | [diff] [blame] | 100 | // called with SurfaceFlinger::mStateLock as soon as the layer is entered |
| 101 | // in the purgatory list |
| 102 | void Layer::onRemoved() |
| 103 | { |
Jamie Gennis | dbe6486 | 2011-07-30 14:33:49 -0700 | [diff] [blame] | 104 | mSurfaceTexture->abandon(); |
Mathias Agopian | 48d819a | 2009-09-10 19:41:18 -0700 | [diff] [blame] | 105 | } |
Mathias Agopian | cbb288b | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 106 | |
Jamie Gennis | a249f2d | 2011-09-16 17:31:54 -0700 | [diff] [blame] | 107 | void Layer::setName(const String8& name) { |
| 108 | LayerBase::setName(name); |
| 109 | mSurfaceTexture->setName(name); |
| 110 | } |
| 111 | |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 112 | sp<ISurface> Layer::createSurface() |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 113 | { |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 114 | class BSurface : public BnSurface, public LayerCleaner { |
| 115 | wp<const Layer> mOwner; |
| 116 | virtual sp<ISurfaceTexture> getSurfaceTexture() const { |
| 117 | sp<ISurfaceTexture> res; |
| 118 | sp<const Layer> that( mOwner.promote() ); |
| 119 | if (that != NULL) { |
| 120 | res = that->mSurfaceTexture; |
| 121 | } |
| 122 | return res; |
| 123 | } |
| 124 | public: |
| 125 | BSurface(const sp<SurfaceFlinger>& flinger, |
| 126 | const sp<Layer>& layer) |
| 127 | : LayerCleaner(flinger, layer), mOwner(layer) { } |
| 128 | }; |
| 129 | sp<ISurface> sur(new BSurface(mFlinger, this)); |
Mathias Agopian | a1f47b9 | 2011-02-15 19:01:06 -0800 | [diff] [blame] | 130 | return sur; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 131 | } |
| 132 | |
Jamie Gennis | 582270d | 2011-08-17 18:19:00 -0700 | [diff] [blame] | 133 | wp<IBinder> Layer::getSurfaceTextureBinder() const |
| 134 | { |
| 135 | return mSurfaceTexture->asBinder(); |
| 136 | } |
| 137 | |
Mathias Agopian | f9d9327 | 2009-06-19 17:00:27 -0700 | [diff] [blame] | 138 | status_t Layer::setBuffers( uint32_t w, uint32_t h, |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 139 | PixelFormat format, uint32_t flags) |
| 140 | { |
Mathias Agopian | 401c257 | 2009-09-23 19:16:27 -0700 | [diff] [blame] | 141 | // this surfaces pixel format |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 142 | PixelFormatInfo info; |
| 143 | status_t err = getPixelFormatInfo(format, &info); |
| 144 | if (err) return err; |
| 145 | |
Mathias Agopian | 401c257 | 2009-09-23 19:16:27 -0700 | [diff] [blame] | 146 | // the display's pixel format |
| 147 | const DisplayHardware& hw(graphicPlane(0).displayHardware()); |
Mathias Agopian | ca99fb8 | 2010-04-14 16:43:44 -0700 | [diff] [blame] | 148 | uint32_t const maxSurfaceDims = min( |
| 149 | hw.getMaxTextureSize(), hw.getMaxViewportDims()); |
| 150 | |
| 151 | // never allow a surface larger than what our underlying GL implementation |
| 152 | // can handle. |
| 153 | if ((uint32_t(w)>maxSurfaceDims) || (uint32_t(h)>maxSurfaceDims)) { |
| 154 | return BAD_VALUE; |
| 155 | } |
| 156 | |
Mathias Agopian | 401c257 | 2009-09-23 19:16:27 -0700 | [diff] [blame] | 157 | PixelFormatInfo displayInfo; |
| 158 | getPixelFormatInfo(hw.getFormat(), &displayInfo); |
Mathias Agopian | a4b740e | 2009-10-05 18:20:39 -0700 | [diff] [blame] | 159 | const uint32_t hwFlags = hw.getFlags(); |
| 160 | |
Mathias Agopian | cbb288b | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 161 | mFormat = format; |
Mathias Agopian | eff062c | 2010-08-25 14:59:15 -0700 | [diff] [blame] | 162 | |
Mathias Agopian | 3330b20 | 2009-10-05 17:07:12 -0700 | [diff] [blame] | 163 | mSecure = (flags & ISurfaceComposer::eSecure) ? true : false; |
Glenn Kasten | 16f0453 | 2011-01-19 15:27:27 -0800 | [diff] [blame] | 164 | mProtectedByApp = (flags & ISurfaceComposer::eProtectedByApp) ? true : false; |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 165 | mOpaqueLayer = (flags & ISurfaceComposer::eOpaque); |
| 166 | mCurrentOpacity = getOpacityForFormat(format); |
| 167 | |
| 168 | mSurfaceTexture->setDefaultBufferSize(w, h); |
| 169 | mSurfaceTexture->setDefaultBufferFormat(format); |
Mathias Agopian | ca99fb8 | 2010-04-14 16:43:44 -0700 | [diff] [blame] | 170 | |
Mathias Agopian | 401c257 | 2009-09-23 19:16:27 -0700 | [diff] [blame] | 171 | // we use the red index |
| 172 | int displayRedSize = displayInfo.getSize(PixelFormatInfo::INDEX_RED); |
| 173 | int layerRedsize = info.getSize(PixelFormatInfo::INDEX_RED); |
| 174 | mNeedsDithering = layerRedsize > displayRedSize; |
| 175 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 176 | return NO_ERROR; |
| 177 | } |
| 178 | |
Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 179 | void Layer::setGeometry(hwc_layer_t* hwcl) |
| 180 | { |
Mathias Agopian | a537c0f | 2011-08-02 15:51:37 -0700 | [diff] [blame] | 181 | LayerBaseClient::setGeometry(hwcl); |
| 182 | |
| 183 | hwcl->flags &= ~HWC_SKIP_LAYER; |
Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 184 | |
| 185 | // we can't do alpha-fade with the hwc HAL |
| 186 | const State& s(drawingState()); |
| 187 | if (s.alpha < 0xFF) { |
| 188 | hwcl->flags = HWC_SKIP_LAYER; |
Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 189 | } |
| 190 | |
Mathias Agopian | 29a367b | 2011-07-12 14:51:45 -0700 | [diff] [blame] | 191 | /* |
| 192 | * Transformations are applied in this order: |
| 193 | * 1) buffer orientation/flip/mirror |
| 194 | * 2) state transformation (window manager) |
| 195 | * 3) layer orientation (screen orientation) |
Mathias Agopian | d992db3 | 2011-08-18 18:31:00 -0700 | [diff] [blame] | 196 | * mTransform is already the composition of (2) and (3) |
Mathias Agopian | 29a367b | 2011-07-12 14:51:45 -0700 | [diff] [blame] | 197 | * (NOTE: the matrices are multiplied in reverse order) |
| 198 | */ |
| 199 | |
| 200 | const Transform bufferOrientation(mCurrentTransform); |
Mathias Agopian | d992db3 | 2011-08-18 18:31:00 -0700 | [diff] [blame] | 201 | const Transform tr(mTransform * bufferOrientation); |
Mathias Agopian | 29a367b | 2011-07-12 14:51:45 -0700 | [diff] [blame] | 202 | |
| 203 | // this gives us only the "orientation" component of the transform |
| 204 | const uint32_t finalTransform = tr.getOrientation(); |
| 205 | |
Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 206 | // we can only handle simple transformation |
Mathias Agopian | 29a367b | 2011-07-12 14:51:45 -0700 | [diff] [blame] | 207 | if (finalTransform & Transform::ROT_INVALID) { |
Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 208 | hwcl->flags = HWC_SKIP_LAYER; |
Mathias Agopian | a537c0f | 2011-08-02 15:51:37 -0700 | [diff] [blame] | 209 | } else { |
| 210 | hwcl->transform = finalTransform; |
Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 211 | } |
Mathias Agopian | c7f3381 | 2011-08-30 15:02:41 -0700 | [diff] [blame] | 212 | |
| 213 | if (isCropped()) { |
| 214 | hwcl->sourceCrop.left = mCurrentCrop.left; |
| 215 | hwcl->sourceCrop.top = mCurrentCrop.top; |
| 216 | hwcl->sourceCrop.right = mCurrentCrop.right; |
| 217 | hwcl->sourceCrop.bottom = mCurrentCrop.bottom; |
| 218 | } else { |
| 219 | const sp<GraphicBuffer>& buffer(mActiveBuffer); |
| 220 | hwcl->sourceCrop.left = 0; |
| 221 | hwcl->sourceCrop.top = 0; |
| 222 | if (buffer != NULL) { |
| 223 | hwcl->sourceCrop.right = buffer->width; |
| 224 | hwcl->sourceCrop.bottom = buffer->height; |
| 225 | } else { |
| 226 | hwcl->sourceCrop.right = mTransformedBounds.width(); |
| 227 | hwcl->sourceCrop.bottom = mTransformedBounds.height(); |
| 228 | } |
| 229 | } |
Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 230 | } |
| 231 | |
| 232 | void Layer::setPerFrameData(hwc_layer_t* hwcl) { |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 233 | const sp<GraphicBuffer>& buffer(mActiveBuffer); |
Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 234 | if (buffer == NULL) { |
Mathias Agopian | da9584d | 2010-12-13 18:51:59 -0800 | [diff] [blame] | 235 | // this can happen if the client never drew into this layer yet, |
| 236 | // or if we ran out of memory. In that case, don't let |
| 237 | // HWC handle it. |
| 238 | hwcl->flags |= HWC_SKIP_LAYER; |
Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 239 | hwcl->handle = NULL; |
Mathias Agopian | a537c0f | 2011-08-02 15:51:37 -0700 | [diff] [blame] | 240 | } else { |
| 241 | hwcl->handle = buffer->handle; |
Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 242 | } |
Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 243 | } |
| 244 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 245 | void Layer::onDraw(const Region& clip) const |
| 246 | { |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 247 | if (CC_UNLIKELY(mActiveBuffer == 0)) { |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 248 | // the texture has not been created yet, this Layer has |
Mathias Agopian | 179169e | 2010-05-06 20:21:45 -0700 | [diff] [blame] | 249 | // in fact never been drawn into. This happens frequently with |
| 250 | // SurfaceView because the WindowManager can't know when the client |
| 251 | // has drawn the first time. |
| 252 | |
| 253 | // If there is nothing under us, we paint the screen in black, otherwise |
| 254 | // we just skip this update. |
| 255 | |
| 256 | // figure out if there is something below us |
| 257 | Region under; |
Mathias Agopian | f7ae69d | 2011-08-23 12:34:29 -0700 | [diff] [blame] | 258 | const SurfaceFlinger::LayerVector& drawingLayers( |
| 259 | mFlinger->mDrawingState.layersSortedByZ); |
Mathias Agopian | 179169e | 2010-05-06 20:21:45 -0700 | [diff] [blame] | 260 | const size_t count = drawingLayers.size(); |
| 261 | for (size_t i=0 ; i<count ; ++i) { |
| 262 | const sp<LayerBase>& layer(drawingLayers[i]); |
| 263 | if (layer.get() == static_cast<LayerBase const*>(this)) |
| 264 | break; |
| 265 | under.orSelf(layer->visibleRegionScreen); |
| 266 | } |
| 267 | // if not everything below us is covered, we plug the holes! |
| 268 | Region holes(clip.subtract(under)); |
| 269 | if (!holes.isEmpty()) { |
Mathias Agopian | 0a91775 | 2010-06-14 21:20:00 -0700 | [diff] [blame] | 270 | clearWithOpenGL(holes, 0, 0, 0, 1); |
Mathias Agopian | 179169e | 2010-05-06 20:21:45 -0700 | [diff] [blame] | 271 | } |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 272 | return; |
| 273 | } |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 274 | |
Jamie Gennis | 9575f60 | 2011-10-07 14:51:16 -0700 | [diff] [blame] | 275 | if (!isProtected()) { |
Mathias Agopian | c492e67 | 2011-10-18 14:49:27 -0700 | [diff] [blame] | 276 | glBindTexture(GL_TEXTURE_EXTERNAL_OES, mTextureName); |
| 277 | GLenum filter = GL_NEAREST; |
Jamie Gennis | 9575f60 | 2011-10-07 14:51:16 -0700 | [diff] [blame] | 278 | if (getFiltering() || needsFiltering() || isFixedSize() || isCropped()) { |
| 279 | // TODO: we could be more subtle with isFixedSize() |
Mathias Agopian | c492e67 | 2011-10-18 14:49:27 -0700 | [diff] [blame] | 280 | filter = GL_LINEAR; |
Jamie Gennis | 9575f60 | 2011-10-07 14:51:16 -0700 | [diff] [blame] | 281 | } |
Mathias Agopian | c492e67 | 2011-10-18 14:49:27 -0700 | [diff] [blame] | 282 | glTexParameterx(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, filter); |
| 283 | glTexParameterx(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, filter); |
Jamie Gennis | 9575f60 | 2011-10-07 14:51:16 -0700 | [diff] [blame] | 284 | glMatrixMode(GL_TEXTURE); |
| 285 | glLoadMatrixf(mTextureMatrix); |
| 286 | glMatrixMode(GL_MODELVIEW); |
Mathias Agopian | c492e67 | 2011-10-18 14:49:27 -0700 | [diff] [blame] | 287 | glDisable(GL_TEXTURE_2D); |
Xavier Ducrohet | 4c4163b | 2011-10-21 16:18:48 -0700 | [diff] [blame^] | 288 | glEnable(GL_TEXTURE_EXTERNAL_OES); |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 289 | } else { |
Mathias Agopian | c492e67 | 2011-10-18 14:49:27 -0700 | [diff] [blame] | 290 | glBindTexture(GL_TEXTURE_2D, mFlinger->getProtectedTexName()); |
Jamie Gennis | 9575f60 | 2011-10-07 14:51:16 -0700 | [diff] [blame] | 291 | glMatrixMode(GL_TEXTURE); |
| 292 | glLoadIdentity(); |
| 293 | glMatrixMode(GL_MODELVIEW); |
Mathias Agopian | c492e67 | 2011-10-18 14:49:27 -0700 | [diff] [blame] | 294 | glDisable(GL_TEXTURE_EXTERNAL_OES); |
| 295 | glEnable(GL_TEXTURE_2D); |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 296 | } |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 297 | |
| 298 | drawWithOpenGL(clip); |
| 299 | |
Mathias Agopian | c492e67 | 2011-10-18 14:49:27 -0700 | [diff] [blame] | 300 | glDisable(GL_TEXTURE_EXTERNAL_OES); |
| 301 | glDisable(GL_TEXTURE_2D); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 302 | } |
| 303 | |
Eric Hassold | ac45e6b | 2011-02-10 14:41:26 -0800 | [diff] [blame] | 304 | // As documented in libhardware header, formats in the range |
| 305 | // 0x100 - 0x1FF are specific to the HAL implementation, and |
| 306 | // are known to have no alpha channel |
| 307 | // TODO: move definition for device-specific range into |
| 308 | // hardware.h, instead of using hard-coded values here. |
| 309 | #define HARDWARE_IS_DEVICE_FORMAT(f) ((f) >= 0x100 && (f) <= 0x1FF) |
| 310 | |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 311 | bool Layer::getOpacityForFormat(uint32_t format) |
Eric Hassold | ac45e6b | 2011-02-10 14:41:26 -0800 | [diff] [blame] | 312 | { |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 313 | if (HARDWARE_IS_DEVICE_FORMAT(format)) { |
| 314 | return true; |
Eric Hassold | ac45e6b | 2011-02-10 14:41:26 -0800 | [diff] [blame] | 315 | } |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 316 | PixelFormatInfo info; |
| 317 | status_t err = getPixelFormatInfo(PixelFormat(format), &info); |
| 318 | // in case of error (unknown format), we assume no blending |
| 319 | return (err || info.h_alpha <= info.l_alpha); |
Eric Hassold | ac45e6b | 2011-02-10 14:41:26 -0800 | [diff] [blame] | 320 | } |
| 321 | |
Eric Hassold | ac45e6b | 2011-02-10 14:41:26 -0800 | [diff] [blame] | 322 | |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 323 | bool Layer::isOpaque() const |
Mathias Agopian | a7f6692 | 2010-05-26 22:08:52 -0700 | [diff] [blame] | 324 | { |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 325 | // if we don't have a buffer yet, we're translucent regardless of the |
| 326 | // layer's opaque flag. |
Jamie Gennis | db5230f | 2011-07-28 14:54:07 -0700 | [diff] [blame] | 327 | if (mActiveBuffer == 0) { |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 328 | return false; |
Jamie Gennis | db5230f | 2011-07-28 14:54:07 -0700 | [diff] [blame] | 329 | } |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 330 | |
| 331 | // if the layer has the opaque flag, then we're always opaque, |
| 332 | // otherwise we use the current buffer's format. |
| 333 | return mOpaqueLayer || mCurrentOpacity; |
Mathias Agopian | a7f6692 | 2010-05-26 22:08:52 -0700 | [diff] [blame] | 334 | } |
| 335 | |
Jamie Gennis | 7a4d0df | 2011-03-09 17:05:02 -0800 | [diff] [blame] | 336 | bool Layer::isProtected() const |
| 337 | { |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 338 | const sp<GraphicBuffer>& activeBuffer(mActiveBuffer); |
Jamie Gennis | 7a4d0df | 2011-03-09 17:05:02 -0800 | [diff] [blame] | 339 | return (activeBuffer != 0) && |
| 340 | (activeBuffer->getUsage() & GRALLOC_USAGE_PROTECTED); |
| 341 | } |
Mathias Agopian | b5b7f26 | 2010-05-07 15:58:44 -0700 | [diff] [blame] | 342 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 343 | uint32_t Layer::doTransaction(uint32_t flags) |
| 344 | { |
| 345 | const Layer::State& front(drawingState()); |
| 346 | const Layer::State& temp(currentState()); |
| 347 | |
Mathias Agopian | a138f89 | 2010-05-21 17:24:35 -0700 | [diff] [blame] | 348 | const bool sizeChanged = (front.requested_w != temp.requested_w) || |
| 349 | (front.requested_h != temp.requested_h); |
| 350 | |
| 351 | if (sizeChanged) { |
Mathias Agopian | cbb288b | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 352 | // the size changed, we need to ask our client to request a new buffer |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 353 | LOGD_IF(DEBUG_RESIZE, |
Mathias Agopian | 3fbce7c | 2011-07-25 19:56:08 -0700 | [diff] [blame] | 354 | "doTransaction: " |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 355 | "resize (layer=%p), requested (%dx%d), drawing (%d,%d), " |
Mathias Agopian | 3fbce7c | 2011-07-25 19:56:08 -0700 | [diff] [blame] | 356 | "scalingMode=%d", |
Mathias Agopian | a138f89 | 2010-05-21 17:24:35 -0700 | [diff] [blame] | 357 | this, |
| 358 | int(temp.requested_w), int(temp.requested_h), |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 359 | int(front.requested_w), int(front.requested_h), |
Mathias Agopian | 3fbce7c | 2011-07-25 19:56:08 -0700 | [diff] [blame] | 360 | mCurrentScalingMode); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 361 | |
Mathias Agopian | a138f89 | 2010-05-21 17:24:35 -0700 | [diff] [blame] | 362 | if (!isFixedSize()) { |
Mathias Agopian | a138f89 | 2010-05-21 17:24:35 -0700 | [diff] [blame] | 363 | // this will make sure LayerBase::doTransaction doesn't update |
| 364 | // the drawing state's size |
| 365 | Layer::State& editDraw(mDrawingState); |
| 366 | editDraw.requested_w = temp.requested_w; |
| 367 | editDraw.requested_h = temp.requested_h; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 368 | } |
Jamie Gennis | 2a0d5b6 | 2011-09-26 16:54:44 -0700 | [diff] [blame] | 369 | |
| 370 | // record the new size, form this point on, when the client request |
| 371 | // a buffer, it'll get the new size. |
| 372 | mSurfaceTexture->setDefaultBufferSize(temp.requested_w, |
| 373 | temp.requested_h); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 374 | } |
Mathias Agopian | cbb288b | 2009-09-07 16:32:45 -0700 | [diff] [blame] | 375 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 376 | return LayerBase::doTransaction(flags); |
| 377 | } |
| 378 | |
Mathias Agopian | a138f89 | 2010-05-21 17:24:35 -0700 | [diff] [blame] | 379 | bool Layer::isFixedSize() const { |
Mathias Agopian | 933389f | 2011-07-18 16:15:08 -0700 | [diff] [blame] | 380 | return mCurrentScalingMode != NATIVE_WINDOW_SCALING_MODE_FREEZE; |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 381 | } |
| 382 | |
| 383 | bool Layer::isCropped() const { |
| 384 | return !mCurrentCrop.isEmpty(); |
| 385 | } |
| 386 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 387 | // ---------------------------------------------------------------------------- |
| 388 | // pageflip handling... |
| 389 | // ---------------------------------------------------------------------------- |
| 390 | |
| 391 | void Layer::lockPageFlip(bool& recomputeVisibleRegions) |
| 392 | { |
Jamie Gennis | 3d8063b | 2011-06-26 18:27:47 -0700 | [diff] [blame] | 393 | if (mQueuedFrames > 0) { |
Jamie Gennis | 351a513 | 2011-09-14 18:23:37 -0700 | [diff] [blame] | 394 | // Capture the old state of the layer for comparisons later |
Jamie Gennis | db5230f | 2011-07-28 14:54:07 -0700 | [diff] [blame] | 395 | const bool oldOpacity = isOpaque(); |
Jamie Gennis | 351a513 | 2011-09-14 18:23:37 -0700 | [diff] [blame] | 396 | sp<GraphicBuffer> oldActiveBuffer = mActiveBuffer; |
Jamie Gennis | db5230f | 2011-07-28 14:54:07 -0700 | [diff] [blame] | 397 | |
Jamie Gennis | 3d8063b | 2011-06-26 18:27:47 -0700 | [diff] [blame] | 398 | // signal another event if we have more frames pending |
| 399 | if (android_atomic_dec(&mQueuedFrames) > 1) { |
| 400 | mFlinger->signalEvent(); |
| 401 | } |
| 402 | |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 403 | if (mSurfaceTexture->updateTexImage() < NO_ERROR) { |
| 404 | // something happened! |
| 405 | recomputeVisibleRegions = true; |
| 406 | return; |
| 407 | } |
Mathias Agopian | 96f0819 | 2010-06-02 23:28:45 -0700 | [diff] [blame] | 408 | |
Jamie Gennis | 351a513 | 2011-09-14 18:23:37 -0700 | [diff] [blame] | 409 | // update the active buffer |
| 410 | mActiveBuffer = mSurfaceTexture->getCurrentBuffer(); |
Mathias Agopian | d343e3d | 2010-03-15 18:15:20 -0700 | [diff] [blame] | 411 | |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 412 | const Rect crop(mSurfaceTexture->getCurrentCrop()); |
| 413 | const uint32_t transform(mSurfaceTexture->getCurrentTransform()); |
Mathias Agopian | 933389f | 2011-07-18 16:15:08 -0700 | [diff] [blame] | 414 | const uint32_t scalingMode(mSurfaceTexture->getCurrentScalingMode()); |
| 415 | if ((crop != mCurrentCrop) || |
| 416 | (transform != mCurrentTransform) || |
| 417 | (scalingMode != mCurrentScalingMode)) |
| 418 | { |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 419 | mCurrentCrop = crop; |
| 420 | mCurrentTransform = transform; |
Mathias Agopian | 933389f | 2011-07-18 16:15:08 -0700 | [diff] [blame] | 421 | mCurrentScalingMode = scalingMode; |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 422 | mFlinger->invalidateHwcGeometry(); |
| 423 | } |
Mathias Agopian | da9584d | 2010-12-13 18:51:59 -0800 | [diff] [blame] | 424 | |
Mathias Agopian | c7f3381 | 2011-08-30 15:02:41 -0700 | [diff] [blame] | 425 | GLfloat textureMatrix[16]; |
| 426 | mSurfaceTexture->getTransformMatrix(textureMatrix); |
| 427 | if (memcmp(textureMatrix, mTextureMatrix, sizeof(textureMatrix))) { |
| 428 | memcpy(mTextureMatrix, textureMatrix, sizeof(textureMatrix)); |
| 429 | mFlinger->invalidateHwcGeometry(); |
| 430 | } |
| 431 | |
Jamie Gennis | 351a513 | 2011-09-14 18:23:37 -0700 | [diff] [blame] | 432 | uint32_t bufWidth = mActiveBuffer->getWidth(); |
| 433 | uint32_t bufHeight = mActiveBuffer->getHeight(); |
| 434 | if (oldActiveBuffer != NULL) { |
| 435 | if (bufWidth != uint32_t(oldActiveBuffer->width) || |
| 436 | bufHeight != uint32_t(oldActiveBuffer->height)) { |
Mathias Agopian | c7f3381 | 2011-08-30 15:02:41 -0700 | [diff] [blame] | 437 | mFlinger->invalidateHwcGeometry(); |
| 438 | } |
| 439 | } |
| 440 | |
Jamie Gennis | 351a513 | 2011-09-14 18:23:37 -0700 | [diff] [blame] | 441 | mCurrentOpacity = getOpacityForFormat(mActiveBuffer->format); |
Jamie Gennis | db5230f | 2011-07-28 14:54:07 -0700 | [diff] [blame] | 442 | if (oldOpacity != isOpaque()) { |
Eric Hassold | ac45e6b | 2011-02-10 14:41:26 -0800 | [diff] [blame] | 443 | recomputeVisibleRegions = true; |
| 444 | } |
| 445 | |
Mathias Agopian | f7ae69d | 2011-08-23 12:34:29 -0700 | [diff] [blame] | 446 | glTexParameterx(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| 447 | glTexParameterx(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 448 | |
Jamie Gennis | a402c4c | 2011-10-14 16:44:08 -0700 | [diff] [blame] | 449 | // update the layer size if needed |
Mathias Agopian | d343e3d | 2010-03-15 18:15:20 -0700 | [diff] [blame] | 450 | const Layer::State& front(drawingState()); |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 451 | |
| 452 | // FIXME: mPostedDirtyRegion = dirty & bounds |
| 453 | mPostedDirtyRegion.set(front.w, front.h); |
| 454 | |
Mathias Agopian | 97c602c | 2011-07-19 15:24:46 -0700 | [diff] [blame] | 455 | if ((front.w != front.requested_w) || |
| 456 | (front.h != front.requested_h)) |
Mathias Agopian | df3e0b9 | 2009-09-30 14:07:22 -0700 | [diff] [blame] | 457 | { |
Mathias Agopian | 97c602c | 2011-07-19 15:24:46 -0700 | [diff] [blame] | 458 | // check that we received a buffer of the right size |
| 459 | // (Take the buffer's orientation into account) |
Mathias Agopian | 97c602c | 2011-07-19 15:24:46 -0700 | [diff] [blame] | 460 | if (mCurrentTransform & Transform::ROT_90) { |
| 461 | swap(bufWidth, bufHeight); |
| 462 | } |
| 463 | |
| 464 | if (isFixedSize() || |
| 465 | (bufWidth == front.requested_w && |
| 466 | bufHeight == front.requested_h)) |
Mathias Agopian | d343e3d | 2010-03-15 18:15:20 -0700 | [diff] [blame] | 467 | { |
| 468 | // Here we pretend the transaction happened by updating the |
| 469 | // current and drawing states. Drawing state is only accessed |
| 470 | // in this thread, no need to have it locked |
| 471 | Layer::State& editDraw(mDrawingState); |
| 472 | editDraw.w = editDraw.requested_w; |
| 473 | editDraw.h = editDraw.requested_h; |
Mathias Agopian | df3e0b9 | 2009-09-30 14:07:22 -0700 | [diff] [blame] | 474 | |
Mathias Agopian | d343e3d | 2010-03-15 18:15:20 -0700 | [diff] [blame] | 475 | // We also need to update the current state so that we don't |
| 476 | // end-up doing too much work during the next transaction. |
| 477 | // NOTE: We actually don't need hold the transaction lock here |
| 478 | // because State::w and State::h are only accessed from |
| 479 | // this thread |
| 480 | Layer::State& editTemp(currentState()); |
| 481 | editTemp.w = editDraw.w; |
| 482 | editTemp.h = editDraw.h; |
Mathias Agopian | df3e0b9 | 2009-09-30 14:07:22 -0700 | [diff] [blame] | 483 | |
Mathias Agopian | d343e3d | 2010-03-15 18:15:20 -0700 | [diff] [blame] | 484 | // recompute visible region |
| 485 | recomputeVisibleRegions = true; |
Mathias Agopian | 97c602c | 2011-07-19 15:24:46 -0700 | [diff] [blame] | 486 | } |
Mathias Agopian | 3fbce7c | 2011-07-25 19:56:08 -0700 | [diff] [blame] | 487 | |
| 488 | LOGD_IF(DEBUG_RESIZE, |
| 489 | "lockPageFlip : " |
| 490 | " (layer=%p), buffer (%ux%u, tr=%02x), " |
| 491 | "requested (%dx%d)", |
| 492 | this, |
| 493 | bufWidth, bufHeight, mCurrentTransform, |
| 494 | front.requested_w, front.requested_h); |
Mathias Agopian | df3e0b9 | 2009-09-30 14:07:22 -0700 | [diff] [blame] | 495 | } |
Mathias Agopian | caa600c | 2009-09-16 18:27:24 -0700 | [diff] [blame] | 496 | } |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 497 | } |
| 498 | |
| 499 | void Layer::unlockPageFlip( |
| 500 | const Transform& planeTransform, Region& outDirtyRegion) |
| 501 | { |
| 502 | Region dirtyRegion(mPostedDirtyRegion); |
| 503 | if (!dirtyRegion.isEmpty()) { |
| 504 | mPostedDirtyRegion.clear(); |
| 505 | // The dirty region is given in the layer's coordinate space |
| 506 | // transform the dirty region by the surface's transformation |
| 507 | // and the global transformation. |
| 508 | const Layer::State& s(drawingState()); |
| 509 | const Transform tr(planeTransform * s.transform); |
| 510 | dirtyRegion = tr.transform(dirtyRegion); |
| 511 | |
| 512 | // At this point, the dirty region is in screen space. |
| 513 | // Make sure it's constrained by the visible region (which |
| 514 | // is in screen space as well). |
| 515 | dirtyRegion.andSelf(visibleRegionScreen); |
| 516 | outDirtyRegion.orSelf(dirtyRegion); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 517 | } |
| 518 | } |
| 519 | |
Mathias Agopian | 1b5e102 | 2010-04-20 17:55:49 -0700 | [diff] [blame] | 520 | void Layer::dump(String8& result, char* buffer, size_t SIZE) const |
| 521 | { |
| 522 | LayerBaseClient::dump(result, buffer, SIZE); |
| 523 | |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 524 | sp<const GraphicBuffer> buf0(mActiveBuffer); |
| 525 | uint32_t w0=0, h0=0, s0=0, f0=0; |
Mathias Agopian | 1b5e102 | 2010-04-20 17:55:49 -0700 | [diff] [blame] | 526 | if (buf0 != 0) { |
| 527 | w0 = buf0->getWidth(); |
| 528 | h0 = buf0->getHeight(); |
| 529 | s0 = buf0->getStride(); |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 530 | f0 = buf0->format; |
Mathias Agopian | 1b5e102 | 2010-04-20 17:55:49 -0700 | [diff] [blame] | 531 | } |
| 532 | snprintf(buffer, SIZE, |
| 533 | " " |
Mathias Agopian | ad795ba | 2011-08-08 16:02:13 -0700 | [diff] [blame] | 534 | "format=%2d, activeBuffer=[%4ux%4u:%4u,%3X]," |
Jamie Gennis | a402c4c | 2011-10-14 16:44:08 -0700 | [diff] [blame] | 535 | " transform-hint=0x%02x, queued-frames=%d\n", |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 536 | mFormat, w0, h0, s0,f0, |
Jamie Gennis | a402c4c | 2011-10-14 16:44:08 -0700 | [diff] [blame] | 537 | getTransformHint(), mQueuedFrames); |
Mathias Agopian | 1b5e102 | 2010-04-20 17:55:49 -0700 | [diff] [blame] | 538 | |
| 539 | result.append(buffer); |
Mathias Agopian | 1b5e102 | 2010-04-20 17:55:49 -0700 | [diff] [blame] | 540 | |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 541 | if (mSurfaceTexture != 0) { |
| 542 | mSurfaceTexture->dump(result, " ", buffer, SIZE); |
Mathias Agopian | 579b3f8 | 2010-06-08 19:54:15 -0700 | [diff] [blame] | 543 | } |
Mathias Agopian | b7e930d | 2010-06-01 15:12:58 -0700 | [diff] [blame] | 544 | } |
| 545 | |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 546 | uint32_t Layer::getEffectiveUsage(uint32_t usage) const |
Mathias Agopian | b7e930d | 2010-06-01 15:12:58 -0700 | [diff] [blame] | 547 | { |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 548 | // TODO: should we do something special if mSecure is set? |
| 549 | if (mProtectedByApp) { |
| 550 | // need a hardware-protected path to external video sink |
| 551 | usage |= GraphicBuffer::USAGE_PROTECTED; |
Jamie Gennis | 54cc83e | 2010-11-02 11:51:32 -0700 | [diff] [blame] | 552 | } |
Jamie Gennis | 3599bf2 | 2011-08-10 11:48:07 -0700 | [diff] [blame] | 553 | usage |= GraphicBuffer::USAGE_HW_COMPOSER; |
Mathias Agopian | a67932f | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 554 | return usage; |
Mathias Agopian | b5b7f26 | 2010-05-07 15:58:44 -0700 | [diff] [blame] | 555 | } |
| 556 | |
Mathias Agopian | a458364 | 2011-08-23 18:03:18 -0700 | [diff] [blame] | 557 | uint32_t Layer::getTransformHint() const { |
| 558 | uint32_t orientation = 0; |
| 559 | if (!mFlinger->mDebugDisableTransformHint) { |
Jamie Gennis | 8d91b42 | 2011-09-23 15:54:34 -0700 | [diff] [blame] | 560 | orientation = getPlaneOrientation(); |
Mathias Agopian | a458364 | 2011-08-23 18:03:18 -0700 | [diff] [blame] | 561 | if (orientation & Transform::ROT_INVALID) { |
| 562 | orientation = 0; |
| 563 | } |
| 564 | } |
| 565 | return orientation; |
| 566 | } |
| 567 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 568 | // --------------------------------------------------------------------------- |
| 569 | |
| 570 | |
| 571 | }; // namespace android |