diff options
Diffstat (limited to 'libs')
| -rw-r--r-- | libs/androidfw/ResourceTypes.cpp | 2 | ||||
| -rw-r--r-- | libs/hwui/Canvas.h | 3 | ||||
| -rw-r--r-- | libs/hwui/DisplayListCanvas.cpp | 38 | ||||
| -rw-r--r-- | libs/hwui/DisplayListCanvas.h | 19 | ||||
| -rw-r--r-- | libs/hwui/Outline.h | 22 | ||||
| -rw-r--r-- | libs/hwui/SkiaCanvas.cpp | 7 |
6 files changed, 38 insertions, 53 deletions
diff --git a/libs/androidfw/ResourceTypes.cpp b/libs/androidfw/ResourceTypes.cpp index 62aabb13858d..4f9af7f83fb1 100644 --- a/libs/androidfw/ResourceTypes.cpp +++ b/libs/androidfw/ResourceTypes.cpp @@ -47,7 +47,7 @@ namespace android { -#ifdef HAVE_WINSOCK +#if defined(_WIN32) #undef nhtol #undef htonl #define ntohl(x) ( ((x) << 24) | (((x) >> 24) & 255) | (((x) << 8) & 0xff0000) | (((x) >> 8) & 0xff00) ) diff --git a/libs/hwui/Canvas.h b/libs/hwui/Canvas.h index 116bc56bfe4d..a0b87f9cadb6 100644 --- a/libs/hwui/Canvas.h +++ b/libs/hwui/Canvas.h @@ -62,6 +62,9 @@ public: virtual int width() = 0; virtual int height() = 0; + virtual void setHighContrastText(bool highContrastText) = 0; + virtual bool isHighContrastText() = 0; + // ---------------------------------------------------------------------------- // Canvas state operations // ---------------------------------------------------------------------------- diff --git a/libs/hwui/DisplayListCanvas.cpp b/libs/hwui/DisplayListCanvas.cpp index 74189aabbc87..c48b070819a4 100644 --- a/libs/hwui/DisplayListCanvas.cpp +++ b/libs/hwui/DisplayListCanvas.cpp @@ -437,16 +437,6 @@ void DisplayListCanvas::drawPosText(const uint16_t* text, const float* positions addDrawOp(op); } -static void simplifyPaint(int color, SkPaint* paint) { - paint->setColor(color); - paint->setShader(nullptr); - paint->setColorFilter(nullptr); - paint->setLooper(nullptr); - paint->setStrokeWidth(4 + 0.04 * paint->getTextSize()); - paint->setStrokeJoin(SkPaint::kRound_Join); - paint->setLooper(nullptr); -} - void DisplayListCanvas::drawText(const uint16_t* glyphs, const float* positions, int count, const SkPaint& paint, float x, float y, float boundsLeft, float boundsTop, float boundsRight, float boundsBottom, @@ -459,31 +449,9 @@ void DisplayListCanvas::drawText(const uint16_t* glyphs, const float* positions, positions = refBuffer<float>(positions, count * 2); Rect bounds(boundsLeft, boundsTop, boundsRight, boundsBottom); - if (CC_UNLIKELY(mHighContrastText)) { - // high contrast draw path - int color = paint.getColor(); - int channelSum = SkColorGetR(color) + SkColorGetG(color) + SkColorGetB(color); - bool darken = channelSum < (128 * 3); - - // outline - SkPaint* outlinePaint = copyPaint(&paint); - simplifyPaint(darken ? SK_ColorWHITE : SK_ColorBLACK, outlinePaint); - outlinePaint->setStyle(SkPaint::kStrokeAndFill_Style); - addDrawOp(new (alloc()) DrawTextOp(text, bytesCount, count, - x, y, positions, outlinePaint, totalAdvance, bounds)); // bounds? - - // inner - SkPaint* innerPaint = copyPaint(&paint); - simplifyPaint(darken ? SK_ColorBLACK : SK_ColorWHITE, innerPaint); - innerPaint->setStyle(SkPaint::kFill_Style); - addDrawOp(new (alloc()) DrawTextOp(text, bytesCount, count, - x, y, positions, innerPaint, totalAdvance, bounds)); - } else { - // standard draw path - DrawOp* op = new (alloc()) DrawTextOp(text, bytesCount, count, - x, y, positions, refPaint(&paint), totalAdvance, bounds); - addDrawOp(op); - } + DrawOp* op = new (alloc()) DrawTextOp(text, bytesCount, count, + x, y, positions, refPaint(&paint), totalAdvance, bounds); + addDrawOp(op); } void DisplayListCanvas::drawRegion(const SkRegion& region, const SkPaint& paint) { diff --git a/libs/hwui/DisplayListCanvas.h b/libs/hwui/DisplayListCanvas.h index 28954d1bba70..f3f5713bbc3f 100644 --- a/libs/hwui/DisplayListCanvas.h +++ b/libs/hwui/DisplayListCanvas.h @@ -101,10 +101,6 @@ public: // TODO: rename for consistency void callDrawGLFunction(Functor* functor); - void setHighContrastText(bool highContrastText) { - mHighContrastText = highContrastText; - } - // ---------------------------------------------------------------------------- // CanvasStateClient interface // ---------------------------------------------------------------------------- @@ -125,6 +121,11 @@ public: virtual int width() override { return mState.getWidth(); } virtual int height() override { return mState.getHeight(); } + virtual void setHighContrastText(bool highContrastText) override { + mHighContrastText = highContrastText; + } + virtual bool isHighContrastText() override { return mHighContrastText; } + // ---------------------------------------------------------------------------- // android/graphics/Canvas state operations // ---------------------------------------------------------------------------- @@ -304,16 +305,6 @@ private: return cachedPaint; } - inline SkPaint* copyPaint(const SkPaint* paint) { - if (!paint) return nullptr; - - SkPaint* returnPaint = new SkPaint(*paint); - std::unique_ptr<const SkPaint> copy(returnPaint); - mDisplayListData->paints.push_back(std::move(copy)); - - return returnPaint; - } - inline const SkRegion* refRegion(const SkRegion* region) { if (!region) { return region; diff --git a/libs/hwui/Outline.h b/libs/hwui/Outline.h index c98932cf095e..8d4d4f085f98 100644 --- a/libs/hwui/Outline.h +++ b/libs/hwui/Outline.h @@ -33,13 +33,29 @@ public: , mAlpha(0.0f) {} void setRoundRect(int left, int top, int right, int bottom, float radius, float alpha) { + mAlpha = alpha; + if (mType == kOutlineType_RoundRect + && left == mBounds.left + && right == mBounds.right + && top == mBounds.top + && bottom == mBounds.bottom + && radius == mRadius) { + // nothing to change, don't do any work + return; + } + mType = kOutlineType_RoundRect; mBounds.set(left, top, right, bottom); mRadius = radius; + + // update mPath to reflect new outline mPath.reset(); - mPath.addRoundRect(SkRect::MakeLTRB(left, top, right, bottom), - radius, radius); - mAlpha = alpha; + if (MathUtils::isPositive(radius)) { + mPath.addRoundRect(SkRect::MakeLTRB(left, top, right, bottom), + radius, radius); + } else { + mPath.addRect(left, top, right, bottom); + } } void setConvexPath(const SkPath* outline, float alpha) { diff --git a/libs/hwui/SkiaCanvas.cpp b/libs/hwui/SkiaCanvas.cpp index 971b53aaf198..77079b7bb788 100644 --- a/libs/hwui/SkiaCanvas.cpp +++ b/libs/hwui/SkiaCanvas.cpp @@ -55,6 +55,11 @@ public: virtual int width() override; virtual int height() override; + virtual void setHighContrastText(bool highContrastText) override { + mHighContrastText = highContrastText; + } + virtual bool isHighContrastText() override { return mHighContrastText; } + virtual int getSaveCount() const override; virtual int save(SkCanvas::SaveFlags flags) override; virtual void restore() override; @@ -135,6 +140,8 @@ private: SkCanvas::SaveFlags saveFlags; }; + bool mHighContrastText = false; + void recordPartialSave(SkCanvas::SaveFlags flags); void saveClipsForFrame(SkTArray<SkClipStack::Element>& clips, int frameSaveCount); void applyClips(const SkTArray<SkClipStack::Element>& clips); |