summaryrefslogtreecommitdiff
path: root/libs/hwui/pipeline/skia/VkInteropFunctorDrawable.cpp
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2020-03-05 02:39:02 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-03-05 02:39:02 +0000
commit3f2f5b01ea04ef16eb2de5a77974ccdeaed46158 (patch)
treed39b093d3b15b072c938e78d313b1f383b014a4d /libs/hwui/pipeline/skia/VkInteropFunctorDrawable.cpp
parent3351d1c3bce1d05d04c94ada855b380c317a481f (diff)
parent4523801b9a6b258c9349491e3760f03ad7c00211 (diff)
Merge "[HWUI] remove libui from HWUI's dependencies"
Diffstat (limited to 'libs/hwui/pipeline/skia/VkInteropFunctorDrawable.cpp')
-rw-r--r--libs/hwui/pipeline/skia/VkInteropFunctorDrawable.cpp56
1 files changed, 31 insertions, 25 deletions
diff --git a/libs/hwui/pipeline/skia/VkInteropFunctorDrawable.cpp b/libs/hwui/pipeline/skia/VkInteropFunctorDrawable.cpp
index 97f6378ee65a..05478baea429 100644
--- a/libs/hwui/pipeline/skia/VkInteropFunctorDrawable.cpp
+++ b/libs/hwui/pipeline/skia/VkInteropFunctorDrawable.cpp
@@ -15,23 +15,25 @@
*/
#include "VkInteropFunctorDrawable.h"
-#include <private/hwui/DrawGlInfo.h>
+#include <EGL/egl.h>
+#include <EGL/eglext.h>
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
+#include <GLES3/gl3.h>
+#include <private/android/AHardwareBufferHelpers.h>
+#include <private/hwui/DrawGlInfo.h>
#include <utils/Color.h>
+#include <utils/GLUtils.h>
#include <utils/Trace.h>
#include <utils/TraceUtils.h>
+
#include <thread>
+
#include "renderthread/EglManager.h"
#include "thread/ThreadBase.h"
#include "utils/TimeUtils.h"
-#include <EGL/eglext.h>
-#include <GLES2/gl2.h>
-#include <GLES2/gl2ext.h>
-#include <GLES3/gl3.h>
-
-#include <utils/GLUtils.h>
-
namespace android {
namespace uirenderer {
namespace skiapipeline {
@@ -75,20 +77,23 @@ void VkInteropFunctorDrawable::onDraw(SkCanvas* canvas) {
SkImageInfo surfaceInfo = canvas->imageInfo();
- if (!mFrameBuffer.get() || mFBInfo != surfaceInfo) {
+ if (mFrameBuffer == nullptr || mFBInfo != surfaceInfo) {
// Buffer will be used as an OpenGL ES render target.
- mFrameBuffer = new GraphicBuffer(
- // TODO: try to reduce the size of the buffer: possibly by using clip bounds.
- static_cast<uint32_t>(surfaceInfo.width()),
- static_cast<uint32_t>(surfaceInfo.height()),
- ColorTypeToPixelFormat(surfaceInfo.colorType()),
- GraphicBuffer::USAGE_HW_TEXTURE | GraphicBuffer::USAGE_SW_WRITE_NEVER |
- GraphicBuffer::USAGE_SW_READ_NEVER | GraphicBuffer::USAGE_HW_RENDER,
- std::string("VkInteropFunctorDrawable::onDraw pid [") + std::to_string(getpid()) +
- "]");
- status_t error = mFrameBuffer->initCheck();
- if (error < 0) {
- ALOGW("VkInteropFunctorDrawable::onDraw() failed in GraphicBuffer.create()");
+ AHardwareBuffer_Desc desc = {
+ .width = static_cast<uint32_t>(surfaceInfo.width()),
+ .height = static_cast<uint32_t>(surfaceInfo.height()),
+ .layers = 1,
+ .format = ColorTypeToBufferFormat(surfaceInfo.colorType()),
+ .usage = AHARDWAREBUFFER_USAGE_CPU_READ_NEVER |
+ AHARDWAREBUFFER_USAGE_CPU_WRITE_NEVER |
+ AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE |
+ AHARDWAREBUFFER_USAGE_GPU_FRAMEBUFFER,
+ };
+
+ mFrameBuffer = allocateAHardwareBuffer(desc);
+
+ if (!mFrameBuffer) {
+ ALOGW("VkInteropFunctorDrawable::onDraw() failed in AHardwareBuffer_allocate()");
return;
}
@@ -106,7 +111,8 @@ void VkInteropFunctorDrawable::onDraw(SkCanvas* canvas) {
uirenderer::renderthread::EglManager::eglErrorString());
// We use an EGLImage to access the content of the GraphicBuffer
// The EGL image is later bound to a 2D texture
- EGLClientBuffer clientBuffer = (EGLClientBuffer)mFrameBuffer->getNativeBuffer();
+ EGLClientBuffer clientBuffer =
+ (EGLClientBuffer)AHardwareBuffer_to_ANativeWindowBuffer(mFrameBuffer.get());
AutoEglImage autoImage(display, clientBuffer);
if (autoImage.image == EGL_NO_IMAGE_KHR) {
ALOGW("Could not create EGL image, err =%s",
@@ -179,9 +185,9 @@ void VkInteropFunctorDrawable::onDraw(SkCanvas* canvas) {
// drawing into the offscreen surface, so we need to reset it here.
canvas->resetMatrix();
- auto functorImage = SkImage::MakeFromAHardwareBuffer(
- reinterpret_cast<AHardwareBuffer*>(mFrameBuffer.get()), kPremul_SkAlphaType,
- canvas->imageInfo().refColorSpace(), kBottomLeft_GrSurfaceOrigin);
+ auto functorImage = SkImage::MakeFromAHardwareBuffer(mFrameBuffer.get(), kPremul_SkAlphaType,
+ canvas->imageInfo().refColorSpace(),
+ kBottomLeft_GrSurfaceOrigin);
canvas->drawImage(functorImage, 0, 0, &paint);
canvas->restore();
}