diff options
-rw-r--r-- | libs/hwui/AutoBackendTextureRelease.cpp | 10 | ||||
-rw-r--r-- | libs/hwui/AutoBackendTextureRelease.h | 9 | ||||
-rw-r--r-- | libs/hwui/DeferredLayerUpdater.cpp | 2 | ||||
-rw-r--r-- | libs/hwui/DeferredLayerUpdater.h | 2 | ||||
-rw-r--r-- | libs/hwui/HardwareBitmapUploader.cpp | 4 | ||||
-rw-r--r-- | libs/hwui/Readback.cpp | 2 | ||||
-rw-r--r-- | libs/hwui/pipeline/skia/GLFunctorDrawable.cpp | 2 | ||||
-rw-r--r-- | libs/hwui/pipeline/skia/LayerDrawable.cpp | 10 | ||||
-rw-r--r-- | libs/hwui/pipeline/skia/LayerDrawable.h | 8 | ||||
-rw-r--r-- | libs/hwui/renderthread/RenderThread.cpp | 6 | ||||
-rw-r--r-- | libs/hwui/renderthread/RenderThread.h | 8 | ||||
-rw-r--r-- | libs/hwui/renderthread/VulkanManager.cpp | 16 | ||||
-rw-r--r-- | libs/hwui/renderthread/VulkanManager.h | 12 | ||||
-rw-r--r-- | libs/hwui/tests/unit/CacheManagerTests.cpp | 4 |
14 files changed, 56 insertions, 39 deletions
diff --git a/libs/hwui/AutoBackendTextureRelease.cpp b/libs/hwui/AutoBackendTextureRelease.cpp index 72747e8fa543..33264d5d5c86 100644 --- a/libs/hwui/AutoBackendTextureRelease.cpp +++ b/libs/hwui/AutoBackendTextureRelease.cpp @@ -25,7 +25,8 @@ using namespace android::uirenderer::renderthread; namespace android { namespace uirenderer { -AutoBackendTextureRelease::AutoBackendTextureRelease(GrContext* context, AHardwareBuffer* buffer) { +AutoBackendTextureRelease::AutoBackendTextureRelease(GrDirectContext* context, + AHardwareBuffer* buffer) { AHardwareBuffer_Desc desc; AHardwareBuffer_describe(buffer, &desc); bool createProtectedImage = 0 != (desc.usage & AHARDWAREBUFFER_USAGE_PROTECTED_CONTENT); @@ -67,8 +68,9 @@ static void releaseProc(SkImage::ReleaseContext releaseContext) { textureRelease->unref(false); } -void AutoBackendTextureRelease::makeImage(AHardwareBuffer* buffer, android_dataspace dataspace, - GrContext* context) { +void AutoBackendTextureRelease::makeImage(AHardwareBuffer* buffer, + android_dataspace dataspace, + GrDirectContext* context) { AHardwareBuffer_Desc desc; AHardwareBuffer_describe(buffer, &desc); SkColorType colorType = GrAHardwareBufferUtils::GetSkColorTypeFromBufferFormat(desc.format); @@ -81,7 +83,7 @@ void AutoBackendTextureRelease::makeImage(AHardwareBuffer* buffer, android_datas } } -void AutoBackendTextureRelease::newBufferContent(GrContext* context) { +void AutoBackendTextureRelease::newBufferContent(GrDirectContext* context) { if (mBackendTexture.isValid()) { mUpdateProc(mImageCtx, context); } diff --git a/libs/hwui/AutoBackendTextureRelease.h b/libs/hwui/AutoBackendTextureRelease.h index acdd63cb7921..06f51fcd1105 100644 --- a/libs/hwui/AutoBackendTextureRelease.h +++ b/libs/hwui/AutoBackendTextureRelease.h @@ -31,7 +31,8 @@ namespace uirenderer { */ class AutoBackendTextureRelease final { public: - AutoBackendTextureRelease(GrContext* context, AHardwareBuffer* buffer); + AutoBackendTextureRelease(GrDirectContext* context, + AHardwareBuffer* buffer); const GrBackendTexture& getTexture() const { return mBackendTexture; } @@ -42,9 +43,11 @@ public: inline sk_sp<SkImage> getImage() const { return mImage; } - void makeImage(AHardwareBuffer* buffer, android_dataspace dataspace, GrContext* context); + void makeImage(AHardwareBuffer* buffer, + android_dataspace dataspace, + GrDirectContext* context); - void newBufferContent(GrContext* context); + void newBufferContent(GrDirectContext* context); private: // The only way to invoke dtor is with unref, when mUsageCount is 0. diff --git a/libs/hwui/DeferredLayerUpdater.cpp b/libs/hwui/DeferredLayerUpdater.cpp index 67d8c07e61de..6589dbd50cf7 100644 --- a/libs/hwui/DeferredLayerUpdater.cpp +++ b/libs/hwui/DeferredLayerUpdater.cpp @@ -189,7 +189,7 @@ void DeferredLayerUpdater::detachSurfaceTexture() { sk_sp<SkImage> DeferredLayerUpdater::ImageSlot::createIfNeeded(AHardwareBuffer* buffer, android_dataspace dataspace, bool forceCreate, - GrContext* context) { + GrDirectContext* context) { if (!mTextureRelease || !mTextureRelease->getImage().get() || dataspace != mDataspace || forceCreate || mBuffer != buffer) { if (buffer != mBuffer) { diff --git a/libs/hwui/DeferredLayerUpdater.h b/libs/hwui/DeferredLayerUpdater.h index 05f3774d6951..6731e9c428d6 100644 --- a/libs/hwui/DeferredLayerUpdater.h +++ b/libs/hwui/DeferredLayerUpdater.h @@ -106,7 +106,7 @@ private: ~ImageSlot() { clear(); } sk_sp<SkImage> createIfNeeded(AHardwareBuffer* buffer, android_dataspace dataspace, - bool forceCreate, GrContext* context); + bool forceCreate, GrDirectContext* context); private: void clear(); diff --git a/libs/hwui/HardwareBitmapUploader.cpp b/libs/hwui/HardwareBitmapUploader.cpp index c2d2ff874816..87244427a719 100644 --- a/libs/hwui/HardwareBitmapUploader.cpp +++ b/libs/hwui/HardwareBitmapUploader.cpp @@ -21,7 +21,7 @@ #include <GLES2/gl2.h> #include <GLES2/gl2ext.h> #include <GLES3/gl3.h> -#include <GrContext.h> +#include <GrDirectContext.h> #include <SkCanvas.h> #include <SkImage.h> #include <utils/GLUtils.h> @@ -285,7 +285,7 @@ private: return (image.get() != nullptr); } - sk_sp<GrContext> mGrContext; + sk_sp<GrDirectContext> mGrContext; renderthread::VulkanManager mVulkanManager; std::mutex mVkLock; }; diff --git a/libs/hwui/Readback.cpp b/libs/hwui/Readback.cpp index 0dea354b7200..b71bb07dbc86 100644 --- a/libs/hwui/Readback.cpp +++ b/libs/hwui/Readback.cpp @@ -118,7 +118,7 @@ CopyResult Readback::copyImageInto(const sk_sp<SkImage>& image, Matrix4& texTran } int imgWidth = image->width(); int imgHeight = image->height(); - sk_sp<GrContext> grContext = sk_ref_sp(mRenderThread.getGrContext()); + sk_sp<GrDirectContext> grContext = sk_ref_sp(mRenderThread.getGrContext()); if (bitmap->colorType() == kRGBA_F16_SkColorType && !grContext->colorTypeSupportedAsSurface(bitmap->colorType())) { diff --git a/libs/hwui/pipeline/skia/GLFunctorDrawable.cpp b/libs/hwui/pipeline/skia/GLFunctorDrawable.cpp index 14a297f785fc..dd0fc695c246 100644 --- a/libs/hwui/pipeline/skia/GLFunctorDrawable.cpp +++ b/libs/hwui/pipeline/skia/GLFunctorDrawable.cpp @@ -15,7 +15,7 @@ */ #include "GLFunctorDrawable.h" -#include <GrContext.h> +#include <GrDirectContext.h> #include <private/hwui/DrawGlInfo.h> #include "FunctorDrawable.h" #include "GrBackendSurface.h" diff --git a/libs/hwui/pipeline/skia/LayerDrawable.cpp b/libs/hwui/pipeline/skia/LayerDrawable.cpp index f839213e9007..f95f347cffaf 100644 --- a/libs/hwui/pipeline/skia/LayerDrawable.cpp +++ b/libs/hwui/pipeline/skia/LayerDrawable.cpp @@ -29,7 +29,7 @@ namespace skiapipeline { void LayerDrawable::onDraw(SkCanvas* canvas) { Layer* layer = mLayerUpdater->backingLayer(); if (layer) { - DrawLayer(canvas->getGrContext(), canvas, layer, nullptr, nullptr, true); + DrawLayer(canvas->recordingContext(), canvas, layer, nullptr, nullptr, true); } } @@ -67,8 +67,12 @@ static bool shouldFilterRect(const SkMatrix& matrix, const SkRect& srcRect, cons isIntegerAligned(dstDevRect.y())); } -bool LayerDrawable::DrawLayer(GrContext* context, SkCanvas* canvas, Layer* layer, - const SkRect* srcRect, const SkRect* dstRect, +// TODO: Context arg probably doesn't belong here – do debug check at callsite instead. +bool LayerDrawable::DrawLayer(GrRecordingContext* context, + SkCanvas* canvas, + Layer* layer, + const SkRect* srcRect, + const SkRect* dstRect, bool useLayerTransform) { if (context == nullptr) { SkDEBUGF(("Attempting to draw LayerDrawable into an unsupported surface")); diff --git a/libs/hwui/pipeline/skia/LayerDrawable.h b/libs/hwui/pipeline/skia/LayerDrawable.h index 7cd515ae9fcb..ffbb480023ac 100644 --- a/libs/hwui/pipeline/skia/LayerDrawable.h +++ b/libs/hwui/pipeline/skia/LayerDrawable.h @@ -32,8 +32,12 @@ class LayerDrawable : public SkDrawable { public: explicit LayerDrawable(DeferredLayerUpdater* layerUpdater) : mLayerUpdater(layerUpdater) {} - static bool DrawLayer(GrContext* context, SkCanvas* canvas, Layer* layer, const SkRect* srcRect, - const SkRect* dstRect, bool useLayerTransform); + static bool DrawLayer(GrRecordingContext* context, + SkCanvas* canvas, + Layer* layer, + const SkRect* srcRect, + const SkRect* dstRect, + bool useLayerTransform); protected: virtual SkRect onGetBounds() override { diff --git a/libs/hwui/renderthread/RenderThread.cpp b/libs/hwui/renderthread/RenderThread.cpp index 206b58f62ea7..565fb61c8994 100644 --- a/libs/hwui/renderthread/RenderThread.cpp +++ b/libs/hwui/renderthread/RenderThread.cpp @@ -190,7 +190,7 @@ void RenderThread::requireGlContext() { auto glesVersion = reinterpret_cast<const char*>(glGetString(GL_VERSION)); auto size = glesVersion ? strlen(glesVersion) : -1; cacheManager().configureContext(&options, glesVersion, size); - sk_sp<GrContext> grContext(GrContext::MakeGL(std::move(glInterface), options)); + sk_sp<GrDirectContext> grContext(GrDirectContext::MakeGL(std::move(glInterface), options)); LOG_ALWAYS_FATAL_IF(!grContext.get()); setGrContext(grContext); } @@ -204,7 +204,7 @@ void RenderThread::requireVkContext() { initGrContextOptions(options); auto vkDriverVersion = mVkManager->getDriverVersion(); cacheManager().configureContext(&options, &vkDriverVersion, sizeof(vkDriverVersion)); - sk_sp<GrContext> grContext = mVkManager->createContext(options); + sk_sp<GrDirectContext> grContext = mVkManager->createContext(options); LOG_ALWAYS_FATAL_IF(!grContext.get()); setGrContext(grContext); } @@ -263,7 +263,7 @@ Readback& RenderThread::readback() { return *mReadback; } -void RenderThread::setGrContext(sk_sp<GrContext> context) { +void RenderThread::setGrContext(sk_sp<GrDirectContext> context) { mCacheManager->reset(context); if (mGrContext) { mRenderState->onContextDestroyed(); diff --git a/libs/hwui/renderthread/RenderThread.h b/libs/hwui/renderthread/RenderThread.h index 2c295bcd8105..b8ce55650516 100644 --- a/libs/hwui/renderthread/RenderThread.h +++ b/libs/hwui/renderthread/RenderThread.h @@ -17,7 +17,7 @@ #ifndef RENDERTHREAD_H_ #define RENDERTHREAD_H_ -#include <GrContext.h> +#include <GrDirectContext.h> #include <SkBitmap.h> #include <apex/choreographer.h> #include <cutils/compiler.h> @@ -106,8 +106,8 @@ public: ProfileDataContainer& globalProfileData() { return mGlobalProfileData; } Readback& readback(); - GrContext* getGrContext() const { return mGrContext.get(); } - void setGrContext(sk_sp<GrContext> cxt); + GrDirectContext* getGrContext() const { return mGrContext.get(); } + void setGrContext(sk_sp<GrDirectContext> cxt); CacheManager& cacheManager() { return *mCacheManager; } VulkanManager& vulkanManager() { return *mVkManager; } @@ -186,7 +186,7 @@ private: ProfileDataContainer mGlobalProfileData; Readback* mReadback = nullptr; - sk_sp<GrContext> mGrContext; + sk_sp<GrDirectContext> mGrContext; CacheManager* mCacheManager; VulkanManager* mVkManager; }; diff --git a/libs/hwui/renderthread/VulkanManager.cpp b/libs/hwui/renderthread/VulkanManager.cpp index 3cb16074dd5e..249936eb485e 100644 --- a/libs/hwui/renderthread/VulkanManager.cpp +++ b/libs/hwui/renderthread/VulkanManager.cpp @@ -20,7 +20,7 @@ #include <EGL/eglext.h> #include <GrBackendSemaphore.h> #include <GrBackendSurface.h> -#include <GrContext.h> +#include <GrDirectContext.h> #include <GrTypes.h> #include <android/sync.h> #include <ui/FatVector.h> @@ -369,7 +369,7 @@ void VulkanManager::initialize() { } } -sk_sp<GrContext> VulkanManager::createContext(const GrContextOptions& options) { +sk_sp<GrDirectContext> VulkanManager::createContext(const GrContextOptions& options) { auto getProc = [](const char* proc_name, VkInstance instance, VkDevice device) { if (device != VK_NULL_HANDLE) { return vkGetDeviceProcAddr(device, proc_name); @@ -388,7 +388,7 @@ sk_sp<GrContext> VulkanManager::createContext(const GrContextOptions& options) { backendContext.fDeviceFeatures2 = &mPhysicalDeviceFeatures2; backendContext.fGetProc = std::move(getProc); - return GrContext::MakeVulkan(backendContext, options); + return GrDirectContext::MakeVulkan(backendContext, options); } VkFunctorInitParams VulkanManager::getVkFunctorInitParams() const { @@ -562,9 +562,11 @@ void VulkanManager::destroySurface(VulkanSurface* surface) { delete surface; } -VulkanSurface* VulkanManager::createSurface(ANativeWindow* window, ColorMode colorMode, +VulkanSurface* VulkanManager::createSurface(ANativeWindow* window, + ColorMode colorMode, sk_sp<SkColorSpace> surfaceColorSpace, - SkColorType surfaceColorType, GrContext* grContext, + SkColorType surfaceColorType, + GrDirectContext* grContext, uint32_t extraBuffers) { LOG_ALWAYS_FATAL_IF(!hasVkContext(), "Not initialized"); if (!window) { @@ -575,7 +577,7 @@ VulkanSurface* VulkanManager::createSurface(ANativeWindow* window, ColorMode col *this, extraBuffers); } -status_t VulkanManager::fenceWait(int fence, GrContext* grContext) { +status_t VulkanManager::fenceWait(int fence, GrDirectContext* grContext) { if (!hasVkContext()) { ALOGE("VulkanManager::fenceWait: VkDevice not initialized"); return INVALID_OPERATION; @@ -623,7 +625,7 @@ status_t VulkanManager::fenceWait(int fence, GrContext* grContext) { return OK; } -status_t VulkanManager::createReleaseFence(int* nativeFence, GrContext* grContext) { +status_t VulkanManager::createReleaseFence(int* nativeFence, GrDirectContext* grContext) { *nativeFence = -1; if (!hasVkContext()) { ALOGE("VulkanManager::createReleaseFence: VkDevice not initialized"); diff --git a/libs/hwui/renderthread/VulkanManager.h b/libs/hwui/renderthread/VulkanManager.h index 8b19f13fdfb9..3f2df8d75d89 100644 --- a/libs/hwui/renderthread/VulkanManager.h +++ b/libs/hwui/renderthread/VulkanManager.h @@ -57,9 +57,11 @@ public: bool hasVkContext() { return mDevice != VK_NULL_HANDLE; } // Create and destroy functions for wrapping an ANativeWindow in a VulkanSurface - VulkanSurface* createSurface(ANativeWindow* window, ColorMode colorMode, + VulkanSurface* createSurface(ANativeWindow* window, + ColorMode colorMode, sk_sp<SkColorSpace> surfaceColorSpace, - SkColorType surfaceColorType, GrContext* grContext, + SkColorType surfaceColorType, + GrDirectContext* grContext, uint32_t extraBuffers); void destroySurface(VulkanSurface* surface); @@ -70,18 +72,18 @@ public: void destroy(); // Inserts a wait on fence command into the Vulkan command buffer. - status_t fenceWait(int fence, GrContext* grContext); + status_t fenceWait(int fence, GrDirectContext* grContext); // Creates a fence that is signaled when all the pending Vulkan commands are finished on the // GPU. - status_t createReleaseFence(int* nativeFence, GrContext* grContext); + status_t createReleaseFence(int* nativeFence, GrDirectContext* grContext); // Returned pointers are owned by VulkanManager. // An instance of VkFunctorInitParams returned from getVkFunctorInitParams refers to // the internal state of VulkanManager: VulkanManager must be alive to use the returned value. VkFunctorInitParams getVkFunctorInitParams() const; - sk_sp<GrContext> createContext(const GrContextOptions& options); + sk_sp<GrDirectContext> createContext(const GrContextOptions& options); uint32_t getDriverVersion() const { return mDriverVersion; } diff --git a/libs/hwui/tests/unit/CacheManagerTests.cpp b/libs/hwui/tests/unit/CacheManagerTests.cpp index a4d7b825520d..edd3e4e4f4d4 100644 --- a/libs/hwui/tests/unit/CacheManagerTests.cpp +++ b/libs/hwui/tests/unit/CacheManagerTests.cpp @@ -26,7 +26,7 @@ using namespace android; using namespace android::uirenderer; using namespace android::uirenderer::renderthread; -static size_t getCacheUsage(GrContext* grContext) { +static size_t getCacheUsage(GrDirectContext* grContext) { size_t cacheUsage; grContext->getResourceCacheUsage(nullptr, &cacheUsage); return cacheUsage; @@ -35,7 +35,7 @@ static size_t getCacheUsage(GrContext* grContext) { RENDERTHREAD_SKIA_PIPELINE_TEST(CacheManager, trimMemory) { int32_t width = DeviceInfo::get()->getWidth(); int32_t height = DeviceInfo::get()->getHeight(); - GrContext* grContext = renderThread.getGrContext(); + GrDirectContext* grContext = renderThread.getGrContext(); ASSERT_TRUE(grContext != nullptr); // create pairs of offscreen render targets and images until we exceed the |