mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 922510 - Extend GonkNativeWindow to support android JB 4.2.2, r=sotaro,gps
This commit is contained in:
parent
3fb0331db1
commit
59195f23b7
@ -24,7 +24,7 @@ LIBS += \
|
|||||||
$(DEPTH)/widget/gonk/libdisplay/$(LIB_PREFIX)display.$(LIB_SUFFIX) \
|
$(DEPTH)/widget/gonk/libdisplay/$(LIB_PREFIX)display.$(LIB_SUFFIX) \
|
||||||
$(MOZ_ZLIB_LIBS) \
|
$(MOZ_ZLIB_LIBS) \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
ifeq (18,$(ANDROID_VERSION))
|
ifeq ($(ANDROID_VERSION),$(findstring $(ANDROID_VERSION),17 18))
|
||||||
LIBS += \
|
LIBS += \
|
||||||
-lgui \
|
-lgui \
|
||||||
-lsuspend \
|
-lsuspend \
|
||||||
|
@ -227,7 +227,7 @@ if test -n "$gonkdir" ; then
|
|||||||
AC_SUBST(MOZ_OMX_DECODER)
|
AC_SUBST(MOZ_OMX_DECODER)
|
||||||
MOZ_RTSP=1
|
MOZ_RTSP=1
|
||||||
;;
|
;;
|
||||||
18)
|
17|18)
|
||||||
GONK_INCLUDES="-I$gonkdir/frameworks/native/include -I$gonkdir/frameworks/av/include -I$gonkdir/frameworks/av/include/media -I$gonkdir/frameworks/av/include/camera -I$gonkdir/frameworks/native/include/media/openmax -I$gonkdir/frameworks/av/media/libstagefright/include"
|
GONK_INCLUDES="-I$gonkdir/frameworks/native/include -I$gonkdir/frameworks/av/include -I$gonkdir/frameworks/av/include/media -I$gonkdir/frameworks/av/include/camera -I$gonkdir/frameworks/native/include/media/openmax -I$gonkdir/frameworks/av/media/libstagefright/include"
|
||||||
if test -d "$gonkdir/external/bluetooth/bluez"; then
|
if test -d "$gonkdir/external/bluetooth/bluez"; then
|
||||||
GONK_INCLUDES+=" -I$gonkdir/external/dbus -I$gonkdir/external/bluetooth/bluez/lib"
|
GONK_INCLUDES+=" -I$gonkdir/external/dbus -I$gonkdir/external/bluetooth/bluez/lib"
|
||||||
|
@ -467,7 +467,7 @@ bool OmxDecoder::AllocateMediaResources()
|
|||||||
|
|
||||||
if ((mVideoTrack != nullptr) && (mVideoSource == nullptr)) {
|
if ((mVideoTrack != nullptr) && (mVideoSource == nullptr)) {
|
||||||
mNativeWindow = new GonkNativeWindow();
|
mNativeWindow = new GonkNativeWindow();
|
||||||
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 18
|
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
|
||||||
mNativeWindowClient = new GonkNativeWindowClient(mNativeWindow->getBufferQueue());
|
mNativeWindowClient = new GonkNativeWindowClient(mNativeWindow->getBufferQueue());
|
||||||
#else
|
#else
|
||||||
mNativeWindowClient = new GonkNativeWindowClient(mNativeWindow);
|
mNativeWindowClient = new GonkNativeWindowClient(mNativeWindow);
|
||||||
|
@ -183,7 +183,7 @@ GonkCameraHardware::Init()
|
|||||||
mNativeWindow = new GonkNativeWindow();
|
mNativeWindow = new GonkNativeWindow();
|
||||||
mNativeWindow->setNewFrameCallback(this);
|
mNativeWindow->setNewFrameCallback(this);
|
||||||
mCamera->setListener(this);
|
mCamera->setListener(this);
|
||||||
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 18
|
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
|
||||||
mCamera->setPreviewTexture(mNativeWindow->getBufferQueue());
|
mCamera->setPreviewTexture(mNativeWindow->getBufferQueue());
|
||||||
#else
|
#else
|
||||||
mCamera->setPreviewTexture(mNativeWindow);
|
mCamera->setPreviewTexture(mNativeWindow);
|
||||||
|
@ -130,7 +130,7 @@ static int32_t getColorFormat(const char* colorFormat) {
|
|||||||
if (!strcmp(colorFormat, "OMX_TI_COLOR_FormatYUV420PackedSemiPlanar")) {
|
if (!strcmp(colorFormat, "OMX_TI_COLOR_FormatYUV420PackedSemiPlanar")) {
|
||||||
return OMX_TI_COLOR_FormatYUV420PackedSemiPlanar;
|
return OMX_TI_COLOR_FormatYUV420PackedSemiPlanar;
|
||||||
}
|
}
|
||||||
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 18
|
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
|
||||||
if (!strcmp(colorFormat, CameraParameters::PIXEL_FORMAT_ANDROID_OPAQUE)) {
|
if (!strcmp(colorFormat, CameraParameters::PIXEL_FORMAT_ANDROID_OPAQUE)) {
|
||||||
return OMX_COLOR_FormatAndroidOpaque;
|
return OMX_COLOR_FormatAndroidOpaque;
|
||||||
}
|
}
|
||||||
@ -542,7 +542,7 @@ status_t GonkCameraSource::start(MetaData *meta) {
|
|||||||
if (meta->findInt64(kKeyTime, &startTimeUs)) {
|
if (meta->findInt64(kKeyTime, &startTimeUs)) {
|
||||||
mStartTimeUs = startTimeUs;
|
mStartTimeUs = startTimeUs;
|
||||||
}
|
}
|
||||||
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 18
|
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
|
||||||
int32_t nBuffers;
|
int32_t nBuffers;
|
||||||
if (meta->findInt32(kKeyNumBuffers, &nBuffers)) {
|
if (meta->findInt32(kKeyNumBuffers, &nBuffers)) {
|
||||||
CHECK_GT(nBuffers, 0);
|
CHECK_GT(nBuffers, 0);
|
||||||
|
@ -480,10 +480,12 @@ status_t GonkBufferQueue::queueBuffer(int buf,
|
|||||||
|
|
||||||
input.deflate(×tamp, &crop, &scalingMode, &transform, &fence);
|
input.deflate(×tamp, &crop, &scalingMode, &transform, &fence);
|
||||||
|
|
||||||
|
#if ANDROID_VERSION >= 18
|
||||||
if (fence == NULL) {
|
if (fence == NULL) {
|
||||||
ST_LOGE("queueBuffer: fence is NULL");
|
ST_LOGE("queueBuffer: fence is NULL");
|
||||||
return BAD_VALUE;
|
return BAD_VALUE;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
ST_LOGV("queueBuffer: slot=%d time=%#llx crop=[%d,%d,%d,%d] tr=%#x "
|
ST_LOGV("queueBuffer: slot=%d time=%#llx crop=[%d,%d,%d,%d] tr=%#x "
|
||||||
"scale=%s",
|
"scale=%s",
|
||||||
@ -583,7 +585,12 @@ status_t GonkBufferQueue::queueBuffer(int buf,
|
|||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ANDROID_VERSION == 17
|
||||||
|
void GonkBufferQueue::cancelBuffer(int buf, sp<Fence> fence) {
|
||||||
|
#else
|
||||||
void GonkBufferQueue::cancelBuffer(int buf, const sp<Fence>& fence) {
|
void GonkBufferQueue::cancelBuffer(int buf, const sp<Fence>& fence) {
|
||||||
|
#endif
|
||||||
|
|
||||||
ST_LOGV("cancelBuffer: slot=%d", buf);
|
ST_LOGV("cancelBuffer: slot=%d", buf);
|
||||||
Mutex::Autolock lock(mMutex);
|
Mutex::Autolock lock(mMutex);
|
||||||
|
|
||||||
@ -601,9 +608,11 @@ void GonkBufferQueue::cancelBuffer(int buf, const sp<Fence>& fence) {
|
|||||||
ST_LOGE("cancelBuffer: slot %d is not owned by the client (state=%d)",
|
ST_LOGE("cancelBuffer: slot %d is not owned by the client (state=%d)",
|
||||||
buf, mSlots[buf].mBufferState);
|
buf, mSlots[buf].mBufferState);
|
||||||
return;
|
return;
|
||||||
|
#if ANDROID_VERSION >= 18
|
||||||
} else if (fence == NULL) {
|
} else if (fence == NULL) {
|
||||||
ST_LOGE("cancelBuffer: fence is NULL");
|
ST_LOGE("cancelBuffer: fence is NULL");
|
||||||
return;
|
return;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
mSlots[buf].mBufferState = BufferSlot::FREE;
|
mSlots[buf].mBufferState = BufferSlot::FREE;
|
||||||
mSlots[buf].mFrameNumber = 0;
|
mSlots[buf].mFrameNumber = 0;
|
||||||
@ -872,7 +881,11 @@ status_t GonkBufferQueue::acquireBuffer(BufferItem *buffer) {
|
|||||||
status_t GonkBufferQueue::releaseBuffer(int buf, const sp<Fence>& fence) {
|
status_t GonkBufferQueue::releaseBuffer(int buf, const sp<Fence>& fence) {
|
||||||
Mutex::Autolock _l(mMutex);
|
Mutex::Autolock _l(mMutex);
|
||||||
|
|
||||||
|
#if ANDROID_VERSION == 17
|
||||||
|
if (buf == INVALID_BUFFER_SLOT) {
|
||||||
|
#else
|
||||||
if (buf == INVALID_BUFFER_SLOT || fence == NULL) {
|
if (buf == INVALID_BUFFER_SLOT || fence == NULL) {
|
||||||
|
#endif
|
||||||
return BAD_VALUE;
|
return BAD_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,11 @@
|
|||||||
#define NATIVEWINDOW_GONKBUFFERQUEUE_H
|
#define NATIVEWINDOW_GONKBUFFERQUEUE_H
|
||||||
|
|
||||||
#include <gui/IGraphicBufferAlloc.h>
|
#include <gui/IGraphicBufferAlloc.h>
|
||||||
|
#if ANDROID_VERSION == 17
|
||||||
|
#include <gui/ISurfaceTexture.h>
|
||||||
|
#else
|
||||||
#include <gui/IGraphicBufferProducer.h>
|
#include <gui/IGraphicBufferProducer.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <ui/Fence.h>
|
#include <ui/Fence.h>
|
||||||
#include <ui/GraphicBuffer.h>
|
#include <ui/GraphicBuffer.h>
|
||||||
@ -30,10 +34,18 @@
|
|||||||
|
|
||||||
#include "mozilla/layers/LayersSurfaces.h"
|
#include "mozilla/layers/LayersSurfaces.h"
|
||||||
|
|
||||||
|
#if ANDROID_VERSION == 17
|
||||||
|
#define IGraphicBufferProducer ISurfaceTexture
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace android {
|
namespace android {
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#if ANDROID_VERSION == 17
|
||||||
|
class GonkBufferQueue : public BnSurfaceTexture {
|
||||||
|
#else
|
||||||
class GonkBufferQueue : public BnGraphicBufferProducer {
|
class GonkBufferQueue : public BnGraphicBufferProducer {
|
||||||
|
#endif
|
||||||
typedef mozilla::layers::SurfaceDescriptor SurfaceDescriptor;
|
typedef mozilla::layers::SurfaceDescriptor SurfaceDescriptor;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -171,6 +183,13 @@ public:
|
|||||||
//
|
//
|
||||||
// In both cases, the producer will need to call requestBuffer to get a
|
// In both cases, the producer will need to call requestBuffer to get a
|
||||||
// GraphicBuffer handle for the returned slot.
|
// GraphicBuffer handle for the returned slot.
|
||||||
|
#if ANDROID_VERSION == 17
|
||||||
|
virtual status_t dequeueBuffer(int *buf, sp<Fence>& fence,
|
||||||
|
uint32_t width, uint32_t height, uint32_t format, uint32_t usage) {
|
||||||
|
return dequeueBuffer(buf, &fence, width, height, format, usage);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
virtual status_t dequeueBuffer(int *buf, sp<Fence>* fence,
|
virtual status_t dequeueBuffer(int *buf, sp<Fence>* fence,
|
||||||
uint32_t width, uint32_t height, uint32_t format, uint32_t usage);
|
uint32_t width, uint32_t height, uint32_t format, uint32_t usage);
|
||||||
|
|
||||||
@ -197,7 +216,11 @@ public:
|
|||||||
//
|
//
|
||||||
// The buffer will not be overwritten until the fence signals. The fence
|
// The buffer will not be overwritten until the fence signals. The fence
|
||||||
// will usually be the one obtained from dequeueBuffer.
|
// will usually be the one obtained from dequeueBuffer.
|
||||||
|
#if ANDROID_VERSION == 17
|
||||||
|
virtual void cancelBuffer(int buf, sp<Fence> fence);
|
||||||
|
#else
|
||||||
virtual void cancelBuffer(int buf, const sp<Fence>& fence);
|
virtual void cancelBuffer(int buf, const sp<Fence>& fence);
|
||||||
|
#endif
|
||||||
|
|
||||||
// setSynchronousMode sets whether dequeueBuffer is synchronous or
|
// setSynchronousMode sets whether dequeueBuffer is synchronous or
|
||||||
// asynchronous. In synchronous mode, dequeueBuffer blocks until
|
// asynchronous. In synchronous mode, dequeueBuffer blocks until
|
||||||
|
@ -102,7 +102,11 @@ void GonkConsumerBase::onFrameAvailable() {
|
|||||||
sp<FrameAvailableListener> listener;
|
sp<FrameAvailableListener> listener;
|
||||||
{ // scope for the lock
|
{ // scope for the lock
|
||||||
Mutex::Autolock lock(mMutex);
|
Mutex::Autolock lock(mMutex);
|
||||||
|
#if ANDROID_VERSION == 17
|
||||||
|
listener = mFrameAvailableListener;
|
||||||
|
#else
|
||||||
listener = mFrameAvailableListener.promote();
|
listener = mFrameAvailableListener.promote();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (listener != NULL) {
|
if (listener != NULL) {
|
||||||
@ -151,7 +155,11 @@ void GonkConsumerBase::abandonLocked() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GonkConsumerBase::setFrameAvailableListener(
|
void GonkConsumerBase::setFrameAvailableListener(
|
||||||
|
#if ANDROID_VERSION == 17
|
||||||
|
const sp<FrameAvailableListener>& listener) {
|
||||||
|
#else
|
||||||
const wp<FrameAvailableListener>& listener) {
|
const wp<FrameAvailableListener>& listener) {
|
||||||
|
#endif
|
||||||
CB_LOGV("setFrameAvailableListener");
|
CB_LOGV("setFrameAvailableListener");
|
||||||
Mutex::Autolock lock(mMutex);
|
Mutex::Autolock lock(mMutex);
|
||||||
mFrameAvailableListener = listener;
|
mFrameAvailableListener = listener;
|
||||||
|
@ -78,7 +78,11 @@ public:
|
|||||||
|
|
||||||
// setFrameAvailableListener sets the listener object that will be notified
|
// setFrameAvailableListener sets the listener object that will be notified
|
||||||
// when a new frame becomes available.
|
// when a new frame becomes available.
|
||||||
|
#if ANDROID_VERSION == 17
|
||||||
|
void setFrameAvailableListener(const sp<FrameAvailableListener>& listener);
|
||||||
|
#else
|
||||||
void setFrameAvailableListener(const wp<FrameAvailableListener>& listener);
|
void setFrameAvailableListener(const wp<FrameAvailableListener>& listener);
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GonkConsumerBase(const GonkConsumerBase&);
|
GonkConsumerBase(const GonkConsumerBase&);
|
||||||
@ -210,7 +214,11 @@ protected:
|
|||||||
// mFrameAvailableListener is the listener object that will be called when a
|
// mFrameAvailableListener is the listener object that will be called when a
|
||||||
// new frame becomes available. If it is not NULL it will be called from
|
// new frame becomes available. If it is not NULL it will be called from
|
||||||
// queueBuffer.
|
// queueBuffer.
|
||||||
|
#if ANDROID_VERSION == 17
|
||||||
|
sp<FrameAvailableListener> mFrameAvailableListener;
|
||||||
|
#else
|
||||||
wp<FrameAvailableListener> mFrameAvailableListener;
|
wp<FrameAvailableListener> mFrameAvailableListener;
|
||||||
|
#endif
|
||||||
|
|
||||||
// The GonkConsumerBase has-a GonkBufferQueue and is responsible for creating this object
|
// The GonkConsumerBase has-a GonkBufferQueue and is responsible for creating this object
|
||||||
// if none is supplied
|
// if none is supplied
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 18
|
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
|
||||||
# include "GonkNativeWindowJB.h"
|
# include "GonkNativeWindowJB.h"
|
||||||
#elif defined(MOZ_WIDGET_GONK) && ANDROID_VERSION == 15
|
#elif defined(MOZ_WIDGET_GONK) && ANDROID_VERSION == 15
|
||||||
# include "GonkNativeWindowICS.h"
|
# include "GonkNativeWindowICS.h"
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 18
|
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
|
||||||
# include "GonkNativeWindowClientJB.h"
|
# include "GonkNativeWindowClientJB.h"
|
||||||
#elif defined(MOZ_WIDGET_GONK) && ANDROID_VERSION == 15
|
#elif defined(MOZ_WIDGET_GONK) && ANDROID_VERSION == 15
|
||||||
# include "GonkNativeWindowClientICS.h"
|
# include "GonkNativeWindowClientICS.h"
|
||||||
|
@ -20,7 +20,11 @@
|
|||||||
//#define LOG_NDEBUG 0
|
//#define LOG_NDEBUG 0
|
||||||
|
|
||||||
#include <android/native_window.h>
|
#include <android/native_window.h>
|
||||||
|
#if ANDROID_VERSION == 17
|
||||||
|
#include <utils/Trace.h>
|
||||||
|
#else
|
||||||
#include <cutils/trace.h>
|
#include <cutils/trace.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <binder/Parcel.h>
|
#include <binder/Parcel.h>
|
||||||
#include <utils/Log.h>
|
#include <utils/Log.h>
|
||||||
@ -32,7 +36,7 @@ namespace android {
|
|||||||
|
|
||||||
GonkNativeWindowClient::GonkNativeWindowClient(
|
GonkNativeWindowClient::GonkNativeWindowClient(
|
||||||
const sp<IGraphicBufferProducer>& bufferProducer)
|
const sp<IGraphicBufferProducer>& bufferProducer)
|
||||||
: mGraphicBufferProducer(bufferProducer)
|
: mBufferProducer(bufferProducer)
|
||||||
{
|
{
|
||||||
// Initialize the ANativeWindow function pointers.
|
// Initialize the ANativeWindow function pointers.
|
||||||
ANativeWindow::setSwapInterval = hook_setSwapInterval;
|
ANativeWindow::setSwapInterval = hook_setSwapInterval;
|
||||||
@ -73,8 +77,12 @@ GonkNativeWindowClient::~GonkNativeWindowClient() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ANDROID_VERSION == 17
|
||||||
|
sp<IGraphicBufferProducer> GonkNativeWindowClient::getISurfaceTexture() const {
|
||||||
|
#else
|
||||||
sp<IGraphicBufferProducer> GonkNativeWindowClient::getIGraphicBufferProducer() const {
|
sp<IGraphicBufferProducer> GonkNativeWindowClient::getIGraphicBufferProducer() const {
|
||||||
return mGraphicBufferProducer;
|
#endif
|
||||||
|
return mBufferProducer;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GonkNativeWindowClient::hook_setSwapInterval(ANativeWindow* window, int interval) {
|
int GonkNativeWindowClient::hook_setSwapInterval(ANativeWindow* window, int interval) {
|
||||||
@ -107,7 +115,11 @@ int GonkNativeWindowClient::hook_dequeueBuffer_DEPRECATED(ANativeWindow* window,
|
|||||||
int fenceFd = -1;
|
int fenceFd = -1;
|
||||||
int result = c->dequeueBuffer(&buf, &fenceFd);
|
int result = c->dequeueBuffer(&buf, &fenceFd);
|
||||||
sp<Fence> fence(new Fence(fenceFd));
|
sp<Fence> fence(new Fence(fenceFd));
|
||||||
|
#if ANDROID_VERSION == 17
|
||||||
|
int waitResult = fence->waitForever(1000, "dequeueBuffer_DEPRECATED");
|
||||||
|
#else
|
||||||
int waitResult = fence->waitForever("dequeueBuffer_DEPRECATED");
|
int waitResult = fence->waitForever("dequeueBuffer_DEPRECATED");
|
||||||
|
#endif
|
||||||
if (waitResult != OK) {
|
if (waitResult != OK) {
|
||||||
ALOGE("dequeueBuffer_DEPRECATED: Fence::wait returned an error: %d",
|
ALOGE("dequeueBuffer_DEPRECATED: Fence::wait returned an error: %d",
|
||||||
waitResult);
|
waitResult);
|
||||||
@ -161,7 +173,7 @@ int GonkNativeWindowClient::setSwapInterval(int interval) {
|
|||||||
if (interval > maxSwapInterval)
|
if (interval > maxSwapInterval)
|
||||||
interval = maxSwapInterval;
|
interval = maxSwapInterval;
|
||||||
|
|
||||||
status_t res = mGraphicBufferProducer->setSynchronousMode(interval ? true : false);
|
status_t res = mBufferProducer->setSynchronousMode(interval ? true : false);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@ -174,10 +186,16 @@ int GonkNativeWindowClient::dequeueBuffer(android_native_buffer_t** buffer,
|
|||||||
int reqW = mReqWidth ? mReqWidth : mUserWidth;
|
int reqW = mReqWidth ? mReqWidth : mUserWidth;
|
||||||
int reqH = mReqHeight ? mReqHeight : mUserHeight;
|
int reqH = mReqHeight ? mReqHeight : mUserHeight;
|
||||||
sp<Fence> fence;
|
sp<Fence> fence;
|
||||||
status_t result = mGraphicBufferProducer->dequeueBuffer(&buf, &fence,
|
#if ANDROID_VERSION == 17
|
||||||
|
status_t result = mBufferProducer->dequeueBuffer(&buf, fence,
|
||||||
reqW, reqH, mReqFormat, mReqUsage);
|
reqW, reqH, mReqFormat, mReqUsage);
|
||||||
|
#else
|
||||||
|
status_t result = mBufferProducer->dequeueBuffer(&buf, &fence,
|
||||||
|
reqW, reqH, mReqFormat, mReqUsage);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (result < 0) {
|
if (result < 0) {
|
||||||
ALOGV("dequeueBuffer: IGraphicBufferProducer::dequeueBuffer(%d, %d, %d, %d)"
|
ALOGV("dequeueBuffer: dequeueBuffer(%d, %d, %d, %d)"
|
||||||
"failed: %d", mReqWidth, mReqHeight, mReqFormat, mReqUsage,
|
"failed: %d", mReqWidth, mReqHeight, mReqFormat, mReqUsage,
|
||||||
result);
|
result);
|
||||||
return result;
|
return result;
|
||||||
@ -188,9 +206,10 @@ int GonkNativeWindowClient::dequeueBuffer(android_native_buffer_t** buffer,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((result & IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION) || gbuf == 0) {
|
if ((result & IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION) || gbuf == 0) {
|
||||||
result = mGraphicBufferProducer->requestBuffer(buf, &gbuf);
|
result = mBufferProducer->requestBuffer(buf, &gbuf);
|
||||||
|
|
||||||
if (result != NO_ERROR) {
|
if (result != NO_ERROR) {
|
||||||
ALOGE("dequeueBuffer: IGraphicBufferProducer::requestBuffer failed: %d",
|
ALOGE("dequeueBuffer: requestBuffer failed: %d",
|
||||||
result);
|
result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -221,7 +240,7 @@ int GonkNativeWindowClient::cancelBuffer(android_native_buffer_t* buffer,
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
sp<Fence> fence(fenceFd >= 0 ? new Fence(fenceFd) : Fence::NO_FENCE);
|
sp<Fence> fence(fenceFd >= 0 ? new Fence(fenceFd) : Fence::NO_FENCE);
|
||||||
mGraphicBufferProducer->cancelBuffer(i, fence);
|
mBufferProducer->cancelBuffer(i, fence);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,7 +288,7 @@ int GonkNativeWindowClient::queueBuffer(android_native_buffer_t* buffer, int fen
|
|||||||
IGraphicBufferProducer::QueueBufferOutput output;
|
IGraphicBufferProducer::QueueBufferOutput output;
|
||||||
IGraphicBufferProducer::QueueBufferInput input(timestamp, crop, mScalingMode,
|
IGraphicBufferProducer::QueueBufferInput input(timestamp, crop, mScalingMode,
|
||||||
mTransform, fence);
|
mTransform, fence);
|
||||||
status_t err = mGraphicBufferProducer->queueBuffer(i, input, &output);
|
status_t err = mBufferProducer->queueBuffer(i, input, &output);
|
||||||
if (err != OK) {
|
if (err != OK) {
|
||||||
ALOGE("queueBuffer: error queuing buffer to SurfaceTexture, %d", err);
|
ALOGE("queueBuffer: error queuing buffer to SurfaceTexture, %d", err);
|
||||||
}
|
}
|
||||||
@ -296,7 +315,7 @@ int GonkNativeWindowClient::query(int what, int* value) const {
|
|||||||
case NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER: {
|
case NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER: {
|
||||||
//sp<ISurfaceComposer> composer(
|
//sp<ISurfaceComposer> composer(
|
||||||
// ComposerService::getComposerService());
|
// ComposerService::getComposerService());
|
||||||
//if (composer->authenticateSurfaceTexture(mGraphicBufferProducer)) {
|
//if (composer->authenticateSurfaceTexture(mBufferProducer)) {
|
||||||
// *value = 1;
|
// *value = 1;
|
||||||
//} else {
|
//} else {
|
||||||
*value = 0;
|
*value = 0;
|
||||||
@ -304,7 +323,11 @@ int GonkNativeWindowClient::query(int what, int* value) const {
|
|||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
}
|
}
|
||||||
case NATIVE_WINDOW_CONCRETE_TYPE:
|
case NATIVE_WINDOW_CONCRETE_TYPE:
|
||||||
|
#if ANDROID_VERSION == 17
|
||||||
|
*value = NATIVE_WINDOW_SURFACE_TEXTURE_CLIENT;
|
||||||
|
#else
|
||||||
*value = NATIVE_WINDOW_SURFACE;
|
*value = NATIVE_WINDOW_SURFACE;
|
||||||
|
#endif
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
case NATIVE_WINDOW_DEFAULT_WIDTH:
|
case NATIVE_WINDOW_DEFAULT_WIDTH:
|
||||||
*value = mUserWidth ? mUserWidth : mDefaultWidth;
|
*value = mUserWidth ? mUserWidth : mDefaultWidth;
|
||||||
@ -320,7 +343,7 @@ int GonkNativeWindowClient::query(int what, int* value) const {
|
|||||||
if (!mConsumerRunningBehind) {
|
if (!mConsumerRunningBehind) {
|
||||||
*value = 0;
|
*value = 0;
|
||||||
} else {
|
} else {
|
||||||
err = mGraphicBufferProducer->query(what, value);
|
err = mBufferProducer->query(what, value);
|
||||||
if (err == NO_ERROR) {
|
if (err == NO_ERROR) {
|
||||||
mConsumerRunningBehind = *value;
|
mConsumerRunningBehind = *value;
|
||||||
}
|
}
|
||||||
@ -329,7 +352,8 @@ int GonkNativeWindowClient::query(int what, int* value) const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return mGraphicBufferProducer->query(what, value);
|
|
||||||
|
return mBufferProducer->query(what, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
int GonkNativeWindowClient::perform(int operation, va_list args)
|
int GonkNativeWindowClient::perform(int operation, va_list args)
|
||||||
@ -474,7 +498,7 @@ int GonkNativeWindowClient::connect(int api) {
|
|||||||
ALOGV("GonkNativeWindowClient::connect");
|
ALOGV("GonkNativeWindowClient::connect");
|
||||||
Mutex::Autolock lock(mMutex);
|
Mutex::Autolock lock(mMutex);
|
||||||
IGraphicBufferProducer::QueueBufferOutput output;
|
IGraphicBufferProducer::QueueBufferOutput output;
|
||||||
int err = mGraphicBufferProducer->connect(api, &output);
|
int err = mBufferProducer->connect(api, &output);
|
||||||
if (err == NO_ERROR) {
|
if (err == NO_ERROR) {
|
||||||
uint32_t numPendingBuffers = 0;
|
uint32_t numPendingBuffers = 0;
|
||||||
output.deflate(&mDefaultWidth, &mDefaultHeight, &mTransformHint,
|
output.deflate(&mDefaultWidth, &mDefaultHeight, &mTransformHint,
|
||||||
@ -491,7 +515,8 @@ int GonkNativeWindowClient::disconnect(int api) {
|
|||||||
ALOGV("GonkNativeWindowClient::disconnect");
|
ALOGV("GonkNativeWindowClient::disconnect");
|
||||||
Mutex::Autolock lock(mMutex);
|
Mutex::Autolock lock(mMutex);
|
||||||
freeAllBuffers();
|
freeAllBuffers();
|
||||||
int err = mGraphicBufferProducer->disconnect(api);
|
int err = mBufferProducer->disconnect(api);
|
||||||
|
|
||||||
if (!err) {
|
if (!err) {
|
||||||
mReqFormat = 0;
|
mReqFormat = 0;
|
||||||
mReqWidth = 0;
|
mReqWidth = 0;
|
||||||
@ -537,7 +562,7 @@ int GonkNativeWindowClient::setBufferCount(int bufferCount)
|
|||||||
ALOGV("GonkNativeWindowClient::setBufferCount");
|
ALOGV("GonkNativeWindowClient::setBufferCount");
|
||||||
Mutex::Autolock lock(mMutex);
|
Mutex::Autolock lock(mMutex);
|
||||||
|
|
||||||
status_t err = mGraphicBufferProducer->setBufferCount(bufferCount);
|
status_t err = mBufferProducer->setBufferCount(bufferCount);
|
||||||
ALOGE_IF(err, "IGraphicBufferProducer::setBufferCount(%d) returned %s",
|
ALOGE_IF(err, "IGraphicBufferProducer::setBufferCount(%d) returned %s",
|
||||||
bufferCount, strerror(-err));
|
bufferCount, strerror(-err));
|
||||||
|
|
||||||
|
@ -18,7 +18,11 @@
|
|||||||
#ifndef NATIVEWINDOW_GONKNATIVEWINDOWCLIENT_JB_H
|
#ifndef NATIVEWINDOW_GONKNATIVEWINDOWCLIENT_JB_H
|
||||||
#define NATIVEWINDOW_GONKNATIVEWINDOWCLIENT_JB_H
|
#define NATIVEWINDOW_GONKNATIVEWINDOWCLIENT_JB_H
|
||||||
|
|
||||||
|
#if ANDROID_VERSION == 17
|
||||||
|
#include <gui/ISurfaceTexture.h>
|
||||||
|
#else
|
||||||
#include <gui/IGraphicBufferProducer.h>
|
#include <gui/IGraphicBufferProducer.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <ui/ANativeObjectBase.h>
|
#include <ui/ANativeObjectBase.h>
|
||||||
#include <ui/Region.h>
|
#include <ui/Region.h>
|
||||||
@ -69,13 +73,19 @@ public:
|
|||||||
* GonkNativeWindowClient was created with. Usually it's an error to use the
|
* GonkNativeWindowClient was created with. Usually it's an error to use the
|
||||||
* IGraphicBufferProducer while the GonkNativeWindowClient is connected.
|
* IGraphicBufferProducer while the GonkNativeWindowClient is connected.
|
||||||
*/
|
*/
|
||||||
|
#if ANDROID_VERSION == 17
|
||||||
|
sp<IGraphicBufferProducer> getISurfaceTexture() const;
|
||||||
|
#else
|
||||||
sp<IGraphicBufferProducer> getIGraphicBufferProducer() const;
|
sp<IGraphicBufferProducer> getIGraphicBufferProducer() const;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* convenience function to check that the given surface is non NULL as
|
/* convenience function to check that the given surface is non NULL as
|
||||||
* well as its IGraphicBufferProducer */
|
* well as its IGraphicBufferProducer */
|
||||||
|
#if ANDROID_VERSION >= 18
|
||||||
static bool isValid(const sp<GonkNativeWindowClient>& surface) {
|
static bool isValid(const sp<GonkNativeWindowClient>& surface) {
|
||||||
return surface != NULL && surface->getIGraphicBufferProducer() != NULL;
|
return surface != NULL && surface->getIGraphicBufferProducer() != NULL;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ~GonkNativeWindowClient();
|
virtual ~GonkNativeWindowClient();
|
||||||
@ -163,8 +173,7 @@ private:
|
|||||||
// mSurfaceTexture is the interface to the surface texture server. All
|
// mSurfaceTexture is the interface to the surface texture server. All
|
||||||
// operations on the surface texture client ultimately translate into
|
// operations on the surface texture client ultimately translate into
|
||||||
// interactions with the server using this interface.
|
// interactions with the server using this interface.
|
||||||
// TODO: rename to mBufferProducer
|
sp<IGraphicBufferProducer> mBufferProducer;
|
||||||
sp<IGraphicBufferProducer> mGraphicBufferProducer;
|
|
||||||
|
|
||||||
// mSlots stores the buffers that have been allocated for each buffer slot.
|
// mSlots stores the buffers that have been allocated for each buffer slot.
|
||||||
// It is initialized to null pointers, and gets filled in with the result of
|
// It is initialized to null pointers, and gets filled in with the result of
|
||||||
|
@ -47,7 +47,7 @@ void GonkNativeWindow::setName(const String8& name) {
|
|||||||
mName = name;
|
mName = name;
|
||||||
mBufferQueue->setConsumerName(name);
|
mBufferQueue->setConsumerName(name);
|
||||||
}
|
}
|
||||||
|
#if ANDROID_VERSION >= 18
|
||||||
status_t GonkNativeWindow::acquireBuffer(BufferItem *item, bool waitForFence) {
|
status_t GonkNativeWindow::acquireBuffer(BufferItem *item, bool waitForFence) {
|
||||||
status_t err;
|
status_t err;
|
||||||
|
|
||||||
@ -92,6 +92,7 @@ status_t GonkNativeWindow::releaseBuffer(const BufferItem &item,
|
|||||||
}
|
}
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
status_t GonkNativeWindow::setDefaultBufferSize(uint32_t w, uint32_t h) {
|
status_t GonkNativeWindow::setDefaultBufferSize(uint32_t w, uint32_t h) {
|
||||||
Mutex::Autolock _l(mMutex);
|
Mutex::Autolock _l(mMutex);
|
||||||
|
@ -86,16 +86,19 @@ class GonkNativeWindow: public GonkConsumerBase
|
|||||||
//
|
//
|
||||||
// If waitForFence is true, and the acquired BufferItem has a valid fence object,
|
// If waitForFence is true, and the acquired BufferItem has a valid fence object,
|
||||||
// acquireBuffer will wait on the fence with no timeout before returning.
|
// acquireBuffer will wait on the fence with no timeout before returning.
|
||||||
|
#if ANDROID_VERSION >= 18
|
||||||
status_t acquireBuffer(BufferItem *item, bool waitForFence = true);
|
status_t acquireBuffer(BufferItem *item, bool waitForFence = true);
|
||||||
|
#endif
|
||||||
// Returns an acquired buffer to the queue, allowing it to be reused. Since
|
// Returns an acquired buffer to the queue, allowing it to be reused. Since
|
||||||
// only a fixed number of buffers may be acquired at a time, old buffers
|
// only a fixed number of buffers may be acquired at a time, old buffers
|
||||||
// must be released by calling releaseBuffer to ensure new buffers can be
|
// must be released by calling releaseBuffer to ensure new buffers can be
|
||||||
// acquired by acquireBuffer. Once a BufferItem is released, the caller must
|
// acquired by acquireBuffer. Once a BufferItem is released, the caller must
|
||||||
// not access any members of the BufferItem, and should immediately remove
|
// not access any members of the BufferItem, and should immediately remove
|
||||||
// all of its references to the BufferItem itself.
|
// all of its references to the BufferItem itself.
|
||||||
|
#if ANDROID_VERSION >= 18
|
||||||
status_t releaseBuffer(const BufferItem &item,
|
status_t releaseBuffer(const BufferItem &item,
|
||||||
const sp<Fence>& releaseFence = Fence::NO_FENCE);
|
const sp<Fence>& releaseFence = Fence::NO_FENCE);
|
||||||
|
#endif
|
||||||
|
|
||||||
sp<IGraphicBufferProducer> getProducerInterface() const { return getBufferQueue(); }
|
sp<IGraphicBufferProducer> getProducerInterface() const { return getBufferQueue(); }
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ EXPORTS += [
|
|||||||
'GonkNativeWindowClient.h',
|
'GonkNativeWindowClient.h',
|
||||||
]
|
]
|
||||||
|
|
||||||
if CONFIG['ANDROID_VERSION'] == '18':
|
if CONFIG['ANDROID_VERSION'] in ('17', '18'):
|
||||||
EXPORTS += [
|
EXPORTS += [
|
||||||
'GonkBufferQueue.h',
|
'GonkBufferQueue.h',
|
||||||
'GonkConsumerBase.h',
|
'GonkConsumerBase.h',
|
||||||
@ -35,7 +35,7 @@ elif CONFIG['ANDROID_VERSION'] == '15':
|
|||||||
]
|
]
|
||||||
|
|
||||||
if CONFIG['MOZ_B2G_CAMERA'] or CONFIG['MOZ_OMX_DECODER']:
|
if CONFIG['MOZ_B2G_CAMERA'] or CONFIG['MOZ_OMX_DECODER']:
|
||||||
if CONFIG['ANDROID_VERSION'] == '18':
|
if CONFIG['ANDROID_VERSION'] in ('17', '18'):
|
||||||
CPP_SOURCES += [
|
CPP_SOURCES += [
|
||||||
'GonkBufferQueue.cpp',
|
'GonkBufferQueue.cpp',
|
||||||
'GonkConsumerBase.cpp',
|
'GonkConsumerBase.cpp',
|
||||||
|
Loading…
Reference in New Issue
Block a user