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