summaryrefslogtreecommitdiffstats
path: root/libs/hwui/Renderer.h
diff options
context:
space:
mode:
Diffstat (limited to 'libs/hwui/Renderer.h')
-rw-r--r--libs/hwui/Renderer.h90
1 files changed, 29 insertions, 61 deletions
diff --git a/libs/hwui/Renderer.h b/libs/hwui/Renderer.h
index 3159d1e..3240bbc 100644
--- a/libs/hwui/Renderer.h
+++ b/libs/hwui/Renderer.h
@@ -20,11 +20,12 @@
#include <SkColorFilter.h>
#include <SkPaint.h>
#include <SkRegion.h>
-
#include <utils/String8.h>
#include "AssetAtlas.h"
+class SkDrawFilter;
+
namespace android {
class Functor;
@@ -56,40 +57,6 @@ class ANDROID_API Renderer {
public:
virtual ~Renderer() {}
- /**
- * Safely retrieves the mode from the specified xfermode. If the specified
- * xfermode is null, the mode is assumed to be SkXfermode::kSrcOver_Mode.
- */
- static inline SkXfermode::Mode getXfermode(SkXfermode* mode) {
- SkXfermode::Mode resultMode;
- if (!SkXfermode::AsMode(mode, &resultMode)) {
- resultMode = SkXfermode::kSrcOver_Mode;
- }
- return resultMode;
- }
-
- // TODO: move to a method on android:Paint
- static inline bool paintWillNotDraw(const SkPaint& paint) {
- return paint.getAlpha() == 0
- && !paint.getColorFilter()
- && getXfermode(paint.getXfermode()) == SkXfermode::kSrcOver_Mode;
- }
-
- // TODO: move to a method on android:Paint
- static inline bool paintWillNotDrawText(const SkPaint& paint) {
- return paint.getAlpha() == 0
- && paint.getLooper() == NULL
- && !paint.getColorFilter()
- && getXfermode(paint.getXfermode()) == SkXfermode::kSrcOver_Mode;
- }
-
- static bool isBlendedColorFilter(const SkColorFilter* filter) {
- if (filter == NULL) {
- return false;
- }
- return (filter->getFlags() & SkColorFilter::kAlphaUnchanged_Flag) == 0;
- }
-
// ----------------------------------------------------------------------------
// Frame state operations
// ----------------------------------------------------------------------------
@@ -111,7 +78,7 @@ public:
* and will not be cleared. If false, the target surface
* will be cleared
*/
- virtual status_t prepare(bool opaque) = 0;
+ virtual void prepare(bool opaque) = 0;
/**
* Prepares the renderer to draw a frame. This method must be invoked
@@ -127,14 +94,16 @@ public:
* and will not be cleared. If false, the target surface
* will be cleared in the specified dirty rectangle
*/
- virtual status_t prepareDirty(float left, float top, float right, float bottom,
+ virtual void prepareDirty(float left, float top, float right, float bottom,
bool opaque) = 0;
/**
* Indicates the end of a frame. This method must be invoked whenever
* the caller is done rendering a frame.
+ * Returns true if any drawing was done during the frame (the output
+ * has changed / is "dirty" and should be displayed to the user).
*/
- virtual void finish() = 0;
+ virtual bool finish() = 0;
// ----------------------------------------------------------------------------
// Canvas state operations
@@ -173,58 +142,57 @@ public:
virtual bool clipPath(const SkPath* path, SkRegion::Op op) = 0;
virtual bool clipRegion(const SkRegion* region, SkRegion::Op op) = 0;
- // Misc - should be implemented with SkPaint inspection
- virtual void resetPaintFilter() = 0;
- virtual void setupPaintFilter(int clearBits, int setBits) = 0;
+ // Misc
+ virtual void setDrawFilter(SkDrawFilter* filter) = 0;
// ----------------------------------------------------------------------------
// Canvas draw operations
// ----------------------------------------------------------------------------
- virtual status_t drawColor(int color, SkXfermode::Mode mode) = 0;
+ virtual void drawColor(int color, SkXfermode::Mode mode) = 0;
// Bitmap-based
- virtual status_t drawBitmap(const SkBitmap* bitmap, const SkPaint* paint) = 0;
- virtual status_t drawBitmap(const SkBitmap* bitmap, float srcLeft, float srcTop,
+ virtual void drawBitmap(const SkBitmap* bitmap, const SkPaint* paint) = 0;
+ virtual void drawBitmap(const SkBitmap* bitmap, float srcLeft, float srcTop,
float srcRight, float srcBottom, float dstLeft, float dstTop,
float dstRight, float dstBottom, const SkPaint* paint) = 0;
- virtual status_t drawBitmapData(const SkBitmap* bitmap, const SkPaint* paint) = 0;
- virtual status_t drawBitmapMesh(const SkBitmap* bitmap, int meshWidth, int meshHeight,
+ virtual void drawBitmapData(const SkBitmap* bitmap, const SkPaint* paint) = 0;
+ virtual void drawBitmapMesh(const SkBitmap* bitmap, int meshWidth, int meshHeight,
const float* vertices, const int* colors, const SkPaint* paint) = 0;
- virtual status_t drawPatch(const SkBitmap* bitmap, const Res_png_9patch* patch,
+ virtual void drawPatch(const SkBitmap* bitmap, const Res_png_9patch* patch,
float left, float top, float right, float bottom, const SkPaint* paint) = 0;
// Shapes
- virtual status_t drawRect(float left, float top, float right, float bottom,
+ virtual void drawRect(float left, float top, float right, float bottom,
const SkPaint* paint) = 0;
- virtual status_t drawRects(const float* rects, int count, const SkPaint* paint) = 0;
- virtual status_t drawRoundRect(float left, float top, float right, float bottom,
+ virtual void drawRects(const float* rects, int count, const SkPaint* paint) = 0;
+ virtual void drawRoundRect(float left, float top, float right, float bottom,
float rx, float ry, const SkPaint* paint) = 0;
- virtual status_t drawCircle(float x, float y, float radius, const SkPaint* paint) = 0;
- virtual status_t drawOval(float left, float top, float right, float bottom,
+ virtual void drawCircle(float x, float y, float radius, const SkPaint* paint) = 0;
+ virtual void drawOval(float left, float top, float right, float bottom,
const SkPaint* paint) = 0;
- virtual status_t drawArc(float left, float top, float right, float bottom,
+ virtual void drawArc(float left, float top, float right, float bottom,
float startAngle, float sweepAngle, bool useCenter, const SkPaint* paint) = 0;
- virtual status_t drawPath(const SkPath* path, const SkPaint* paint) = 0;
- virtual status_t drawLines(const float* points, int count, const SkPaint* paint) = 0;
- virtual status_t drawPoints(const float* points, int count, const SkPaint* paint) = 0;
+ virtual void drawPath(const SkPath* path, const SkPaint* paint) = 0;
+ virtual void drawLines(const float* points, int count, const SkPaint* paint) = 0;
+ virtual void drawPoints(const float* points, int count, const SkPaint* paint) = 0;
// Text
- virtual status_t drawText(const char* text, int bytesCount, int count, float x, float y,
+ virtual void drawText(const char* text, int bytesCount, int count, float x, float y,
const float* positions, const SkPaint* paint, float totalAdvance, const Rect& bounds,
DrawOpMode drawOpMode = kDrawOpMode_Immediate) = 0;
- virtual status_t drawTextOnPath(const char* text, int bytesCount, int count, const SkPath* path,
+ virtual void drawTextOnPath(const char* text, int bytesCount, int count, const SkPath* path,
float hOffset, float vOffset, const SkPaint* paint) = 0;
- virtual status_t drawPosText(const char* text, int bytesCount, int count,
+ virtual void drawPosText(const char* text, int bytesCount, int count,
const float* positions, const SkPaint* paint) = 0;
// ----------------------------------------------------------------------------
// Canvas draw operations - special
// ----------------------------------------------------------------------------
- virtual status_t drawRenderNode(RenderNode* renderNode, Rect& dirty,
+ virtual void drawRenderNode(RenderNode* renderNode, Rect& dirty,
int32_t replayFlags) = 0;
// TODO: rename for consistency
- virtual status_t callDrawGLFunction(Functor* functor, Rect& dirty) = 0;
+ virtual void callDrawGLFunction(Functor* functor, Rect& dirty) = 0;
}; // class Renderer
}; // namespace uirenderer