Layer.cpp revision a0db308c3d62301ae41b2e2bcf295c4ee4c7b08e
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 17#define ATRACE_TAG ATRACE_TAG_GRAPHICS 18 19#include <stdlib.h> 20#include <stdint.h> 21#include <sys/types.h> 22#include <math.h> 23 24#include <cutils/compiler.h> 25#include <cutils/native_handle.h> 26#include <cutils/properties.h> 27 28#include <utils/Errors.h> 29#include <utils/Log.h> 30#include <utils/StopWatch.h> 31#include <utils/Trace.h> 32 33#include <ui/GraphicBuffer.h> 34#include <ui/PixelFormat.h> 35 36#include <gui/Surface.h> 37 38#include "clz.h" 39#include "DisplayHardware/DisplayHardware.h" 40#include "DisplayHardware/HWComposer.h" 41#include "GLExtensions.h" 42#include "Layer.h" 43#include "SurfaceFlinger.h" 44#include "SurfaceTextureLayer.h" 45 46#define DEBUG_RESIZE 0 47 48namespace android { 49 50// --------------------------------------------------------------------------- 51 52Layer::Layer(SurfaceFlinger* flinger, 53 DisplayID display, const sp<Client>& client) 54 : LayerBaseClient(flinger, display, client), 55 mTextureName(-1U), 56 mQueuedFrames(0), 57 mCurrentTransform(0), 58 mCurrentScalingMode(NATIVE_WINDOW_SCALING_MODE_FREEZE), 59 mCurrentOpacity(true), 60 mRefreshPending(false), 61 mFrameLatencyNeeded(false), 62 mFrameLatencyOffset(0), 63 mFormat(PIXEL_FORMAT_NONE), 64 mGLExtensions(GLExtensions::getInstance()), 65 mOpaqueLayer(true), 66 mNeedsDithering(false), 67 mSecure(false), 68 mProtectedByApp(false) 69{ 70 mCurrentCrop.makeInvalid(); 71 glGenTextures(1, &mTextureName); 72} 73 74void Layer::onLayerDisplayed() { 75 if (mFrameLatencyNeeded) { 76 const DisplayHardware& hw(graphicPlane(0).displayHardware()); 77 mFrameStats[mFrameLatencyOffset].timestamp = mSurfaceTexture->getTimestamp(); 78 mFrameStats[mFrameLatencyOffset].set = systemTime(); 79 mFrameStats[mFrameLatencyOffset].vsync = hw.getRefreshTimestamp(); 80 mFrameLatencyOffset = (mFrameLatencyOffset + 1) % 128; 81 mFrameLatencyNeeded = false; 82 } 83} 84 85void Layer::onFirstRef() 86{ 87 LayerBaseClient::onFirstRef(); 88 89 struct FrameQueuedListener : public SurfaceTexture::FrameAvailableListener { 90 FrameQueuedListener(Layer* layer) : mLayer(layer) { } 91 private: 92 wp<Layer> mLayer; 93 virtual void onFrameAvailable() { 94 sp<Layer> that(mLayer.promote()); 95 if (that != 0) { 96 that->onFrameQueued(); 97 } 98 } 99 }; 100 101 // Creates a custom BufferQueue for SurfaceTexture to use 102 sp<BufferQueue> bq = new SurfaceTextureLayer(); 103 mSurfaceTexture = new SurfaceTexture(mTextureName, true, 104 GL_TEXTURE_EXTERNAL_OES, false, bq); 105 106 mSurfaceTexture->setConsumerUsageBits(getEffectiveUsage(0)); 107 mSurfaceTexture->setFrameAvailableListener(new FrameQueuedListener(this)); 108 mSurfaceTexture->setSynchronousMode(true); 109 110#ifdef TARGET_DISABLE_TRIPLE_BUFFERING 111#warning "disabling triple buffering" 112 mSurfaceTexture->setBufferCountServer(2); 113#else 114 mSurfaceTexture->setBufferCountServer(3); 115#endif 116} 117 118Layer::~Layer() 119{ 120 mFlinger->postMessageAsync( 121 new SurfaceFlinger::MessageDestroyGLTexture(mTextureName) ); 122} 123 124void Layer::onFrameQueued() { 125 android_atomic_inc(&mQueuedFrames); 126 mFlinger->signalLayerUpdate(); 127} 128 129// called with SurfaceFlinger::mStateLock as soon as the layer is entered 130// in the purgatory list 131void Layer::onRemoved() 132{ 133 mSurfaceTexture->abandon(); 134} 135 136void Layer::setName(const String8& name) { 137 LayerBase::setName(name); 138 mSurfaceTexture->setName(name); 139} 140 141void Layer::validateVisibility(const Transform& globalTransform) { 142 LayerBase::validateVisibility(globalTransform); 143 144 // This optimization allows the SurfaceTexture to bake in 145 // the rotation so hardware overlays can be used 146 mSurfaceTexture->setTransformHint(getTransformHint()); 147} 148 149sp<ISurface> Layer::createSurface() 150{ 151 class BSurface : public BnSurface, public LayerCleaner { 152 wp<const Layer> mOwner; 153 virtual sp<ISurfaceTexture> getSurfaceTexture() const { 154 sp<ISurfaceTexture> res; 155 sp<const Layer> that( mOwner.promote() ); 156 if (that != NULL) { 157 res = that->mSurfaceTexture->getBufferQueue(); 158 } 159 return res; 160 } 161 public: 162 BSurface(const sp<SurfaceFlinger>& flinger, 163 const sp<Layer>& layer) 164 : LayerCleaner(flinger, layer), mOwner(layer) { } 165 }; 166 sp<ISurface> sur(new BSurface(mFlinger, this)); 167 return sur; 168} 169 170wp<IBinder> Layer::getSurfaceTextureBinder() const 171{ 172 return mSurfaceTexture->getBufferQueue()->asBinder(); 173} 174 175status_t Layer::setBuffers( uint32_t w, uint32_t h, 176 PixelFormat format, uint32_t flags) 177{ 178 // this surfaces pixel format 179 PixelFormatInfo info; 180 status_t err = getPixelFormatInfo(format, &info); 181 if (err) { 182 ALOGE("unsupported pixelformat %d", format); 183 return err; 184 } 185 186 // the display's pixel format 187 const DisplayHardware& hw(graphicPlane(0).displayHardware()); 188 uint32_t const maxSurfaceDims = min( 189 hw.getMaxTextureSize(), hw.getMaxViewportDims()); 190 191 // never allow a surface larger than what our underlying GL implementation 192 // can handle. 193 if ((uint32_t(w)>maxSurfaceDims) || (uint32_t(h)>maxSurfaceDims)) { 194 ALOGE("dimensions too large %u x %u", uint32_t(w), uint32_t(h)); 195 return BAD_VALUE; 196 } 197 198 PixelFormatInfo displayInfo; 199 getPixelFormatInfo(hw.getFormat(), &displayInfo); 200 const uint32_t hwFlags = hw.getFlags(); 201 202 mFormat = format; 203 204 mSecure = (flags & ISurfaceComposer::eSecure) ? true : false; 205 mProtectedByApp = (flags & ISurfaceComposer::eProtectedByApp) ? true : false; 206 mOpaqueLayer = (flags & ISurfaceComposer::eOpaque); 207 mCurrentOpacity = getOpacityForFormat(format); 208 209 mSurfaceTexture->setDefaultBufferSize(w, h); 210 mSurfaceTexture->setDefaultBufferFormat(format); 211 mSurfaceTexture->setConsumerUsageBits(getEffectiveUsage(0)); 212 213 // we use the red index 214 int displayRedSize = displayInfo.getSize(PixelFormatInfo::INDEX_RED); 215 int layerRedsize = info.getSize(PixelFormatInfo::INDEX_RED); 216 mNeedsDithering = layerRedsize > displayRedSize; 217 218 return NO_ERROR; 219} 220 221void Layer::setGeometry(hwc_layer_t* hwcl) 222{ 223 LayerBaseClient::setGeometry(hwcl); 224 225 hwcl->flags &= ~HWC_SKIP_LAYER; 226 227 // we can't do alpha-fade with the hwc HAL 228 const State& s(drawingState()); 229 if (s.alpha < 0xFF) { 230 hwcl->flags = HWC_SKIP_LAYER; 231 } 232 233 /* 234 * Transformations are applied in this order: 235 * 1) buffer orientation/flip/mirror 236 * 2) state transformation (window manager) 237 * 3) layer orientation (screen orientation) 238 * mTransform is already the composition of (2) and (3) 239 * (NOTE: the matrices are multiplied in reverse order) 240 */ 241 242 const Transform bufferOrientation(mCurrentTransform); 243 const Transform tr(mTransform * bufferOrientation); 244 245 // this gives us only the "orientation" component of the transform 246 const uint32_t finalTransform = tr.getOrientation(); 247 248 // we can only handle simple transformation 249 if (finalTransform & Transform::ROT_INVALID) { 250 hwcl->flags = HWC_SKIP_LAYER; 251 } else { 252 hwcl->transform = finalTransform; 253 } 254 255 if (isCropped()) { 256 hwcl->sourceCrop.left = mCurrentCrop.left; 257 hwcl->sourceCrop.top = mCurrentCrop.top; 258 hwcl->sourceCrop.right = mCurrentCrop.right; 259 hwcl->sourceCrop.bottom = mCurrentCrop.bottom; 260 } else { 261 const sp<GraphicBuffer>& buffer(mActiveBuffer); 262 hwcl->sourceCrop.left = 0; 263 hwcl->sourceCrop.top = 0; 264 if (buffer != NULL) { 265 hwcl->sourceCrop.right = buffer->width; 266 hwcl->sourceCrop.bottom = buffer->height; 267 } else { 268 hwcl->sourceCrop.right = mTransformedBounds.width(); 269 hwcl->sourceCrop.bottom = mTransformedBounds.height(); 270 } 271 } 272} 273 274void Layer::setPerFrameData(hwc_layer_t* hwcl) { 275 const sp<GraphicBuffer>& buffer(mActiveBuffer); 276 if (buffer == NULL) { 277 // this can happen if the client never drew into this layer yet, 278 // or if we ran out of memory. In that case, don't let 279 // HWC handle it. 280 hwcl->flags |= HWC_SKIP_LAYER; 281 hwcl->handle = NULL; 282 } else { 283 hwcl->handle = buffer->handle; 284 } 285} 286 287void Layer::onDraw(const Region& clip) const 288{ 289 ATRACE_CALL(); 290 291 if (CC_UNLIKELY(mActiveBuffer == 0)) { 292 // the texture has not been created yet, this Layer has 293 // in fact never been drawn into. This happens frequently with 294 // SurfaceView because the WindowManager can't know when the client 295 // has drawn the first time. 296 297 // If there is nothing under us, we paint the screen in black, otherwise 298 // we just skip this update. 299 300 // figure out if there is something below us 301 Region under; 302 const SurfaceFlinger::LayerVector& drawingLayers( 303 mFlinger->mDrawingState.layersSortedByZ); 304 const size_t count = drawingLayers.size(); 305 for (size_t i=0 ; i<count ; ++i) { 306 const sp<LayerBase>& layer(drawingLayers[i]); 307 if (layer.get() == static_cast<LayerBase const*>(this)) 308 break; 309 under.orSelf(layer->visibleRegionScreen); 310 } 311 // if not everything below us is covered, we plug the holes! 312 Region holes(clip.subtract(under)); 313 if (!holes.isEmpty()) { 314 clearWithOpenGL(holes, 0, 0, 0, 1); 315 } 316 return; 317 } 318 319 if (!isProtected()) { 320 glBindTexture(GL_TEXTURE_EXTERNAL_OES, mTextureName); 321 GLenum filter = GL_NEAREST; 322 if (getFiltering() || needsFiltering() || isFixedSize() || isCropped()) { 323 // TODO: we could be more subtle with isFixedSize() 324 filter = GL_LINEAR; 325 } 326 glTexParameterx(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, filter); 327 glTexParameterx(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, filter); 328 glMatrixMode(GL_TEXTURE); 329 glLoadMatrixf(mTextureMatrix); 330 glMatrixMode(GL_MODELVIEW); 331 glDisable(GL_TEXTURE_2D); 332 glEnable(GL_TEXTURE_EXTERNAL_OES); 333 } else { 334 glBindTexture(GL_TEXTURE_2D, mFlinger->getProtectedTexName()); 335 glMatrixMode(GL_TEXTURE); 336 glLoadIdentity(); 337 glMatrixMode(GL_MODELVIEW); 338 glDisable(GL_TEXTURE_EXTERNAL_OES); 339 glEnable(GL_TEXTURE_2D); 340 } 341 342 drawWithOpenGL(clip); 343 344 glDisable(GL_TEXTURE_EXTERNAL_OES); 345 glDisable(GL_TEXTURE_2D); 346} 347 348// As documented in libhardware header, formats in the range 349// 0x100 - 0x1FF are specific to the HAL implementation, and 350// are known to have no alpha channel 351// TODO: move definition for device-specific range into 352// hardware.h, instead of using hard-coded values here. 353#define HARDWARE_IS_DEVICE_FORMAT(f) ((f) >= 0x100 && (f) <= 0x1FF) 354 355bool Layer::getOpacityForFormat(uint32_t format) 356{ 357 if (HARDWARE_IS_DEVICE_FORMAT(format)) { 358 return true; 359 } 360 PixelFormatInfo info; 361 status_t err = getPixelFormatInfo(PixelFormat(format), &info); 362 // in case of error (unknown format), we assume no blending 363 return (err || info.h_alpha <= info.l_alpha); 364} 365 366 367bool Layer::isOpaque() const 368{ 369 // if we don't have a buffer yet, we're translucent regardless of the 370 // layer's opaque flag. 371 if (mActiveBuffer == 0) { 372 return false; 373 } 374 375 // if the layer has the opaque flag, then we're always opaque, 376 // otherwise we use the current buffer's format. 377 return mOpaqueLayer || mCurrentOpacity; 378} 379 380bool Layer::isProtected() const 381{ 382 const sp<GraphicBuffer>& activeBuffer(mActiveBuffer); 383 return (activeBuffer != 0) && 384 (activeBuffer->getUsage() & GRALLOC_USAGE_PROTECTED); 385} 386 387uint32_t Layer::doTransaction(uint32_t flags) 388{ 389 ATRACE_CALL(); 390 391 const Layer::State& front(drawingState()); 392 const Layer::State& temp(currentState()); 393 394 const bool sizeChanged = (front.requested_w != temp.requested_w) || 395 (front.requested_h != temp.requested_h); 396 397 if (sizeChanged) { 398 // the size changed, we need to ask our client to request a new buffer 399 ALOGD_IF(DEBUG_RESIZE, 400 "doTransaction: " 401 "resize (layer=%p), requested (%dx%d), drawing (%d,%d), " 402 "scalingMode=%d", 403 this, 404 int(temp.requested_w), int(temp.requested_h), 405 int(front.requested_w), int(front.requested_h), 406 mCurrentScalingMode); 407 408 if (!isFixedSize()) { 409 // this will make sure LayerBase::doTransaction doesn't update 410 // the drawing state's size 411 Layer::State& editDraw(mDrawingState); 412 editDraw.requested_w = temp.requested_w; 413 editDraw.requested_h = temp.requested_h; 414 } 415 416 // record the new size, form this point on, when the client request 417 // a buffer, it'll get the new size. 418 mSurfaceTexture->setDefaultBufferSize(temp.requested_w, 419 temp.requested_h); 420 } 421 422 return LayerBase::doTransaction(flags); 423} 424 425bool Layer::isFixedSize() const { 426 return mCurrentScalingMode != NATIVE_WINDOW_SCALING_MODE_FREEZE; 427} 428 429bool Layer::isCropped() const { 430 return !mCurrentCrop.isEmpty(); 431} 432 433// ---------------------------------------------------------------------------- 434// pageflip handling... 435// ---------------------------------------------------------------------------- 436 437bool Layer::onPreComposition() { 438 mRefreshPending = false; 439 return mQueuedFrames > 0; 440} 441 442void Layer::lockPageFlip(bool& recomputeVisibleRegions) 443{ 444 ATRACE_CALL(); 445 446 if (mQueuedFrames > 0) { 447 448 // if we've already called updateTexImage() without going through 449 // a composition step, we have to skip this layer at this point 450 // because we cannot call updateTeximage() without a corresponding 451 // compositionComplete() call. 452 // we'll trigger an update in onPreComposition(). 453 if (mRefreshPending) { 454 mPostedDirtyRegion.clear(); 455 return; 456 } 457 mRefreshPending = true; 458 459 // Capture the old state of the layer for comparisons later 460 const bool oldOpacity = isOpaque(); 461 sp<GraphicBuffer> oldActiveBuffer = mActiveBuffer; 462 463 // signal another event if we have more frames pending 464 if (android_atomic_dec(&mQueuedFrames) > 1) { 465 mFlinger->signalLayerUpdate(); 466 } 467 468 if (mSurfaceTexture->updateTexImage() < NO_ERROR) { 469 // something happened! 470 recomputeVisibleRegions = true; 471 return; 472 } 473 474 // update the active buffer 475 mActiveBuffer = mSurfaceTexture->getCurrentBuffer(); 476 mFrameLatencyNeeded = true; 477 478 if (oldActiveBuffer == NULL && mActiveBuffer != NULL) { 479 // the first time we receive a buffer, we need to trigger a 480 // geometry invalidation. 481 mFlinger->invalidateHwcGeometry(); 482 } 483 484 const Rect crop(mSurfaceTexture->getCurrentCrop()); 485 const uint32_t transform(mSurfaceTexture->getCurrentTransform()); 486 const uint32_t scalingMode(mSurfaceTexture->getCurrentScalingMode()); 487 if ((crop != mCurrentCrop) || 488 (transform != mCurrentTransform) || 489 (scalingMode != mCurrentScalingMode)) 490 { 491 mCurrentCrop = crop; 492 mCurrentTransform = transform; 493 mCurrentScalingMode = scalingMode; 494 mFlinger->invalidateHwcGeometry(); 495 } 496 497 GLfloat textureMatrix[16]; 498 mSurfaceTexture->getTransformMatrix(textureMatrix); 499 if (memcmp(textureMatrix, mTextureMatrix, sizeof(textureMatrix))) { 500 memcpy(mTextureMatrix, textureMatrix, sizeof(textureMatrix)); 501 mFlinger->invalidateHwcGeometry(); 502 } 503 504 uint32_t bufWidth = mActiveBuffer->getWidth(); 505 uint32_t bufHeight = mActiveBuffer->getHeight(); 506 if (oldActiveBuffer != NULL) { 507 if (bufWidth != uint32_t(oldActiveBuffer->width) || 508 bufHeight != uint32_t(oldActiveBuffer->height)) { 509 mFlinger->invalidateHwcGeometry(); 510 } 511 } 512 513 mCurrentOpacity = getOpacityForFormat(mActiveBuffer->format); 514 if (oldOpacity != isOpaque()) { 515 recomputeVisibleRegions = true; 516 } 517 518 glTexParameterx(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 519 glTexParameterx(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 520 521 // update the layer size if needed 522 const Layer::State& front(drawingState()); 523 524 // FIXME: mPostedDirtyRegion = dirty & bounds 525 mPostedDirtyRegion.set(front.w, front.h); 526 527 if ((front.w != front.requested_w) || 528 (front.h != front.requested_h)) 529 { 530 // check that we received a buffer of the right size 531 // (Take the buffer's orientation into account) 532 if (mCurrentTransform & Transform::ROT_90) { 533 swap(bufWidth, bufHeight); 534 } 535 536 if (isFixedSize() || 537 (bufWidth == front.requested_w && 538 bufHeight == front.requested_h)) 539 { 540 // Here we pretend the transaction happened by updating the 541 // current and drawing states. Drawing state is only accessed 542 // in this thread, no need to have it locked 543 Layer::State& editDraw(mDrawingState); 544 editDraw.w = editDraw.requested_w; 545 editDraw.h = editDraw.requested_h; 546 547 // We also need to update the current state so that we don't 548 // end-up doing too much work during the next transaction. 549 // NOTE: We actually don't need hold the transaction lock here 550 // because State::w and State::h are only accessed from 551 // this thread 552 Layer::State& editTemp(currentState()); 553 editTemp.w = editDraw.w; 554 editTemp.h = editDraw.h; 555 556 // recompute visible region 557 recomputeVisibleRegions = true; 558 } 559 560 ALOGD_IF(DEBUG_RESIZE, 561 "lockPageFlip : " 562 " (layer=%p), buffer (%ux%u, tr=%02x), " 563 "requested (%dx%d)", 564 this, 565 bufWidth, bufHeight, mCurrentTransform, 566 front.requested_w, front.requested_h); 567 } 568 } 569} 570 571void Layer::unlockPageFlip( 572 const Transform& planeTransform, Region& outDirtyRegion) 573{ 574 ATRACE_CALL(); 575 576 Region postedRegion(mPostedDirtyRegion); 577 if (!postedRegion.isEmpty()) { 578 mPostedDirtyRegion.clear(); 579 if (!visibleRegionScreen.isEmpty()) { 580 // The dirty region is given in the layer's coordinate space 581 // transform the dirty region by the surface's transformation 582 // and the global transformation. 583 const Layer::State& s(drawingState()); 584 const Transform tr(planeTransform * s.transform); 585 postedRegion = tr.transform(postedRegion); 586 587 // At this point, the dirty region is in screen space. 588 // Make sure it's constrained by the visible region (which 589 // is in screen space as well). 590 postedRegion.andSelf(visibleRegionScreen); 591 outDirtyRegion.orSelf(postedRegion); 592 } 593 } 594} 595 596void Layer::dump(String8& result, char* buffer, size_t SIZE) const 597{ 598 LayerBaseClient::dump(result, buffer, SIZE); 599 600 sp<const GraphicBuffer> buf0(mActiveBuffer); 601 uint32_t w0=0, h0=0, s0=0, f0=0; 602 if (buf0 != 0) { 603 w0 = buf0->getWidth(); 604 h0 = buf0->getHeight(); 605 s0 = buf0->getStride(); 606 f0 = buf0->format; 607 } 608 snprintf(buffer, SIZE, 609 " " 610 "format=%2d, activeBuffer=[%4ux%4u:%4u,%3X]," 611 " transform-hint=0x%02x, queued-frames=%d, mRefreshPending=%d\n", 612 mFormat, w0, h0, s0,f0, 613 getTransformHint(), mQueuedFrames, mRefreshPending); 614 615 result.append(buffer); 616 617 if (mSurfaceTexture != 0) { 618 mSurfaceTexture->dump(result, " ", buffer, SIZE); 619 } 620} 621 622void Layer::dumpStats(String8& result, char* buffer, size_t SIZE) const 623{ 624 LayerBaseClient::dumpStats(result, buffer, SIZE); 625 const size_t o = mFrameLatencyOffset; 626 const DisplayHardware& hw(graphicPlane(0).displayHardware()); 627 const nsecs_t period = hw.getRefreshPeriod(); 628 result.appendFormat("%lld\n", period); 629 for (size_t i=0 ; i<128 ; i++) { 630 const size_t index = (o+i) % 128; 631 const nsecs_t time_app = mFrameStats[index].timestamp; 632 const nsecs_t time_set = mFrameStats[index].set; 633 const nsecs_t time_vsync = mFrameStats[index].vsync; 634 result.appendFormat("%lld\t%lld\t%lld\n", 635 time_app, 636 time_vsync, 637 time_set); 638 } 639 result.append("\n"); 640} 641 642void Layer::clearStats() 643{ 644 LayerBaseClient::clearStats(); 645 memset(mFrameStats, 0, sizeof(mFrameStats)); 646} 647 648uint32_t Layer::getEffectiveUsage(uint32_t usage) const 649{ 650 // TODO: should we do something special if mSecure is set? 651 if (mProtectedByApp) { 652 // need a hardware-protected path to external video sink 653 usage |= GraphicBuffer::USAGE_PROTECTED; 654 } 655 usage |= GraphicBuffer::USAGE_HW_COMPOSER; 656 return usage; 657} 658 659uint32_t Layer::getTransformHint() const { 660 uint32_t orientation = 0; 661 if (!mFlinger->mDebugDisableTransformHint) { 662 orientation = getPlaneOrientation(); 663 if (orientation & Transform::ROT_INVALID) { 664 orientation = 0; 665 } 666 } 667 return orientation; 668} 669 670// --------------------------------------------------------------------------- 671 672 673}; // namespace android 674