ADROID 2.1 架构解析 12 图形系统 1 Pixelflinger

Android GUI 系列之Surfaceflinger Android回炉系列之Surfaceflinger 前言 很早开始就有想写写博客的想法,毕竟好记心不如烂笔头,这段时间公司业务要求,对音视频、渲染等要有深度理解,突然之间发现自己脑袋是空空的,没办法就只有系统性的回炉一遍,同时也做好存档,以便于后期的复习、升华做铺垫!好了废话不多说了。我们首先从界面绘制渲染开始,竟然是绘制那么针对我们Android系统而言我们是怎么把视图呈现给用户的呢?带着这个疑惑,我们就从surfaceflinger开始一一解析。 一、Surfaceflinger是什么? 通过查阅 阅读详情

1 Pixelflinger

1.1 Pixelflinger 简介

Pixelflinger是Android系统中为OpenGLES引擎提供的一套软件渲染器(renderer)。OpenGLES引擎提供了一系列基础绘图功能。这些功能包括定义各种颜色格式像素位置、画点画线、绘制矩形及三角形、填充纹理等等。由于OpenGLES相当于一个状态机,配置OpenGLEs状态的函数也均由Pixelflinger提供。

Pixelflinger涉及到的代码路径:

system/core/libpixelflinger

system/core/include/libpixelflinger

system/core/include/private/pixelflinger

1.2 Pixelflinger生成的库

libpixelflinger_armv6.a

libpixelflinger_static.a

libpixelflinger.so

1.3 Pixelflinger两大数据结构

1.3.1 context_t 结构

该结构是Pixelflinger的主结构,里面含有GGLContext接口结构和state、format等属性。

system/core/include/private/pixelflinger/ggl_context.h

struct context_t {

GGLContext procs;

state_t state;

shade_t shade;

iterators_t iterators;

generated_vars_t generated_vars __attribute__((aligned(32)));

uint8_t ditherMatrix[GGL_DITHER_SIZE] __attribute__((aligned(32)));

uint32_t packed;

uint32_t packed8888;

const GGLFormat* formats;

uint32_t dirty;

texture_t* activeTMU;

uint32_t activeTMUIndex;



void (*init_y)(context_t* c, int32_t y);

void (*step_y)(context_t* c);

void (*scanline)(context_t* c);

void (*span)(context_t* c);

void (*rect)(context_t* c, size_t yc);

void* base;

Assembly* scanline_as;

GGLenum error;

};

1.3.2 GGLContext 结构

Pixelflinger对外是用GGLContext结构提供接口引用的,如下是GGLContext结构形式。

system/core/include/pixelflinger/pixelflinger.h

typedef struct {

// immediate rendering

void (*pointx)(void *con,const GGLcoord* v, GGLcoord r);

void (*linex)(void *con,

const GGLcoord*v0, const GGLcoord* v1, GGLcoord width);

void (*recti)(void* c,GGLint l, GGLint t, GGLint r, GGLint b);

void (*trianglex)(void* c,

GGLcoord const*v0, GGLcoord const* v1, GGLcoord const* v2);



// scissor

void (*scissor)(void* c,GGLint x, GGLint y, GGLsizei width, GGLsizei height);



// Set the textures andcolor buffers

void(*activeTexture)(void* c, GGLuint tmu);

void (*bindTexture)(void*c, const GGLSurface* surface);

void (*colorBuffer)(void*c, const GGLSurface* surface);

void (*readBuffer)(void*c, const GGLSurface* surface);

void (*depthBuffer)(void*c, const GGLSurface* surface);

void(*bindTextureLod)(void* c, GGLuint tmu, const GGLSurface* surface);



// enable/disable features

void (*enable)(void* c,GGLenum name);

void (*disable)(void* c,GGLenum name);

void(*enableDisable)(void* c, GGLenum name, GGLboolean en);



// specify the fragment'scolor

void (*shadeModel)(void*c, GGLenum mode);

void (*color4xv)(void* c,const GGLclampx* color);

// specify color iterators(16.16)

void(*colorGrad12xv)(void* c, const GGLcolor* grad);



// specify Z coordinateiterators (0.32)

void (*zGrad3xv)(void* c,const GGLfixed32* grad);



// specify W coordinateiterators (16.16)

void (*wGrad3xv)(void* c,const GGLfixed* grad);



// specify fog iterator &color (16.16)

void (*fogGrad3xv)(void*c, const GGLfixed* grad);

void (*fogColor3xv)(void*c, const GGLclampx* color);



// specify blendingparameters

void (*blendFunc)(void* c,GGLenum src, GGLenum dst);

void(*blendFuncSeparate)(void* c, GGLenum src, GGLenum dst,

GGLenumsrcAlpha, GGLenum dstAplha);



// texture environnement(REPLACE / MODULATE / DECAL / BLEND)

void (*texEnvi)(void* c, GGLenum target,

GGLenumpname,

GGLintparam);



void (*texEnvxv)(void* c,GGLenum target,

GGLenum pname,const GGLfixed* params);



// texture parameters(Wrapping, filter)

void(*texParameteri)(void* c, GGLenum target,

GGLenumpname,

GGLintparam);



// texture iterators(16.16)

void (*texCoord2i)(void*c, GGLint s, GGLint t);

void (*texCoord2x)(void*c, GGLfixed s, GGLfixed t);

// s, dsdx, dsdy, scale,t, dtdx, dtdy, tscale

// This api uses blockfloating-point for S and T texture coordinates.

// All values are given in16.16, scaled by 'scale'. In other words,

// set scale to 0, for16.16 values.

void(*texCoordGradScale8xv)(void* c, GGLint tmu, const int32_t* grad8);

void (*texGeni)(void* c,GGLenum coord, GGLenum pname, GGLint param);



// masking

void (*colorMask)(void* c, GGLboolean red,

GGLbooleangreen,

GGLbooleanblue,

GGLbooleanalpha);



void (*depthMask)(void* c,GGLboolean flag);



void (*stencilMask)(void*c, GGLuint mask);



// alpha func

void (*alphaFuncx)(void*c, GGLenum func, GGLclampx ref);



// depth func

void (*depthFunc)(void* c,GGLenum func);



// logic op

void (*logicOp)(void* c,GGLenum opcode);



// clear

void (*clear)(void* c,GGLbitfield mask);

void (*clearColorx)(void*c,

GGLclampx r,GGLclampx g, GGLclampx b, GGLclampx a);

void (*clearDepthx)(void*c, GGLclampx depth);

void (*clearStencil)(void*c, GGLint s);



// framebuffer operations

void (*copyPixels)(void*c, GGLint x, GGLint y,

GGLsizei width,GGLsizei height, GGLenum type);

void (*rasterPos2x)(void*c, GGLfixed x, GGLfixed y);

void (*rasterPos2i)(void*c, GGLint x, GGLint y);

} GGLContext;

1.4 Pixelflinger的引用和释放

下面是pixelflinger的初始化函数和释放函数

system/core/libpixelflinger/pixelflinger.cpp

ssize_t gglInit(GGLContext**context)

{

void* const base =malloc(sizeof(context_t) + 32);

if (base) {

// always align thecontext on cache lines

context_t *c =(context_t *)((ptrdiff_t(base)+31) & ~0x1FL);

ggl_init_context(c);

c->base = base;

*context = (GGLContext*)c;

} else {

return -1;

}

return 0;

}



ssize_t gglUninit(GGLContext*con)

{

GGL_CONTEXT(c,(void*)con);

ggl_uninit_context(c);

free(c->base);

return 0;

}



gglInit 和 gglUninit是初opengl引用的,它们分别被引用的位置如下:

frameworks/base/opengl/libagl/texture.cpp

GGLContext*getRasterizer(ogles_context_t* c)

{

GGLContext* ggl =c->textures.ggl;

..

gglInit(&ggl);

…

}



voidogles_uninit_texture(ogles_context_t* c)

{

if (c->textures.ggl)

gglUninit(c->textures.ggl);

…

}

1.5 Pixelflinger支持的像素格式

voidggl_init_context(context_t* c)

{

...

c->formats =gglGetPixelFormatTable();

…

}

formats 指向pixelformat支持的像素格式表,该表在下面文件里:

system/core/libpixelflinger/format.cpp

const GGLFormat*gglGetPixelFormatTable(size_t* numEntries)

{

if (numEntries) {

*numEntries =sizeof(android::gPixelFormatInfos)/sizeof(GGLFormat);

}

returnandroid::gPixelFormatInfos;

}

static GGLFormat constgPixelFormatInfos[] =

{ // Alpha Red Green Blue

{ 0, 0, {{ 0, 0, 0, 0, 0, 0, 0, 0 }}, 0 }, // PIXEL_FORMAT_NONE

{ 4, 32, {{32,24, 8, 0, 16, 8, 24,16 }}, GGL_RGBA }, // PIXEL_FORMAT_RGBA_8888

{ 4, 24, {{ 0, 0, 8, 0, 16, 8, 24,16 }}, GGL_RGB }, // PIXEL_FORMAT_RGBX_8888

{ 3, 24, {{ 0, 0, 8, 0, 16, 8, 24,16 }}, GGL_RGB }, // PIXEL_FORMAT_RGB_888

{ 2, 16, {{ 0, 0, 16,11, 11, 5, 5, 0 }}, GGL_RGB }, // PIXEL_FORMAT_RGB_565

{ 4, 32, {{32,24, 24,16, 16, 8, 8, 0 }}, GGL_RGBA }, // PIXEL_FORMAT_BGRA_8888

{ 2, 16, {{ 1, 0, 16,11, 11, 6, 6, 1 }}, GGL_RGBA }, // PIXEL_FORMAT_RGBA_5551

{ 2, 16, {{ 4, 0, 16,12, 12, 8, 8, 4 }}, GGL_RGBA }, // PIXEL_FORMAT_RGBA_4444

{ 1, 8, {{ 8, 0, 0, 0, 0, 0, 0, 0 }}, GGL_ALPHA}, // PIXEL_FORMAT_A8

{ 1, 8, {{ 0, 0, 8, 0, 8, 0, 8, 0 }}, GGL_LUMINANCE},//PIXEL_FORMAT_L8

{ 2, 16, {{16, 8, 8, 0, 8, 0, 8, 0 }}, GGL_LUMINANCE_ALPHA},// PIXEL_FORMAT_LA_88

{ 1, 8, {{ 0, 0, 8, 5, 5, 2, 2, 0 }}, GGL_RGB }, // PIXEL_FORMAT_RGB_332

{ 0, 0, {{ 0, 0, 0, 0, 0, 0, 0, 0 }}, 0 }, // PIXEL_FORMAT_NONE

{ 0, 0, {{ 0, 0, 0, 0, 0, 0, 0, 0 }}, 0 }, // PIXEL_FORMAT_NONE

{ 0, 0, {{ 0, 0, 0, 0, 0, 0, 0, 0 }}, 0 }, // PIXEL_FORMAT_NONE

{ 0, 0, {{ 0, 0, 0, 0, 0, 0, 0, 0 }}, 0 }, // PIXEL_FORMAT_NONE



{ 1, 16, {{ 0, 8, 0, 8, 0, 8, 0, 0 }}, GGL_Y_CB_CR_SP },// PIXEL_FORMAT_YCbCr_422_SP

{ 1, 12, {{ 0, 8, 0, 8, 0, 8, 0, 0 }}, GGL_Y_CB_CR_SP },// PIXEL_FORMAT_YCbCr_420_SP

{ 1, 16, {{ 0, 8, 0, 8, 0, 8, 0, 0 }}, GGL_Y_CB_CR_P }, // PIXEL_FORMAT_YCbCr_422_P

{ 1, 12, {{ 0, 8, 0, 8, 0, 8, 0, 0 }}, GGL_Y_CB_CR_P }, // PIXEL_FORMAT_YCbCr_420_P

{ 1, 16, {{ 0, 8, 0, 8, 0, 8, 0, 0 }}, GGL_Y_CB_CR_I }, // PIXEL_FORMAT_YCbCr_422_I

{ 1, 12, {{ 0, 8, 0, 8, 0, 8, 0, 0 }}, GGL_Y_CB_CR_I }, // PIXEL_FORMAT_YCbCr_420_I

{ 0, 0, {{ 0, 0, 0, 0, 0, 0, 0, 0 }}, 0 }, // PIXEL_FORMAT_NONE

{ 0, 0, {{ 0, 0, 0, 0, 0, 0, 0, 0 }}, 0 }, // PIXEL_FORMAT_NONE

{ 2, 16, {{ 0, 0, 16, 0, 0, 0, 0, 0 }}, GGL_DEPTH_COMPONENT},

{ 1, 8, {{ 8, 0, 0, 0, 0, 0, 0, 0 }}, GGL_STENCIL_INDEX },

{ 4, 24, {{ 0, 0, 24, 0, 0, 0, 0, 0 }}, GGL_DEPTH_COMPONENT},

{ 4, 8, {{ 32,24, 0, 0, 0, 0, 0, 0 }}, GGL_STENCIL_INDEX },

};

1.6 Pixelflinger 接口

1.6.1 裁剪操作函数

void(*scissor)(void* c, GGLint x, GGLint y, GGLsizei width, GGLsizeiheight);

该函数的功能是设置裁剪范围:

c->state.scissor.left = x;

c->state.scissor.top = y;

c->state.scissor.right = width;

c->state.scissor.bottom= height;

1.6.2 纹理和色彩缓冲设置函数

void(*activeTexture)(void* c, GGLuint tmu);

该函数的功能是设置activeTexture索引及值:

c->activeTMUIndex= tmu;

c->activeTMU= &(c->state.texture[tmu]);


void(*bindTexture)(void* c, const GGLSurface* surface);

该函数的功能是将activeTMU的surface绑定到源surface:

ggl_set_surface(c,&(c->activeTMU->surface), surface);


void(*colorBuffer)(void* c, const GGLSurface* surface);

该函数的功能是将state.buffers.color 绑定到源surface:

ggl_set_surface(c,&(c->state.buffers.color), surface);



void(*readBuffer)(void* c, const GGLSurface* surface);

该函数的功能是将state.buffers.read 绑定到源surface:

ggl_set_surface(c,&(c->state.buffers.read), surface);



void(*depthBuffer)(void* c, const GGLSurface* surface);

该函数的功能是将state.buffers.depth.format初始化为GGL_PIXEL_FORMAT_NONE:

c->state.buffers.depth.format= GGL_PIXEL_FORMAT_NONE;

1.6.3 使能或禁止某种属性

Pixelflinger开放如下属性可供使能或禁止:

GGL_BLEND

混合使能:

if (enable) c->state.enables|= GGL_ENABLE_BLENDING;

else c->state.enables &= ~GGL_ENABLE_BLENDING;



GGL_SCISSOR_TEST

裁剪测试使能:

if (enable) c->state.enables|= GGL_ENABLE_SCISSOR_TEST;

else c->state.enables &= ~GGL_ENABLE_SCISSOR_TEST;



GGL_ALPHA_TEST

ALPHA测试使能:

if (enable) c->state.enables|= GGL_ENABLE_ALPHA_TEST;

else c->state.enables &= ~GGL_ENABLE_ALPHA_TEST;



GGL_COLOR_LOGIC_OP

顔色逻辑操作使能:

if (enable) c->state.enables|= GGL_ENABLE_LOGIC_OP;

else c->state.enables &= ~GGL_ENABLE_LOGIC_OP;



GGL_DITHER

抖动使能:

if (enable) c->state.enables|= GGL_ENABLE_DITHER;

else c->state.enables &= ~GGL_ENABLE_DITHER;



static voidenable_disable(context_t* c, GGLenum name, int en)

{

switch (name) {

case GGL_BLEND: ggl_enable_blending(c, en); break;

case GGL_SCISSOR_TEST: ggl_enable_scissor_test(c, en); break;

case GGL_ALPHA_TEST: ggl_enable_alpha_test(c, en); break;

case GGL_COLOR_LOGIC_OP: ggl_enable_logic_op(c, en); break;

case GGL_DITHER: ggl_enable_dither(c, en); break;

case GGL_STENCIL_TEST: ggl_enable_stencil_test(c, en); break;

case GGL_DEPTH_TEST: ggl_enable_depth_test(c, en); break;

case GGL_AA: ggl_enable_aa(c, en); break;

case GGL_TEXTURE_2D: ggl_enable_texture2d(c, en); break;

case GGL_W_LERP: ggl_enable_w_lerp(c, en); break;

case GGL_FOG: ggl_enable_fog(c, en); break;

caseGGL_POINT_SMOOTH_NICE: ggl_enable_point_aa_nice(c, en); break;

}

}



void (*enable)(void* c,GGLenum name);

该函数的功能是使用某种属性:

enable_disable(c, name, 1);



void(*disable)(void* c, GGLenum name);

该函数的功能是禁止某种属性:

enable_disable(c, name, 0);



void(*enableDisable)(void* c, GGLenum name, GGLboolean en);

该函数的功能是使用或禁止某种属性:

enable_disable(c, name, en ?1 : 0);

1.6.4 指定片段顔色

void(*shadeModel)(void* c, GGLenum mode);

该函数的功能是指定阴影模式,是FLAT还是SMOOTH:

caseGGL_FLAT:

if(c->state.enables & GGL_ENABLE_SMOOTH) {

c->state.enables&= ~GGL_ENABLE_SMOOTH;

ggl_state_changed(c,GGL_PIXEL_PIPELINE_STATE);

}

break;

caseGGL_SMOOTH:

if(!(c->state.enables & GGL_ENABLE_SMOOTH)) {

c->state.enables|= GGL_ENABLE_SMOOTH;

ggl_state_changed(c,GGL_PIXEL_PIPELINE_STATE);

}


void(*color4xv)(void* c, const GGLclampx* color);

该函数的功能是指定渐变的顔色:

c->shade.r0 =gglFixedToIteratedColor(color[0]);

c->shade.g0 =gglFixedToIteratedColor(color[1]);

c->shade.b0 =gglFixedToIteratedColor(color[2]);

c->shade.a0 =gglFixedToIteratedColor(color[3]);

1.6.5 迭代程序

void(*colorGrad12xv)(void* c, const GGLcolor* grad);

该函数的功能是指定渐变的顔色及顔色位置:

constint32_t round = 0x8000;

c->shade.r0 = grad[ 0] + round;

c->shade.drdx= grad[ 1];

c->shade.drdy= grad[ 2];

c->shade.g0 = grad[ 3] + round;

c->shade.dgdx= grad[ 4];

c->shade.dgdy= grad[ 5];

c->shade.b0 = grad[ 6] + round;

c->shade.dbdx= grad[ 7];

c->shade.dbdy= grad[ 8];

c->shade.a0 = grad[ 9] + round;

c->shade.dadx= grad[10];

c->shade.dady= grad[11];



void (*zGrad3xv)(void*c, const GGLfixed32* grad);

该函数的功能是指定渐变的Z轴值及Z值位置:

const uint32_t round =0x8000;

c->shade.z0 = grad[0] +round;

c->shade.dzdx = grad[1];

c->shade.dzdy = grad[2];



void (*wGrad3xv)(void*c, const GGLfixed* grad);

该函数的功能是指定渐变的W轴值及W值位置:

const uint32_t round =0x8000;

c->shade.z0 = grad[0] +round;

c->shade.dzdx = grad[1];

c->shade.dzdy = grad[2];

void(*fogGrad3xv)(void* c, const GGLfixed* grad);

该函数的功能是指定渐变的雾化值:

c->shade.f0 = grad[0];

c->shade.dfdx = grad[1];

c->shade.dfdy = grad[2];



void(*fogColor3xv)(void* c, const GGLclampx* color);

该函数的功能是指定雾化顔色:

c->state.fog.color[GGLFormat::RED] = (r - (r>>8))>>8;

c->state.fog.color[GGLFormat::GREEN]=(g - (g>>8))>>8;

c->state.fog.color[GGLFormat::BLUE]= (b - (b>>8))>>8;

1.6.6 指定混合参数

void(*blendFunc)(void* c, GGLenum src, GGLenum dst);

该函数的功能是指定混合源和混合目的地,同src和src_alpha一致,dst和dst_alpha一致:

c->state.blend.src = src;

c->state.blend.src_alpha= src;

c->state.blend.dst =dst;

c->state.blend.dst_alpha= dst;

c->state.blend.alpha_separate= 0;



void(*blendFuncSeparate)(void* c, GGLenum src, GGLenum dst,

GGLenumsrcAlpha, GGLenum dstAplha);

该函数的功能是指定混合源和混合目的地,同src和src_alpha分开,dst和dst_alpha分开:

c->state.blend.src = src;

c->state.blend.src_alpha= srcAlpha;

c->state.blend.dst =dst;

c->state.blend.dst_alpha= dstAplha;

c->state.blend.alpha_separate= 1;

1.6.7 指定纹理参数

void (*texEnvi)(void*c, GGLenum target,

GGLenumpname,

GGLintparam);

该函数的功能是指定纹理环境参数:

case GGL_REPLACE:

case GGL_MODULATE:

case GGL_DECAL:

case GGL_BLEND:

case GGL_ADD:

if (c->activeTMU->env!= param) {

c->activeTMU->env= param;



void(*texEnvxv)(void* c, GGLenum target,

GGLenumpname, const GGLfixed* params);

该函数的功能是指定纹理环境模式:

switch (pname) {

case GGL_TEXTURE_ENV_MODE:

ggl_texEnvi(con,target, pname, params[0]);

break;

caseGGL_TEXTURE_ENV_COLOR: {

uint8_t* const color =c->activeTMU->env_color;

const GGLclampx r =gglClampx(params[0]);

const GGLclampx g =gglClampx(params[1]);

const GGLclampx b =gglClampx(params[2]);

const GGLclampx a =gglClampx(params[3]);

color[0] =(a-(a>>8))>>8;

color[1] =(r-(r>>8))>>8;

color[2] =(g-(g>>8))>>8;

color[3] =(b-(b>>8))>>8;

break;

}



void(*texParameteri)(void* c, GGLenum target,

GGLenumpname,

GGLintparam);

该函数的功能是指定纹理参数:

switch (pname) {

case GGL_TEXTURE_WRAP_S:

what =&c->activeTMU->s_wrap;

case GGL_TEXTURE_WRAP_T:

caseGGL_TEXTURE_MIN_FILTER:

caseGGL_TEXTURE_MAG_FILTER:

*what = param;



void(*texCoord2x)(void* c, GGLfixed s, GGLfixed t);

该函数的功能是设置纹理渐变的s和t:

c->activeTMU->shade.is0= s;

c->activeTMU->shade.it0= t;

c->activeTMU->shade.sscale=0;

c->activeTMU->shade.tscale=0;



void(*texCoordGradScale8xv)(void* c, GGLint tmu, const int32_t* grad8);

该函数的功能是设置渐变的S、T以及SCALE:

texture_t& u =c->state.texture[tmu];

u.shade.is0 = grad[0];

u.shade.idsdx = grad[1];

u.shade.idsdy = grad[2];

u.shade.it0 = grad[3];

u.shade.idtdx = grad[4];

u.shade.idtdy = grad[5];

u.shade.sscale= grad[6];

u.shade.tscale= grad[7];



void(*texGeni)(void* c, GGLenum coord, GGLenum pname, GGLint param);

该函数的功能是设置 S和 T 的参数:

if (coord == GGL_S) coord_ptr = &(c->activeTMU->s_coord);

else if (coord == GGL_T) coord_ptr = &(c->activeTMU->t_coord);

*coord_ptr = uint32_t(param);



1.6.8 屏蔽函数

void (*colorMask)(void*c, GGLboolean red,

GGLbooleangreen,

GGLbooleanblue,

GGLbooleanalpha);

该函数的功能是设置顔色掩码:

if (a) mask |= 1 <<GGLFormat::ALPHA;

if (r) mask |= 1 <<GGLFormat::RED;

if (g) mask |= 1 <<GGLFormat::GREEN;

if (b) mask |= 1 <<GGLFormat::BLUE;

c->state.mask.color= mask;



void(*depthMask)(void* c, GGLboolean flag);

该函数的功能是设置深度掩码:

c->state.mask.depth =flag?1:0;



void(*stencilMask)(void* c, GGLuint mask);

该函数的功能是设置蜡版掩码:

c->state.mask.stencil =mask;


基于android o版本单手模式实现 单手模式用例图如下 单手模式主要流程 主要控制点在SurfaceControlWithBackground.java这个文件里 1、控制位置 @Override public void setPosition(float x, float y) { super.setPosition(x, y); if (mBackgroundCont... 阅读详情

相关推荐

android surfaceflinger研究----显示系统

这周抽空研究了一下SurfaceFlinger,发现真正复杂的并不是SurfaceFlinger本身,而是android的display显示系统,网上关于这部分的介绍有不少,本不打算写的,但是发现还是记录一下研究代码的过程比较好,一是能够帮助自己理清思路,另一个原因就是以后当这块内容忘记的时候,能快速的通过这个记录捡起来。     一.  android显示系统的建立     我们看Surfa

杜文涛的专栏 3万+

[转] Android ‍Pixelflinger 研究

<br /><br />转自 http://hi.baidu.com/aokikyon/blog/item/2e8ca6130db328906438db18.html<br /> <br />1. Pixelflinger简介<br />Pixelflinger是Android系统中为OpenGL ES引擎提供的一套软件渲染器(renderer)。系统启动时通过查看启动日志信息可以获取当前Pixelflinger的软件版本(代码)。Pixelflinger软件版本随着Android版本的升级而提高,目前最新

王贵平的专栏—分享学习的快乐,感悟人生的真谛! 4630

android jni 屏幕截图 NativeScreenCapture

android jni 屏幕截图

android Pixelflinger

1 Pixelflinger 1.1 Pixelflinger 简介 Pixelflinger是Android系统中为OpenGLES引擎提供的一套软件渲染器(renderer)。OpenGLES引擎提供了一系列基础绘图功能。这些功能包括定义各种颜色格式像素位置、画点画线、绘制矩形及三角形、填充纹理等等。由于OpenGLES相当于一个状态机,配置OpenGLEs状态的函数也均由

Eliot_shao的专栏 813

企业AI Agent的审计与合规

本文将带你从**“0基础理解企业AI Agent审计与合规”到核心概念梳理:用大白话+学术定义拆解什么是“企业AI Agent”、“可审计性(Auditability)”、“可解释性(Explainability,XAI)≠可审计性”、“合规性(Compliance)”、“黑盒拆解的三层维度”等硬核但必须掌握的概念;风险与合规背景:从**内部风险(数据泄露、误操作、模型偏差)和。

Java大师兄的博客 301

PWM控制技术+Simulink仿真详解

想要理解SVPWM控制技术,首先要了解PWM控制技术。 PWM控制技术就是对脉冲宽度进行调制的技术,通过对一系列脉冲宽度进行调制来等效获得所需要的波形(包括形状和幅值)。 PWM控制的基本原理:冲量(窄脉冲的面积)相等而形状不同的窄脉冲加在具有惯性的环节上时,其效果(输出响应波形)基本相同,即面积等效原理;用一系列幅值相等,宽度按一定规律变化的高频脉冲序列代替期望的输出波形,多用于逆变电路的控制; PWM信号生成的方法有:计算法、调制法、跟踪法,主要对调制法进行详解 ...

小师兄的学习记录 5万+

PBRT_V2 总结记录 <53> Procedural Texturing

Solid Texture And Procedural Texturing : it is natural to generalize texture functions to be defined over three-dimensional domains (often called solid textures) rather than just 2D (s , t). Solid t...

aa20274270的博客 374

A Mathematical Framework for Transformer Circuits—(一)

transformer数学理解理论

qq_42208244的博客 2665

Android4.0.3 显示系统深入理解

1. 简介               网上已经有很多兄弟对Android的显示系统做了深入解剖,很是佩服。可最近小弟在研究Android4.0时发现出入比较大,也许是Android4.0的修改比较多吧!因为小弟没有看Android4.0以前的代码。        面对这么复杂一个Android显示系统,如何入手呢? 根据以前的经验,不管它有多么复杂,其功能不就是以下三步曲吗?   1)显示

MyArrow的专栏 3万+

别再折腾SNAP了!ENVI 5.6.0 直接拖拽打开Sentinel-2 L2A数据的正确姿势

本文详细介绍了ENVI 5.6.0直接处理Sentinel-2 L2A数据的高效方法,无需通过SNAP进行繁琐的重采样预处理。通过直接拖拽XML文件,用户可以快速加载不同分辨率的波段数据,显著提升工作效率。文章还对比了直接打开与SNAP重采样流程的优劣,并提供了常见问题解决方案和高级应用技巧。

weixin_30296405的博客 637

使用LaTex写IEEE trans 论文的参考文献(bib)

(1)在.TeX文件的最下方添加这几行内容,主要为生成tran形式的参考文献,第二行为参考文献名称,我命名为reference.bib,所以写的是reference,要根据自己的命名改写。(5)如果要在文中引用的话,就在.tex文件中添加\cite{},中括号里面内容为方框圈出来部分,但引用之后,在参考文献后面会出现[1]这样的标识,不知道为什么。(4)完成(3)以后,点击工具-命令-LaTeX,编译,然后按照此步骤LaTeX-bibtex-LaTeX-LaTeX,就可以完成参考文献的导入。

qq_45884215的博客 6260

android pixelflinger 研究,[转载][转] Android ‍Pixelflinger 研究

1.Pixelflinger简介Pixelflinger是Android系统中为 OpenGLES引擎提供的一套软件渲染器(renderer)。系统启动时通过查看启动日志信息可以获取当前Pixelflinger的软件版本(代码)。Pixelflinger软件版本随着Android版本的升级而提高,目前最新的版本为1.3(基于Android2.2系统)。I/SurfaceFlinger( 1931)...

weixin_42365038的博客 190

Unity UGUI深度优化

Unity UGUI优化相关

不定时分享所学所得,包括游戏开发和其他收获! 2722

android pixelflinger 研究,Android Pixelflinger 研究

1. Pixelflinger简介Pixelflinger是Android系统中为 OpenGL ES引擎提供的一套软件渲染器(renderer)。系统启动时通过查看启动日志信息可以获取当前Pixelflinger的软件版本(代码)。 Pixelflinger软件版本随着Android版本的升级而提高,目前最新的版本为1.3(基于Android2.2系统)。I/SurfaceFlinger( 19...

weixin_34007963的博客 180

三种方式实现电脑端同时登陆多个微信

现在越来越人都有两个甚至多个微信号,有时候我们需要登录在电脑回复消息,那么怎样才能在一个电脑上同时登录两个微信甚至是多个微信号(微信多开)呢?希望下列三种方法能对各位博友有帮助。 方法一:微信网页版实现 我们知道,目前网页版微信还是可以使用的。所以,我们可以利用多个浏览器来实现在同一台电脑上登录两个或多个微信的目的。 1.首先,我们在浏览器的搜索栏输入“微信网页版”,点击搜索并点开搜索到的带“官网”标志的链接进入网页版微信。 2.打开另外一个浏览器,比如刚才打开的是自己安装的第三方浏览器,那么我们再打开W

清平乐的技术专栏 1万+

【QNX Hypervisor 2.2 用户手册】2.6 处理qvm终止

你可以注册通知,以在qvm进程实例退出时得到通知。这样你就可以采取相应的措施来响应这种终止事件。

从0到1,突破自己 1109

PixelFlinger

简介Pixelflinger是Android系统中为OpenGL ES引擎提供的一套软件渲染器(renderer),为OpenGL ES引擎提供了一系列基础绘图功能。这些功能包括定义各种颜色格式像素位置、画点画线、绘制矩形及三角形、填充纹理等等。由于OpenGL ES相当于一个状态机,配置OpenGL ES状态的函数也均由Pixelflinger提供。 Pixelflinger的相关源码路径如下:

qilu0882的专栏 1204

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

android系统学习笔记四

Android的GUI系统 AndroidGUI系统综述 C语言部分包括: pixelFlinger(下层工具库) 头文件/system/core/include/pixelflinger其生成的动态库libpixelflinger.so只连接                    ...

weixin_30273763的博客 169

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

Android Transform

Transform详解 深入了解TransformApi 如何理解 Transform API Gradle 学习之 Android 插件的 Transform API Android Gradle Transform 详解

ruanyandong的博客 1793

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

Android的源代码结构

 (hanchao3c Android开发者论坛原创,转载请注明)Google提供的Android包含了原始Android的目标机代码,主机编译工具、仿真环境,代码包经过解压缩后,第一级别的目录和文件如下所示:.|-- Makefile        (全局的Makefile)|-- bionic          (Bionic含义为仿生,这里面是一些基础的库的源代码)|

况天宝的专栏 810

OpenHarmony + RN:PixelFormat图片格式处理

PixelFormat 决定了图像在内存中的存储方式,直接影响渲染性能与内存占用。

2501_91746149的博客 554

recovery 加入充电显示进程

基于Andriod系统的平台在没有硬件充电指示的情况下只有进入andriod系统才能进行充电指示,而我们有时候仅仅需要充电而不需要进入系统,本文介绍了实现这种功能的方法。 具体过程如下:当内核启动后调用充电指示控制程序。充电指示程序发现如果外部供电就开始显示充电的画面,同时将设备的电源控制锁定为关闭状态(这样当拔掉电源时候系统自动关闭),如果在充电指示过程中又按了开机键,就重新开启电源按键。

android 分析 2014

recovery图片资源的再分析

1. 概述 为了进一步分析recovery系统使用资源png文件的过程,我们把相关代码剥离出来,作成小例子进行分析。 2. 正向分析的代码 这个小例子的第一步是能够遍历出png中所有locale的图片信息。 2.1 代码 代码如下: /* * gcc png_example.c -Iinclude -lpng * * The original code

A Flying Bird 3311

Android Recovery的汉化 显示中文

首先下载开源的recovery源码:https://github.com/xiaolu/android_bootable_recovery

ncepu307的专栏 3415

Android display system introduce(Qualcomm 8x60 platform)(二、SW架构--1)

一、Overview    上图的原型取自高通的文档,由于原图无法描述现有的架构,我在原图的基础了做了些修改,主要是增加了overlay部分,另外其他部分根据现有的软件也做了些许改动。下面先对上图做个大概的介绍,后面会针对重点部分做详细的分析。         最上面一层为应用程序,根据数据类型以及应用的不同可以分为几种。第一种是最普通的应用,如UI界面的显示,这部分通常数据类型为RGB格式,数据无须再经过特殊的处理。该应用可以说遍布各个应用程序,几乎是实时存在的。第二种是针对大块YUV数据的应用,如cam

3178

OpenGL中的Scissor

OPENGL SCISSOR

xuexi23456的博客 1194
上一篇: YUV 像素格式
下一篇: git 教程(7)
skdev
博客等级 码龄20年 139粉丝 84原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值