Merge "Make SkiaVulkanPipeline go through RenderThread to get VulkanManger." into sc-dev

This commit is contained in:
Greg Daniel
2021-04-09 13:23:41 +00:00
committed by Android (Google) Code Review
2 changed files with 15 additions and 11 deletions

View File

@@ -43,8 +43,7 @@ namespace android {
namespace uirenderer { namespace uirenderer {
namespace skiapipeline { namespace skiapipeline {
SkiaVulkanPipeline::SkiaVulkanPipeline(renderthread::RenderThread& thread) SkiaVulkanPipeline::SkiaVulkanPipeline(renderthread::RenderThread& thread) : SkiaPipeline(thread) {
: SkiaPipeline(thread), mVkManager(thread.vulkanManager()) {
thread.renderState().registerContextCallback(this); thread.renderState().registerContextCallback(this);
} }
@@ -52,13 +51,17 @@ SkiaVulkanPipeline::~SkiaVulkanPipeline() {
mRenderThread.renderState().removeContextCallback(this); mRenderThread.renderState().removeContextCallback(this);
} }
VulkanManager& SkiaVulkanPipeline::vulkanManager() {
return mRenderThread.vulkanManager();
}
MakeCurrentResult SkiaVulkanPipeline::makeCurrent() { MakeCurrentResult SkiaVulkanPipeline::makeCurrent() {
return MakeCurrentResult::AlreadyCurrent; return MakeCurrentResult::AlreadyCurrent;
} }
Frame SkiaVulkanPipeline::getFrame() { Frame SkiaVulkanPipeline::getFrame() {
LOG_ALWAYS_FATAL_IF(mVkSurface == nullptr, "getFrame() called on a context with no surface!"); LOG_ALWAYS_FATAL_IF(mVkSurface == nullptr, "getFrame() called on a context with no surface!");
return mVkManager.dequeueNextBuffer(mVkSurface); return vulkanManager().dequeueNextBuffer(mVkSurface);
} }
bool SkiaVulkanPipeline::draw(const Frame& frame, const SkRect& screenDirty, const SkRect& dirty, bool SkiaVulkanPipeline::draw(const Frame& frame, const SkRect& screenDirty, const SkRect& dirty,
@@ -85,7 +88,7 @@ bool SkiaVulkanPipeline::draw(const Frame& frame, const SkRect& screenDirty, con
{ {
ATRACE_NAME("flush commands"); ATRACE_NAME("flush commands");
mVkManager.finishFrame(backBuffer.get()); vulkanManager().finishFrame(backBuffer.get());
} }
layerUpdateQueue->clear(); layerUpdateQueue->clear();
@@ -106,7 +109,7 @@ bool SkiaVulkanPipeline::swapBuffers(const Frame& frame, bool drew, const SkRect
currentFrameInfo->markSwapBuffers(); currentFrameInfo->markSwapBuffers();
if (*requireSwap) { if (*requireSwap) {
mVkManager.swapBuffers(mVkSurface, screenDirty); vulkanManager().swapBuffers(mVkSurface, screenDirty);
} }
return *requireSwap; return *requireSwap;
@@ -122,15 +125,15 @@ void SkiaVulkanPipeline::onStop() {}
bool SkiaVulkanPipeline::setSurface(ANativeWindow* surface, SwapBehavior swapBehavior) { bool SkiaVulkanPipeline::setSurface(ANativeWindow* surface, SwapBehavior swapBehavior) {
if (mVkSurface) { if (mVkSurface) {
mVkManager.destroySurface(mVkSurface); vulkanManager().destroySurface(mVkSurface);
mVkSurface = nullptr; mVkSurface = nullptr;
} }
if (surface) { if (surface) {
mRenderThread.requireVkContext(); mRenderThread.requireVkContext();
mVkSurface = mVkSurface =
mVkManager.createSurface(surface, mColorMode, mSurfaceColorSpace, mSurfaceColorType, vulkanManager().createSurface(surface, mColorMode, mSurfaceColorSpace,
mRenderThread.getGrContext(), 0); mSurfaceColorType, mRenderThread.getGrContext(), 0);
} }
return mVkSurface != nullptr; return mVkSurface != nullptr;
@@ -141,7 +144,7 @@ bool SkiaVulkanPipeline::isSurfaceReady() {
} }
bool SkiaVulkanPipeline::isContextReady() { bool SkiaVulkanPipeline::isContextReady() {
return CC_LIKELY(mVkManager.hasVkContext()); return CC_LIKELY(vulkanManager().hasVkContext());
} }
void SkiaVulkanPipeline::invokeFunctor(const RenderThread& thread, Functor* functor) { void SkiaVulkanPipeline::invokeFunctor(const RenderThread& thread, Functor* functor) {
@@ -156,7 +159,7 @@ sk_sp<Bitmap> SkiaVulkanPipeline::allocateHardwareBitmap(renderthread::RenderThr
void SkiaVulkanPipeline::onContextDestroyed() { void SkiaVulkanPipeline::onContextDestroyed() {
if (mVkSurface) { if (mVkSurface) {
mVkManager.destroySurface(mVkSurface); vulkanManager().destroySurface(mVkSurface);
mVkSurface = nullptr; mVkSurface = nullptr;
} }
} }

View File

@@ -55,7 +55,8 @@ protected:
void onContextDestroyed() override; void onContextDestroyed() override;
private: private:
renderthread::VulkanManager& mVkManager; renderthread::VulkanManager& vulkanManager();
renderthread::VulkanSurface* mVkSurface = nullptr; renderthread::VulkanSurface* mVkSurface = nullptr;
}; };