SurfaceComposerClient::createSurface() returns NULL

1,138 views
Skip to first unread message

roy.be...@googlemail.com

unread,
Dec 28, 2008, 10:49:51 AM12/28/08
to android-platform
Hi,
I'm trying to create a Surface, using SurfaceComposerClient, and to
render to the screen using Skia.
However, SurfaceComposerClient::createSurface() always returns NULL...
Is there anything you can spot that is wrong or something missing in
the below code snippet?
(If you can point to a working example, that would be much
appreciated.

Thanks!


sp<SurfaceComposerClient> client = new SurfaceComposerClient();

printf("number =%d \n", client->getNumberOfDisplays());
DisplayInfo dispInfo;
client->getDisplayInfo(0,&dispInfo);
printf("w =%d h=%d format =%d [vs %d] \n", dispInfo.w, dispInfo.h,
dispInfo.pixelFormatInfo.format, PIXEL_FORMAT_RGB_565);

int ok = client->initCheck();
printf("initCheck %d [%d]\n", ok, NO_ERROR);

sp<Surface> surface1 = client->createSurface(getpid(),
0/*dpy*/,
dispInfo.w, dispInfo.h,

dispInfo.pixelFormatInfo.format,
0); //create a surface
//Here is where the problems start.... the surface is alway
NULL
if(surface1 == NULL){
printf("surface1 == NULL\n"); //sadly, this is always printed...
}

hanchao3c

unread,
Dec 29, 2008, 1:05:12 AM12/29/08
to android-platform
In fact the SurfaceComposerClient now is implement by SurfaceFlinger:
frameworks/base/libs/surfaceflinger/

The current calling processing for create an Surface:



SurfaceComposerClient::createSurface (ISurface → Suface)
→ (IsurfaceFlingerClient:: createSurface)
→ Bclient::createSurface (It is in
SurfaceFlinger code)
→ SurfaceFlinger::createSurface
(Then create the true Surface)
LayerBaseClient* layer = 0;
sp<LayerBaseClient::Surface> surfaceHandle;
eFXSurfaceNormal → Layer or LayerBuffer
eFXSurfaceBlur → LayerBlur
eFXSurfaceDim → LayerDim
surfaceHandle = layer->getSurface();


Now SurfaceComposerClient is used by Surface JNI code , you can refer:
frameworks/base/core/jni/android_view_Surface.cpp



Could you tell you why you need "new" a SurfaceComposerClient by
yourself.

hanchao3c

unread,
Dec 29, 2008, 1:13:22 AM12/29/08
to android-platform
In this header file :
frameworks/base/include/ui/ISurfaceComposer.h
enum { // (keep in sync with Surface.java)
eHidden = 0x00000004,
eGPU = 0x00000008,
eHardware = 0x00000010,
eDestroyBackbuffer = 0x00000020,
eSecure = 0x00000080,
eNonPremultiplied = 0x00000100,
ePushBuffers = 0x00000200,

eFXSurfaceNormal = 0x00000000,
eFXSurfaceBlur = 0x00010000,
eFXSurfaceDim = 0x00020000,
eFXSurfaceMask = 0x000F0000,
};

This value is control to Create which Surface , The implement is
different in SurfaceFlinger: ( framework/base/libs/surfaceflinger/
SurfaceFlinger.cpp)

roy.be...@googlemail.com

unread,
Dec 30, 2008, 5:53:36 AM12/30/08
to android-platform
Hi,
I am playing with running native applications on Android (yes, I know
it is now supported.. but this is so much fun :-).

I admit I couldn't understand how to use your explanation on the
underlying work - what do I need to do differently from the code I
submitted?
(BTW, the code I use is indeed from android_view_Surface.cpp , as you
suggested)

Thanks

roy.be...@googlemail.com

unread,
Dec 30, 2008, 6:03:15 AM12/30/08
to android-platform
One more piece of information, that might be important - Looking at
the printed warnings, I see "W/Parcel ( 286): Attempt to read object
from Parcel 0xbeb7a910 at offset 0 that is not in the object list".

Is this directly related, or is it just an indirect symptom happening
down the stream?

Jean-Baptiste Queru

unread,
Dec 30, 2008, 10:57:33 AM12/30/08
to android-...@googlegroups.com
This discussion should move to the android-discuss mailing list, so
that the android-platform list can stay focused on discussing changes
to the platform itself.

Thanks,
JBQ


--
Jean-Baptiste M. "JBQ" Queru
Android Engineer, Google.

freepine

unread,
Jan 7, 2009, 1:14:45 AM1/7/09
to android-...@googlegroups.com
Are you using android source code from 1.0 release? I've met this issue before.

It seems there was a bug of frameworks/base/libs/ui/ISurfaceFlingerClient.cpp in 1.0 release which was already resolved in cupcake branch. It works for me now with the fix from cupcake.

@@ -82,7 +82,7 @@ public:
         data.writeInt32(format);
         data.writeInt32(flags);
         remote()->transact(CREATE_SURFACE, data, &reply);
-        params->readFromParcel(data);
+        params->readFromParcel(reply);
         return interface_cast<ISurface>(reply.readStrongBinder());

hanchao3c

unread,
Jan 7, 2009, 1:39:01 AM1/7/09
to android-platform
oh.
The interface has some issue.
It is not an standard method.

On Jan 7, 2:14 pm, freepine <freep...@gmail.com> wrote:
> Are you using android source code from 1.0 release? I've met this issue
> before.
> It seems there was a bug of
> frameworks/base/libs/ui/ISurfaceFlingerClient.cpp in 1.0 release which was
> already resolved in cupcake branch. It works for me now with the fix from
> cupcake.
>
> --- a/libs/ui/ISurfaceFlingerClient.cpp<http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;...>
> +++ b/libs/ui/ISurfaceFlingerClient.cpp<http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;...>
> @@ -82,7<http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;...>
> +82,7<http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;...>@@
>  public:
>          data.writeInt32(format);
>          data.writeInt32(flags);
>          remote()->transact(CREATE_SURFACE, data, &reply);
> -        params->readFromParcel(data);
> +        params->readFromParcel(reply);
>          return interface_cast<ISurface>(reply.readStrongBinder());
>
> On Tue, Dec 30, 2008 at 7:03 PM, roy.vi...@googlemail.com <

freepine

unread,
Jan 7, 2009, 1:48:57 AM1/7/09
to android-...@googlegroups.com
Yes, it's just for test purpose and I am satisfied with it as long as PV can construct node graph and start data flow successfully:)

I guess it was a typo while implementing it, but I am really curious that API demo can play video successfully with 1.0 SDK.

-freepine
Reply all
Reply to author
Forward
0 new messages