Loading libs/hwui/RecordingCanvas.cpp +16 −1 Original line number Diff line number Diff line Loading @@ -51,6 +51,9 @@ #include "include/gpu/GrDirectContext.h" #include "pipeline/skia/AnimatedDrawables.h" #include "pipeline/skia/FunctorDrawable.h" #ifdef __ANDROID__ #include "renderthread/CanvasContext.h" #endif namespace android { namespace uirenderer { Loading Loading @@ -489,7 +492,19 @@ struct DrawPoints final : Op { size_t count; SkPaint paint; void draw(SkCanvas* c, const SkMatrix&) const { if (paint.isAntiAlias()) { c->drawPoints(mode, count, pod<SkPoint>(this), paint); } else { c->save(); #ifdef __ANDROID__ auto pixelSnap = renderthread::CanvasContext::getActiveContext()->getPixelSnapMatrix(); auto transform = c->getLocalToDevice(); transform.postConcat(pixelSnap); c->setMatrix(transform); #endif c->drawPoints(mode, count, pod<SkPoint>(this), paint); c->restore(); } } }; struct DrawVertices final : Op { Loading libs/hwui/pipeline/skia/SkiaOpenGLPipeline.h +8 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,14 @@ public: bool isSurfaceReady() override; bool isContextReady() override; const SkM44& getPixelSnapMatrix() const override { // Small (~1/16th) nudge to ensure that pixel-aligned non-AA'd draws fill the // desired fragment static const SkScalar kOffset = 0.063f; static const SkM44 sSnapMatrix = SkM44::Translate(kOffset, kOffset); return sSnapMatrix; } static void invokeFunctor(const renderthread::RenderThread& thread, Functor* functor); protected: Loading libs/hwui/pipeline/skia/SkiaVulkanPipeline.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -215,6 +215,10 @@ void SkiaVulkanPipeline::onContextDestroyed() { } } const SkM44& SkiaVulkanPipeline::getPixelSnapMatrix() const { return mVkSurface->getPixelSnapMatrix(); } } /* namespace skiapipeline */ } /* namespace uirenderer */ } /* namespace android */ libs/hwui/pipeline/skia/SkiaVulkanPipeline.h +1 −0 Original line number Diff line number Diff line Loading @@ -55,6 +55,7 @@ public: bool isContextReady() override; bool supportsExtendedRangeHdr() const override { return true; } void setTargetSdrHdrRatio(float ratio) override; const SkM44& getPixelSnapMatrix() const override; static void invokeFunctor(const renderthread::RenderThread& thread, Functor* functor); static sk_sp<Bitmap> allocateHardwareBitmap(renderthread::RenderThread& thread, Loading libs/hwui/renderthread/CanvasContext.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -871,6 +871,10 @@ SkISize CanvasContext::getNextFrameSize() const { return size; } const SkM44& CanvasContext::getPixelSnapMatrix() const { return mRenderPipeline->getPixelSnapMatrix(); } void CanvasContext::prepareAndDraw(RenderNode* node) { ATRACE_CALL(); Loading Loading
libs/hwui/RecordingCanvas.cpp +16 −1 Original line number Diff line number Diff line Loading @@ -51,6 +51,9 @@ #include "include/gpu/GrDirectContext.h" #include "pipeline/skia/AnimatedDrawables.h" #include "pipeline/skia/FunctorDrawable.h" #ifdef __ANDROID__ #include "renderthread/CanvasContext.h" #endif namespace android { namespace uirenderer { Loading Loading @@ -489,7 +492,19 @@ struct DrawPoints final : Op { size_t count; SkPaint paint; void draw(SkCanvas* c, const SkMatrix&) const { if (paint.isAntiAlias()) { c->drawPoints(mode, count, pod<SkPoint>(this), paint); } else { c->save(); #ifdef __ANDROID__ auto pixelSnap = renderthread::CanvasContext::getActiveContext()->getPixelSnapMatrix(); auto transform = c->getLocalToDevice(); transform.postConcat(pixelSnap); c->setMatrix(transform); #endif c->drawPoints(mode, count, pod<SkPoint>(this), paint); c->restore(); } } }; struct DrawVertices final : Op { Loading
libs/hwui/pipeline/skia/SkiaOpenGLPipeline.h +8 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,14 @@ public: bool isSurfaceReady() override; bool isContextReady() override; const SkM44& getPixelSnapMatrix() const override { // Small (~1/16th) nudge to ensure that pixel-aligned non-AA'd draws fill the // desired fragment static const SkScalar kOffset = 0.063f; static const SkM44 sSnapMatrix = SkM44::Translate(kOffset, kOffset); return sSnapMatrix; } static void invokeFunctor(const renderthread::RenderThread& thread, Functor* functor); protected: Loading
libs/hwui/pipeline/skia/SkiaVulkanPipeline.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -215,6 +215,10 @@ void SkiaVulkanPipeline::onContextDestroyed() { } } const SkM44& SkiaVulkanPipeline::getPixelSnapMatrix() const { return mVkSurface->getPixelSnapMatrix(); } } /* namespace skiapipeline */ } /* namespace uirenderer */ } /* namespace android */
libs/hwui/pipeline/skia/SkiaVulkanPipeline.h +1 −0 Original line number Diff line number Diff line Loading @@ -55,6 +55,7 @@ public: bool isContextReady() override; bool supportsExtendedRangeHdr() const override { return true; } void setTargetSdrHdrRatio(float ratio) override; const SkM44& getPixelSnapMatrix() const override; static void invokeFunctor(const renderthread::RenderThread& thread, Functor* functor); static sk_sp<Bitmap> allocateHardwareBitmap(renderthread::RenderThread& thread, Loading
libs/hwui/renderthread/CanvasContext.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -871,6 +871,10 @@ SkISize CanvasContext::getNextFrameSize() const { return size; } const SkM44& CanvasContext::getPixelSnapMatrix() const { return mRenderPipeline->getPixelSnapMatrix(); } void CanvasContext::prepareAndDraw(RenderNode* node) { ATRACE_CALL(); Loading