When Android compiles surface C + + programs, an error is missing. o File

Source: Internet
Author: User
Tags set background

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.