Recently in the study of Android surface system, wrote a small demo, compile time. Always error, said is missing. o file, but look at the code has been no problem. Later found that the original was written under window, and then in the Linux compilation, suffix more ^m. So that leads to compilation just.
A similar error is actually prompted. There must have been a similar error in that piece of code. Do not know, check up can be exhausted, know very quickly can know how to check.
By the way, write the source code.
Testsurface.cpp
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <getopt.h>
#include <cutils/memory.h>
#include <native_window.h>
#include <utils/Log.h>
#include <binder/IPCThreadState.h>
#include <binder/ProcessState.h>
#include <binder/IServiceManager.h>
#include <ui/GraphicBuffer.h>
#include <gui/Surface.h>
#include <gui/ISurfaceComposer.h>
#include <gui/SurfaceComposerClient.h>
#include <cutils/properties.h>
#include <ui/DisplayInfo.h>
using namespace Android;
int main (int argv,char *argc[])
{
sp<processstate> proc (processstate::self ());
Processstate::self ()->startthreadpool ();
sp<surfacecomposerclient> client = new Surfacecomposerclient ();
sp<surfacecontrol> Surfacecontrol = Client->createsurface (String8 ("Testsurface"), Pixel_format_ rgbx_8888, 0);
DisplayInfo Dinfo;
sp<ibinder> display = Surfacecomposerclient::getbuiltindisplay (
Isurfacecomposer::edisplayidmain);
Surfacecomposerclient::getdisplayinfo (display, &dinfo);
uint32_t DISPW = DINFO.W;
uint32_t DISPH = dinfo.h;
/* Create backgound surface */
sp<surfacecontrol> Bg_surfacecontrol = Client->createsurface (
String8 ("Test-bg-surface"), DISPW, DISPH, pixel_format_rgbx_8888);
sp<surface> bg_surface = Bg_surfacecontrol->getsurface ();
/* Set Background layer Z-order */
Surfacecomposerclient::openglobaltransaction ();
Bg_surfacecontrol->setlayer (200000);
Surfacecomposerclient::closeglobaltransaction ();
/* Clear Background layer Black */
Anativewindow_buffer Outbuffer;
Bg_surface->lock (&outbuffer, NULL);
ssize_t BPR = outbuffer.stride * Bytesperpixel (Outbuffer.format);
Android_memset32 ((uint32_t*) outbuffer.bits, 0xff000000, BPR * outbuffer.height);
Bg_surface->unlockandpost ();
Sleep (5);
Bg_surface->lock (&outbuffer, NULL);
BPR = Outbuffer.stride * Bytesperpixel (Outbuffer.format);
Android_memset32 ((uint32_t*) outbuffer.bits, 0xf800, BPR * outbuffer.height);
Bg_surface->unlockandpost ();
Sleep (5);
Bg_surface->lock (&outbuffer, NULL);
BPR = Outbuffer.stride * Bytesperpixel (Outbuffer.format);
Android_memset32 ((uint32_t*) outbuffer.bits, 0x7e56, BPR * outbuffer.height);
Bg_surface->unlockandpost ();
Sleep (5);
return 0;
}
Android.mk
Local_path:= $ (call My-dir)
Include $ (clear_vars)
local_src_files:= Testsurface.cpp
Local_c_includes: = external/skia/include/core \
Frameworks/native/include/android
Local_shared_libraries: = libcutils \
Libutils \
Libbinder \
Libui \
Libgui \
local_module:= Testsurface
Local_module_tags: = Tests
Include $ (build_executable)
When Android compiles surface C + + programs, an error is missing. o File