Banish DisplayID from the SurfaceFlinger API.
Use only display tokens in the API to refer to new displays. Don't require the caller to specify the display when creating a surface (since in general a surface could be shown on any display). This is intended to be a minimum change just to update the API. Note that SurfaceFlinger still uses DisplayID in a few places internally that might cause some features not to work properly when there are multiple displays (LayerScreenshot, for example). Change-Id: I3d91eec2da406eefd97bcd53655d403ad865a7e6
This commit is contained in:
parent
225c66a48c
commit
9d4e3d2f42
|
@ -65,7 +65,7 @@ public:
|
|||
/* return an IDisplayEventConnection */
|
||||
virtual sp<IDisplayEventConnection> createDisplayEventConnection() = 0;
|
||||
|
||||
/* create a display with given id.
|
||||
/* create a display
|
||||
* requires ACCESS_SURFACE_FLINGER permission.
|
||||
*/
|
||||
virtual sp<IBinder> createDisplay() = 0;
|
||||
|
@ -92,10 +92,10 @@ public:
|
|||
/* Capture the specified screen. requires READ_FRAME_BUFFER permission
|
||||
* This function will fail if there is a secure window on screen.
|
||||
*/
|
||||
virtual status_t captureScreen(DisplayID dpy, sp<IMemoryHeap>* heap,
|
||||
virtual status_t captureScreen(const sp<IBinder>& display, sp<IMemoryHeap>* heap,
|
||||
uint32_t* width, uint32_t* height, PixelFormat* format,
|
||||
uint32_t reqWidth, uint32_t reqHeight, uint32_t minLayerZ,
|
||||
uint32_t maxLayerZ) = 0;
|
||||
uint32_t reqWidth, uint32_t reqHeight,
|
||||
uint32_t minLayerZ, uint32_t maxLayerZ) = 0;
|
||||
|
||||
|
||||
/* triggers screen off and waits for it to complete */
|
||||
|
@ -104,12 +104,12 @@ public:
|
|||
/* triggers screen on and waits for it to complete */
|
||||
virtual void unblank() = 0;
|
||||
|
||||
/* returns information about a physical screen. This is intended to be
|
||||
* used by low-level native tests */
|
||||
virtual status_t getDisplayInfo(DisplayID dpy, DisplayInfo* info) = 0;
|
||||
/* returns information about a display
|
||||
* intended to be used to get information about built-in displays */
|
||||
virtual status_t getDisplayInfo(const sp<IBinder>& display, DisplayInfo* info) = 0;
|
||||
|
||||
/* connects to an external display */
|
||||
virtual void connectDisplay(const sp<ISurfaceTexture> display) = 0;
|
||||
virtual void connectDisplay(const sp<ISurfaceTexture>& display) = 0;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
|
|
@ -33,6 +33,7 @@ namespace android {
|
|||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// TODO: Remove this declaration, it is only used internally by SurfaceFlinger.
|
||||
typedef int32_t DisplayID;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -70,7 +71,7 @@ public:
|
|||
* Requires ACCESS_SURFACE_FLINGER permission
|
||||
*/
|
||||
virtual sp<ISurface> createSurface(surface_data_t* data,
|
||||
const String8& name, DisplayID display, uint32_t w, uint32_t h,
|
||||
const String8& name, uint32_t w, uint32_t h,
|
||||
PixelFormat format, uint32_t flags) = 0;
|
||||
|
||||
/*
|
||||
|
|
|
@ -60,6 +60,7 @@ public:
|
|||
// release surface data from java
|
||||
void clear();
|
||||
|
||||
status_t setLayerStack(int32_t layerStack);
|
||||
status_t setLayer(int32_t layer);
|
||||
status_t setPosition(int32_t x, int32_t y);
|
||||
status_t setSize(uint32_t w, uint32_t h);
|
||||
|
|
|
@ -39,6 +39,7 @@ class DisplayInfo;
|
|||
class Composer;
|
||||
class IMemoryHeap;
|
||||
class ISurfaceComposerClient;
|
||||
class ISurfaceTexture;
|
||||
class Region;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
@ -64,7 +65,7 @@ public:
|
|||
void* cookie = NULL, uint32_t flags = 0);
|
||||
|
||||
// Get information about a display
|
||||
static status_t getDisplayInfo(DisplayID dpy, DisplayInfo* info);
|
||||
static status_t getDisplayInfo(const sp<IBinder>& display, DisplayInfo* info);
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// surface creation / destruction
|
||||
|
@ -72,23 +73,19 @@ public:
|
|||
//! Create a surface
|
||||
sp<SurfaceControl> createSurface(
|
||||
const String8& name,// name of the surface
|
||||
DisplayID display, // Display to create this surface on
|
||||
uint32_t w, // width in pixel
|
||||
uint32_t h, // height in pixel
|
||||
PixelFormat format, // pixel-format desired
|
||||
uint32_t flags = 0 // usage flags
|
||||
);
|
||||
|
||||
sp<SurfaceControl> createSurface(
|
||||
DisplayID display, // Display to create this surface on
|
||||
uint32_t w, // width in pixel
|
||||
uint32_t h, // height in pixel
|
||||
PixelFormat format, // pixel-format desired
|
||||
uint32_t flags = 0 // usage flags
|
||||
);
|
||||
|
||||
//! Create a display
|
||||
static sp<IBinder> createDisplay();
|
||||
|
||||
//! Get the token for the existing default displays.
|
||||
//! Possible values for id are eDisplayIdMain and eDisplayIdHdmi.
|
||||
static sp<IBinder> getBuiltInDisplay(int32_t id);
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Composer parameters
|
||||
// All composer parameters must be changed within a transaction
|
||||
|
@ -102,9 +99,6 @@ public:
|
|||
//! Close a composer transaction on all active SurfaceComposerClients.
|
||||
static void closeGlobalTransaction(bool synchronous = false);
|
||||
|
||||
//! Set the orientation of the given display
|
||||
static int setOrientation(DisplayID dpy, int orientation, uint32_t flags);
|
||||
|
||||
status_t hide(SurfaceID id);
|
||||
status_t show(SurfaceID id, int32_t layer = -1);
|
||||
status_t setFlags(SurfaceID id, uint32_t flags, uint32_t mask);
|
||||
|
@ -150,9 +144,11 @@ public:
|
|||
ScreenshotClient();
|
||||
|
||||
// frees the previous screenshot and capture a new one
|
||||
status_t update();
|
||||
status_t update(uint32_t reqWidth, uint32_t reqHeight);
|
||||
status_t update(uint32_t reqWidth, uint32_t reqHeight,
|
||||
status_t update(const sp<IBinder>& display);
|
||||
status_t update(const sp<IBinder>& display,
|
||||
uint32_t reqWidth, uint32_t reqHeight);
|
||||
status_t update(const sp<IBinder>& display,
|
||||
uint32_t reqWidth, uint32_t reqHeight,
|
||||
uint32_t minLayerZ, uint32_t maxLayerZ);
|
||||
|
||||
// release memory occupied by the screenshot
|
||||
|
|
|
@ -102,15 +102,15 @@ public:
|
|||
remote()->transact(BnSurfaceComposer::BOOT_FINISHED, data, &reply);
|
||||
}
|
||||
|
||||
virtual status_t captureScreen(DisplayID dpy,
|
||||
sp<IMemoryHeap>* heap,
|
||||
virtual status_t captureScreen(
|
||||
const sp<IBinder>& display, sp<IMemoryHeap>* heap,
|
||||
uint32_t* width, uint32_t* height, PixelFormat* format,
|
||||
uint32_t reqWidth, uint32_t reqHeight,
|
||||
uint32_t minLayerZ, uint32_t maxLayerZ)
|
||||
{
|
||||
Parcel data, reply;
|
||||
data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
|
||||
data.writeInt32(dpy);
|
||||
data.writeStrongBinder(display);
|
||||
data.writeInt32(reqWidth);
|
||||
data.writeInt32(reqHeight);
|
||||
data.writeInt32(minLayerZ);
|
||||
|
@ -210,18 +210,18 @@ public:
|
|||
remote()->transact(BnSurfaceComposer::UNBLANK, data, &reply);
|
||||
}
|
||||
|
||||
virtual status_t getDisplayInfo(DisplayID dpy, DisplayInfo* info)
|
||||
virtual status_t getDisplayInfo(const sp<IBinder>& display, DisplayInfo* info)
|
||||
{
|
||||
Parcel data, reply;
|
||||
data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
|
||||
data.writeInt32(dpy);
|
||||
data.writeStrongBinder(display);
|
||||
remote()->transact(BnSurfaceComposer::GET_DISPLAY_INFO, data, &reply);
|
||||
memcpy(info, reply.readInplace(sizeof(DisplayInfo)), sizeof(DisplayInfo));
|
||||
return reply.readInt32();
|
||||
}
|
||||
|
||||
|
||||
virtual void connectDisplay(const sp<ISurfaceTexture> display) {
|
||||
virtual void connectDisplay(const sp<ISurfaceTexture>& display) {
|
||||
Parcel data, reply;
|
||||
data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
|
||||
data.writeStrongBinder(display->asBinder());
|
||||
|
@ -274,7 +274,7 @@ status_t BnSurfaceComposer::onTransact(
|
|||
} break;
|
||||
case CAPTURE_SCREEN: {
|
||||
CHECK_INTERFACE(ISurfaceComposer, data, reply);
|
||||
DisplayID dpy = data.readInt32();
|
||||
sp<IBinder> display = data.readStrongBinder();
|
||||
uint32_t reqWidth = data.readInt32();
|
||||
uint32_t reqHeight = data.readInt32();
|
||||
uint32_t minLayerZ = data.readInt32();
|
||||
|
@ -282,7 +282,7 @@ status_t BnSurfaceComposer::onTransact(
|
|||
sp<IMemoryHeap> heap;
|
||||
uint32_t w, h;
|
||||
PixelFormat f;
|
||||
status_t res = captureScreen(dpy, &heap, &w, &h, &f,
|
||||
status_t res = captureScreen(display, &heap, &w, &h, &f,
|
||||
reqWidth, reqHeight, minLayerZ, maxLayerZ);
|
||||
reply->writeStrongBinder(heap->asBinder());
|
||||
reply->writeInt32(w);
|
||||
|
@ -327,8 +327,8 @@ status_t BnSurfaceComposer::onTransact(
|
|||
case GET_DISPLAY_INFO: {
|
||||
CHECK_INTERFACE(ISurfaceComposer, data, reply);
|
||||
DisplayInfo info;
|
||||
DisplayID dpy = data.readInt32();
|
||||
status_t result = getDisplayInfo(dpy, &info);
|
||||
sp<IBinder> display = data.readStrongBinder();
|
||||
status_t result = getDisplayInfo(display, &info);
|
||||
memcpy(reply->writeInplace(sizeof(DisplayInfo)), &info, sizeof(DisplayInfo));
|
||||
reply->writeInt32(result);
|
||||
} break;
|
||||
|
|
|
@ -52,7 +52,6 @@ public:
|
|||
|
||||
virtual sp<ISurface> createSurface( surface_data_t* params,
|
||||
const String8& name,
|
||||
DisplayID display,
|
||||
uint32_t w,
|
||||
uint32_t h,
|
||||
PixelFormat format,
|
||||
|
@ -61,7 +60,6 @@ public:
|
|||
Parcel data, reply;
|
||||
data.writeInterfaceToken(ISurfaceComposerClient::getInterfaceDescriptor());
|
||||
data.writeString8(name);
|
||||
data.writeInt32(display);
|
||||
data.writeInt32(w);
|
||||
data.writeInt32(h);
|
||||
data.writeInt32(format);
|
||||
|
@ -93,12 +91,11 @@ status_t BnSurfaceComposerClient::onTransact(
|
|||
CHECK_INTERFACE(ISurfaceComposerClient, data, reply);
|
||||
surface_data_t params;
|
||||
String8 name = data.readString8();
|
||||
DisplayID display = data.readInt32();
|
||||
uint32_t w = data.readInt32();
|
||||
uint32_t h = data.readInt32();
|
||||
PixelFormat format = data.readInt32();
|
||||
uint32_t flags = data.readInt32();
|
||||
sp<ISurface> s = createSurface(¶ms, name, display, w, h,
|
||||
sp<ISurface> s = createSurface(¶ms, name, w, h,
|
||||
format, flags);
|
||||
params.writeToParcel(reply);
|
||||
reply->writeStrongBinder(s->asBinder());
|
||||
|
|
|
@ -92,6 +92,12 @@ bool SurfaceControl::isSameSurface(
|
|||
return lhs->mSurface->asBinder() == rhs->mSurface->asBinder();
|
||||
}
|
||||
|
||||
status_t SurfaceControl::setLayerStack(int32_t layerStack) {
|
||||
status_t err = validate();
|
||||
if (err < 0) return err;
|
||||
const sp<SurfaceComposerClient>& client(mClient);
|
||||
return client->setLayerStack(mToken, layerStack);
|
||||
}
|
||||
status_t SurfaceControl::setLayer(int32_t layer) {
|
||||
status_t err = validate();
|
||||
if (err < 0) return err;
|
||||
|
@ -299,8 +305,11 @@ void Surface::init(const sp<ISurfaceTexture>& surfaceTexture)
|
|||
setUsage(GraphicBuffer::USAGE_HW_RENDER);
|
||||
}
|
||||
|
||||
// TODO: the display metrics should come from the display manager
|
||||
DisplayInfo dinfo;
|
||||
SurfaceComposerClient::getDisplayInfo(0, &dinfo);
|
||||
sp<IBinder> display = SurfaceComposerClient::getBuiltInDisplay(
|
||||
ISurfaceComposer::eDisplayIdMain);
|
||||
SurfaceComposerClient::getDisplayInfo(display, &dinfo);
|
||||
const_cast<float&>(ANativeWindow::xdpi) = dinfo.xdpi;
|
||||
const_cast<float&>(ANativeWindow::ydpi) = dinfo.ydpi;
|
||||
const_cast<uint32_t&>(ANativeWindow::flags) = 0;
|
||||
|
|
|
@ -94,6 +94,7 @@ class Composer : public Singleton<Composer>
|
|||
|
||||
public:
|
||||
sp<IBinder> createDisplay();
|
||||
sp<IBinder> getBuiltInDisplay(int32_t id);
|
||||
|
||||
status_t setPosition(const sp<SurfaceComposerClient>& client, SurfaceID id,
|
||||
float x, float y);
|
||||
|
@ -135,6 +136,10 @@ sp<IBinder> Composer::createDisplay() {
|
|||
return ComposerService::getComposerService()->createDisplay();
|
||||
}
|
||||
|
||||
sp<IBinder> Composer::getBuiltInDisplay(int32_t id) {
|
||||
return ComposerService::getComposerService()->getBuiltInDisplay(id);
|
||||
}
|
||||
|
||||
void Composer::closeGlobalTransactionImpl(bool synchronous) {
|
||||
sp<ISurfaceComposer> sm(ComposerService::getComposerService());
|
||||
|
||||
|
@ -402,26 +407,8 @@ void SurfaceComposerClient::dispose() {
|
|||
mStatus = NO_INIT;
|
||||
}
|
||||
|
||||
sp<SurfaceControl> SurfaceComposerClient::createSurface(
|
||||
DisplayID display,
|
||||
uint32_t w,
|
||||
uint32_t h,
|
||||
PixelFormat format,
|
||||
uint32_t flags)
|
||||
{
|
||||
String8 name;
|
||||
const size_t SIZE = 128;
|
||||
char buffer[SIZE];
|
||||
snprintf(buffer, SIZE, "<pid_%d>", getpid());
|
||||
name.append(buffer);
|
||||
|
||||
return SurfaceComposerClient::createSurface(name, display,
|
||||
w, h, format, flags);
|
||||
}
|
||||
|
||||
sp<SurfaceControl> SurfaceComposerClient::createSurface(
|
||||
const String8& name,
|
||||
DisplayID display,
|
||||
uint32_t w,
|
||||
uint32_t h,
|
||||
PixelFormat format,
|
||||
|
@ -431,7 +418,7 @@ sp<SurfaceControl> SurfaceComposerClient::createSurface(
|
|||
if (mStatus == NO_ERROR) {
|
||||
ISurfaceComposerClient::surface_data_t data;
|
||||
sp<ISurface> surface = mClient->createSurface(&data, name,
|
||||
display, w, h, format, flags);
|
||||
w, h, format, flags);
|
||||
if (surface != 0) {
|
||||
result = new SurfaceControl(this, surface, data);
|
||||
}
|
||||
|
@ -443,6 +430,10 @@ sp<IBinder> SurfaceComposerClient::createDisplay() {
|
|||
return Composer::getInstance().createDisplay();
|
||||
}
|
||||
|
||||
sp<IBinder> SurfaceComposerClient::getBuiltInDisplay(int32_t id) {
|
||||
return Composer::getInstance().getBuiltInDisplay(id);
|
||||
}
|
||||
|
||||
status_t SurfaceComposerClient::destroySurface(SurfaceID sid) {
|
||||
if (mStatus != NO_ERROR)
|
||||
return mStatus;
|
||||
|
@ -517,12 +508,6 @@ status_t SurfaceComposerClient::setMatrix(SurfaceID id, float dsdx, float dtdx,
|
|||
return getComposer().setMatrix(this, id, dsdx, dtdx, dsdy, dtdy);
|
||||
}
|
||||
|
||||
status_t SurfaceComposerClient::setOrientation(DisplayID dpy,
|
||||
int orientation, uint32_t flags)
|
||||
{
|
||||
return Composer::getInstance().setOrientation(orientation);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void SurfaceComposerClient::setDisplaySurface(const sp<IBinder>& token,
|
||||
|
@ -553,9 +538,9 @@ void SurfaceComposerClient::setDisplayFrame(const sp<IBinder>& token,
|
|||
// ----------------------------------------------------------------------------
|
||||
|
||||
status_t SurfaceComposerClient::getDisplayInfo(
|
||||
DisplayID dpy, DisplayInfo* info)
|
||||
const sp<IBinder>& display, DisplayInfo* info)
|
||||
{
|
||||
return ComposerService::getComposerService()->getDisplayInfo(dpy, info);
|
||||
return ComposerService::getComposerService()->getDisplayInfo(display, info);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -564,30 +549,32 @@ ScreenshotClient::ScreenshotClient()
|
|||
: mWidth(0), mHeight(0), mFormat(PIXEL_FORMAT_NONE) {
|
||||
}
|
||||
|
||||
status_t ScreenshotClient::update() {
|
||||
status_t ScreenshotClient::update(const sp<IBinder>& display) {
|
||||
sp<ISurfaceComposer> s(ComposerService::getComposerService());
|
||||
if (s == NULL) return NO_INIT;
|
||||
mHeap = 0;
|
||||
return s->captureScreen(0, &mHeap,
|
||||
return s->captureScreen(display, &mHeap,
|
||||
&mWidth, &mHeight, &mFormat, 0, 0,
|
||||
0, -1UL);
|
||||
}
|
||||
|
||||
status_t ScreenshotClient::update(uint32_t reqWidth, uint32_t reqHeight) {
|
||||
status_t ScreenshotClient::update(const sp<IBinder>& display,
|
||||
uint32_t reqWidth, uint32_t reqHeight) {
|
||||
sp<ISurfaceComposer> s(ComposerService::getComposerService());
|
||||
if (s == NULL) return NO_INIT;
|
||||
mHeap = 0;
|
||||
return s->captureScreen(0, &mHeap,
|
||||
return s->captureScreen(display, &mHeap,
|
||||
&mWidth, &mHeight, &mFormat, reqWidth, reqHeight,
|
||||
0, -1UL);
|
||||
}
|
||||
|
||||
status_t ScreenshotClient::update(uint32_t reqWidth, uint32_t reqHeight,
|
||||
status_t ScreenshotClient::update(const sp<IBinder>& display,
|
||||
uint32_t reqWidth, uint32_t reqHeight,
|
||||
uint32_t minLayerZ, uint32_t maxLayerZ) {
|
||||
sp<ISurfaceComposer> s(ComposerService::getComposerService());
|
||||
if (s == NULL) return NO_INIT;
|
||||
mHeap = 0;
|
||||
return s->captureScreen(0, &mHeap,
|
||||
return s->captureScreen(display, &mHeap,
|
||||
&mWidth, &mHeight, &mFormat, reqWidth, reqHeight,
|
||||
minLayerZ, maxLayerZ);
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ protected:
|
|||
ASSERT_EQ(NO_ERROR, mComposerClient->initCheck());
|
||||
|
||||
mSurfaceControl = mComposerClient->createSurface(
|
||||
String8("Test Surface"), 0,
|
||||
String8("Test Surface"),
|
||||
getSurfaceWidth(), getSurfaceHeight(),
|
||||
PIXEL_FORMAT_RGB_888, 0);
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ protected:
|
|||
ASSERT_EQ(NO_ERROR, mComposerClient->initCheck());
|
||||
|
||||
mSurfaceControl = mComposerClient->createSurface(
|
||||
String8("Test Surface"), 0, 32, 32, PIXEL_FORMAT_RGBA_8888, 0);
|
||||
String8("Test Surface"), 32, 32, PIXEL_FORMAT_RGBA_8888, 0);
|
||||
|
||||
ASSERT_TRUE(mSurfaceControl != NULL);
|
||||
ASSERT_TRUE(mSurfaceControl->isValid());
|
||||
|
@ -85,7 +85,8 @@ TEST_F(SurfaceTest, ScreenshotsOfProtectedBuffersSucceed) {
|
|||
uint32_t w=0, h=0;
|
||||
PixelFormat fmt=0;
|
||||
sp<ISurfaceComposer> sf(ComposerService::getComposerService());
|
||||
ASSERT_EQ(NO_ERROR, sf->captureScreen(0, &heap, &w, &h, &fmt, 64, 64, 0,
|
||||
sp<IBinder> display(sf->getBuiltInDisplay(ISurfaceComposer::eDisplayIdMain));
|
||||
ASSERT_EQ(NO_ERROR, sf->captureScreen(display, &heap, &w, &h, &fmt, 64, 64, 0,
|
||||
0x7fffffff));
|
||||
ASSERT_TRUE(heap != NULL);
|
||||
|
||||
|
@ -117,7 +118,7 @@ TEST_F(SurfaceTest, ScreenshotsOfProtectedBuffersSucceed) {
|
|||
}
|
||||
heap = 0;
|
||||
w = h = fmt = 0;
|
||||
ASSERT_EQ(NO_ERROR, sf->captureScreen(0, &heap, &w, &h, &fmt,
|
||||
ASSERT_EQ(NO_ERROR, sf->captureScreen(display, &heap, &w, &h, &fmt,
|
||||
64, 64, 0, 0x7fffffff));
|
||||
ASSERT_TRUE(heap != NULL);
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ status_t Client::onTransact(
|
|||
sp<ISurface> Client::createSurface(
|
||||
ISurfaceComposerClient::surface_data_t* params,
|
||||
const String8& name,
|
||||
DisplayID display, uint32_t w, uint32_t h, PixelFormat format,
|
||||
uint32_t w, uint32_t h, PixelFormat format,
|
||||
uint32_t flags)
|
||||
{
|
||||
/*
|
||||
|
@ -125,7 +125,6 @@ sp<ISurface> Client::createSurface(
|
|||
ISurfaceComposerClient::surface_data_t* params;
|
||||
Client* client;
|
||||
const String8& name;
|
||||
DisplayID display;
|
||||
uint32_t w, h;
|
||||
PixelFormat format;
|
||||
uint32_t flags;
|
||||
|
@ -133,22 +132,23 @@ sp<ISurface> Client::createSurface(
|
|||
MessageCreateLayer(SurfaceFlinger* flinger,
|
||||
ISurfaceComposerClient::surface_data_t* params,
|
||||
const String8& name, Client* client,
|
||||
DisplayID display, uint32_t w, uint32_t h, PixelFormat format,
|
||||
uint32_t w, uint32_t h, PixelFormat format,
|
||||
uint32_t flags)
|
||||
: flinger(flinger), params(params), client(client), name(name),
|
||||
display(display), w(w), h(h), format(format), flags(flags)
|
||||
w(w), h(h), format(format), flags(flags)
|
||||
{
|
||||
}
|
||||
sp<ISurface> getResult() const { return result; }
|
||||
virtual bool handler() {
|
||||
// TODO don't require display id to create a layer
|
||||
result = flinger->createLayer(params, name, client,
|
||||
display, w, h, format, flags);
|
||||
ISurfaceComposer::eDisplayIdMain, w, h, format, flags);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
sp<MessageBase> msg = new MessageCreateLayer(mFlinger.get(),
|
||||
params, name, this, display, w, h, format, flags);
|
||||
params, name, this, w, h, format, flags);
|
||||
mFlinger->postMessageSync(msg);
|
||||
return static_cast<MessageCreateLayer*>( msg.get() )->getResult();
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ private:
|
|||
// ISurfaceComposerClient interface
|
||||
virtual sp<ISurface> createSurface(
|
||||
surface_data_t* params, const String8& name,
|
||||
DisplayID display, uint32_t w, uint32_t h,PixelFormat format,
|
||||
uint32_t w, uint32_t h,PixelFormat format,
|
||||
uint32_t flags);
|
||||
|
||||
virtual status_t destroySurface(SurfaceID surfaceId);
|
||||
|
|
|
@ -511,9 +511,11 @@ bool SurfaceFlinger::authenticateSurfaceTexture(
|
|||
return false;
|
||||
}
|
||||
|
||||
status_t SurfaceFlinger::getDisplayInfo(DisplayID dpy, DisplayInfo* info) {
|
||||
// TODO: this is here only for compatibility -- should go away eventually.
|
||||
if (uint32_t(dpy) >= 1) {
|
||||
status_t SurfaceFlinger::getDisplayInfo(const sp<IBinder>& display, DisplayInfo* info) {
|
||||
// TODO: this is mostly here only for compatibility
|
||||
// the display size is needed but the display metrics should come from elsewhere
|
||||
if (display != mDefaultDisplays[ISurfaceComposer::eDisplayIdMain]) {
|
||||
// TODO: additional displays not yet supported
|
||||
return BAD_INDEX;
|
||||
}
|
||||
|
||||
|
@ -570,7 +572,7 @@ sp<IDisplayEventConnection> SurfaceFlinger::createDisplayEventConnection() {
|
|||
return mEventThread->createEventConnection();
|
||||
}
|
||||
|
||||
void SurfaceFlinger::connectDisplay(const sp<ISurfaceTexture> surface) {
|
||||
void SurfaceFlinger::connectDisplay(const sp<ISurfaceTexture>& surface) {
|
||||
|
||||
sp<IBinder> token;
|
||||
{ // scope for the lock
|
||||
|
@ -2242,7 +2244,7 @@ status_t SurfaceFlinger::renderScreenToTextureLocked(DisplayID dpy,
|
|||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
status_t SurfaceFlinger::captureScreenImplLocked(DisplayID dpy,
|
||||
status_t SurfaceFlinger::captureScreenImplLocked(const sp<IBinder>& display,
|
||||
sp<IMemoryHeap>* heap,
|
||||
uint32_t* w, uint32_t* h, PixelFormat* f,
|
||||
uint32_t sw, uint32_t sh,
|
||||
|
@ -2252,9 +2254,8 @@ status_t SurfaceFlinger::captureScreenImplLocked(DisplayID dpy,
|
|||
|
||||
status_t result = PERMISSION_DENIED;
|
||||
|
||||
// only one display supported for now
|
||||
if (CC_UNLIKELY(uint32_t(dpy) >= DISPLAY_COUNT)) {
|
||||
ALOGE("invalid display %d", dpy);
|
||||
const DisplayDeviceState& disp(mDrawingState.displays.valueFor(display));
|
||||
if (CC_UNLIKELY(disp.id < 0)) {
|
||||
return BAD_VALUE;
|
||||
}
|
||||
|
||||
|
@ -2263,7 +2264,7 @@ status_t SurfaceFlinger::captureScreenImplLocked(DisplayID dpy,
|
|||
}
|
||||
|
||||
// get screen geometry
|
||||
sp<const DisplayDevice> hw(getDisplayDevice(dpy));
|
||||
sp<const DisplayDevice> hw(getDisplayDevice(disp.id));
|
||||
const uint32_t hw_w = hw->getWidth();
|
||||
const uint32_t hw_h = hw->getHeight();
|
||||
|
||||
|
@ -2316,6 +2317,7 @@ status_t SurfaceFlinger::captureScreenImplLocked(DisplayID dpy,
|
|||
glClearColor(0,0,0,1);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
// TODO: filter the layers that are drawn based on the layer stack of the display.
|
||||
const LayerVector& layers(mDrawingState.layersSortedByZ);
|
||||
const size_t count = layers.size();
|
||||
for (size_t i=0 ; i<count ; ++i) {
|
||||
|
@ -2377,14 +2379,13 @@ status_t SurfaceFlinger::captureScreenImplLocked(DisplayID dpy,
|
|||
}
|
||||
|
||||
|
||||
status_t SurfaceFlinger::captureScreen(DisplayID dpy,
|
||||
status_t SurfaceFlinger::captureScreen(const sp<IBinder>& display,
|
||||
sp<IMemoryHeap>* heap,
|
||||
uint32_t* width, uint32_t* height, PixelFormat* format,
|
||||
uint32_t sw, uint32_t sh,
|
||||
uint32_t minLayerZ, uint32_t maxLayerZ)
|
||||
{
|
||||
// only one display supported for now
|
||||
if (CC_UNLIKELY(uint32_t(dpy) >= DISPLAY_COUNT))
|
||||
if (CC_UNLIKELY(display == 0))
|
||||
return BAD_VALUE;
|
||||
|
||||
if (!GLExtensions::getInstance().haveFramebufferObject())
|
||||
|
@ -2392,7 +2393,7 @@ status_t SurfaceFlinger::captureScreen(DisplayID dpy,
|
|||
|
||||
class MessageCaptureScreen : public MessageBase {
|
||||
SurfaceFlinger* flinger;
|
||||
DisplayID dpy;
|
||||
sp<IBinder> display;
|
||||
sp<IMemoryHeap>* heap;
|
||||
uint32_t* w;
|
||||
uint32_t* h;
|
||||
|
@ -2403,11 +2404,11 @@ status_t SurfaceFlinger::captureScreen(DisplayID dpy,
|
|||
uint32_t maxLayerZ;
|
||||
status_t result;
|
||||
public:
|
||||
MessageCaptureScreen(SurfaceFlinger* flinger, DisplayID dpy,
|
||||
MessageCaptureScreen(SurfaceFlinger* flinger, const sp<IBinder>& display,
|
||||
sp<IMemoryHeap>* heap, uint32_t* w, uint32_t* h, PixelFormat* f,
|
||||
uint32_t sw, uint32_t sh,
|
||||
uint32_t minLayerZ, uint32_t maxLayerZ)
|
||||
: flinger(flinger), dpy(dpy),
|
||||
: flinger(flinger), display(display),
|
||||
heap(heap), w(w), h(h), f(f), sw(sw), sh(sh),
|
||||
minLayerZ(minLayerZ), maxLayerZ(maxLayerZ),
|
||||
result(PERMISSION_DENIED)
|
||||
|
@ -2418,14 +2419,14 @@ status_t SurfaceFlinger::captureScreen(DisplayID dpy,
|
|||
}
|
||||
virtual bool handler() {
|
||||
Mutex::Autolock _l(flinger->mStateLock);
|
||||
result = flinger->captureScreenImplLocked(dpy,
|
||||
result = flinger->captureScreenImplLocked(display,
|
||||
heap, w, h, f, sw, sh, minLayerZ, maxLayerZ);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
sp<MessageBase> msg = new MessageCaptureScreen(this,
|
||||
dpy, heap, width, height, format, sw, sh, minLayerZ, maxLayerZ);
|
||||
display, heap, width, height, format, sw, sh, minLayerZ, maxLayerZ);
|
||||
status_t res = postMessageSync(msg);
|
||||
if (res == NO_ERROR) {
|
||||
res = static_cast<MessageCaptureScreen*>( msg.get() )->getResult();
|
||||
|
|
|
@ -195,7 +195,7 @@ private:
|
|||
virtual bool authenticateSurfaceTexture(
|
||||
const sp<ISurfaceTexture>& surface) const;
|
||||
virtual sp<IDisplayEventConnection> createDisplayEventConnection();
|
||||
virtual status_t captureScreen(DisplayID dpy, sp<IMemoryHeap>* heap,
|
||||
virtual status_t captureScreen(const sp<IBinder>& display, sp<IMemoryHeap>* heap,
|
||||
uint32_t* width, uint32_t* height, PixelFormat* format,
|
||||
uint32_t reqWidth, uint32_t reqHeight, uint32_t minLayerZ,
|
||||
uint32_t maxLayerZ);
|
||||
|
@ -203,8 +203,8 @@ private:
|
|||
virtual void blank();
|
||||
// called when screen is turning back on
|
||||
virtual void unblank();
|
||||
virtual status_t getDisplayInfo(DisplayID dpy, DisplayInfo* info);
|
||||
virtual void connectDisplay(const sp<ISurfaceTexture> display);
|
||||
virtual status_t getDisplayInfo(const sp<IBinder>& display, DisplayInfo* info);
|
||||
virtual void connectDisplay(const sp<ISurfaceTexture>& display);
|
||||
|
||||
/* ------------------------------------------------------------------------
|
||||
* DeathRecipient interface
|
||||
|
@ -304,7 +304,7 @@ private:
|
|||
|
||||
void startBootAnim();
|
||||
|
||||
status_t captureScreenImplLocked(DisplayID dpy, sp<IMemoryHeap>* heap,
|
||||
status_t captureScreenImplLocked(const sp<IBinder>& display, sp<IMemoryHeap>* heap,
|
||||
uint32_t* width, uint32_t* height, PixelFormat* format,
|
||||
uint32_t reqWidth, uint32_t reqHeight, uint32_t minLayerZ,
|
||||
uint32_t maxLayerZ);
|
||||
|
|
|
@ -57,7 +57,8 @@ public:
|
|||
uint32_t w=0, h=0;
|
||||
PixelFormat fmt=0;
|
||||
sp<ISurfaceComposer> sf(ComposerService::getComposerService());
|
||||
ASSERT_EQ(NO_ERROR, sf->captureScreen(0, &heap, &w, &h, &fmt, 0, 0,
|
||||
sp<IBinder> display(sf->getBuiltInDisplay(ISurfaceComposer::eDisplayIdMain));
|
||||
ASSERT_EQ(NO_ERROR, sf->captureScreen(display, &heap, &w, &h, &fmt, 0, 0,
|
||||
0, INT_MAX));
|
||||
ASSERT_TRUE(heap != NULL);
|
||||
ASSERT_EQ(PIXEL_FORMAT_RGBA_8888, fmt);
|
||||
|
@ -93,15 +94,17 @@ protected:
|
|||
mComposerClient = new SurfaceComposerClient;
|
||||
ASSERT_EQ(NO_ERROR, mComposerClient->initCheck());
|
||||
|
||||
sp<IBinder> display(SurfaceComposerClient::getBuiltInDisplay(
|
||||
ISurfaceComposer::eDisplayIdMain));
|
||||
DisplayInfo info;
|
||||
SurfaceComposerClient::getDisplayInfo(0, &info);
|
||||
SurfaceComposerClient::getDisplayInfo(display, &info);
|
||||
|
||||
ssize_t displayWidth = info.w;
|
||||
ssize_t displayHeight = info.h;
|
||||
|
||||
// Background surface
|
||||
mBGSurfaceControl = mComposerClient->createSurface(
|
||||
String8("BG Test Surface"), 0, displayWidth, displayHeight,
|
||||
String8("BG Test Surface"), displayWidth, displayHeight,
|
||||
PIXEL_FORMAT_RGBA_8888, 0);
|
||||
ASSERT_TRUE(mBGSurfaceControl != NULL);
|
||||
ASSERT_TRUE(mBGSurfaceControl->isValid());
|
||||
|
@ -109,7 +112,7 @@ protected:
|
|||
|
||||
// Foreground surface
|
||||
mFGSurfaceControl = mComposerClient->createSurface(
|
||||
String8("FG Test Surface"), 0, 64, 64, PIXEL_FORMAT_RGBA_8888, 0);
|
||||
String8("FG Test Surface"), 64, 64, PIXEL_FORMAT_RGBA_8888, 0);
|
||||
ASSERT_TRUE(mFGSurfaceControl != NULL);
|
||||
ASSERT_TRUE(mFGSurfaceControl->isValid());
|
||||
|
||||
|
@ -117,7 +120,7 @@ protected:
|
|||
|
||||
// Synchronization surface
|
||||
mSyncSurfaceControl = mComposerClient->createSurface(
|
||||
String8("Sync Test Surface"), 0, 1, 1, PIXEL_FORMAT_RGBA_8888, 0);
|
||||
String8("Sync Test Surface"), 1, 1, PIXEL_FORMAT_RGBA_8888, 0);
|
||||
ASSERT_TRUE(mSyncSurfaceControl != NULL);
|
||||
ASSERT_TRUE(mSyncSurfaceControl->isValid());
|
||||
|
||||
|
|
|
@ -38,8 +38,8 @@ int main(int argc, char** argv)
|
|||
// create a client to surfaceflinger
|
||||
sp<SurfaceComposerClient> client = new SurfaceComposerClient();
|
||||
|
||||
sp<Surface> surface = client->createSurface(0, 160, 240,
|
||||
PIXEL_FORMAT_RGB_565);
|
||||
sp<Surface> surface = client->createSurface(String8("resize"),
|
||||
160, 240, PIXEL_FORMAT_RGB_565, 0);
|
||||
|
||||
|
||||
SurfaceComposerClient::openGlobalTransaction();
|
||||
|
|
|
@ -42,7 +42,8 @@ int main(int argc, char** argv)
|
|||
sp<IMemoryHeap> heap;
|
||||
uint32_t w, h;
|
||||
PixelFormat f;
|
||||
status_t err = composer->captureScreen(0, &heap, &w, &h, &f, 0, 0);
|
||||
sp<IBinder> display(composer->getBuiltInDisplay(ISurfaceComposer::eDisplayIdMain));
|
||||
status_t err = composer->captureScreen(display, &heap, &w, &h, &f, 0, 0);
|
||||
if (err != NO_ERROR) {
|
||||
fprintf(stderr, "screen capture failed: %s\n", strerror(-err));
|
||||
exit(0);
|
||||
|
|
|
@ -37,7 +37,7 @@ int main(int argc, char** argv)
|
|||
sp<SurfaceComposerClient> client = new SurfaceComposerClient();
|
||||
|
||||
sp<SurfaceControl> surfaceControl = client->createSurface(
|
||||
0, 160, 240, PIXEL_FORMAT_RGB_565);
|
||||
String8("surface"), 160, 240, PIXEL_FORMAT_RGB_565, 0);
|
||||
SurfaceComposerClient::openGlobalTransaction();
|
||||
surfaceControl->setLayer(100000);
|
||||
SurfaceComposerClient::closeGlobalTransaction();
|
||||
|
|
Loading…
Reference in New Issue