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

  1. //
  2. // GLCanvas gives a convenient interface to draw using OpenGL.
  3. //
  4. // When a rectangle is specified in this interface, it means the region
  5. // [x, x+width) * [y, y+height)
  6. //
  7. public interface GLCanvas {
  8. // Tells GLCanvas the size of the underlying GL surface. This should be
  9. // called before first drawing and when the size of GL surface is changed.
  10. // This is called by GLRoot and should not be called by the clients
  11. // who only want to draw on the GLCanvas. Both width and height must be
  12. // nonnegative.
  13. public void setSize(int width, int height);
  14.  
  15. public void setSize(int x, int y, int width, int height);
  16.  
  17. public void clearBuffer();
  18. public void clearBuffer(float[] argb);
  19.  
  20. public void setAlpha(float alpha);
  21. public float getAlpha();
  22.  
  23. public void multiplyAlpha(float alpha);
  24.  
  25. public void translate(float x, float y, float z);
  26. public void translate(float x, float y);
  27. public void scale(float sx, float sy, float sz);
  28. public void rotate(float angle, float x, float y, float z);
  29. public void multiplyMatrix(float[] mMatrix, int offset);
  30.  
  31. public void save();
  32.  
  33. public void save(int saveFlags);
  34.  
  35. public static final int SAVE_FLAG_ALL = 0xFFFFFFFF;
  36. public static final int SAVE_FLAG_ALPHA = 0x01;
  37. public static final int SAVE_FLAG_MATRIX = 0x02;
  38.  
  39. public void restore();
  40.  
  41. // Draws a line using the specified paint from (x1, y1) to (x2, y2).
  42. // (Both end points are included).
  43. public void drawLine(float x1, float y1, float x2, float y2, GLPaint paint);
  44.  
  45. // Draws a rectangle using the specified paint from (x1, y1) to (x2, y2).
  46. // (Both end points are included).
  47. public void drawRect(float x1, float y1, float x2, float y2, GLPaint paint);
  48.  
  49. // Fills the specified rectangle with the specified color.
  50. public void fillRect(float x, float y, float width, float height, int color);
  51.  
  52. // Draws a texture to the specified rectangle.
  53. public void drawTexture(
  54. BasicTexture texture, int x, int y, int width, int height);
  55. public void drawMesh(BasicTexture tex, int x, int y, int xyBuffer,
  56. int uvBuffer, int indexBuffer, int indexCount);
  57.  
  58. // Draws the source rectangle part of the texture to the target rectangle.
  59. public void drawTexture(BasicTexture texture, RectF source, RectF target);
  60.  
  61. // Draw a texture with a specified texture transform.
  62. public void drawTexture(BasicTexture texture, float[] mTextureTransform,
  63. int x, int y, int w, int h);
  64.  
  65. // Draw two textures to the specified rectangle. The actual texture used is
  66. // from * (1 - ratio) + to * ratio
  67. // The two textures must have the same size.
  68. public void drawMixed(BasicTexture from, int toColor,
  69. float ratio, int x, int y, int w, int h);
  70.  
  71. // Draw a region of a texture and a specified color to the specified
  72. // rectangle. The actual color used is from * (1 - ratio) + to * ratio.
  73. // The region of the texture is defined by parameter "src". The target
  74. // rectangle is specified by parameter "target".
  75. public void drawMixed(BasicTexture from, int toColor,
  76. float ratio, RectF src, RectF target);
  77.  
  78. public GL11 getGLInstance();
  79.  
  80. public boolean unloadTexture(BasicTexture texture);
  81.  
  82. public void deleteBuffer(int bufferId);
  83.  
  84. public void deleteRecycledResources();
  85.  
  86. public void dumpStatisticsAndClear();
  87.  
  88. public void beginRenderTarget(RawTexture texture);
  89.  
  90. public void endRenderTarget();
  91. }

这里留下了我觉得与最终布局形成有比较直接关系的地方的注释(完整内容可查看源码),从这些注释中,我意识到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. [leetcode tree]96. Unique Binary Search Trees

    Given n, how many structurally unique BST's (binary search trees) that store values 1...n? For examp ...

  2. iOS Sprite Kit教程之场景的设置

    iOS Sprite Kit教程之场景的设置 Sprite Kit中设置场景 在图2.8所示的效果中,可以看到新增的场景是没有任何内容的,本节将讲解对场景的三个设置,即颜色的设置.显示模式的设置以及测 ...

  3. python中的super( test, self).__init__()

    python中的super( test, self).__init__() 对继承自父类的属性进行初始化 首先找到test的父类(比如是类A),然后把类test的对象self转换为类A的对象,然后“被 ...

  4. wikioi 1078 最小生成树 Kruskal算法

    1078 最小生成树 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 白银 Silver       题目描述 Description 农民约翰被选为他们镇的镇长!他其中一个竞选承诺 ...

  5. GPS坐标定位与距离计算

    Android获取当前位置(GPS和网络定位) 1.比较: GPS准确度高但耗电多,网络定位耗电少但准确度低 2.代码 ①添加权限: AndroidManifest.xml: <!-- 两种pr ...

  6. Python学习笔记(五)—列表的学习

    总结内容: 1.list的定义 2.list的取值 3.list数据的增加 4.list数据的删除 5.list数据的修改 6.list数据的查询 7.list方法的介绍 8.list的合并 9.多维 ...

  7. PHP通过AJAX及Access-Control-Allow-Origin实现跨域访问

    这里的跨域实质上是由浏览器同源策略限制的一类请求场景,浏览器同源策略SOP(Same origin policy)是一种约定,由Netscape公司1995年引入浏览器,它是浏览器最核心也最基本的安全 ...

  8. HDU 3487 Play with Chain (splay tree)

    Play with Chain Time Limit: 6000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)T ...

  9. 埃及分解:将2/n分解成为1/x+1/y的格式

    算法 古埃及以前创造出灿烂的人类文明,他们的分数表示却非常令人不解.古埃及喜欢把一个分数分解为类似: 1/a + 1/b 的格式. 这里,a 和 b 必须是不同的两个整数,分子必须为 1 比方,2/1 ...

  10. MVC实现多选下拉框,保存并显示多选项

    在"MVC实现多选下拉框"中,主要是多选下拉框的显示,而实际情况通常是:选择多个选项提交后,需要在编辑页把所有选中的项显示出来. 模拟这样的一个场景:一个车迷可能有多个自己喜欢的汽 ...