首先申明,找到这个类是在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是在代码中一点一点画出来的,因此所有的布局视图都要到代码中去发现和寻找。

Android4.2.2 Gallery2源码分析(4)——GLCanvas.java的更多相关文章

  1. Android4.2.2 Gallery2源码分析(5)——GLCanvasImpl.java

    GLCanvasImpl.java是接口GLCanvas的唯一实现类,也就是说二者在功能上完全等同.代码中调用GLCanvas对象函数的地方,等效于调用GLCanvasImpl中的该函数,GLCanv ...

  2. Android4.2.2 Gallery2源码分析(2)——发现Gallery.java

    上文中,main.xml是我直接提出来的,并没有说明是怎么找到它的,现在说明发现它的理由: 一般我们分析界面布局会用到hierarchyviewer这个工具,从工具中,我们对应到视图,最主要的视图id ...

  3. JVM源码分析之一个Java进程究竟能创建多少线程

    JVM源码分析之一个Java进程究竟能创建多少线程 原创: 寒泉子 你假笨 2016-12-06 概述 虽然这篇文章的标题打着JVM源码分析的旗号,不过本文不仅仅从JVM源码角度来分析,更多的来自于L ...

  4. JDK源码分析:Short.java

    Short是基本数据类型short的包装类. 1)声明部: public final class Short extends Number implements Comparable<Short ...

  5. JDK源码分析:Object.java

    一. 序言 Object.java是一切类的基类,所以了解该类有一定的必要 二 .属性及方法分析 方法列表: private static native void registerNatives(); ...

  6. JDK源码分析:Integer.java部分源码解析

    1)声明部: public final class Integer extends Number implements Comparable<Integer> extends Number ...

  7. JDK源码分析:Byte.java

    Byte是基本数据类型byte的包装类. 1)声明部分: public final class Byte extends Number implements Comparable<Byte> ...

  8. Java集合系列:-----------03ArrayList源码分析

    上一章,我们学习了Collection的架构.这一章开始,我们对Collection的具体实现类进行讲解:首先,讲解List,而List中ArrayList又最为常用.因此,本章我们讲解ArrayLi ...

  9. [源码分析]Java1.8中StringJoiner的使用以及源码分析

    [源码分析]StringJoiner的使用以及源码分析 StringJoiner是Java里1.8新增的类, 或许有一部分人没有接触过. 所以本文将从使用例子入手, 分析StringJoiner的源码 ...

随机推荐

  1. 使用补丁修改DSDT/SSDT [DSDT/SSDT综合教程]

    请尊重原贴作者 与 本贴楼主.原作者把自己丰富的经验分享给了大家,本贴作者每个贴子平均花了3个小时翻译.      所以,转载请注明出处:原贴地址:http://www.tonymacx86.com/ ...

  2. python实现括号匹配

    1.用一个栈[python中可以用List]就可以解决,时间和空间复杂度都是O(n) # -*- coding: utf8 -*- # 符号表 SYMBOLS = {'}': '{', ']': '[ ...

  3. BOM知识梳理

    学过前端开发的地球人应该都了解,JavaScript分为三个部分:ECMAScript(JS语言本身基础语法),DOM(文档对象模型,应用程序编程接口),BOM(浏览器对象模型). BOM,实际上与浏 ...

  4. Educational Codeforces Round 44 (Rated for Div. 2)

    题目链接:https://codeforces.com/contest/985 ’A.Chess Placing 题意:给了一维的一个棋盘,共有n(n必为偶数)个格子.棋盘上是黑白相间的.现在棋盘上有 ...

  5. 【枚举】【贪心】Codeforces Round #482 (Div. 2) B. Treasure Hunt

    题意:给你3个字符串,3个人各对自己的字符串执行n轮操作,每一次选择一个字符变为任意一个和原来不同的字符.最后问你谁能使自己的串中的任意重复子串出现的次数最大化. 显然只需关注字符而非子串. 枚举每个 ...

  6. js的继承实现方式

    1. 使用call或者apply来实现js对象继承 function Animal(age){ this.age = age; this.say = function(){ console.log(' ...

  7. ZOJ 2969 Easy Task

    E - Easy Task Description Calculating the derivation of a polynomial is an easy task. Given a functi ...

  8. Hihocoder #1082 : 然而沼跃鱼早就看穿了一切 暴力

    时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 fjxmlhx每天都在被沼跃鱼刷屏,因此他急切的找到了你希望你写一个程序屏蔽所有句子中的沼跃鱼(“marshtomp”,不区 ...

  9. Github好用的Python库使用学习日记

    开源好用的Python库 Overview 所有内容基本源于下面的两个网站 awesome-python python3官方文档 you-get(命令行操作的媒体下载工具) you-get的git项目 ...

  10. flask 中 session的源码解析

    1.首先请求上下文和应用上下文中已经知道session是一个LocalProxy()对象 2.然后需要了解整个请求流程, 3.客户端的请求进来时,会调用app.wsgi_app(),于此此时,会生成一 ...