Loading libs/renderengine/gl/GLESRenderEngine.cpp +34 −34 Original line number Original line Diff line number Diff line Loading @@ -960,7 +960,7 @@ EGLImageKHR GLESRenderEngine::createFramebufferImageIfNeeded(ANativeWindowBuffer } } status_t GLESRenderEngine::drawLayers(const DisplaySettings& display, status_t GLESRenderEngine::drawLayers(const DisplaySettings& display, const std::vector<LayerSettings>& layers, const std::vector<const LayerSettings*>& layers, ANativeWindowBuffer* const buffer, ANativeWindowBuffer* const buffer, const bool useFramebufferCache, base::unique_fd&& bufferFence, const bool useFramebufferCache, base::unique_fd&& bufferFence, base::unique_fd* drawFence) { base::unique_fd* drawFence) { Loading @@ -985,9 +985,9 @@ status_t GLESRenderEngine::drawLayers(const DisplaySettings& display, // Blurs in multiple layers are not supported, given the cost of the shader. // Blurs in multiple layers are not supported, given the cost of the shader. const LayerSettings* blurLayer = nullptr; const LayerSettings* blurLayer = nullptr; if (CC_LIKELY(mBlurFilter != nullptr)) { if (CC_LIKELY(mBlurFilter != nullptr)) { for (auto const& layer : layers) { for (auto const layer : layers) { if (layer.backgroundBlurRadius > 0) { if (layer->backgroundBlurRadius > 0) { blurLayer = &layer; blurLayer = layer; } } } } } } Loading Loading @@ -1035,9 +1035,9 @@ status_t GLESRenderEngine::drawLayers(const DisplaySettings& display, .setTexCoords(2 /* size */) .setTexCoords(2 /* size */) .setCropCoords(2 /* size */) .setCropCoords(2 /* size */) .build(); .build(); for (auto const& layer : layers) { for (auto const layer : layers) { if (blurLayer == &layer) { if (blurLayer == layer) { auto status = mBlurFilter->prepare(layer.backgroundBlurRadius); auto status = mBlurFilter->prepare(layer->backgroundBlurRadius); if (status != NO_ERROR) { if (status != NO_ERROR) { ALOGE("Failed to render blur effect! Aborting GPU composition for buffer (%p).", ALOGE("Failed to render blur effect! Aborting GPU composition for buffer (%p).", buffer->handle); buffer->handle); Loading Loading @@ -1065,40 +1065,40 @@ status_t GLESRenderEngine::drawLayers(const DisplaySettings& display, } } } } mState.maxMasteringLuminance = layer.source.buffer.maxMasteringLuminance; mState.maxMasteringLuminance = layer->source.buffer.maxMasteringLuminance; mState.maxContentLuminance = layer.source.buffer.maxContentLuminance; mState.maxContentLuminance = layer->source.buffer.maxContentLuminance; mState.projectionMatrix = projectionMatrix * layer.geometry.positionTransform; mState.projectionMatrix = projectionMatrix * layer->geometry.positionTransform; const FloatRect bounds = layer.geometry.boundaries; const FloatRect bounds = layer->geometry.boundaries; Mesh::VertexArray<vec2> position(mesh.getPositionArray<vec2>()); Mesh::VertexArray<vec2> position(mesh.getPositionArray<vec2>()); position[0] = vec2(bounds.left, bounds.top); position[0] = vec2(bounds.left, bounds.top); position[1] = vec2(bounds.left, bounds.bottom); position[1] = vec2(bounds.left, bounds.bottom); position[2] = vec2(bounds.right, bounds.bottom); position[2] = vec2(bounds.right, bounds.bottom); position[3] = vec2(bounds.right, bounds.top); position[3] = vec2(bounds.right, bounds.top); setupLayerCropping(layer, mesh); setupLayerCropping(*layer, mesh); setColorTransform(display.colorTransform * layer.colorTransform); setColorTransform(display.colorTransform * layer->colorTransform); bool usePremultipliedAlpha = true; bool usePremultipliedAlpha = true; bool disableTexture = true; bool disableTexture = true; bool isOpaque = false; bool isOpaque = false; if (layer.source.buffer.buffer != nullptr) { if (layer->source.buffer.buffer != nullptr) { disableTexture = false; disableTexture = false; isOpaque = layer.source.buffer.isOpaque; isOpaque = layer->source.buffer.isOpaque; sp<GraphicBuffer> gBuf = layer.source.buffer.buffer; sp<GraphicBuffer> gBuf = layer->source.buffer.buffer; bindExternalTextureBuffer(layer.source.buffer.textureName, gBuf, bindExternalTextureBuffer(layer->source.buffer.textureName, gBuf, layer.source.buffer.fence); layer->source.buffer.fence); usePremultipliedAlpha = layer.source.buffer.usePremultipliedAlpha; usePremultipliedAlpha = layer->source.buffer.usePremultipliedAlpha; Texture texture(Texture::TEXTURE_EXTERNAL, layer.source.buffer.textureName); Texture texture(Texture::TEXTURE_EXTERNAL, layer->source.buffer.textureName); mat4 texMatrix = layer.source.buffer.textureTransform; mat4 texMatrix = layer->source.buffer.textureTransform; texture.setMatrix(texMatrix.asArray()); texture.setMatrix(texMatrix.asArray()); texture.setFiltering(layer.source.buffer.useTextureFiltering); texture.setFiltering(layer->source.buffer.useTextureFiltering); texture.setDimensions(gBuf->getWidth(), gBuf->getHeight()); texture.setDimensions(gBuf->getWidth(), gBuf->getHeight()); setSourceY410BT2020(layer.source.buffer.isY410BT2020); setSourceY410BT2020(layer->source.buffer.isY410BT2020); renderengine::Mesh::VertexArray<vec2> texCoords(mesh.getTexCoordArray<vec2>()); renderengine::Mesh::VertexArray<vec2> texCoords(mesh.getTexCoordArray<vec2>()); texCoords[0] = vec2(0.0, 0.0); texCoords[0] = vec2(0.0, 0.0); Loading @@ -1108,32 +1108,32 @@ status_t GLESRenderEngine::drawLayers(const DisplaySettings& display, setupLayerTexturing(texture); setupLayerTexturing(texture); } } const half3 solidColor = layer.source.solidColor; const half3 solidColor = layer->source.solidColor; const half4 color = half4(solidColor.r, solidColor.g, solidColor.b, layer.alpha); const half4 color = half4(solidColor.r, solidColor.g, solidColor.b, layer->alpha); // Buffer sources will have a black solid color ignored in the shader, // Buffer sources will have a black solid color ignored in the shader, // so in that scenario the solid color passed here is arbitrary. // so in that scenario the solid color passed here is arbitrary. setupLayerBlending(usePremultipliedAlpha, isOpaque, disableTexture, color, setupLayerBlending(usePremultipliedAlpha, isOpaque, disableTexture, color, layer.geometry.roundedCornersRadius); layer->geometry.roundedCornersRadius); if (layer.disableBlending) { if (layer->disableBlending) { glDisable(GL_BLEND); glDisable(GL_BLEND); } } setSourceDataSpace(layer.sourceDataspace); setSourceDataSpace(layer->sourceDataspace); if (layer.shadow.length > 0.0f) { if (layer->shadow.length > 0.0f) { handleShadow(layer.geometry.boundaries, layer.geometry.roundedCornersRadius, handleShadow(layer->geometry.boundaries, layer->geometry.roundedCornersRadius, layer.shadow); layer->shadow); } } // We only want to do a special handling for rounded corners when having rounded corners // We only want to do a special handling for rounded corners when having rounded corners // is the only reason it needs to turn on blending, otherwise, we handle it like the // is the only reason it needs to turn on blending, otherwise, we handle it like the // usual way since it needs to turn on blending anyway. // usual way since it needs to turn on blending anyway. else if (layer.geometry.roundedCornersRadius > 0.0 && color.a >= 1.0f && isOpaque) { else if (layer->geometry.roundedCornersRadius > 0.0 && color.a >= 1.0f && isOpaque) { handleRoundedCorners(display, layer, mesh); handleRoundedCorners(display, *layer, mesh); } else { } else { drawMesh(mesh); drawMesh(mesh); } } // Cleanup if there's a buffer source // Cleanup if there's a buffer source if (layer.source.buffer.buffer != nullptr) { if (layer->source.buffer.buffer != nullptr) { disableBlending(); disableBlending(); setSourceY410BT2020(false); setSourceY410BT2020(false); disableTexturing(); disableTexturing(); Loading libs/renderengine/gl/GLESRenderEngine.h +2 −1 Original line number Original line Diff line number Diff line Loading @@ -71,7 +71,8 @@ public: bool isProtected() const override { return mInProtectedContext; } bool isProtected() const override { return mInProtectedContext; } bool supportsProtectedContent() const override; bool supportsProtectedContent() const override; bool useProtectedContext(bool useProtectedContext) override; bool useProtectedContext(bool useProtectedContext) override; status_t drawLayers(const DisplaySettings& display, const std::vector<LayerSettings>& layers, status_t drawLayers(const DisplaySettings& display, const std::vector<const LayerSettings*>& layers, ANativeWindowBuffer* buffer, const bool useFramebufferCache, ANativeWindowBuffer* buffer, const bool useFramebufferCache, base::unique_fd&& bufferFence, base::unique_fd* drawFence) override; base::unique_fd&& bufferFence, base::unique_fd* drawFence) override; Loading libs/renderengine/include/renderengine/LayerSettings.h +3 −1 Original line number Original line Diff line number Diff line Loading @@ -52,7 +52,7 @@ struct Buffer { // Transform matrix to apply to texture coordinates. // Transform matrix to apply to texture coordinates. mat4 textureTransform = mat4(); mat4 textureTransform = mat4(); // Wheteher to use pre-multiplied alpha // Whether to use pre-multiplied alpha. bool usePremultipliedAlpha = true; bool usePremultipliedAlpha = true; // Override flag that alpha for each pixel in the buffer *must* be 1.0. // Override flag that alpha for each pixel in the buffer *must* be 1.0. Loading Loading @@ -153,6 +153,8 @@ struct LayerSettings { int backgroundBlurRadius = 0; int backgroundBlurRadius = 0; }; }; // Keep in sync with custom comparison function in // compositionengine/impl/ClientCompositionRequestCache.cpp static inline bool operator==(const Buffer& lhs, const Buffer& rhs) { static inline bool operator==(const Buffer& lhs, const Buffer& rhs) { return lhs.buffer == rhs.buffer && lhs.fence == rhs.fence && return lhs.buffer == rhs.buffer && lhs.fence == rhs.fence && lhs.textureName == rhs.textureName && lhs.textureName == rhs.textureName && Loading libs/renderengine/include/renderengine/RenderEngine.h +1 −1 Original line number Original line Diff line number Diff line Loading @@ -154,7 +154,7 @@ public: // @return An error code indicating whether drawing was successful. For // @return An error code indicating whether drawing was successful. For // now, this always returns NO_ERROR. // now, this always returns NO_ERROR. virtual status_t drawLayers(const DisplaySettings& display, virtual status_t drawLayers(const DisplaySettings& display, const std::vector<LayerSettings>& layers, const std::vector<const LayerSettings*>& layers, ANativeWindowBuffer* buffer, const bool useFramebufferCache, ANativeWindowBuffer* buffer, const bool useFramebufferCache, base::unique_fd&& bufferFence, base::unique_fd* drawFence) = 0; base::unique_fd&& bufferFence, base::unique_fd* drawFence) = 0; Loading libs/renderengine/include/renderengine/mock/RenderEngine.h +1 −1 Original line number Original line Diff line number Diff line Loading @@ -56,7 +56,7 @@ public: MOCK_CONST_METHOD0(supportsProtectedContent, bool()); MOCK_CONST_METHOD0(supportsProtectedContent, bool()); MOCK_METHOD1(useProtectedContext, bool(bool)); MOCK_METHOD1(useProtectedContext, bool(bool)); MOCK_METHOD6(drawLayers, MOCK_METHOD6(drawLayers, status_t(const DisplaySettings&, const std::vector<LayerSettings>&, status_t(const DisplaySettings&, const std::vector<const LayerSettings*>&, ANativeWindowBuffer*, const bool, base::unique_fd&&, base::unique_fd*)); ANativeWindowBuffer*, const bool, base::unique_fd&&, base::unique_fd*)); }; }; Loading Loading
libs/renderengine/gl/GLESRenderEngine.cpp +34 −34 Original line number Original line Diff line number Diff line Loading @@ -960,7 +960,7 @@ EGLImageKHR GLESRenderEngine::createFramebufferImageIfNeeded(ANativeWindowBuffer } } status_t GLESRenderEngine::drawLayers(const DisplaySettings& display, status_t GLESRenderEngine::drawLayers(const DisplaySettings& display, const std::vector<LayerSettings>& layers, const std::vector<const LayerSettings*>& layers, ANativeWindowBuffer* const buffer, ANativeWindowBuffer* const buffer, const bool useFramebufferCache, base::unique_fd&& bufferFence, const bool useFramebufferCache, base::unique_fd&& bufferFence, base::unique_fd* drawFence) { base::unique_fd* drawFence) { Loading @@ -985,9 +985,9 @@ status_t GLESRenderEngine::drawLayers(const DisplaySettings& display, // Blurs in multiple layers are not supported, given the cost of the shader. // Blurs in multiple layers are not supported, given the cost of the shader. const LayerSettings* blurLayer = nullptr; const LayerSettings* blurLayer = nullptr; if (CC_LIKELY(mBlurFilter != nullptr)) { if (CC_LIKELY(mBlurFilter != nullptr)) { for (auto const& layer : layers) { for (auto const layer : layers) { if (layer.backgroundBlurRadius > 0) { if (layer->backgroundBlurRadius > 0) { blurLayer = &layer; blurLayer = layer; } } } } } } Loading Loading @@ -1035,9 +1035,9 @@ status_t GLESRenderEngine::drawLayers(const DisplaySettings& display, .setTexCoords(2 /* size */) .setTexCoords(2 /* size */) .setCropCoords(2 /* size */) .setCropCoords(2 /* size */) .build(); .build(); for (auto const& layer : layers) { for (auto const layer : layers) { if (blurLayer == &layer) { if (blurLayer == layer) { auto status = mBlurFilter->prepare(layer.backgroundBlurRadius); auto status = mBlurFilter->prepare(layer->backgroundBlurRadius); if (status != NO_ERROR) { if (status != NO_ERROR) { ALOGE("Failed to render blur effect! Aborting GPU composition for buffer (%p).", ALOGE("Failed to render blur effect! Aborting GPU composition for buffer (%p).", buffer->handle); buffer->handle); Loading Loading @@ -1065,40 +1065,40 @@ status_t GLESRenderEngine::drawLayers(const DisplaySettings& display, } } } } mState.maxMasteringLuminance = layer.source.buffer.maxMasteringLuminance; mState.maxMasteringLuminance = layer->source.buffer.maxMasteringLuminance; mState.maxContentLuminance = layer.source.buffer.maxContentLuminance; mState.maxContentLuminance = layer->source.buffer.maxContentLuminance; mState.projectionMatrix = projectionMatrix * layer.geometry.positionTransform; mState.projectionMatrix = projectionMatrix * layer->geometry.positionTransform; const FloatRect bounds = layer.geometry.boundaries; const FloatRect bounds = layer->geometry.boundaries; Mesh::VertexArray<vec2> position(mesh.getPositionArray<vec2>()); Mesh::VertexArray<vec2> position(mesh.getPositionArray<vec2>()); position[0] = vec2(bounds.left, bounds.top); position[0] = vec2(bounds.left, bounds.top); position[1] = vec2(bounds.left, bounds.bottom); position[1] = vec2(bounds.left, bounds.bottom); position[2] = vec2(bounds.right, bounds.bottom); position[2] = vec2(bounds.right, bounds.bottom); position[3] = vec2(bounds.right, bounds.top); position[3] = vec2(bounds.right, bounds.top); setupLayerCropping(layer, mesh); setupLayerCropping(*layer, mesh); setColorTransform(display.colorTransform * layer.colorTransform); setColorTransform(display.colorTransform * layer->colorTransform); bool usePremultipliedAlpha = true; bool usePremultipliedAlpha = true; bool disableTexture = true; bool disableTexture = true; bool isOpaque = false; bool isOpaque = false; if (layer.source.buffer.buffer != nullptr) { if (layer->source.buffer.buffer != nullptr) { disableTexture = false; disableTexture = false; isOpaque = layer.source.buffer.isOpaque; isOpaque = layer->source.buffer.isOpaque; sp<GraphicBuffer> gBuf = layer.source.buffer.buffer; sp<GraphicBuffer> gBuf = layer->source.buffer.buffer; bindExternalTextureBuffer(layer.source.buffer.textureName, gBuf, bindExternalTextureBuffer(layer->source.buffer.textureName, gBuf, layer.source.buffer.fence); layer->source.buffer.fence); usePremultipliedAlpha = layer.source.buffer.usePremultipliedAlpha; usePremultipliedAlpha = layer->source.buffer.usePremultipliedAlpha; Texture texture(Texture::TEXTURE_EXTERNAL, layer.source.buffer.textureName); Texture texture(Texture::TEXTURE_EXTERNAL, layer->source.buffer.textureName); mat4 texMatrix = layer.source.buffer.textureTransform; mat4 texMatrix = layer->source.buffer.textureTransform; texture.setMatrix(texMatrix.asArray()); texture.setMatrix(texMatrix.asArray()); texture.setFiltering(layer.source.buffer.useTextureFiltering); texture.setFiltering(layer->source.buffer.useTextureFiltering); texture.setDimensions(gBuf->getWidth(), gBuf->getHeight()); texture.setDimensions(gBuf->getWidth(), gBuf->getHeight()); setSourceY410BT2020(layer.source.buffer.isY410BT2020); setSourceY410BT2020(layer->source.buffer.isY410BT2020); renderengine::Mesh::VertexArray<vec2> texCoords(mesh.getTexCoordArray<vec2>()); renderengine::Mesh::VertexArray<vec2> texCoords(mesh.getTexCoordArray<vec2>()); texCoords[0] = vec2(0.0, 0.0); texCoords[0] = vec2(0.0, 0.0); Loading @@ -1108,32 +1108,32 @@ status_t GLESRenderEngine::drawLayers(const DisplaySettings& display, setupLayerTexturing(texture); setupLayerTexturing(texture); } } const half3 solidColor = layer.source.solidColor; const half3 solidColor = layer->source.solidColor; const half4 color = half4(solidColor.r, solidColor.g, solidColor.b, layer.alpha); const half4 color = half4(solidColor.r, solidColor.g, solidColor.b, layer->alpha); // Buffer sources will have a black solid color ignored in the shader, // Buffer sources will have a black solid color ignored in the shader, // so in that scenario the solid color passed here is arbitrary. // so in that scenario the solid color passed here is arbitrary. setupLayerBlending(usePremultipliedAlpha, isOpaque, disableTexture, color, setupLayerBlending(usePremultipliedAlpha, isOpaque, disableTexture, color, layer.geometry.roundedCornersRadius); layer->geometry.roundedCornersRadius); if (layer.disableBlending) { if (layer->disableBlending) { glDisable(GL_BLEND); glDisable(GL_BLEND); } } setSourceDataSpace(layer.sourceDataspace); setSourceDataSpace(layer->sourceDataspace); if (layer.shadow.length > 0.0f) { if (layer->shadow.length > 0.0f) { handleShadow(layer.geometry.boundaries, layer.geometry.roundedCornersRadius, handleShadow(layer->geometry.boundaries, layer->geometry.roundedCornersRadius, layer.shadow); layer->shadow); } } // We only want to do a special handling for rounded corners when having rounded corners // We only want to do a special handling for rounded corners when having rounded corners // is the only reason it needs to turn on blending, otherwise, we handle it like the // is the only reason it needs to turn on blending, otherwise, we handle it like the // usual way since it needs to turn on blending anyway. // usual way since it needs to turn on blending anyway. else if (layer.geometry.roundedCornersRadius > 0.0 && color.a >= 1.0f && isOpaque) { else if (layer->geometry.roundedCornersRadius > 0.0 && color.a >= 1.0f && isOpaque) { handleRoundedCorners(display, layer, mesh); handleRoundedCorners(display, *layer, mesh); } else { } else { drawMesh(mesh); drawMesh(mesh); } } // Cleanup if there's a buffer source // Cleanup if there's a buffer source if (layer.source.buffer.buffer != nullptr) { if (layer->source.buffer.buffer != nullptr) { disableBlending(); disableBlending(); setSourceY410BT2020(false); setSourceY410BT2020(false); disableTexturing(); disableTexturing(); Loading
libs/renderengine/gl/GLESRenderEngine.h +2 −1 Original line number Original line Diff line number Diff line Loading @@ -71,7 +71,8 @@ public: bool isProtected() const override { return mInProtectedContext; } bool isProtected() const override { return mInProtectedContext; } bool supportsProtectedContent() const override; bool supportsProtectedContent() const override; bool useProtectedContext(bool useProtectedContext) override; bool useProtectedContext(bool useProtectedContext) override; status_t drawLayers(const DisplaySettings& display, const std::vector<LayerSettings>& layers, status_t drawLayers(const DisplaySettings& display, const std::vector<const LayerSettings*>& layers, ANativeWindowBuffer* buffer, const bool useFramebufferCache, ANativeWindowBuffer* buffer, const bool useFramebufferCache, base::unique_fd&& bufferFence, base::unique_fd* drawFence) override; base::unique_fd&& bufferFence, base::unique_fd* drawFence) override; Loading
libs/renderengine/include/renderengine/LayerSettings.h +3 −1 Original line number Original line Diff line number Diff line Loading @@ -52,7 +52,7 @@ struct Buffer { // Transform matrix to apply to texture coordinates. // Transform matrix to apply to texture coordinates. mat4 textureTransform = mat4(); mat4 textureTransform = mat4(); // Wheteher to use pre-multiplied alpha // Whether to use pre-multiplied alpha. bool usePremultipliedAlpha = true; bool usePremultipliedAlpha = true; // Override flag that alpha for each pixel in the buffer *must* be 1.0. // Override flag that alpha for each pixel in the buffer *must* be 1.0. Loading Loading @@ -153,6 +153,8 @@ struct LayerSettings { int backgroundBlurRadius = 0; int backgroundBlurRadius = 0; }; }; // Keep in sync with custom comparison function in // compositionengine/impl/ClientCompositionRequestCache.cpp static inline bool operator==(const Buffer& lhs, const Buffer& rhs) { static inline bool operator==(const Buffer& lhs, const Buffer& rhs) { return lhs.buffer == rhs.buffer && lhs.fence == rhs.fence && return lhs.buffer == rhs.buffer && lhs.fence == rhs.fence && lhs.textureName == rhs.textureName && lhs.textureName == rhs.textureName && Loading
libs/renderengine/include/renderengine/RenderEngine.h +1 −1 Original line number Original line Diff line number Diff line Loading @@ -154,7 +154,7 @@ public: // @return An error code indicating whether drawing was successful. For // @return An error code indicating whether drawing was successful. For // now, this always returns NO_ERROR. // now, this always returns NO_ERROR. virtual status_t drawLayers(const DisplaySettings& display, virtual status_t drawLayers(const DisplaySettings& display, const std::vector<LayerSettings>& layers, const std::vector<const LayerSettings*>& layers, ANativeWindowBuffer* buffer, const bool useFramebufferCache, ANativeWindowBuffer* buffer, const bool useFramebufferCache, base::unique_fd&& bufferFence, base::unique_fd* drawFence) = 0; base::unique_fd&& bufferFence, base::unique_fd* drawFence) = 0; Loading
libs/renderengine/include/renderengine/mock/RenderEngine.h +1 −1 Original line number Original line Diff line number Diff line Loading @@ -56,7 +56,7 @@ public: MOCK_CONST_METHOD0(supportsProtectedContent, bool()); MOCK_CONST_METHOD0(supportsProtectedContent, bool()); MOCK_METHOD1(useProtectedContext, bool(bool)); MOCK_METHOD1(useProtectedContext, bool(bool)); MOCK_METHOD6(drawLayers, MOCK_METHOD6(drawLayers, status_t(const DisplaySettings&, const std::vector<LayerSettings>&, status_t(const DisplaySettings&, const std::vector<const LayerSettings*>&, ANativeWindowBuffer*, const bool, base::unique_fd&&, base::unique_fd*)); ANativeWindowBuffer*, const bool, base::unique_fd&&, base::unique_fd*)); }; }; Loading