drm_hwcomposer: remove compositor interface
The compositor interface had only one implementation and one user. The
compositor interface also needs to change to accomodate some changes for
fences to work optimally.
Change-Id: I02d21b0a0e86fa21b3c5f4ad84ff571611643994
diff --git a/Android.mk b/Android.mk
index ccb230e..de1658f 100644
--- a/Android.mk
+++ b/Android.mk
@@ -37,7 +37,6 @@
system/core/libsync/include \
LOCAL_SRC_FILES := \
- compositor.cpp \
drmresources.cpp \
drmcomposition.cpp \
drmcompositor.cpp \
diff --git a/compositor.cpp b/compositor.cpp
deleted file mode 100644
index 3f85dc7..0000000
--- a/compositor.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2015 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 "compositor.h"
-
-#include <sstream>
-
-namespace android {
-
-Targeting::~Targeting() {
-}
-
-Composition::~Composition() {
-}
-
-Compositor::~Compositor() {
-}
-
-void Compositor::Dump(std::ostringstream */* out */) const {
-}
-
-} // namespace android
diff --git a/compositor.h b/compositor.h
deleted file mode 100644
index b424b37..0000000
--- a/compositor.h
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright (C) 2015 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 DRM_HWCOMPOSER_COMPOSITOR_H_
-#define DRM_HWCOMPOSER_COMPOSITOR_H_
-
-#include "importer.h"
-
-#include <sstream>
-
-struct hwc_layer_1;
-struct hwc_drm_bo;
-
-namespace android {
-
-class GraphicBuffer;
-template <typename T>
-class sp;
-
-class Targeting {
- public:
- // Prepares the given framebuffer for use as output of this compositor. On
- // success, takes a reference to the given buffer and returns a non- negative
- // integer that is used as a handle to the prepared target. On failure,
- // returns a negative integer.
- virtual int CreateTarget(sp<android::GraphicBuffer> &buffer) = 0;
-
- // Sets the target framebuffer of all subsequent composite calls. The target
- // must be an integer previously returned by a successful call to createTarget
- // of this compositor or the target can be -1 to indicate that no custom
- // buffer should be used for subsequent calls.
- virtual void SetTarget(int target) = 0;
-
- // Releases the reference to the buffer underlying the given target. The given
- // target will no longer be valid for use for setTarget. Calling this on a
- // target that was used in the last setTarget call or that is the target of a
- // composition that has not yet signaled its fence is undefined behavior.
- virtual void ForgetTarget(int target) = 0;
-
- protected:
- ~Targeting();
-};
-
-class Composition {
- public:
- // Releases and invalidates the composition.
- virtual ~Composition();
-
- // Adds the given layer, whose handle has been imported into the given buffer
- // object, to the given display of the composition. The layer may be modified
- // to include a releaseFenceFd.
- //
- // Upon success, the compositor takes ownership of bo and is responsible
- // for calling importer->ReleaseBuffer(bo), where importer is the importer
- // provided on CreateComposition(). Returns 0 on success.
- virtual int AddLayer(int display, hwc_layer_1 *layer, hwc_drm_bo *bo) = 0;
-
- // Gets the number of successful AddLayer calls that can be made on the
- // composition and display, up to num_needed.
- virtual unsigned GetRemainingLayers(int display,
- unsigned num_needed) const = 0;
-};
-
-class Compositor {
- public:
- virtual ~Compositor();
-
- // This must be called once before any other methods called. It must be called
- // on the thread the Compositor is meant to operate on to initialize thread
- // local variables. Returns 0 on success.
- virtual int Init() = 0;
-
- // If this compositor supports targeting to output buffers, this returns a
- // non-null pointer. Otherwise, returns null.
- virtual Targeting *targeting() = 0;
-
- // Starts a fresh composition.
- virtual Composition *CreateComposition(Importer *importer) = 0;
-
- // Transfers ownership of composition to the Compositor (whether or not this
- // call returns success) for compositing.
- // On success returns a syncpoint fd that will be signaled when composition is
- // complete or -1 if compositing was completed by this method's return. On
- // error returns an integer less than -1. The composition is invalid after
- // this call.
- virtual int QueueComposition(Composition *composition) = 0;
-
- // compositors require that every QueueComposition be paired with a Composite
- // on a worker thread. Each Composite call handles one composition that was
- // submitted via QueueComposition in FIFO order. Returns 0 on success.
- virtual int Composite() = 0;
-
- // Dumps state from the Compositor to the out stream
- virtual void Dump(std::ostringstream *out) const;
-};
-
-} // namespace android
-
-#endif
diff --git a/drmcomposition.h b/drmcomposition.h
index 06af71d..69bf6d9 100644
--- a/drmcomposition.h
+++ b/drmcomposition.h
@@ -17,7 +17,6 @@
#ifndef ANDROID_DRM_COMPOSITION_H_
#define ANDROID_DRM_COMPOSITION_H_
-#include "compositor.h"
#include "drm_hwcomposer.h"
#include "drmdisplaycomposition.h"
#include "drmplane.h"
@@ -32,15 +31,15 @@
namespace android {
-class DrmComposition : public Composition {
+class DrmComposition {
public:
DrmComposition(DrmResources *drm, Importer *importer);
~DrmComposition();
- virtual int Init();
+ int Init();
- virtual unsigned GetRemainingLayers(int display, unsigned num_needed) const;
- virtual int AddLayer(int display, hwc_layer_1_t *layer, hwc_drm_bo_t *bo);
+ unsigned GetRemainingLayers(int display, unsigned num_needed) const;
+ int AddLayer(int display, hwc_layer_1_t *layer, hwc_drm_bo_t *bo);
int AddDpmsMode(int display, uint32_t dpms_mode);
int DisableUnusedPlanes();
diff --git a/drmcompositor.cpp b/drmcompositor.cpp
index 3bab93f..082e75d 100644
--- a/drmcompositor.cpp
+++ b/drmcompositor.cpp
@@ -47,7 +47,7 @@
return 0;
}
-Composition *DrmCompositor::CreateComposition(Importer *importer) {
+DrmComposition *DrmCompositor::CreateComposition(Importer *importer) {
DrmComposition *composition = new DrmComposition(drm_, importer);
if (!composition) {
ALOGE("Failed to allocate drm composition");
@@ -62,10 +62,8 @@
return composition;
}
-int DrmCompositor::QueueComposition(Composition *composition) {
- DrmComposition *drm_composition = (DrmComposition *)composition;
-
- int ret = drm_composition->DisableUnusedPlanes();
+int DrmCompositor::QueueComposition(DrmComposition *composition) {
+ int ret = composition->DisableUnusedPlanes();
if (ret) {
ALOGE("Failed to disable unused planes %d", ret);
return ret;
@@ -75,7 +73,7 @@
iter != drm_->end_connectors(); ++iter) {
int display = (*iter)->display();
int ret = compositor_map_[display].QueueComposition(
- drm_composition->TakeDisplayComposition(display));
+ composition->TakeDisplayComposition(display));
if (ret) {
ALOGE("Failed to queue composition for display %d", display);
delete composition;
diff --git a/drmcompositor.h b/drmcompositor.h
index 5f47034..aa4a876 100644
--- a/drmcompositor.h
+++ b/drmcompositor.h
@@ -17,7 +17,7 @@
#ifndef ANDROID_DRM_COMPOSITOR_H_
#define ANDROID_DRM_COMPOSITOR_H_
-#include "compositor.h"
+#include "drmcomposition.h"
#include "drmdisplaycompositor.h"
#include "importer.h"
@@ -26,22 +26,18 @@
namespace android {
-class DrmCompositor : public Compositor {
+class DrmCompositor {
public:
DrmCompositor(DrmResources *drm);
~DrmCompositor();
- virtual int Init();
+ int Init();
- virtual Targeting *targeting() {
- return NULL;
- }
+ DrmComposition *CreateComposition(Importer *importer);
- virtual Composition *CreateComposition(Importer *importer);
-
- virtual int QueueComposition(Composition *composition);
- virtual int Composite();
- virtual void Dump(std::ostringstream *out) const;
+ int QueueComposition(DrmComposition *composition);
+ int Composite();
+ void Dump(std::ostringstream *out) const;
private:
DrmCompositor(const DrmCompositor &) = delete;
diff --git a/drmresources.cpp b/drmresources.cpp
index 9be990f..feb5187 100644
--- a/drmresources.cpp
+++ b/drmresources.cpp
@@ -467,7 +467,7 @@
return -EINVAL;
}
- DrmComposition *comp = (DrmComposition *)compositor_.CreateComposition(NULL);
+ DrmComposition *comp = compositor_.CreateComposition(NULL);
if (!comp) {
ALOGE("Failed to create composition for dpms on %d", display);
return -ENOMEM;
@@ -478,7 +478,7 @@
delete comp;
return ret;
}
- ret = compositor_.QueueComposition((Composition *)comp);
+ ret = compositor_.QueueComposition(comp);
if (ret) {
ALOGE("Failed to queue dpms composition on %d %d", display, ret);
return ret;
diff --git a/hwcomposer.cpp b/hwcomposer.cpp
index b4b1a50..a83c247 100644
--- a/hwcomposer.cpp
+++ b/hwcomposer.cpp
@@ -110,7 +110,7 @@
static void hwc_set_cleanup(size_t num_displays,
hwc_display_contents_1_t **display_contents,
- Composition *composition) {
+ DrmComposition *composition) {
for (int i = 0; i < (int)num_displays; ++i) {
if (!display_contents[i])
continue;
@@ -133,7 +133,7 @@
}
static int hwc_add_layer(int display, hwc_context_t *ctx, hwc_layer_1_t *layer,
- Composition *composition) {
+ DrmComposition *composition) {
hwc_drm_bo_t bo;
int ret = ctx->importer->ImportBuffer(layer->handle, &bo);
if (ret) {
@@ -171,7 +171,7 @@
hwc_display_contents_1_t **display_contents) {
ATRACE_CALL();
struct hwc_context_t *ctx = (struct hwc_context_t *)&dev->common;
- Composition *composition =
+ DrmComposition *composition =
ctx->drm.compositor()->CreateComposition(ctx->importer);
if (!composition) {
ALOGE("Drm composition init failed");