Extend shared compositor to return primary display config
This commit is contained in:
parent
506998cfba
commit
fce7466ff9
2 changed files with 74 additions and 6 deletions
|
|
@ -25,8 +25,12 @@
|
||||||
#include <gui/DisplayEventReceiver.h>
|
#include <gui/DisplayEventReceiver.h>
|
||||||
#include <gui/IDisplayEventConnection.h>
|
#include <gui/IDisplayEventConnection.h>
|
||||||
#include <gui/BitTube.h>
|
#include <gui/BitTube.h>
|
||||||
|
#include <gui/BufferQueue.h>
|
||||||
|
|
||||||
#include <hardware/hwcomposer_defs.h>
|
#include <hardware/hwcomposer_defs.h>
|
||||||
|
#include <hardware/hardware.h>
|
||||||
|
|
||||||
|
#include <cutils/properties.h>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
class DisplayDevice {
|
class DisplayDevice {
|
||||||
|
|
@ -68,6 +72,16 @@ private:
|
||||||
sp<BitTube> const mChannel;
|
sp<BitTube> const mChannel;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class Surface {
|
||||||
|
public:
|
||||||
|
Surface() {
|
||||||
|
BufferQueue::createBufferQueue(&producer, &consumer);
|
||||||
|
}
|
||||||
|
|
||||||
|
sp<IGraphicBufferProducer> producer;
|
||||||
|
sp<IGraphicBufferConsumer> consumer;
|
||||||
|
};
|
||||||
|
|
||||||
class Client : public BnSurfaceComposerClient {
|
class Client : public BnSurfaceComposerClient {
|
||||||
public:
|
public:
|
||||||
Client() { }
|
Client() { }
|
||||||
|
|
@ -108,6 +122,19 @@ namespace anbox {
|
||||||
namespace android {
|
namespace android {
|
||||||
SurfaceComposer::SurfaceComposer() :
|
SurfaceComposer::SurfaceComposer() :
|
||||||
mPrimaryDisplay(new BBinder) {
|
mPrimaryDisplay(new BBinder) {
|
||||||
|
|
||||||
|
hw_module_t const* module;
|
||||||
|
int err = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module);
|
||||||
|
if (err != 0) {
|
||||||
|
ALOGE("%s module not found", GRALLOC_HARDWARE_MODULE_ID);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
framebuffer_open(module, &mFbDev);
|
||||||
|
}
|
||||||
|
|
||||||
|
SurfaceComposer::~SurfaceComposer() {
|
||||||
|
if (mFbDev)
|
||||||
|
framebuffer_close(mFbDev);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SurfaceComposer::binderDied(const wp<IBinder>&) {
|
void SurfaceComposer::binderDied(const wp<IBinder>&) {
|
||||||
|
|
@ -158,6 +185,18 @@ void SurfaceComposer::setTransactionState(const Vector<ComposerState>& state,
|
||||||
|
|
||||||
void SurfaceComposer::bootFinished() {
|
void SurfaceComposer::bootFinished() {
|
||||||
ALOGI("%s", __PRETTY_FUNCTION__);
|
ALOGI("%s", __PRETTY_FUNCTION__);
|
||||||
|
|
||||||
|
// wait patiently for the window manager death
|
||||||
|
const String16 name("window");
|
||||||
|
sp<IBinder> window(defaultServiceManager()->getService(name));
|
||||||
|
if (window != 0) {
|
||||||
|
window->linkToDeath(static_cast<IBinder::DeathRecipient*>(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
// stop boot animation
|
||||||
|
// formerly we would just kill the process, but we now ask it to exit so it
|
||||||
|
// can choose where to stop the animation.
|
||||||
|
property_set("service.bootanim.exit", "1");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SurfaceComposer::authenticateSurfaceTexture(const sp<IGraphicBufferProducer>& surface) const {
|
bool SurfaceComposer::authenticateSurfaceTexture(const sp<IGraphicBufferProducer>& surface) const {
|
||||||
|
|
@ -174,12 +213,32 @@ status_t SurfaceComposer::getDisplayConfigs(const sp<IBinder>& display, Vector<D
|
||||||
|
|
||||||
configs->clear();
|
configs->clear();
|
||||||
|
|
||||||
|
class Density {
|
||||||
|
static int getDensityFromProperty(char const* propName) {
|
||||||
|
char property[PROPERTY_VALUE_MAX];
|
||||||
|
int density = 0;
|
||||||
|
if (property_get(propName, property, NULL) > 0) {
|
||||||
|
density = atoi(property);
|
||||||
|
}
|
||||||
|
return density;
|
||||||
|
}
|
||||||
|
public:
|
||||||
|
static int getBuildDensity() {
|
||||||
|
return getDensityFromProperty("ro.sf.lcd_density"); }
|
||||||
|
};
|
||||||
|
|
||||||
|
float density = Density::getBuildDensity() / 160.0f;
|
||||||
|
|
||||||
|
// We will provide a single display configuration element here which is
|
||||||
|
// the framebuffer we're based on. No further display configurations
|
||||||
|
// are needed in our case.
|
||||||
DisplayInfo info = DisplayInfo();
|
DisplayInfo info = DisplayInfo();
|
||||||
info.w = 0;
|
info.density = density;
|
||||||
info.h = 0;
|
info.w = mFbDev->width;
|
||||||
info.xdpi = 0;
|
info.h = mFbDev->height;
|
||||||
info.ydpi = 0;
|
info.xdpi = mFbDev->xdpi;
|
||||||
info.fps = 60;
|
info.ydpi = mFbDev->ydpi;
|
||||||
|
info.fps = mFbDev->fps;
|
||||||
info.secure = true;
|
info.secure = true;
|
||||||
configs->push_back(info);
|
configs->push_back(info);
|
||||||
|
|
||||||
|
|
@ -188,11 +247,13 @@ status_t SurfaceComposer::getDisplayConfigs(const sp<IBinder>& display, Vector<D
|
||||||
|
|
||||||
status_t SurfaceComposer::getDisplayStats(const sp<IBinder>& display, DisplayStatInfo* stats) {
|
status_t SurfaceComposer::getDisplayStats(const sp<IBinder>& display, DisplayStatInfo* stats) {
|
||||||
ALOGI("%s", __PRETTY_FUNCTION__);
|
ALOGI("%s", __PRETTY_FUNCTION__);
|
||||||
return OK;
|
return NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SurfaceComposer::getActiveConfig(const sp<IBinder>& display) {
|
int SurfaceComposer::getActiveConfig(const sp<IBinder>& display) {
|
||||||
ALOGI("%s", __PRETTY_FUNCTION__);
|
ALOGI("%s", __PRETTY_FUNCTION__);
|
||||||
|
|
||||||
|
// We only provide one so it will be always our default
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,14 +18,19 @@
|
||||||
#ifndef ANBOX_ANDROID_SURFACE_COMPOSER_H_
|
#ifndef ANBOX_ANDROID_SURFACE_COMPOSER_H_
|
||||||
#define ANBOX_ANDROID_SURFACE_COMPOSER_H_
|
#define ANBOX_ANDROID_SURFACE_COMPOSER_H_
|
||||||
|
|
||||||
|
#include <gui/IGraphicBufferProducer.h>
|
||||||
|
#include <gui/IGraphicBufferConsumer.h>
|
||||||
#include <gui/ISurfaceComposer.h>
|
#include <gui/ISurfaceComposer.h>
|
||||||
#include <ui/Rect.h>
|
#include <ui/Rect.h>
|
||||||
#include <binder/BinderService.h>
|
#include <binder/BinderService.h>
|
||||||
|
|
||||||
using namespace android;
|
using namespace android;
|
||||||
|
|
||||||
|
struct framebuffer_device_t;
|
||||||
|
|
||||||
namespace anbox {
|
namespace anbox {
|
||||||
namespace android {
|
namespace android {
|
||||||
|
class Framebuffer;
|
||||||
class SurfaceComposer : public BinderService<SurfaceComposer>,
|
class SurfaceComposer : public BinderService<SurfaceComposer>,
|
||||||
public BnSurfaceComposer,
|
public BnSurfaceComposer,
|
||||||
public IBinder::DeathRecipient {
|
public IBinder::DeathRecipient {
|
||||||
|
|
@ -33,6 +38,7 @@ public:
|
||||||
static char const *getServiceName() { return "SurfaceFlinger"; }
|
static char const *getServiceName() { return "SurfaceFlinger"; }
|
||||||
|
|
||||||
SurfaceComposer();
|
SurfaceComposer();
|
||||||
|
virtual ~SurfaceComposer();
|
||||||
|
|
||||||
void binderDied(const wp<IBinder>& who) override;
|
void binderDied(const wp<IBinder>& who) override;
|
||||||
|
|
||||||
|
|
@ -62,6 +68,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
sp<IBinder> mPrimaryDisplay;
|
sp<IBinder> mPrimaryDisplay;
|
||||||
|
framebuffer_device_t *mFbDev;
|
||||||
};
|
};
|
||||||
} // namespace android
|
} // namespace android
|
||||||
} // namespace anbox
|
} // namespace anbox
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue