summaryrefslogtreecommitdiffstats
path: root/libs/hwui/OpenGLRenderer.h
diff options
context:
space:
mode:
Diffstat (limited to 'libs/hwui/OpenGLRenderer.h')
-rw-r--r--libs/hwui/OpenGLRenderer.h131
1 files changed, 85 insertions, 46 deletions
diff --git a/libs/hwui/OpenGLRenderer.h b/libs/hwui/OpenGLRenderer.h
index 9afb7ad..6046531 100644
--- a/libs/hwui/OpenGLRenderer.h
+++ b/libs/hwui/OpenGLRenderer.h
@@ -98,6 +98,24 @@ enum ClipSideFlags {
kClipSide_ConservativeFull = 0x1F
};
+/**
+ * Defines additional transformation that should be applied by the model view matrix, beyond that of
+ * the currentTransform()
+ */
+enum ModelViewMode {
+ /**
+ * Used when the model view should simply translate geometry passed to the shader. The resulting
+ * matrix will be a simple translation.
+ */
+ kModelViewMode_Translate = 0,
+
+ /**
+ * Used when the model view should translate and scale geometry. The resulting matrix will be a
+ * translation + scale. This is frequently used together with VBO 0, the (0,0,1,1) rect.
+ */
+ kModelViewMode_TranslateAndScale = 1,
+};
+
///////////////////////////////////////////////////////////////////////////////
// Renderer
///////////////////////////////////////////////////////////////////////////////
@@ -247,33 +265,17 @@ public:
ANDROID_API void getMatrix(SkMatrix* matrix);
virtual void setMatrix(SkMatrix* matrix);
virtual void concatMatrix(SkMatrix* matrix);
+ virtual void concatMatrix(Matrix4& matrix) {
+ currentTransform().multiply(matrix);
+ }
+ void translateZ(float z) {
+ currentTransform().translate(0,0,z);
+ }
ANDROID_API const Rect& getClipBounds();
- /**
- * Performs a quick reject but adjust the bounds to account for stroke width if necessary,
- * and handling snapOut for AA geometry.
- */
- bool quickRejectPreStroke(float left, float top, float right, float bottom, SkPaint* paint);
-
- /**
- * Returns false and sets scissor based upon bounds if drawing won't be clipped out
- */
- bool quickReject(float left, float top, float right, float bottom, bool snapOut = false);
- bool quickReject(const Rect& bounds) {
- return quickReject(bounds.left, bounds.top, bounds.right, bounds.bottom);
- }
-
- /**
- * Same as quickReject, without the scissor, instead returning clipRequired through pointer.
- * clipRequired will be only set if not rejected
- */
- ANDROID_API bool quickRejectNoScissor(float left, float top, float right, float bottom,
- bool snapOut = false, bool* clipRequired = NULL);
- bool quickRejectNoScissor(const Rect& bounds, bool* clipRequired = NULL) {
- return quickRejectNoScissor(bounds.left, bounds.top, bounds.right, bounds.bottom,
- clipRequired);
- }
+ ANDROID_API bool quickRejectConservative(float left, float top,
+ float right, float bottom) const;
virtual bool clipRect(float left, float top, float right, float bottom, SkRegion::Op op);
virtual bool clipPath(SkPath* path, SkRegion::Op op);
@@ -281,7 +283,6 @@ public:
virtual Rect* getClipRect();
virtual status_t drawDisplayList(DisplayList* displayList, Rect& dirty, int32_t replayFlags);
- virtual void outputDisplayList(DisplayList* displayList);
virtual status_t drawLayer(Layer* layer, float x, float y);
virtual status_t drawBitmap(SkBitmap* bitmap, float left, float top, SkPaint* paint);
status_t drawBitmaps(SkBitmap* bitmap, AssetAtlas::Entry* entry, int bitmapCount,
@@ -319,6 +320,9 @@ public:
DrawOpMode drawOpMode = kDrawOpMode_Immediate);
virtual status_t drawRects(const float* rects, int count, SkPaint* paint);
+ status_t drawShadow(const mat4& casterTransform, float casterAlpha,
+ float width, float height);
+
virtual void resetShader();
virtual void setupShader(SkiaShader* shader);
@@ -477,6 +481,16 @@ protected:
*/
void attachStencilBufferToLayer(Layer* layer);
+ bool calculateQuickRejectForScissor(float left, float top, float right, float bottom,
+ bool* clipRequired, bool snapOut) const;
+
+ bool quickRejectSetupScissor(float left, float top, float right, float bottom,
+ SkPaint* paint = NULL);
+ bool quickRejectSetupScissor(const Rect& bounds, SkPaint* paint = NULL) {
+ return quickRejectSetupScissor(bounds.left, bounds.top,
+ bounds.right, bounds.bottom, paint);
+ }
+
/**
* Compose the layer defined in the current snapshot with the layer
* defined by the previous snapshot.
@@ -654,12 +668,11 @@ private:
* @param alpha The translucency of the layer
* @param mode The blending mode of the layer
* @param flags The layer save flags
- * @param previousFbo The name of the current framebuffer
*
* @return True if the layer was successfully created, false otherwise
*/
bool createLayer(float left, float top, float right, float bottom,
- int alpha, SkXfermode::Mode mode, int flags, GLuint previousFbo);
+ int alpha, SkXfermode::Mode mode, int flags);
/**
* Creates a new layer stored in the specified snapshot as an FBO.
@@ -667,9 +680,8 @@ private:
* @param layer The layer to store as an FBO
* @param snapshot The snapshot associated with the new layer
* @param bounds The bounds of the layer
- * @param previousFbo The name of the current framebuffer
*/
- bool createFboLayer(Layer* layer, Rect& bounds, Rect& clip, GLuint previousFbo);
+ bool createFboLayer(Layer* layer, Rect& bounds, Rect& clip);
/**
* Compose the specified layer as a region.
@@ -831,32 +843,33 @@ private:
* @param swapSrcDst Whether or not the src and dst blending operations should be swapped
* @param ignoreTransform True if the current transform should be ignored
* @param vbo The VBO used to draw the mesh
- * @param ignoreScale True if the model view matrix should not be scaled
+ * @param modelViewMode Defines whether the model view matrix should be scaled
* @param dirty True if calling this method should dirty the current layer
*/
void drawTextureMesh(float left, float top, float right, float bottom, GLuint texture,
float alpha, SkXfermode::Mode mode, bool blend,
GLvoid* vertices, GLvoid* texCoords, GLenum drawMode, GLsizei elementsCount,
bool swapSrcDst = false, bool ignoreTransform = false, GLuint vbo = 0,
- bool ignoreScale = false, bool dirty = true);
+ ModelViewMode modelViewMode = kModelViewMode_TranslateAndScale, bool dirty = true);
void drawIndexedTextureMesh(float left, float top, float right, float bottom, GLuint texture,
float alpha, SkXfermode::Mode mode, bool blend,
GLvoid* vertices, GLvoid* texCoords, GLenum drawMode, GLsizei elementsCount,
bool swapSrcDst = false, bool ignoreTransform = false, GLuint vbo = 0,
- bool ignoreScale = false, bool dirty = true);
+ ModelViewMode modelViewMode = kModelViewMode_TranslateAndScale, bool dirty = true);
void drawAlpha8TextureMesh(float left, float top, float right, float bottom,
GLuint texture, bool hasColor, int color, int alpha, SkXfermode::Mode mode,
GLvoid* vertices, GLvoid* texCoords, GLenum drawMode, GLsizei elementsCount,
- bool ignoreTransform, bool ignoreScale = false, bool dirty = true);
+ bool ignoreTransform, ModelViewMode modelViewMode = kModelViewMode_TranslateAndScale,
+ bool dirty = true);
/**
* Draws the specified list of vertices as quads using indexed GL_TRIANGLES.
* If the number of vertices to draw exceeds the number of indices we have
* pre-allocated, this method will generate several glDrawElements() calls.
*/
- void drawIndexedQuads(Vertex* mesh, GLsizei quadsCount);
+ void issueIndexedQuadDraw(Vertex* mesh, GLsizei quadsCount);
/**
* Draws text underline and strike-through if needed.
@@ -868,8 +881,7 @@ private:
* @param y The y coordinate where the text will be drawn
* @param paint The paint to draw the text with
*/
- void drawTextDecorations(const char* text, int bytesCount, float totalAdvance,
- float x, float y, SkPaint* paint);
+ void drawTextDecorations(float totalAdvance, float x, float y, SkPaint* paint);
/**
* Draws shadow layer on text (with optional positions).
@@ -978,14 +990,26 @@ private:
bool swapSrcDst = false);
void setupDrawProgram();
void setupDrawDirtyRegionsDisabled();
- void setupDrawModelViewIdentity(bool offset = false);
- void setupDrawModelView(float left, float top, float right, float bottom,
- bool ignoreTransform = false, bool ignoreModelView = false);
- void setupDrawModelViewTranslate(float left, float top, float right, float bottom,
- bool ignoreTransform = false);
+
+ /**
+ * Setup the current program matrices based upon the nature of the geometry.
+ *
+ * @param mode If kModelViewMode_Translate, the geometry must be translated by the left and top
+ * parameters. If kModelViewMode_TranslateAndScale, the geometry that exists in the (0,0, 1,1)
+ * space must be scaled up and translated to fill the quad provided in (l,t,r,b). These
+ * transformations are stored in the modelView matrix and uploaded to the shader.
+ *
+ * @param offset Set to true if the the matrix should be fudged (translated) slightly to disambiguate
+ * geometry pixel positioning. See Vertex::gGeometryFudgeFactor.
+ *
+ * @param ignoreTransform Set to true if l,t,r,b coordinates already in layer space,
+ * currentTransform() will be ignored. (e.g. when drawing clip in layer coordinates to stencil,
+ * or when simple translation has been extracted)
+ */
+ void setupDrawModelView(ModelViewMode mode, bool offset,
+ float left, float top, float right, float bottom, bool ignoreTransform = false);
void setupDrawColorUniforms();
void setupDrawPureColorUniforms();
- void setupDrawShaderIdentityUniforms();
void setupDrawShaderUniforms(bool ignoreTransform = false);
void setupDrawColorFilterUniforms();
void setupDrawSimpleMesh();
@@ -1004,11 +1028,13 @@ private:
void updateLayers();
void flushLayers();
+#if DEBUG_LAYERS_AS_REGIONS
/**
* Renders the specified region as a series of rectangles. This method
* is used for debugging only.
*/
- void drawRegionRects(const Region& region);
+ void drawRegionRectsDebug(const Region& region);
+#endif
/**
* Renders the specified region as a series of rectangles. The region
@@ -1052,10 +1078,23 @@ private:
// Dimensions of the drawing surface
int mWidth, mHeight;
- // Matrix used for ortho projection in shaders
- mat4 mOrthoMatrix;
+ // Matrix used for view/projection in shaders
+ mat4 mViewProjMatrix;
- // Model-view matrix used to position/size objects
+ /**
+ * Model-view matrix used to position/size objects
+ *
+ * Stores operation-local modifications to the draw matrix that aren't incorporated into the
+ * currentTransform().
+ *
+ * If generated with kModelViewMode_Translate, the mModelView will reflect an x/y offset,
+ * e.g. the offset in drawLayer(). If generated with kModelViewMode_TranslateAndScale,
+ * mModelView will reflect a translation and scale, e.g. the translation and scale required to
+ * make VBO 0 (a rect of (0,0,1,1)) scaled to match the x,y offset, and width/height of a
+ * bitmap.
+ *
+ * Used as input to SkiaShader transformation.
+ */
mat4 mModelView;
// Number of saved states