void Layer::onDraw(const Region& clip) const { if (CC_UNLIKELY(mActiveBuffer == 0)) { // the texture has not been created yet, this Layer has // in fact never been drawn into. This happens frequently with // SurfaceView because the WindowManager can't know when the client // has drawn the first time. // If there is nothing under us, we paint the screen in black, otherwise // we just skip this update. // figure out if there is something below us Region under; const SurfaceFlinger::LayerVector& drawingLayers( mFlinger->mDrawingState.layersSortedByZ); const size_t count = drawingLayers.size(); for (size_t i=0 ; i<count ; ++i) { const sp<LayerBase>& layer(drawingLayers[i]); if (layer.get() == static_cast<LayerBase const*>(this)) break; under.orSelf(layer->visibleRegionScreen); } // if not everything below us is covered, we plug the holes! Region holes(clip.subtract(under)); if (!holes.isEmpty()) { clearWithOpenGL(holes, 0, 0, 0, 1); } return; } if (!isProtected()) { glBindTexture(GL_TEXTURE_EXTERNAL_OES, mTextureName); GLenum filter = GL_NEAREST; if (getFiltering() || needsFiltering() || isFixedSize() || isCropped()) { // TODO: we could be more subtle with isFixedSize() filter = GL_LINEAR; } glTexParameterx(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, filter); glTexParameterx(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, filter); glMatrixMode(GL_TEXTURE); glLoadMatrixf(mTextureMatrix); glMatrixMode(GL_MODELVIEW); glDisable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_EXTERNAL_OES); } else { glBindTexture(GL_TEXTURE_2D, mFlinger->getProtectedTexName()); glMatrixMode(GL_TEXTURE); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); glDisable(GL_TEXTURE_EXTERNAL_OES); glEnable(GL_TEXTURE_2D); } drawWithOpenGL(clip); glDisable(GL_TEXTURE_EXTERNAL_OES); glDisable(GL_TEXTURE_2D); }
void Layer::setGeometry(hwc_layer_t* hwcl) { LayerBaseClient::setGeometry(hwcl); hwcl->flags &= ~HWC_SKIP_LAYER; const DisplayHardware& hw(graphicPlane(0).displayHardware()); // we can't do alpha-fade with the hwc HAL. C2D composition // can handle fade cases const State& s(drawingState()); if ((s.alpha < 0xFF) && !(DisplayHardware::C2D_COMPOSITION & hw.getFlags())) { hwcl->flags = HWC_SKIP_LAYER; } hwcl->alpha = s.alpha; /* * Transformations are applied in this order: * 1) buffer orientation/flip/mirror * 2) state transformation (window manager) * 3) layer orientation (screen orientation) * mTransform is already the composition of (2) and (3) * (NOTE: the matrices are multiplied in reverse order) */ const Transform bufferOrientation(mCurrentTransform); const Transform tr(mTransform * bufferOrientation); // this gives us only the "orientation" component of the transform const uint32_t finalTransform = tr.getOrientation(); // we can only handle simple transformation if (finalTransform & Transform::ROT_INVALID) { hwcl->flags = HWC_SKIP_LAYER; } else { hwcl->transform = finalTransform; } if (isCropped()) { hwcl->sourceCrop.left = mCurrentCrop.left; hwcl->sourceCrop.top = mCurrentCrop.top; hwcl->sourceCrop.right = mCurrentCrop.right; hwcl->sourceCrop.bottom = mCurrentCrop.bottom; } else { const sp<GraphicBuffer>& buffer(mActiveBuffer); hwcl->sourceCrop.left = 0; hwcl->sourceCrop.top = 0; if (buffer != NULL) { hwcl->sourceCrop.right = buffer->width; hwcl->sourceCrop.bottom = buffer->height; } else { hwcl->sourceCrop.right = mTransformedBounds.width(); hwcl->sourceCrop.bottom = mTransformedBounds.height(); } } }
void Layer::setGeometry(hwc_layer_t* hwcl) { LayerBaseClient::setGeometry(hwcl); hwcl->flags &= ~HWC_SKIP_LAYER; const DisplayHardware& hw(graphicPlane(0).displayHardware()); // we can't do alpha-fade with the hwc HAL, // unless we are using C2D const State& s(drawingState()); if (s.alpha < 0xFF) { if ((QCCompositionType::getInstance().getCompositionType() & COMPOSITION_TYPE_C2D) && (!isOpaque())) { hwcl->blending = mPremultipliedAlpha ? HWC_BLENDING_PREMULT : HWC_BLENDING_COVERAGE; } else { hwcl->flags = HWC_SKIP_LAYER; } } //hwcl->alpha = s.alpha; /* * Transformations are applied in this order: * 1) buffer orientation/flip/mirror * 2) state transformation (window manager) * 3) layer orientation (screen orientation) * mTransform is already the composition of (2) and (3) * (NOTE: the matrices are multiplied in reverse order) */ const Transform bufferOrientation(mCurrentTransform); const Transform tr(mTransform * bufferOrientation); // this gives us only the "orientation" component of the transform const uint32_t finalTransform = tr.getOrientation(); // we can only handle simple transformation if (finalTransform & Transform::ROT_INVALID) { hwcl->flags = HWC_SKIP_LAYER; } else { hwcl->transform = finalTransform; //mBufferTransform will have the srcTransform //include src and final transform in the hwcl->transform hwcl->transform = (( bufferOrientation.getOrientation() << SHIFT_SRC_TRANSFORM) | hwcl->transform); } if (isCropped()) { hwcl->sourceCrop.left = mCurrentCrop.left; hwcl->sourceCrop.top = mCurrentCrop.top; hwcl->sourceCrop.right = mCurrentCrop.right; hwcl->sourceCrop.bottom = mCurrentCrop.bottom; } else { const sp<GraphicBuffer>& buffer(mActiveBuffer); hwcl->sourceCrop.left = 0; hwcl->sourceCrop.top = 0; if (buffer != NULL) { hwcl->sourceCrop.right = buffer->width; hwcl->sourceCrop.bottom = buffer->height; } else { hwcl->sourceCrop.right = mTransformedBounds.width(); hwcl->sourceCrop.bottom = mTransformedBounds.height(); } } }