Loading services/surfaceflinger/Layer.cpp +3 −2 Original line number Diff line number Diff line Loading @@ -104,6 +104,7 @@ Layer::Layer(const LayerCreationArgs& args) mCurrentState.api = -1; mCurrentState.hasColorTransform = false; mCurrentState.colorSpaceAgnostic = false; mCurrentState.metadata = args.metadata; // drawing state & current state are identical mDrawingState = mCurrentState; Loading Loading @@ -1266,8 +1267,8 @@ bool Layer::setBackgroundColor(const half3& color, float alpha, ui::Dataspace da // create background color layer if one does not yet exist uint32_t flags = ISurfaceComposerClient::eFXSurfaceColor; const String8& name = mName + "BackgroundColorLayer"; mCurrentState.bgColorLayer = new ColorLayer(LayerCreationArgs(mFlinger.get(), nullptr, name, 0, 0, flags)); mCurrentState.bgColorLayer = new ColorLayer( LayerCreationArgs(mFlinger.get(), nullptr, name, 0, 0, flags, LayerMetadata())); // add to child list addChild(mCurrentState.bgColorLayer); Loading services/surfaceflinger/Layer.h +4 −2 Original line number Diff line number Diff line Loading @@ -80,8 +80,9 @@ class SurfaceInterceptor; struct LayerCreationArgs { LayerCreationArgs(SurfaceFlinger* flinger, const sp<Client>& client, const String8& name, uint32_t w, uint32_t h, uint32_t flags) : flinger(flinger), client(client), name(name), w(w), h(h), flags(flags) {} uint32_t w, uint32_t h, uint32_t flags, LayerMetadata metadata) : flinger(flinger), client(client), name(name), w(w), h(h), flags(flags), metadata(std::move(metadata)) {} SurfaceFlinger* flinger; const sp<Client>& client; Loading @@ -89,6 +90,7 @@ struct LayerCreationArgs { uint32_t w; uint32_t h; uint32_t flags; LayerMetadata metadata; }; class Layer : public virtual compositionengine::LayerFE { Loading services/surfaceflinger/SurfaceFlinger.cpp +43 −37 Original line number Diff line number Diff line Loading @@ -4004,14 +4004,27 @@ status_t SurfaceFlinger::createLayer(const String8& name, const sp<Client>& clie String8 uniqueName = getUniqueLayerName(name); bool primaryDisplayOnly = false; // window type is WINDOW_TYPE_DONT_SCREENSHOT from SurfaceControl.java // TODO b/64227542 if (metadata.has(METADATA_WINDOW_TYPE)) { int32_t windowType = metadata.getInt32(METADATA_WINDOW_TYPE, 0); if (windowType == 441731) { metadata.setInt32(METADATA_WINDOW_TYPE, 2024); // TYPE_NAVIGATION_BAR_PANEL primaryDisplayOnly = true; } } switch (flags & ISurfaceComposerClient::eFXSurfaceMask) { case ISurfaceComposerClient::eFXSurfaceBufferQueue: result = createBufferQueueLayer(client, uniqueName, w, h, flags, format, handle, gbp, &layer); result = createBufferQueueLayer(client, uniqueName, w, h, flags, std::move(metadata), format, handle, gbp, &layer); break; case ISurfaceComposerClient::eFXSurfaceBufferState: result = createBufferStateLayer(client, uniqueName, w, h, flags, handle, &layer); result = createBufferStateLayer(client, uniqueName, w, h, flags, std::move(metadata), handle, &layer); break; case ISurfaceComposerClient::eFXSurfaceColor: // check if buffer size is set for color layer. Loading @@ -4021,9 +4034,8 @@ status_t SurfaceFlinger::createLayer(const String8& name, const sp<Client>& clie return BAD_VALUE; } result = createColorLayer(client, uniqueName, w, h, flags, handle, &layer); result = createColorLayer(client, uniqueName, w, h, flags, std::move(metadata), handle, &layer); break; case ISurfaceComposerClient::eFXSurfaceContainer: // check if buffer size is set for container layer. Loading @@ -4032,8 +4044,7 @@ status_t SurfaceFlinger::createLayer(const String8& name, const sp<Client>& clie int(w), int(h)); return BAD_VALUE; } result = createContainerLayer(client, uniqueName, w, h, flags, result = createContainerLayer(client, uniqueName, w, h, flags, std::move(metadata), handle, &layer); break; default: Loading @@ -4045,17 +4056,9 @@ status_t SurfaceFlinger::createLayer(const String8& name, const sp<Client>& clie return result; } // window type is WINDOW_TYPE_DONT_SCREENSHOT from SurfaceControl.java // TODO b/64227542 if (metadata.has(METADATA_WINDOW_TYPE)) { int32_t windowType = metadata.getInt32(METADATA_WINDOW_TYPE, 0); if (windowType == 441731) { metadata.setInt32(METADATA_WINDOW_TYPE, 2024); // TYPE_NAVIGATION_BAR_PANEL if (primaryDisplayOnly) { layer->setPrimaryDisplayOnly(); } } layer->setMetadata(metadata); bool addToCurrentState = callingThreadHasUnscopedSurfaceFlingerAccess(); result = addClientLayer(client, *handle, *gbp, layer, *parent, Loading Loading @@ -4099,7 +4102,8 @@ String8 SurfaceFlinger::getUniqueLayerName(const String8& name) status_t SurfaceFlinger::createBufferQueueLayer(const sp<Client>& client, const String8& name, uint32_t w, uint32_t h, uint32_t flags, PixelFormat& format, sp<IBinder>* handle, LayerMetadata metadata, PixelFormat& format, sp<IBinder>* handle, sp<IGraphicBufferProducer>* gbp, sp<Layer>* outLayer) { // initialize the surfaces Loading @@ -4113,8 +4117,8 @@ status_t SurfaceFlinger::createBufferQueueLayer(const sp<Client>& client, const break; } sp<BufferQueueLayer> layer = getFactory().createBufferQueueLayer(LayerCreationArgs(this, client, name, w, h, flags)); sp<BufferQueueLayer> layer = getFactory().createBufferQueueLayer( LayerCreationArgs(this, client, name, w, h, flags, std::move(metadata))); status_t err = layer->setDefaultBufferProperties(w, h, format); if (err == NO_ERROR) { *handle = layer->getHandle(); Loading @@ -4128,30 +4132,31 @@ status_t SurfaceFlinger::createBufferQueueLayer(const sp<Client>& client, const status_t SurfaceFlinger::createBufferStateLayer(const sp<Client>& client, const String8& name, uint32_t w, uint32_t h, uint32_t flags, sp<IBinder>* handle, sp<Layer>* outLayer) { sp<BufferStateLayer> layer = getFactory().createBufferStateLayer(LayerCreationArgs(this, client, name, w, h, flags)); LayerMetadata metadata, sp<IBinder>* handle, sp<Layer>* outLayer) { sp<BufferStateLayer> layer = getFactory().createBufferStateLayer( LayerCreationArgs(this, client, name, w, h, flags, std::move(metadata))); *handle = layer->getHandle(); *outLayer = layer; return NO_ERROR; } status_t SurfaceFlinger::createColorLayer(const sp<Client>& client, const String8& name, uint32_t w, uint32_t h, uint32_t flags, sp<IBinder>* handle, sp<Layer>* outLayer) { *outLayer = getFactory().createColorLayer(LayerCreationArgs(this, client, name, w, h, flags)); status_t SurfaceFlinger::createColorLayer(const sp<Client>& client, const String8& name, uint32_t w, uint32_t h, uint32_t flags, LayerMetadata metadata, sp<IBinder>* handle, sp<Layer>* outLayer) { *outLayer = getFactory().createColorLayer( LayerCreationArgs(this, client, name, w, h, flags, std::move(metadata))); *handle = (*outLayer)->getHandle(); return NO_ERROR; } status_t SurfaceFlinger::createContainerLayer(const sp<Client>& client, const String8& name, uint32_t w, uint32_t h, uint32_t flags, sp<IBinder>* handle, sp<Layer>* outLayer) { *outLayer = getFactory().createContainerLayer(LayerCreationArgs(this, client, name, w, h, flags)); status_t SurfaceFlinger::createContainerLayer(const sp<Client>& client, const String8& name, uint32_t w, uint32_t h, uint32_t flags, LayerMetadata metadata, sp<IBinder>* handle, sp<Layer>* outLayer) { *outLayer = getFactory().createContainerLayer( LayerCreationArgs(this, client, name, w, h, flags, std::move(metadata))); *handle = (*outLayer)->getHandle(); return NO_ERROR; } Loading Loading @@ -5388,7 +5393,8 @@ status_t SurfaceFlinger::captureLayers(const sp<IBinder>& layerHandleBinder, Rect bounds = getBounds(); screenshotParentLayer = mFlinger->getFactory().createContainerLayer( LayerCreationArgs(mFlinger, nullptr, String8("Screenshot Parent"), bounds.getWidth(), bounds.getHeight(), 0)); bounds.getWidth(), bounds.getHeight(), 0, LayerMetadata())); ReparentForDrawing reparent(mLayer, screenshotParentLayer, sourceCrop); drawLayers(); Loading services/surfaceflinger/SurfaceFlinger.h +11 −11 Original line number Diff line number Diff line Loading @@ -604,21 +604,21 @@ private: sp<IBinder>* handle, sp<IGraphicBufferProducer>* gbp, sp<Layer>* parent); status_t createBufferQueueLayer(const sp<Client>& client, const String8& name, uint32_t w, uint32_t h, uint32_t flags, PixelFormat& format, sp<IBinder>* outHandle, sp<IGraphicBufferProducer>* outGbp, sp<Layer>* outLayer); uint32_t h, uint32_t flags, LayerMetadata metadata, PixelFormat& format, sp<IBinder>* outHandle, sp<IGraphicBufferProducer>* outGbp, sp<Layer>* outLayer); status_t createBufferStateLayer(const sp<Client>& client, const String8& name, uint32_t w, uint32_t h, uint32_t flags, sp<IBinder>* outHandle, sp<Layer>* outLayer); uint32_t h, uint32_t flags, LayerMetadata metadata, sp<IBinder>* outHandle, sp<Layer>* outLayer); status_t createColorLayer(const sp<Client>& client, const String8& name, uint32_t w, uint32_t h, uint32_t flags, sp<IBinder>* outHandle, status_t createColorLayer(const sp<Client>& client, const String8& name, uint32_t w, uint32_t h, uint32_t flags, LayerMetadata metadata, sp<IBinder>* outHandle, sp<Layer>* outLayer); status_t createContainerLayer(const sp<Client>& client, const String8& name, uint32_t w, uint32_t h, uint32_t flags, sp<IBinder>* outHandle, sp<Layer>* outLayer); status_t createContainerLayer(const sp<Client>& client, const String8& name, uint32_t w, uint32_t h, uint32_t flags, LayerMetadata metadata, sp<IBinder>* outHandle, sp<Layer>* outLayer); String8 getUniqueLayerName(const String8& name); Loading services/surfaceflinger/tests/unittests/CompositionTest.cpp +3 −2 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ #include <gmock/gmock.h> #include <gtest/gtest.h> #include <gui/IProducerListener.h> #include <gui/LayerMetadata.h> #include <log/log.h> #include <renderengine/mock/Framebuffer.h> #include <renderengine/mock/Image.h> Loading Loading @@ -806,7 +807,7 @@ struct ColorLayerVariant : public BaseLayerVariant<LayerProperties> { return new ColorLayer(LayerCreationArgs(test->mFlinger.mFlinger.get(), sp<Client>(), String8("test-layer"), LayerProperties::WIDTH, LayerProperties::HEIGHT, LayerProperties::LAYER_FLAGS)); LayerProperties::LAYER_FLAGS, LayerMetadata())); }); auto& layerDrawingState = test->mFlinger.mutableLayerDrawingState(layer); Loading Loading @@ -847,7 +848,7 @@ struct BufferLayerVariant : public BaseLayerVariant<LayerProperties> { LayerCreationArgs(test->mFlinger.mFlinger.get(), sp<Client>(), String8("test-layer"), LayerProperties::WIDTH, LayerProperties::HEIGHT, LayerProperties::LAYER_FLAGS)); LayerProperties::LAYER_FLAGS, LayerMetadata())); }); LayerProperties::setupLayerState(test, layer); Loading Loading
services/surfaceflinger/Layer.cpp +3 −2 Original line number Diff line number Diff line Loading @@ -104,6 +104,7 @@ Layer::Layer(const LayerCreationArgs& args) mCurrentState.api = -1; mCurrentState.hasColorTransform = false; mCurrentState.colorSpaceAgnostic = false; mCurrentState.metadata = args.metadata; // drawing state & current state are identical mDrawingState = mCurrentState; Loading Loading @@ -1266,8 +1267,8 @@ bool Layer::setBackgroundColor(const half3& color, float alpha, ui::Dataspace da // create background color layer if one does not yet exist uint32_t flags = ISurfaceComposerClient::eFXSurfaceColor; const String8& name = mName + "BackgroundColorLayer"; mCurrentState.bgColorLayer = new ColorLayer(LayerCreationArgs(mFlinger.get(), nullptr, name, 0, 0, flags)); mCurrentState.bgColorLayer = new ColorLayer( LayerCreationArgs(mFlinger.get(), nullptr, name, 0, 0, flags, LayerMetadata())); // add to child list addChild(mCurrentState.bgColorLayer); Loading
services/surfaceflinger/Layer.h +4 −2 Original line number Diff line number Diff line Loading @@ -80,8 +80,9 @@ class SurfaceInterceptor; struct LayerCreationArgs { LayerCreationArgs(SurfaceFlinger* flinger, const sp<Client>& client, const String8& name, uint32_t w, uint32_t h, uint32_t flags) : flinger(flinger), client(client), name(name), w(w), h(h), flags(flags) {} uint32_t w, uint32_t h, uint32_t flags, LayerMetadata metadata) : flinger(flinger), client(client), name(name), w(w), h(h), flags(flags), metadata(std::move(metadata)) {} SurfaceFlinger* flinger; const sp<Client>& client; Loading @@ -89,6 +90,7 @@ struct LayerCreationArgs { uint32_t w; uint32_t h; uint32_t flags; LayerMetadata metadata; }; class Layer : public virtual compositionengine::LayerFE { Loading
services/surfaceflinger/SurfaceFlinger.cpp +43 −37 Original line number Diff line number Diff line Loading @@ -4004,14 +4004,27 @@ status_t SurfaceFlinger::createLayer(const String8& name, const sp<Client>& clie String8 uniqueName = getUniqueLayerName(name); bool primaryDisplayOnly = false; // window type is WINDOW_TYPE_DONT_SCREENSHOT from SurfaceControl.java // TODO b/64227542 if (metadata.has(METADATA_WINDOW_TYPE)) { int32_t windowType = metadata.getInt32(METADATA_WINDOW_TYPE, 0); if (windowType == 441731) { metadata.setInt32(METADATA_WINDOW_TYPE, 2024); // TYPE_NAVIGATION_BAR_PANEL primaryDisplayOnly = true; } } switch (flags & ISurfaceComposerClient::eFXSurfaceMask) { case ISurfaceComposerClient::eFXSurfaceBufferQueue: result = createBufferQueueLayer(client, uniqueName, w, h, flags, format, handle, gbp, &layer); result = createBufferQueueLayer(client, uniqueName, w, h, flags, std::move(metadata), format, handle, gbp, &layer); break; case ISurfaceComposerClient::eFXSurfaceBufferState: result = createBufferStateLayer(client, uniqueName, w, h, flags, handle, &layer); result = createBufferStateLayer(client, uniqueName, w, h, flags, std::move(metadata), handle, &layer); break; case ISurfaceComposerClient::eFXSurfaceColor: // check if buffer size is set for color layer. Loading @@ -4021,9 +4034,8 @@ status_t SurfaceFlinger::createLayer(const String8& name, const sp<Client>& clie return BAD_VALUE; } result = createColorLayer(client, uniqueName, w, h, flags, handle, &layer); result = createColorLayer(client, uniqueName, w, h, flags, std::move(metadata), handle, &layer); break; case ISurfaceComposerClient::eFXSurfaceContainer: // check if buffer size is set for container layer. Loading @@ -4032,8 +4044,7 @@ status_t SurfaceFlinger::createLayer(const String8& name, const sp<Client>& clie int(w), int(h)); return BAD_VALUE; } result = createContainerLayer(client, uniqueName, w, h, flags, result = createContainerLayer(client, uniqueName, w, h, flags, std::move(metadata), handle, &layer); break; default: Loading @@ -4045,17 +4056,9 @@ status_t SurfaceFlinger::createLayer(const String8& name, const sp<Client>& clie return result; } // window type is WINDOW_TYPE_DONT_SCREENSHOT from SurfaceControl.java // TODO b/64227542 if (metadata.has(METADATA_WINDOW_TYPE)) { int32_t windowType = metadata.getInt32(METADATA_WINDOW_TYPE, 0); if (windowType == 441731) { metadata.setInt32(METADATA_WINDOW_TYPE, 2024); // TYPE_NAVIGATION_BAR_PANEL if (primaryDisplayOnly) { layer->setPrimaryDisplayOnly(); } } layer->setMetadata(metadata); bool addToCurrentState = callingThreadHasUnscopedSurfaceFlingerAccess(); result = addClientLayer(client, *handle, *gbp, layer, *parent, Loading Loading @@ -4099,7 +4102,8 @@ String8 SurfaceFlinger::getUniqueLayerName(const String8& name) status_t SurfaceFlinger::createBufferQueueLayer(const sp<Client>& client, const String8& name, uint32_t w, uint32_t h, uint32_t flags, PixelFormat& format, sp<IBinder>* handle, LayerMetadata metadata, PixelFormat& format, sp<IBinder>* handle, sp<IGraphicBufferProducer>* gbp, sp<Layer>* outLayer) { // initialize the surfaces Loading @@ -4113,8 +4117,8 @@ status_t SurfaceFlinger::createBufferQueueLayer(const sp<Client>& client, const break; } sp<BufferQueueLayer> layer = getFactory().createBufferQueueLayer(LayerCreationArgs(this, client, name, w, h, flags)); sp<BufferQueueLayer> layer = getFactory().createBufferQueueLayer( LayerCreationArgs(this, client, name, w, h, flags, std::move(metadata))); status_t err = layer->setDefaultBufferProperties(w, h, format); if (err == NO_ERROR) { *handle = layer->getHandle(); Loading @@ -4128,30 +4132,31 @@ status_t SurfaceFlinger::createBufferQueueLayer(const sp<Client>& client, const status_t SurfaceFlinger::createBufferStateLayer(const sp<Client>& client, const String8& name, uint32_t w, uint32_t h, uint32_t flags, sp<IBinder>* handle, sp<Layer>* outLayer) { sp<BufferStateLayer> layer = getFactory().createBufferStateLayer(LayerCreationArgs(this, client, name, w, h, flags)); LayerMetadata metadata, sp<IBinder>* handle, sp<Layer>* outLayer) { sp<BufferStateLayer> layer = getFactory().createBufferStateLayer( LayerCreationArgs(this, client, name, w, h, flags, std::move(metadata))); *handle = layer->getHandle(); *outLayer = layer; return NO_ERROR; } status_t SurfaceFlinger::createColorLayer(const sp<Client>& client, const String8& name, uint32_t w, uint32_t h, uint32_t flags, sp<IBinder>* handle, sp<Layer>* outLayer) { *outLayer = getFactory().createColorLayer(LayerCreationArgs(this, client, name, w, h, flags)); status_t SurfaceFlinger::createColorLayer(const sp<Client>& client, const String8& name, uint32_t w, uint32_t h, uint32_t flags, LayerMetadata metadata, sp<IBinder>* handle, sp<Layer>* outLayer) { *outLayer = getFactory().createColorLayer( LayerCreationArgs(this, client, name, w, h, flags, std::move(metadata))); *handle = (*outLayer)->getHandle(); return NO_ERROR; } status_t SurfaceFlinger::createContainerLayer(const sp<Client>& client, const String8& name, uint32_t w, uint32_t h, uint32_t flags, sp<IBinder>* handle, sp<Layer>* outLayer) { *outLayer = getFactory().createContainerLayer(LayerCreationArgs(this, client, name, w, h, flags)); status_t SurfaceFlinger::createContainerLayer(const sp<Client>& client, const String8& name, uint32_t w, uint32_t h, uint32_t flags, LayerMetadata metadata, sp<IBinder>* handle, sp<Layer>* outLayer) { *outLayer = getFactory().createContainerLayer( LayerCreationArgs(this, client, name, w, h, flags, std::move(metadata))); *handle = (*outLayer)->getHandle(); return NO_ERROR; } Loading Loading @@ -5388,7 +5393,8 @@ status_t SurfaceFlinger::captureLayers(const sp<IBinder>& layerHandleBinder, Rect bounds = getBounds(); screenshotParentLayer = mFlinger->getFactory().createContainerLayer( LayerCreationArgs(mFlinger, nullptr, String8("Screenshot Parent"), bounds.getWidth(), bounds.getHeight(), 0)); bounds.getWidth(), bounds.getHeight(), 0, LayerMetadata())); ReparentForDrawing reparent(mLayer, screenshotParentLayer, sourceCrop); drawLayers(); Loading
services/surfaceflinger/SurfaceFlinger.h +11 −11 Original line number Diff line number Diff line Loading @@ -604,21 +604,21 @@ private: sp<IBinder>* handle, sp<IGraphicBufferProducer>* gbp, sp<Layer>* parent); status_t createBufferQueueLayer(const sp<Client>& client, const String8& name, uint32_t w, uint32_t h, uint32_t flags, PixelFormat& format, sp<IBinder>* outHandle, sp<IGraphicBufferProducer>* outGbp, sp<Layer>* outLayer); uint32_t h, uint32_t flags, LayerMetadata metadata, PixelFormat& format, sp<IBinder>* outHandle, sp<IGraphicBufferProducer>* outGbp, sp<Layer>* outLayer); status_t createBufferStateLayer(const sp<Client>& client, const String8& name, uint32_t w, uint32_t h, uint32_t flags, sp<IBinder>* outHandle, sp<Layer>* outLayer); uint32_t h, uint32_t flags, LayerMetadata metadata, sp<IBinder>* outHandle, sp<Layer>* outLayer); status_t createColorLayer(const sp<Client>& client, const String8& name, uint32_t w, uint32_t h, uint32_t flags, sp<IBinder>* outHandle, status_t createColorLayer(const sp<Client>& client, const String8& name, uint32_t w, uint32_t h, uint32_t flags, LayerMetadata metadata, sp<IBinder>* outHandle, sp<Layer>* outLayer); status_t createContainerLayer(const sp<Client>& client, const String8& name, uint32_t w, uint32_t h, uint32_t flags, sp<IBinder>* outHandle, sp<Layer>* outLayer); status_t createContainerLayer(const sp<Client>& client, const String8& name, uint32_t w, uint32_t h, uint32_t flags, LayerMetadata metadata, sp<IBinder>* outHandle, sp<Layer>* outLayer); String8 getUniqueLayerName(const String8& name); Loading
services/surfaceflinger/tests/unittests/CompositionTest.cpp +3 −2 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ #include <gmock/gmock.h> #include <gtest/gtest.h> #include <gui/IProducerListener.h> #include <gui/LayerMetadata.h> #include <log/log.h> #include <renderengine/mock/Framebuffer.h> #include <renderengine/mock/Image.h> Loading Loading @@ -806,7 +807,7 @@ struct ColorLayerVariant : public BaseLayerVariant<LayerProperties> { return new ColorLayer(LayerCreationArgs(test->mFlinger.mFlinger.get(), sp<Client>(), String8("test-layer"), LayerProperties::WIDTH, LayerProperties::HEIGHT, LayerProperties::LAYER_FLAGS)); LayerProperties::LAYER_FLAGS, LayerMetadata())); }); auto& layerDrawingState = test->mFlinger.mutableLayerDrawingState(layer); Loading Loading @@ -847,7 +848,7 @@ struct BufferLayerVariant : public BaseLayerVariant<LayerProperties> { LayerCreationArgs(test->mFlinger.mFlinger.get(), sp<Client>(), String8("test-layer"), LayerProperties::WIDTH, LayerProperties::HEIGHT, LayerProperties::LAYER_FLAGS)); LayerProperties::LAYER_FLAGS, LayerMetadata())); }); LayerProperties::setupLayerState(test, layer); Loading