From f837c93a1b392dbc4f7099d0c4fb723e32ca438e Mon Sep 17 00:00:00 2001 From: Wonsik Kim Date: Mon, 24 Feb 2014 14:20:35 +0900 Subject: [PATCH] Implement video plane layer Binding with video source will follow. Change-Id: Ic14e9757f5b61f4055cbeda47c1bafae0a621abb --- include/gui/ISurfaceComposerClient.h | 1 + services/surfaceflinger/Android.mk | 1 + services/surfaceflinger/LayerVideoPlane.cpp | 66 +++++++++++++++++++++ services/surfaceflinger/LayerVideoPlane.h | 47 +++++++++++++++ services/surfaceflinger/SurfaceFlinger.cpp | 16 +++++ services/surfaceflinger/SurfaceFlinger.h | 4 ++ 6 files changed, 135 insertions(+) create mode 100644 services/surfaceflinger/LayerVideoPlane.cpp create mode 100644 services/surfaceflinger/LayerVideoPlane.h diff --git a/include/gui/ISurfaceComposerClient.h b/include/gui/ISurfaceComposerClient.h index cb9816fb2..8caa7651a 100644 --- a/include/gui/ISurfaceComposerClient.h +++ b/include/gui/ISurfaceComposerClient.h @@ -49,6 +49,7 @@ public: eFXSurfaceNormal = 0x00000000, eFXSurfaceDim = 0x00020000, + eFXSurfaceVideoPlane= 0x00040000, eFXSurfaceMask = 0x000F0000, }; diff --git a/services/surfaceflinger/Android.mk b/services/surfaceflinger/Android.mk index 49a017f0f..28de90a06 100644 --- a/services/surfaceflinger/Android.mk +++ b/services/surfaceflinger/Android.mk @@ -10,6 +10,7 @@ LOCAL_SRC_FILES:= \ FrameTracker.cpp \ Layer.cpp \ LayerDim.cpp \ + LayerVideoPlane.cpp \ MessageQueue.cpp \ SurfaceFlinger.cpp \ SurfaceFlingerConsumer.cpp \ diff --git a/services/surfaceflinger/LayerVideoPlane.cpp b/services/surfaceflinger/LayerVideoPlane.cpp new file mode 100644 index 000000000..995c43ad2 --- /dev/null +++ b/services/surfaceflinger/LayerVideoPlane.cpp @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include + +#include +#include + +#include + +#include "LayerVideoPlane.h" +#include "SurfaceFlinger.h" +#include "DisplayDevice.h" +#include "RenderEngine/RenderEngine.h" + +#define DEBUG_BLUE_SURFACE 1 + +namespace android { +// --------------------------------------------------------------------------- + +LayerVideoPlane::LayerVideoPlane(SurfaceFlinger* flinger, const sp& client, + const String8& name, uint32_t w, uint32_t h, uint32_t flags) + : Layer(flinger, client, name, w, h, flags) { +} + +LayerVideoPlane::~LayerVideoPlane() { +} + +void LayerVideoPlane::onDraw(const sp& hw, + const Region& /* clip */, bool useIdentityTransform) const +{ +#if DEBUG_BLUE_SURFACE + Mesh mesh(Mesh::TRIANGLE_FAN, 4, 2); + computeGeometry(hw, mesh, useIdentityTransform); + RenderEngine& engine(mFlinger->getRenderEngine()); + engine.setupFillWithColor(0.0f, 0.0f, 1.0f, 1.0f); + engine.drawMesh(mesh); +#else + // TODO +#endif +} + +bool LayerVideoPlane::isVisible() const { + const Layer::State& s(getDrawingState()); + return !(s.flags & layer_state_t::eLayerHidden); +} + + +// --------------------------------------------------------------------------- + +}; // namespace android diff --git a/services/surfaceflinger/LayerVideoPlane.h b/services/surfaceflinger/LayerVideoPlane.h new file mode 100644 index 000000000..a07c6890a --- /dev/null +++ b/services/surfaceflinger/LayerVideoPlane.h @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ANDROID_LAYER_VIDEO_PLANE_H +#define ANDROID_LAYER_VIDEO_PLANE_H + +#include +#include + +#include "Layer.h" + +// --------------------------------------------------------------------------- + +namespace android { + +class LayerVideoPlane : public Layer +{ +public: + LayerVideoPlane(SurfaceFlinger* flinger, const sp& client, + const String8& name, uint32_t w, uint32_t h, uint32_t flags); + virtual ~LayerVideoPlane(); + + virtual const char* getTypeId() const { return "LayerVideoPlane"; } + virtual void onDraw(const sp& hw, const Region& clip, + bool useIdentityTransform) const; + virtual bool isFixedSize() const { return true; } + virtual bool isVisible() const; +}; + +// --------------------------------------------------------------------------- + +}; // namespace android + +#endif // ANDROID_LAYER_VIDEO_PLANE_H diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 808fa1bc2..0d835dce0 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -64,6 +64,7 @@ #include "EventThread.h" #include "Layer.h" #include "LayerDim.h" +#include "LayerVideoPlane.h" #include "SurfaceFlinger.h" #include "DisplayHardware/FramebufferSurface.h" @@ -1937,6 +1938,11 @@ status_t SurfaceFlinger::createLayer( name, w, h, flags, handle, gbp, &layer); break; + case ISurfaceComposerClient::eFXSurfaceVideoPlane: + result = createVideoPlaneLayer(client, + name, w, h, flags, + handle, gbp, &layer); + break; default: result = BAD_VALUE; break; @@ -1994,6 +2000,16 @@ status_t SurfaceFlinger::createDimLayer(const sp& client, return NO_ERROR; } +status_t SurfaceFlinger::createVideoPlaneLayer(const sp& client, + const String8& name, uint32_t w, uint32_t h, uint32_t flags, + sp* handle, sp* gbp, sp* outLayer) +{ + *outLayer = new LayerVideoPlane(this, client, name, w, h, flags); + *handle = (*outLayer)->getHandle(); + *gbp = (*outLayer)->getBufferQueue(); + return NO_ERROR; +} + status_t SurfaceFlinger::onLayerRemoved(const sp& client, const sp& handle) { // called by the window manager when it wants to remove a Layer diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h index 923046715..c473d933c 100644 --- a/services/surfaceflinger/SurfaceFlinger.h +++ b/services/surfaceflinger/SurfaceFlinger.h @@ -280,6 +280,10 @@ private: uint32_t w, uint32_t h, uint32_t flags, sp* outHandle, sp* outGbp, sp* outLayer); + status_t createVideoPlaneLayer(const sp& client, const String8& name, + uint32_t w, uint32_t h, uint32_t flags, sp* outHandle, + sp* outGbp, sp* outLayer); + // called in response to the window-manager calling // ISurfaceComposerClient::destroySurface() status_t onLayerRemoved(const sp& client, const sp& handle);