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