Use the NDK headers for AHardwareBuffer.

Bug: 6672
Change-Id: I5abd86149e912d91234853109ebd2a6b0ac5eaa2
Reviewed-on: https://skia-review.googlesource.com/20980
Reviewed-by: Stan Iliev <stani@google.com>
Commit-Queue: Derek Sollenberger <djsollen@google.com>
This commit is contained in:
Derek Sollenberger 2017-06-27 15:37:25 -04:00 committed by Skia Commit-Bot
parent 3921ba236f
commit 7a86987815
5 changed files with 13 additions and 13 deletions

View File

@ -486,6 +486,11 @@ optional("gpu") {
libs = []
if (is_android) {
sources += [ "src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp" ]
# this lib is required to link against AHardwareBuffer
if (defined(ndk_api) && ndk_api >= 26) {
libs += [ "android" ]
}
} else if (skia_use_egl) {
sources += [ "src/gpu/gl/egl/GrGLCreateNativeInterface_egl.cpp" ]
libs += [ "EGL" ]

View File

@ -29,9 +29,7 @@ class GrContext;
class GrContextThreadSafeProxy;
class GrTexture;
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
struct AHardwareBuffer;
#endif
/**
* SkImage is an abstraction for drawing a rectagle of pixels, though the
@ -236,7 +234,7 @@ public:
const SkMatrix*, const SkPaint*, BitDepth,
sk_sp<SkColorSpace>);
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
#if defined(SK_BUILD_FOR_ANDROID) && __ANDROID_API__ >= 26
/**
* Create a new image from the an Android hardware buffer.
* The new image takes a reference on the buffer.

View File

@ -6,13 +6,14 @@
*/
#include "SkTypes.h"
//TODO: This define is temporary and we will compile with NDK after
//TODO: Skia bug 6672 is resolved.
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
#if defined(SK_BUILD_FOR_ANDROID) && __ANDROID_API__ >= 26
#define GL_GLEXT_PROTOTYPES
#define EGL_EGLEXT_PROTOTYPES
#include "GrAHardwareBufferImageGenerator.h"
#include <android/hardware_buffer.h>
#include "GrBackendSurface.h"
#include "GrContext.h"
#include "GrContextPriv.h"
@ -65,8 +66,7 @@ std::unique_ptr<SkImageGenerator> GrAHardwareBufferImageGenerator::Make(
GrAHardwareBufferImageGenerator::GrAHardwareBufferImageGenerator(const SkImageInfo& info,
AHardwareBuffer* graphicBuffer, SkAlphaType alphaType)
: INHERITED(info)
, fGraphicBuffer(graphicBuffer)
, fAlphaType(alphaType) {
, fGraphicBuffer(graphicBuffer) {
AHardwareBuffer_acquire(fGraphicBuffer);
}

View File

@ -9,7 +9,7 @@
#include "SkImageGenerator.h"
#include <android/hardware_buffer.h>
struct AHardwareBuffer;
/**
* GrAHardwareBufferImageGenerator allows to create an SkImage attached to
@ -45,7 +45,6 @@ private:
static void deleteImageTexture(void* ctx);
AHardwareBuffer* fGraphicBuffer;
SkAlphaType fAlphaType;
typedef SkImageGenerator INHERITED;
};

View File

@ -12,9 +12,7 @@
#include "SkAutoPixmapStorage.h"
#include "GrBackendSurface.h"
#include "GrBackendTextureImageGenerator.h"
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
#include "GrAHardwareBufferImageGenerator.h"
#endif
#include "GrBitmapTextureMaker.h"
#include "GrCaps.h"
#include "GrContext.h"
@ -512,7 +510,7 @@ sk_sp<SkImage> SkImage::MakeCrossContextFromEncoded(GrContext* context, sk_sp<Sk
return SkImage::MakeFromGenerator(std::move(gen));
}
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
#if defined(SK_BUILD_FOR_ANDROID) && __ANDROID_API__ >= 26
sk_sp<SkImage> SkImage::MakeFromAHardwareBuffer(AHardwareBuffer* graphicBuffer, SkAlphaType at,
sk_sp<SkColorSpace> cs) {
auto gen = GrAHardwareBufferImageGenerator::Make(graphicBuffer, at, cs);