Loading libs/hwui/DeferredLayerUpdater.cpp +8 −6 Original line number Diff line number Diff line Loading @@ -167,12 +167,13 @@ void DeferredLayerUpdater::apply() { // (invoked by createIfNeeded) will add a ref to the AHardwareBuffer. AHardwareBuffer_release(hardwareBuffer); if (layerImage.get()) { SkMatrix textureTransform; mat4(transformMatrix).copyTo(textureTransform); // force filtration if buffer size != layer size bool forceFilter = mWidth != layerImage->width() || mHeight != layerImage->height(); updateLayer(forceFilter, textureTransform, layerImage); SkRect currentCropRect = SkRect::MakeLTRB(currentCrop.left, currentCrop.top, currentCrop.right, currentCrop.bottom); updateLayer(forceFilter, layerImage, outTransform, currentCropRect); } } } Loading @@ -184,12 +185,13 @@ void DeferredLayerUpdater::apply() { } } void DeferredLayerUpdater::updateLayer(bool forceFilter, const SkMatrix& textureTransform, const sk_sp<SkImage>& layerImage) { void DeferredLayerUpdater::updateLayer(bool forceFilter, const sk_sp<SkImage>& layerImage, const uint32_t transform, SkRect currentCrop) { mLayer->setBlend(mBlend); mLayer->setForceFilter(forceFilter); mLayer->setSize(mWidth, mHeight); mLayer->getTexTransform() = textureTransform; mLayer->setCurrentCropRect(currentCrop); mLayer->setWindowTransform(transform); mLayer->setImage(layerImage); } Loading libs/hwui/DeferredLayerUpdater.h +2 −2 Original line number Diff line number Diff line Loading @@ -90,8 +90,8 @@ public: void detachSurfaceTexture(); void updateLayer(bool forceFilter, const SkMatrix& textureTransform, const sk_sp<SkImage>& layerImage); void updateLayer(bool forceFilter, const sk_sp<SkImage>& layerImage, const uint32_t transform, SkRect currentCrop); void destroyLayer(); Loading libs/hwui/Layer.cpp +0 −2 Original line number Diff line number Diff line Loading @@ -35,7 +35,6 @@ Layer::Layer(RenderState& renderState, sk_sp<SkColorFilter> colorFilter, int alp // preserves the old inc/dec ref locations. This should be changed... incStrong(nullptr); renderState.registerLayer(this); texTransform.setIdentity(); transform.setIdentity(); } Loading Loading @@ -101,7 +100,6 @@ void Layer::draw(SkCanvas* canvas) { const int layerHeight = getHeight(); if (layerImage) { SkMatrix textureMatrixInv; textureMatrixInv = getTexTransform(); // TODO: after skia bug https://bugs.chromium.org/p/skia/issues/detail?id=7075 is fixed // use bottom left origin and remove flipV and invert transformations. SkMatrix flipV; Loading libs/hwui/Layer.h +19 −6 Original line number Diff line number Diff line Loading @@ -74,10 +74,18 @@ public: void setColorFilter(sk_sp<SkColorFilter> filter) { mColorFilter = filter; }; inline SkMatrix& getTexTransform() { return texTransform; } inline SkMatrix& getTransform() { return transform; } inline SkRect getCurrentCropRect() { return mCurrentCropRect; } inline void setCurrentCropRect(const SkRect currentCropRect) { mCurrentCropRect = currentCropRect; } inline void setWindowTransform(uint32_t windowTransform) { mWindowTransform = windowTransform; } inline uint32_t getWindowTransform() { return mWindowTransform; } /** * Posts a decStrong call to the appropriate thread. * Thread-safe. Loading Loading @@ -116,14 +124,19 @@ private: SkBlendMode mode; /** * Optional texture coordinates transform. * Optional transform. */ SkMatrix texTransform; SkMatrix transform; /** * Optional transform. * Optional crop */ SkMatrix transform; SkRect mCurrentCropRect; /** * Optional transform */ uint32_t mWindowTransform; /** * An image backing the layer. Loading libs/hwui/Readback.cpp +5 −18 Original line number Diff line number Diff line Loading @@ -243,18 +243,14 @@ CopyResult Readback::copySurfaceIntoLegacy(ANativeWindow* window, const Rect& sr static_cast<android_dataspace>(ANativeWindow_getBuffersDataSpace(window))); sk_sp<SkImage> image = SkImage::MakeFromAHardwareBuffer(sourceBuffer.get(), kPremul_SkAlphaType, colorSpace); return copyImageInto(image, texTransform, srcRect, bitmap); return copyImageInto(image, srcRect, bitmap); } CopyResult Readback::copyHWBitmapInto(Bitmap* hwBitmap, SkBitmap* bitmap) { LOG_ALWAYS_FATAL_IF(!hwBitmap->isHardware()); Rect srcRect; Matrix4 transform; transform.loadScale(1, -1, 1); transform.translate(0, -1); return copyImageInto(hwBitmap->makeImage(), transform, srcRect, bitmap); return copyImageInto(hwBitmap->makeImage(), srcRect, bitmap); } CopyResult Readback::copyLayerInto(DeferredLayerUpdater* deferredLayer, SkBitmap* bitmap) { Loading @@ -279,14 +275,11 @@ CopyResult Readback::copyLayerInto(DeferredLayerUpdater* deferredLayer, SkBitmap CopyResult Readback::copyImageInto(const sk_sp<SkImage>& image, SkBitmap* bitmap) { Rect srcRect; Matrix4 transform; transform.loadScale(1, -1, 1); transform.translate(0, -1); return copyImageInto(image, transform, srcRect, bitmap); return copyImageInto(image, srcRect, bitmap); } CopyResult Readback::copyImageInto(const sk_sp<SkImage>& image, Matrix4& texTransform, const Rect& srcRect, SkBitmap* bitmap) { CopyResult Readback::copyImageInto(const sk_sp<SkImage>& image, const Rect& srcRect, SkBitmap* bitmap) { ATRACE_CALL(); if (Properties::getRenderPipelineType() == RenderPipelineType::SkiaGL) { mRenderThread.requireGlContext(); Loading @@ -303,11 +296,6 @@ CopyResult Readback::copyImageInto(const sk_sp<SkImage>& image, Matrix4& texTran CopyResult copyResult = CopyResult::UnknownError; int displayedWidth = imgWidth, displayedHeight = imgHeight; // If this is a 90 or 270 degree rotation we need to swap width/height to get the device // size. if (texTransform[Matrix4::kSkewX] >= 0.5f || texTransform[Matrix4::kSkewX] <= -0.5f) { std::swap(displayedWidth, displayedHeight); } SkRect skiaDestRect = SkRect::MakeWH(bitmap->width(), bitmap->height()); SkRect skiaSrcRect = srcRect.toSkRect(); if (skiaSrcRect.isEmpty()) { Loading @@ -320,7 +308,6 @@ CopyResult Readback::copyImageInto(const sk_sp<SkImage>& image, Matrix4& texTran Layer layer(mRenderThread.renderState(), nullptr, 255, SkBlendMode::kSrc); layer.setSize(displayedWidth, displayedHeight); texTransform.copyTo(layer.getTexTransform()); layer.setImage(image); // Scaling filter is not explicitly set here, because it is done inside copyLayerInfo // after checking the necessity based on the src/dest rect size and the transformation. Loading Loading
libs/hwui/DeferredLayerUpdater.cpp +8 −6 Original line number Diff line number Diff line Loading @@ -167,12 +167,13 @@ void DeferredLayerUpdater::apply() { // (invoked by createIfNeeded) will add a ref to the AHardwareBuffer. AHardwareBuffer_release(hardwareBuffer); if (layerImage.get()) { SkMatrix textureTransform; mat4(transformMatrix).copyTo(textureTransform); // force filtration if buffer size != layer size bool forceFilter = mWidth != layerImage->width() || mHeight != layerImage->height(); updateLayer(forceFilter, textureTransform, layerImage); SkRect currentCropRect = SkRect::MakeLTRB(currentCrop.left, currentCrop.top, currentCrop.right, currentCrop.bottom); updateLayer(forceFilter, layerImage, outTransform, currentCropRect); } } } Loading @@ -184,12 +185,13 @@ void DeferredLayerUpdater::apply() { } } void DeferredLayerUpdater::updateLayer(bool forceFilter, const SkMatrix& textureTransform, const sk_sp<SkImage>& layerImage) { void DeferredLayerUpdater::updateLayer(bool forceFilter, const sk_sp<SkImage>& layerImage, const uint32_t transform, SkRect currentCrop) { mLayer->setBlend(mBlend); mLayer->setForceFilter(forceFilter); mLayer->setSize(mWidth, mHeight); mLayer->getTexTransform() = textureTransform; mLayer->setCurrentCropRect(currentCrop); mLayer->setWindowTransform(transform); mLayer->setImage(layerImage); } Loading
libs/hwui/DeferredLayerUpdater.h +2 −2 Original line number Diff line number Diff line Loading @@ -90,8 +90,8 @@ public: void detachSurfaceTexture(); void updateLayer(bool forceFilter, const SkMatrix& textureTransform, const sk_sp<SkImage>& layerImage); void updateLayer(bool forceFilter, const sk_sp<SkImage>& layerImage, const uint32_t transform, SkRect currentCrop); void destroyLayer(); Loading
libs/hwui/Layer.cpp +0 −2 Original line number Diff line number Diff line Loading @@ -35,7 +35,6 @@ Layer::Layer(RenderState& renderState, sk_sp<SkColorFilter> colorFilter, int alp // preserves the old inc/dec ref locations. This should be changed... incStrong(nullptr); renderState.registerLayer(this); texTransform.setIdentity(); transform.setIdentity(); } Loading Loading @@ -101,7 +100,6 @@ void Layer::draw(SkCanvas* canvas) { const int layerHeight = getHeight(); if (layerImage) { SkMatrix textureMatrixInv; textureMatrixInv = getTexTransform(); // TODO: after skia bug https://bugs.chromium.org/p/skia/issues/detail?id=7075 is fixed // use bottom left origin and remove flipV and invert transformations. SkMatrix flipV; Loading
libs/hwui/Layer.h +19 −6 Original line number Diff line number Diff line Loading @@ -74,10 +74,18 @@ public: void setColorFilter(sk_sp<SkColorFilter> filter) { mColorFilter = filter; }; inline SkMatrix& getTexTransform() { return texTransform; } inline SkMatrix& getTransform() { return transform; } inline SkRect getCurrentCropRect() { return mCurrentCropRect; } inline void setCurrentCropRect(const SkRect currentCropRect) { mCurrentCropRect = currentCropRect; } inline void setWindowTransform(uint32_t windowTransform) { mWindowTransform = windowTransform; } inline uint32_t getWindowTransform() { return mWindowTransform; } /** * Posts a decStrong call to the appropriate thread. * Thread-safe. Loading Loading @@ -116,14 +124,19 @@ private: SkBlendMode mode; /** * Optional texture coordinates transform. * Optional transform. */ SkMatrix texTransform; SkMatrix transform; /** * Optional transform. * Optional crop */ SkMatrix transform; SkRect mCurrentCropRect; /** * Optional transform */ uint32_t mWindowTransform; /** * An image backing the layer. Loading
libs/hwui/Readback.cpp +5 −18 Original line number Diff line number Diff line Loading @@ -243,18 +243,14 @@ CopyResult Readback::copySurfaceIntoLegacy(ANativeWindow* window, const Rect& sr static_cast<android_dataspace>(ANativeWindow_getBuffersDataSpace(window))); sk_sp<SkImage> image = SkImage::MakeFromAHardwareBuffer(sourceBuffer.get(), kPremul_SkAlphaType, colorSpace); return copyImageInto(image, texTransform, srcRect, bitmap); return copyImageInto(image, srcRect, bitmap); } CopyResult Readback::copyHWBitmapInto(Bitmap* hwBitmap, SkBitmap* bitmap) { LOG_ALWAYS_FATAL_IF(!hwBitmap->isHardware()); Rect srcRect; Matrix4 transform; transform.loadScale(1, -1, 1); transform.translate(0, -1); return copyImageInto(hwBitmap->makeImage(), transform, srcRect, bitmap); return copyImageInto(hwBitmap->makeImage(), srcRect, bitmap); } CopyResult Readback::copyLayerInto(DeferredLayerUpdater* deferredLayer, SkBitmap* bitmap) { Loading @@ -279,14 +275,11 @@ CopyResult Readback::copyLayerInto(DeferredLayerUpdater* deferredLayer, SkBitmap CopyResult Readback::copyImageInto(const sk_sp<SkImage>& image, SkBitmap* bitmap) { Rect srcRect; Matrix4 transform; transform.loadScale(1, -1, 1); transform.translate(0, -1); return copyImageInto(image, transform, srcRect, bitmap); return copyImageInto(image, srcRect, bitmap); } CopyResult Readback::copyImageInto(const sk_sp<SkImage>& image, Matrix4& texTransform, const Rect& srcRect, SkBitmap* bitmap) { CopyResult Readback::copyImageInto(const sk_sp<SkImage>& image, const Rect& srcRect, SkBitmap* bitmap) { ATRACE_CALL(); if (Properties::getRenderPipelineType() == RenderPipelineType::SkiaGL) { mRenderThread.requireGlContext(); Loading @@ -303,11 +296,6 @@ CopyResult Readback::copyImageInto(const sk_sp<SkImage>& image, Matrix4& texTran CopyResult copyResult = CopyResult::UnknownError; int displayedWidth = imgWidth, displayedHeight = imgHeight; // If this is a 90 or 270 degree rotation we need to swap width/height to get the device // size. if (texTransform[Matrix4::kSkewX] >= 0.5f || texTransform[Matrix4::kSkewX] <= -0.5f) { std::swap(displayedWidth, displayedHeight); } SkRect skiaDestRect = SkRect::MakeWH(bitmap->width(), bitmap->height()); SkRect skiaSrcRect = srcRect.toSkRect(); if (skiaSrcRect.isEmpty()) { Loading @@ -320,7 +308,6 @@ CopyResult Readback::copyImageInto(const sk_sp<SkImage>& image, Matrix4& texTran Layer layer(mRenderThread.renderState(), nullptr, 255, SkBlendMode::kSrc); layer.setSize(displayedWidth, displayedHeight); texTransform.copyTo(layer.getTexTransform()); layer.setImage(image); // Scaling filter is not explicitly set here, because it is done inside copyLayerInfo // after checking the necessity based on the src/dest rect size and the transformation. Loading