diff options
author | Tom Hudson <tomhudson@google.com> | 2015-03-05 10:30:18 -0500 |
---|---|---|
committer | Tom Hudson <tomhudson@google.com> | 2015-03-05 10:31:52 -0500 |
commit | b1476ae7d515d6c406b4367cfb4ada8ce2d116e1 (patch) | |
tree | 59b045cf8bd439eeea6148a585722d7333f9719b /libs | |
parent | 445e1c5ddda15c7118e4b52f9c7a7c77267efb34 (diff) | |
download | frameworks_base-b1476ae7d515d6c406b4367cfb4ada8ce2d116e1.zip frameworks_base-b1476ae7d515d6c406b4367cfb4ada8ce2d116e1.tar.gz frameworks_base-b1476ae7d515d6c406b4367cfb4ada8ce2d116e1.tar.bz2 |
Fix bug, change crashes to warnings
Improve behavior when we get a call to draw 0 points.
Replace one ALWAYS_FATAL statements with noop.
Change-Id: I864b7a9633dfa3dc6eefa403beca4cc7ae14074f
Diffstat (limited to 'libs')
-rw-r--r-- | libs/hwui/DisplayListRenderer.h | 2 | ||||
-rw-r--r-- | libs/hwui/SkiaCanvasProxy.cpp | 15 | ||||
-rw-r--r-- | libs/hwui/SkiaCanvasProxy.h | 10 |
3 files changed, 21 insertions, 6 deletions
diff --git a/libs/hwui/DisplayListRenderer.h b/libs/hwui/DisplayListRenderer.h index 71c1fc3..d313c18 100644 --- a/libs/hwui/DisplayListRenderer.h +++ b/libs/hwui/DisplayListRenderer.h @@ -216,7 +216,7 @@ public: virtual void drawVertices(SkCanvas::VertexMode vertexMode, int vertexCount, const float* verts, const float* tex, const int* colors, const uint16_t* indices, int indexCount, const SkPaint& paint) override - { LOG_ALWAYS_FATAL("DisplayListRenderer does not support drawVertices()"); } + { /* DisplayListRenderer does not support drawVertices(); ignore */ } // Bitmap-based virtual void drawBitmap(const SkBitmap& bitmap, float left, float top, const SkPaint* paint) override; diff --git a/libs/hwui/SkiaCanvasProxy.cpp b/libs/hwui/SkiaCanvasProxy.cpp index 3c65705..ec1bb90 100644 --- a/libs/hwui/SkiaCanvasProxy.cpp +++ b/libs/hwui/SkiaCanvasProxy.cpp @@ -22,9 +22,10 @@ namespace android { namespace uirenderer { -SkiaCanvasProxy::SkiaCanvasProxy(Canvas* canvas) +SkiaCanvasProxy::SkiaCanvasProxy(Canvas* canvas, bool filterHwuiCalls) : INHERITED(canvas->width(), canvas->height()) - , mCanvas(canvas) {} + , mCanvas(canvas) + , mFilterHwuiCalls(filterHwuiCalls) {} void SkiaCanvasProxy::onDrawPaint(const SkPaint& paint) { mCanvas->drawPaint(paint); @@ -32,6 +33,10 @@ void SkiaCanvasProxy::onDrawPaint(const SkPaint& paint) { void SkiaCanvasProxy::onDrawPoints(PointMode pointMode, size_t count, const SkPoint pts[], const SkPaint& paint) { + if (!pts || count == 0) { + return; + } + // convert the SkPoints into floats SK_COMPILE_ASSERT(sizeof(SkPoint) == sizeof(float)*2, SkPoint_is_no_longer_2_floats); const size_t floatCount = count << 1; @@ -118,6 +123,9 @@ void SkiaCanvasProxy::onDrawSprite(const SkBitmap& bitmap, int left, int top, void SkiaCanvasProxy::onDrawVertices(VertexMode mode, int vertexCount, const SkPoint vertices[], const SkPoint texs[], const SkColor colors[], SkXfermode*, const uint16_t indices[], int indexCount, const SkPaint& paint) { + if (mFilterHwuiCalls) { + return; + } // convert the SkPoints into floats SK_COMPILE_ASSERT(sizeof(SkPoint) == sizeof(float)*2, SkPoint_is_no_longer_2_floats); const int floatCount = vertexCount << 1; @@ -312,6 +320,9 @@ void SkiaCanvasProxy::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScala void SkiaCanvasProxy::onDrawPatch(const SkPoint cubics[12], const SkColor colors[4], const SkPoint texCoords[4], SkXfermode* xmode, const SkPaint& paint) { + if (mFilterHwuiCalls) { + return; + } SkPatchUtils::VertexData data; SkMatrix matrix; diff --git a/libs/hwui/SkiaCanvasProxy.h b/libs/hwui/SkiaCanvasProxy.h index 4322fcf..0de9650 100644 --- a/libs/hwui/SkiaCanvasProxy.h +++ b/libs/hwui/SkiaCanvasProxy.h @@ -27,16 +27,19 @@ namespace uirenderer { /** * This class serves as a proxy between Skia's SkCanvas and Android Framework's - * Canvas. The class does not maintain any state and will pass through any request - * directly to the Canvas provided in the constructor. + * Canvas. The class does not maintain any draw-related state and will pass + * through most requests directly to the Canvas provided in the constructor. * * Upon construction it is expected that the provided Canvas has already been * prepared for recording and will continue to be in the recording state while * this proxy class is being used. + * + * If filterHwuiCalls is true, the proxy silently ignores away draw calls that + * aren't supported by HWUI. */ class ANDROID_API SkiaCanvasProxy : public SkCanvas { public: - SkiaCanvasProxy(Canvas* canvas); + SkiaCanvasProxy(Canvas* canvas, bool filterHwuiCalls = false); virtual ~SkiaCanvasProxy() {} protected: @@ -94,6 +97,7 @@ protected: private: Canvas* mCanvas; + bool mFilterHwuiCalls; typedef SkCanvas INHERITED; }; |