diff options
Diffstat (limited to 'libs')
-rw-r--r-- | libs/hwui/Readback.cpp | 27 | ||||
-rw-r--r-- | libs/hwui/apex/android_canvas.cpp | 4 | ||||
-rw-r--r-- | libs/hwui/pipeline/skia/GLFunctorDrawable.cpp | 2 | ||||
-rw-r--r-- | libs/hwui/pipeline/skia/SkiaOpenGLPipeline.cpp | 7 | ||||
-rw-r--r-- | libs/hwui/pipeline/skia/SkiaPipeline.cpp | 10 | ||||
-rw-r--r-- | libs/hwui/renderthread/VulkanSurface.cpp | 5 | ||||
-rw-r--r-- | libs/hwui/tests/unit/CacheManagerTests.cpp | 5 | ||||
-rw-r--r-- | libs/hwui/tests/unit/RenderNodeDrawableTests.cpp | 9 | ||||
-rw-r--r-- | libs/hwui/tests/unit/SkiaCanvasTests.cpp | 2 | ||||
-rw-r--r-- | libs/hwui/tests/unit/SkiaPipelineTests.cpp | 14 |
10 files changed, 46 insertions, 39 deletions
diff --git a/libs/hwui/Readback.cpp b/libs/hwui/Readback.cpp index 377b5bbc523e..afe4c3896ed2 100644 --- a/libs/hwui/Readback.cpp +++ b/libs/hwui/Readback.cpp @@ -30,6 +30,7 @@ #include <SkSamplingOptions.h> #include <SkSurface.h> #include "include/gpu/GpuTypes.h" // from Skia +#include <include/gpu/ganesh/SkSurfaceGanesh.h> #include <gui/TraceUtils.h> #include <private/android/AHardwareBufferHelpers.h> #include <shaders/shaders.h> @@ -173,16 +174,16 @@ void Readback::copySurfaceInto(ANativeWindow* window, const std::shared_ptr<Copy SkBitmap skBitmap = request->getDestinationBitmap(srcRect.width(), srcRect.height()); SkBitmap* bitmap = &skBitmap; sk_sp<SkSurface> tmpSurface = - SkSurface::MakeRenderTarget(mRenderThread.getGrContext(), skgpu::Budgeted::kYes, - bitmap->info(), 0, kTopLeft_GrSurfaceOrigin, nullptr); + SkSurfaces::RenderTarget(mRenderThread.getGrContext(), skgpu::Budgeted::kYes, + bitmap->info(), 0, kTopLeft_GrSurfaceOrigin, nullptr); // if we can't generate a GPU surface that matches the destination bitmap (e.g. 565) then we // attempt to do the intermediate rendering step in 8888 if (!tmpSurface.get()) { SkImageInfo tmpInfo = bitmap->info().makeColorType(SkColorType::kN32_SkColorType); - tmpSurface = SkSurface::MakeRenderTarget(mRenderThread.getGrContext(), - skgpu::Budgeted::kYes, - tmpInfo, 0, kTopLeft_GrSurfaceOrigin, nullptr); + tmpSurface = SkSurfaces::RenderTarget(mRenderThread.getGrContext(), + skgpu::Budgeted::kYes, + tmpInfo, 0, kTopLeft_GrSurfaceOrigin, nullptr); if (!tmpSurface.get()) { ALOGW("Unable to generate GPU buffer in a format compatible with the provided bitmap"); return request->onCopyFinished(CopyResult::UnknownError); @@ -348,19 +349,19 @@ bool Readback::copyLayerInto(Layer* layer, const SkRect* srcRect, const SkRect* * a scaling issue (b/62262733) that was encountered when sampling from an EGLImage into a * software buffer. */ - sk_sp<SkSurface> tmpSurface = SkSurface::MakeRenderTarget(mRenderThread.getGrContext(), - skgpu::Budgeted::kYes, - bitmap->info(), - 0, - kTopLeft_GrSurfaceOrigin, nullptr); + sk_sp<SkSurface> tmpSurface = SkSurfaces::RenderTarget(mRenderThread.getGrContext(), + skgpu::Budgeted::kYes, + bitmap->info(), + 0, + kTopLeft_GrSurfaceOrigin, nullptr); // if we can't generate a GPU surface that matches the destination bitmap (e.g. 565) then we // attempt to do the intermediate rendering step in 8888 if (!tmpSurface.get()) { SkImageInfo tmpInfo = bitmap->info().makeColorType(SkColorType::kN32_SkColorType); - tmpSurface = SkSurface::MakeRenderTarget(mRenderThread.getGrContext(), - skgpu::Budgeted::kYes, - tmpInfo, 0, kTopLeft_GrSurfaceOrigin, nullptr); + tmpSurface = SkSurfaces::RenderTarget(mRenderThread.getGrContext(), + skgpu::Budgeted::kYes, + tmpInfo, 0, kTopLeft_GrSurfaceOrigin, nullptr); if (!tmpSurface.get()) { ALOGW("Unable to generate GPU buffer in a format compatible with the provided bitmap"); return false; diff --git a/libs/hwui/apex/android_canvas.cpp b/libs/hwui/apex/android_canvas.cpp index 905b123076a2..19f726a31b33 100644 --- a/libs/hwui/apex/android_canvas.cpp +++ b/libs/hwui/apex/android_canvas.cpp @@ -45,9 +45,9 @@ static bool convert(const ANativeWindow_Buffer* buffer, SkImageInfo imageInfo = uirenderer::ANativeWindowToImageInfo(*buffer, cs); size_t rowBytes = buffer->stride * imageInfo.bytesPerPixel(); - // If SkSurface::MakeRasterDirect fails then we should as well as we will not be able to + // If SkSurfaces::WrapPixels fails then we should as well as we will not be able to // draw into the canvas. - sk_sp<SkSurface> surface = SkSurface::MakeRasterDirect(imageInfo, buffer->bits, rowBytes); + sk_sp<SkSurface> surface = SkSurfaces::WrapPixels(imageInfo, buffer->bits, rowBytes); if (surface.get() != nullptr) { if (outBitmap) { outBitmap->setInfo(imageInfo, rowBytes); diff --git a/libs/hwui/pipeline/skia/GLFunctorDrawable.cpp b/libs/hwui/pipeline/skia/GLFunctorDrawable.cpp index 70d7f4281ab6..ff7c89a468de 100644 --- a/libs/hwui/pipeline/skia/GLFunctorDrawable.cpp +++ b/libs/hwui/pipeline/skia/GLFunctorDrawable.cpp @@ -96,7 +96,7 @@ void GLFunctorDrawable::onDraw(SkCanvas* canvas) { SkImageInfo surfaceInfo = canvas->imageInfo().makeWH(clipBounds.width(), clipBounds.height()); tmpSurface = - SkSurface::MakeRenderTarget(directContext, skgpu::Budgeted::kYes, surfaceInfo); + SkSurfaces::RenderTarget(directContext, skgpu::Budgeted::kYes, surfaceInfo); tmpSurface->getCanvas()->clear(SK_ColorTRANSPARENT); GrGLFramebufferInfo fboInfo; diff --git a/libs/hwui/pipeline/skia/SkiaOpenGLPipeline.cpp b/libs/hwui/pipeline/skia/SkiaOpenGLPipeline.cpp index cf31173d266e..17f30c2689a2 100644 --- a/libs/hwui/pipeline/skia/SkiaOpenGLPipeline.cpp +++ b/libs/hwui/pipeline/skia/SkiaOpenGLPipeline.cpp @@ -16,6 +16,7 @@ #include "SkiaOpenGLPipeline.h" +#include <include/gpu/ganesh/SkSurfaceGanesh.h> #include <GrBackendSurface.h> #include <SkBlendMode.h> #include <SkImageInfo.h> @@ -150,9 +151,9 @@ IRenderPipeline::DrawResult SkiaOpenGLPipeline::draw( surface = getBufferSkSurface(bufferParams); preTransform = bufferParams.getTransform(); } else { - surface = SkSurface::MakeFromBackendRenderTarget(mRenderThread.getGrContext(), backendRT, - getSurfaceOrigin(), colorType, - mSurfaceColorSpace, &props); + surface = SkSurfaces::WrapBackendRenderTarget(mRenderThread.getGrContext(), backendRT, + getSurfaceOrigin(), colorType, + mSurfaceColorSpace, &props); preTransform = SkMatrix::I(); } diff --git a/libs/hwui/pipeline/skia/SkiaPipeline.cpp b/libs/hwui/pipeline/skia/SkiaPipeline.cpp index 494633d57210..3d77877cf6eb 100644 --- a/libs/hwui/pipeline/skia/SkiaPipeline.cpp +++ b/libs/hwui/pipeline/skia/SkiaPipeline.cpp @@ -16,6 +16,8 @@ #include "SkiaPipeline.h" +#include <include/android/SkSurfaceAndroid.h> +#include <include/gpu/ganesh/SkSurfaceGanesh.h> #include <SkCanvas.h> #include <SkColor.h> #include <SkColorSpace.h> @@ -186,9 +188,9 @@ bool SkiaPipeline::createOrUpdateLayer(RenderNode* node, const DamageAccumulator kPremul_SkAlphaType, getSurfaceColorSpace()); SkSurfaceProps props(0, kUnknown_SkPixelGeometry); SkASSERT(mRenderThread.getGrContext() != nullptr); - node->setLayerSurface(SkSurface::MakeRenderTarget(mRenderThread.getGrContext(), - skgpu::Budgeted::kYes, info, 0, - this->getSurfaceOrigin(), &props)); + node->setLayerSurface(SkSurfaces::RenderTarget(mRenderThread.getGrContext(), + skgpu::Budgeted::kYes, info, 0, + this->getSurfaceOrigin(), &props)); if (node->getLayerSurface()) { // update the transform in window of the layer to reset its origin wrt light source // position @@ -620,7 +622,7 @@ sk_sp<SkSurface> SkiaPipeline::getBufferSkSurface( auto bufferColorSpace = bufferParams.getColorSpace(); if (mBufferSurface == nullptr || mBufferColorSpace == nullptr || !SkColorSpace::Equals(mBufferColorSpace.get(), bufferColorSpace.get())) { - mBufferSurface = SkSurface::MakeFromAHardwareBuffer( + mBufferSurface = SkSurfaces::WrapAndroidHardwareBuffer( mRenderThread.getGrContext(), mHardwareBuffer, kTopLeft_GrSurfaceOrigin, bufferColorSpace, nullptr, true); mBufferColorSpace = bufferColorSpace; diff --git a/libs/hwui/renderthread/VulkanSurface.cpp b/libs/hwui/renderthread/VulkanSurface.cpp index 3168cb09291b..b0ba619c63a4 100644 --- a/libs/hwui/renderthread/VulkanSurface.cpp +++ b/libs/hwui/renderthread/VulkanSurface.cpp @@ -16,6 +16,7 @@ #include "VulkanSurface.h" +#include <include/android/SkSurfaceAndroid.h> #include <GrDirectContext.h> #include <SkSurface.h> #include <algorithm> @@ -470,12 +471,12 @@ VulkanSurface::NativeBufferInfo* VulkanSurface::dequeueNativeBuffer() { surfaceProps = SkSurfaceProps(SkSurfaceProps::kAlwaysDither_Flag | surfaceProps.flags(), surfaceProps.pixelGeometry()); } - bufferInfo->skSurface = SkSurface::MakeFromAHardwareBuffer( + bufferInfo->skSurface = SkSurfaces::WrapAndroidHardwareBuffer( mGrContext, ANativeWindowBuffer_getHardwareBuffer(bufferInfo->buffer.get()), kTopLeft_GrSurfaceOrigin, mWindowInfo.colorspace, &surfaceProps, /*from_window=*/true); if (bufferInfo->skSurface.get() == nullptr) { - ALOGE("SkSurface::MakeFromAHardwareBuffer failed"); + ALOGE("SkSurfaces::WrapAndroidHardwareBuffer failed"); mNativeWindow->cancelBuffer(mNativeWindow.get(), buffer, mNativeBuffers[idx].dequeue_fence.release()); mNativeBuffers[idx].dequeued = false; diff --git a/libs/hwui/tests/unit/CacheManagerTests.cpp b/libs/hwui/tests/unit/CacheManagerTests.cpp index 03a955c83870..cc7d34b3994e 100644 --- a/libs/hwui/tests/unit/CacheManagerTests.cpp +++ b/libs/hwui/tests/unit/CacheManagerTests.cpp @@ -21,6 +21,7 @@ #include "tests/common/TestUtils.h" #include <SkImageAndroid.h> +#include <include/gpu/ganesh/SkSurfaceGanesh.h> #include "include/gpu/GpuTypes.h" // from Skia using namespace android; @@ -46,8 +47,8 @@ RENDERTHREAD_SKIA_PIPELINE_TEST(CacheManager, DISABLED_trimMemory) { while (getCacheUsage(grContext) <= renderThread.cacheManager().getBackgroundCacheSize()) { SkImageInfo info = SkImageInfo::MakeA8(width, height); - sk_sp<SkSurface> surface = SkSurface::MakeRenderTarget(grContext, skgpu::Budgeted::kYes, - info); + sk_sp<SkSurface> surface = SkSurfaces::RenderTarget(grContext, skgpu::Budgeted::kYes, + info); surface->getCanvas()->drawColor(SK_AlphaTRANSPARENT); grContext->flushAndSubmit(); diff --git a/libs/hwui/tests/unit/RenderNodeDrawableTests.cpp b/libs/hwui/tests/unit/RenderNodeDrawableTests.cpp index 596bd37e4cf5..dd95c4f6e525 100644 --- a/libs/hwui/tests/unit/RenderNodeDrawableTests.cpp +++ b/libs/hwui/tests/unit/RenderNodeDrawableTests.cpp @@ -141,7 +141,7 @@ TEST(RenderNodeDrawable, zReorder) { } TEST(RenderNodeDrawable, composeOnLayer) { - auto surface = SkSurface::MakeRasterN32Premul(1, 1); + auto surface = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(1, 1)); SkCanvas& canvas = *surface->getCanvas(); canvas.drawColor(SK_ColorBLUE, SkBlendMode::kSrcOver); ASSERT_EQ(TestUtils::getColor(surface, 0, 0), SK_ColorBLUE); @@ -152,7 +152,7 @@ TEST(RenderNodeDrawable, composeOnLayer) { }); // attach a layer to the render node - auto surfaceLayer = SkSurface::MakeRasterN32Premul(1, 1); + auto surfaceLayer = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(1, 1)); auto canvas2 = surfaceLayer->getCanvas(); canvas2->drawColor(SK_ColorWHITE, SkBlendMode::kSrcOver); rootNode->setLayerSurface(surfaceLayer); @@ -187,7 +187,7 @@ static SkMatrix getRecorderMatrix(const SkiaRecordingCanvas& recorder) { } TEST(RenderNodeDrawable, saveLayerClipAndMatrixRestore) { - auto surface = SkSurface::MakeRasterN32Premul(400, 800); + auto surface = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(400, 800)); SkCanvas& canvas = *surface->getCanvas(); canvas.drawColor(SK_ColorWHITE, SkBlendMode::kSrcOver); ASSERT_EQ(TestUtils::getColor(surface, 0, 0), SK_ColorWHITE); @@ -1074,7 +1074,8 @@ RENDERTHREAD_SKIA_PIPELINE_TEST(RenderNodeDrawable, layerComposeQuality) { }); layerNode->animatorProperties().mutateLayerProperties().setType(LayerType::RenderLayer); - layerNode->setLayerSurface(SkSurface::MakeRasterN32Premul(LAYER_WIDTH, LAYER_HEIGHT)); + layerNode->setLayerSurface(SkSurfaces::Raster(SkImageInfo::MakeN32Premul(LAYER_WIDTH, + LAYER_HEIGHT))); FrameTestCanvas canvas; RenderNodeDrawable drawable(layerNode.get(), &canvas, true); diff --git a/libs/hwui/tests/unit/SkiaCanvasTests.cpp b/libs/hwui/tests/unit/SkiaCanvasTests.cpp index 87c52161d68e..e53fcaa474e2 100644 --- a/libs/hwui/tests/unit/SkiaCanvasTests.cpp +++ b/libs/hwui/tests/unit/SkiaCanvasTests.cpp @@ -36,7 +36,7 @@ using namespace android; using namespace android::uirenderer; TEST(SkiaCanvas, drawShadowLayer) { - auto surface = SkSurface::MakeRasterN32Premul(10, 10); + auto surface = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(10, 10)); SkiaCanvas canvas(surface->getCanvas()); // clear to white diff --git a/libs/hwui/tests/unit/SkiaPipelineTests.cpp b/libs/hwui/tests/unit/SkiaPipelineTests.cpp index 4d0595e03da6..6f180e7498cb 100644 --- a/libs/hwui/tests/unit/SkiaPipelineTests.cpp +++ b/libs/hwui/tests/unit/SkiaPipelineTests.cpp @@ -54,7 +54,7 @@ RENDERTHREAD_SKIA_PIPELINE_TEST(SkiaPipeline, renderFrame) { bool opaque = true; android::uirenderer::Rect contentDrawBounds(0, 0, 1, 1); auto pipeline = std::make_unique<SkiaOpenGLPipeline>(renderThread); - auto surface = SkSurface::MakeRasterN32Premul(1, 1); + auto surface = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(1, 1)); surface->getCanvas()->drawColor(SK_ColorBLUE, SkBlendMode::kSrcOver); ASSERT_EQ(TestUtils::getColor(surface, 0, 0), SK_ColorBLUE); pipeline->renderFrame(layerUpdateQueue, dirty, renderNodes, opaque, contentDrawBounds, surface, @@ -76,7 +76,7 @@ RENDERTHREAD_SKIA_PIPELINE_TEST(SkiaPipeline, renderFrameCheckOpaque) { renderNodes.push_back(halfGreenNode); android::uirenderer::Rect contentDrawBounds(0, 0, 2, 2); auto pipeline = std::make_unique<SkiaOpenGLPipeline>(renderThread); - auto surface = SkSurface::MakeRasterN32Premul(2, 2); + auto surface = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(2, 2)); surface->getCanvas()->drawColor(SK_ColorBLUE, SkBlendMode::kSrcOver); ASSERT_EQ(TestUtils::getColor(surface, 0, 0), SK_ColorBLUE); pipeline->renderFrame(layerUpdateQueue, dirty, renderNodes, true, contentDrawBounds, surface, @@ -100,7 +100,7 @@ RENDERTHREAD_SKIA_PIPELINE_TEST(SkiaPipeline, renderFrameCheckDirtyRect) { renderNodes.push_back(redNode); android::uirenderer::Rect contentDrawBounds(0, 0, 2, 2); auto pipeline = std::make_unique<SkiaOpenGLPipeline>(renderThread); - auto surface = SkSurface::MakeRasterN32Premul(2, 2); + auto surface = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(2, 2)); surface->getCanvas()->drawColor(SK_ColorBLUE, SkBlendMode::kSrcOver); ASSERT_EQ(TestUtils::getColor(surface, 0, 0), SK_ColorBLUE); pipeline->renderFrame(layerUpdateQueue, dirty, renderNodes, true, contentDrawBounds, surface, @@ -116,7 +116,7 @@ RENDERTHREAD_SKIA_PIPELINE_TEST(SkiaPipeline, renderLayer) { 0, 0, 1, 1, [](RenderProperties& props, SkiaRecordingCanvas& redCanvas) { redCanvas.drawColor(SK_ColorRED, SkBlendMode::kSrcOver); }); - auto surfaceLayer1 = SkSurface::MakeRasterN32Premul(1, 1); + auto surfaceLayer1 = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(1, 1)); surfaceLayer1->getCanvas()->drawColor(SK_ColorWHITE, SkBlendMode::kSrcOver); ASSERT_EQ(TestUtils::getColor(surfaceLayer1, 0, 0), SK_ColorWHITE); redNode->setLayerSurface(surfaceLayer1); @@ -127,7 +127,7 @@ RENDERTHREAD_SKIA_PIPELINE_TEST(SkiaPipeline, renderLayer) { 0, 0, 2, 2, [](RenderProperties& props, SkiaRecordingCanvas& blueCanvas) { blueCanvas.drawColor(SK_ColorBLUE, SkBlendMode::kSrcOver); }); - auto surfaceLayer2 = SkSurface::MakeRasterN32Premul(2, 2); + auto surfaceLayer2 = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(2, 2)); surfaceLayer2->getCanvas()->drawColor(SK_ColorWHITE, SkBlendMode::kSrcOver); ASSERT_EQ(TestUtils::getColor(surfaceLayer2, 0, 0), SK_ColorWHITE); blueNode->setLayerSurface(surfaceLayer2); @@ -169,7 +169,7 @@ RENDERTHREAD_SKIA_PIPELINE_TEST(SkiaPipeline, renderOverdraw) { // empty contentDrawBounds is avoiding backdrop/content logic, which would lead to less overdraw android::uirenderer::Rect contentDrawBounds(0, 0, 0, 0); auto pipeline = std::make_unique<SkiaOpenGLPipeline>(renderThread); - auto surface = SkSurface::MakeRasterN32Premul(1, 1); + auto surface = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(1, 1)); // Initialize the canvas to blue. surface->getCanvas()->drawColor(SK_ColorBLUE, SkBlendMode::kSrcOver); @@ -428,7 +428,7 @@ RENDERTHREAD_SKIA_PIPELINE_TEST(SkiaPipeline, pictureCallback) { renderNodes.push_back(redNode); bool opaque = true; android::uirenderer::Rect contentDrawBounds(0, 0, 1, 1); - auto surface = SkSurface::MakeRasterN32Premul(1, 1); + auto surface = SkSurfaces::Raster(SkImageInfo::MakeN32Premul(1, 1)); pipeline->renderFrame(layerUpdateQueue, dirty, renderNodes, opaque, contentDrawBounds, surface, SkMatrix::I()); |