Android4.2.2 Gallery2源码分析(4)——GLCanvas.java

首先申明,找到这个类是在GLRootView.java中发现的线索。这是一个接口,源码中对该接口作了详细的说明:

//
// GLCanvas gives a convenient interface to draw using OpenGL.
//
// When a rectangle is specified in this interface, it means the region
// [x, x+width) * [y, y+height)
//
public interface GLCanvas {
    // Tells GLCanvas the size of the underlying GL surface. This should be
    // called before first drawing and when the size of GL surface is changed.
    // This is called by GLRoot and should not be called by the clients
    // who only want to draw on the GLCanvas. Both width and height must be
    // nonnegative.
    public void setSize(int width, int height);


    public void setSize(int x, int y, int width, int height);


    public void clearBuffer();
    public void clearBuffer(float[] argb);


    public void setAlpha(float alpha);
    public float getAlpha();


    public void multiplyAlpha(float alpha);


    public void translate(float x, float y, float z);
    public void translate(float x, float y);
    public void scale(float sx, float sy, float sz);
    public void rotate(float angle, float x, float y, float z);
    public void multiplyMatrix(float[] mMatrix, int offset);


    public void save();


    public void save(int saveFlags);

    public static final int SAVE_FLAG_ALL = 0xFFFFFFFF;
    public static final int SAVE_FLAG_ALPHA = 0x01;
    public static final int SAVE_FLAG_MATRIX = 0x02;


    public void restore();

    // Draws a line using the specified paint from (x1, y1) to (x2, y2).
    // (Both end points are included).
    public void drawLine(float x1, float y1, float x2, float y2, GLPaint paint);

    // Draws a rectangle using the specified paint from (x1, y1) to (x2, y2).
    // (Both end points are included).
    public void drawRect(float x1, float y1, float x2, float y2, GLPaint paint);

    // Fills the specified rectangle with the specified color.
    public void fillRect(float x, float y, float width, float height, int color);

    // Draws a texture to the specified rectangle.
    public void drawTexture(
            BasicTexture texture, int x, int y, int width, int height);
    public void drawMesh(BasicTexture tex, int x, int y, int xyBuffer,
            int uvBuffer, int indexBuffer, int indexCount);

    // Draws the source rectangle part of the texture to the target rectangle.
    public void drawTexture(BasicTexture texture, RectF source, RectF target);

    // Draw a texture with a specified texture transform.
    public void drawTexture(BasicTexture texture, float[] mTextureTransform,
                int x, int y, int w, int h);

    // Draw two textures to the specified rectangle. The actual texture used is
    // from * (1 - ratio) + to * ratio
    // The two textures must have the same size.
    public void drawMixed(BasicTexture from, int toColor,
            float ratio, int x, int y, int w, int h);

    // Draw a region of a texture and a specified color to the specified
    // rectangle. The actual color used is from * (1 - ratio) + to * ratio.
    // The region of the texture is defined by parameter "src". The target
    // rectangle is specified by parameter "target".
    public void drawMixed(BasicTexture from, int toColor,
            float ratio, RectF src, RectF target);

    public GL11 getGLInstance();


    public boolean unloadTexture(BasicTexture texture);


    public void deleteBuffer(int bufferId);


    public void deleteRecycledResources();


    public void dumpStatisticsAndClear();

    public void beginRenderTarget(RawTexture texture);

    public void endRenderTarget();
}

这里留下了我觉得与最终布局形成有比较直接关系的地方的注释(完整内容可查看源码),从这些注释中,我意识到Gallery的布局之所以不同我之前所见的那些布局视图,是因为这里使用了OpenGL,并且使用了OpenGL材质渲染,那么不能根据以往的经验直接找到视图也就不足为奇了,因为OpenGL是在代码中一点一点画出来的,因此所有的布局视图都要到代码中去发现和寻找。

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
Android 4.2.2通用升级包是为了提升Android 4.2.2操作系统的性能和功能而推出的更新版本。通常,Android设备厂商会在发现操作系统存在漏洞、安全问题或者希望增加新功能时发布这样的升级包。 通过安装Android 4.2.2通用升级包,用户可以享受到一些列的改进。例如,在新版本中,可能会修复一些已知的漏洞和安全问题,以保证用户在使用过程中的安全性。此外,还有可能改善系统的稳定性和流畅度,提升用户的使用体验。 另外,Android 4.2.2通用升级包也可能会增加一些新功能和特性。这些功能可能包括更好的通知管理、更快的界面响应速度、更强大的多任务处理能力、更好的电池管理以及更全面的隐私保护等。这些功能的增加可以让用户在使用设备时更加便利和舒适。 为了安装Android 4.2.2通用升级包,用户需要先下载升级包文件,并将其保存到设备的存储空间中。然后,在设备的设置菜单中,找到软件更新选项,并点击检查更新。系统会自动检测到升级包文件的存在,并询问用户是否愿意安装更新。用户可以选择同意,并等待系统完成更新过程。 需要注意的是,在升级过程中,用户的设备可能需要重启一次或者在一段时间内无法使用。因此,在安装升级包之前,用户应该备份好设备中的重要数据,以防止数据丢失。另外,在升级过程中,用户还应该确保设备有足够的电量,以避免升级被中断。 总之,Android 4.2.2通用升级包是为了改善操作系统的性能和功能而发布的更新版本。用户可以通过下载和安装升级包来享受到更好的安全性、稳定性和功能体验。但在升级前,用户需要备份数据并确保设备有足够的电量。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值