--- a/layout/build/moz.build
+++ b/layout/build/moz.build
@@ -79,28 +79,16 @@ elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'an
LOCAL_INCLUDES += [
'/dom/system',
'/dom/system/android',
]
elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
LOCAL_INCLUDES += [
'/dom/system/gonk',
]
- if CONFIG['ANDROID_VERSION'] == '15':
- LOCAL_INCLUDES += [
- '%' + '%s/%s' % (CONFIG['ANDROID_SOURCE'], d) for d in [
- 'dalvik/libnativehelper/include/nativehelper',
- 'frameworks/base/include',
- 'frameworks/base/include/binder',
- 'frameworks/base/include/media',
- 'frameworks/base/include/media/stagefright/openmax',
- 'frameworks/base/include/utils',
- 'frameworks/base/media/libstagefright/include',
- ]
- ]
if CONFIG['MOZ_B2G_FM']:
LOCAL_INCLUDES += [
'/dom/fmradio',
]
if CONFIG['MOZ_B2G_BT']:
LOCAL_INCLUDES += [
--- a/media/omx-plugin/moz.build
+++ b/media/omx-plugin/moz.build
@@ -31,32 +31,16 @@ else:
if CONFIG['GNU_CXX']:
# Stagefright header files define many multichar constants.
CXXFLAGS += [
'-Wno-multichar',
'-Wno-shadow',
]
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
- if CONFIG['ANDROID_VERSION'] == '15':
- LOCAL_INCLUDES += [
- '%' + '%s/%s' % (CONFIG['ANDROID_SOURCE'], d) for d in [
- 'dalvik/libnativehelper/include/nativehelper',
- 'frameworks/base/include/',
- 'frameworks/base/include/binder/',
- 'frameworks/base/include/media/',
- 'frameworks/base/include/media/stagefright/openmax',
- 'frameworks/base/include/utils/',
- 'frameworks/base/media/libstagefright/include',
- 'frameworks/base/native/include',
- 'hardware/libhardware/include',
- 'system/core/include',
- ]
- ]
-
EXTRA_DSO_LDOPTS += [
'-lutils',
'-lstagefright',
'-lmedia',
'-lstagefright_omx',
'-lbinder',
'-lui',
'-lhardware',
deleted file mode 100644
--- a/widget/gonk/hwchal/HwcICS.cpp
+++ /dev/null
@@ -1,134 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* vim:set ts=4 sw=4 sts=4 et: */
-/*
- * Copyright (c) 2015 The Linux Foundation. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "HwcICS.h"
-#include "cutils/properties.h"
-#include "libdisplay/GonkDisplay.h"
-
-namespace mozilla {
-
-HwcICS::HwcICS()
- : HwcHALBase()
-{
- mHwc = (HwcDevice*)GetGonkDisplay()->GetHWCDevice();
- if (!mHwc) {
- printf_stderr("HwcHAL Error: Cannot load hwcomposer");
- }
-}
-
-HwcICS::~HwcICS()
-{
- mHwc = nullptr;
- mEGLDisplay = nullptr;
- mEGLSurface = nullptr;
-}
-
-void
-HwcICS::SetEGLInfo(hwc_display_t aEGLDisplay,
- hwc_surface_t aEGLSurface)
-{
- mEGLDisplay = aEGLDisplay;
- mEGLSurface = aEGLSurface;
-}
-
-bool
-HwcICS::Query(QueryType aType)
-{
- bool value = false;
- switch (aType) {
- case QueryType::COLOR_FILL: {
- char propValue[PROPERTY_VALUE_MAX];
- property_get("ro.display.colorfill", propValue, "0");
- value = (atoi(propValue) == 1) ? true : false;
- break;
- }
- case QueryType::RB_SWAP:
- value = true;
- break;
-
- default:
- value = false;
- }
- return value;
-}
-
-int
-HwcICS::Set(HwcList* aList,
- uint32_t aDisp)
-{
- if (!mHwc) {
- return -1;
- }
- return mHwc->set(mHwc, mEGLDisplay, mEGLSurface, aList);
-}
-
-int
-HwcICS::ResetHwc()
-{
- return -1;
-}
-
-int
-HwcICS::Prepare(HwcList *aList,
- uint32_t aDisp,
- hwc_rect_t aDispRect,
- buffer_handle_t aHandle,
- int aFenceFd)
-{
- return mHwc->prepare(mHwc, aList);
-}
-
-bool
-HwcICS::SupportTransparency() const
-{
- return false;
-}
-
-uint32_t
-HwcICS::GetGeometryChangedFlag(bool aGeometryChanged) const
-{
- return HWC_GEOMETRY_CHANGED;
-}
-
-void
-HwcICS::SetCrop(HwcLayer& aLayer,
- const hwc_rect_t &aSrcCrop) const
-{
- aLayer.sourceCrop = aSrcCrop;
-}
-
-bool
-HwcICS::EnableVsync(bool aEnable)
-{
- return false;
-}
-
-bool
-HwcICS::RegisterHwcEventCallback(const HwcHALProcs_t &aProcs)
-{
- return false;
-}
-
-// Create HwcICS
-UniquePtr<HwcHALBase>
-HwcHALBase::CreateHwcHAL()
-{
- return Move(MakeUnique<HwcICS>());
-}
-
-} // namespace mozilla
deleted file mode 100644
--- a/widget/gonk/hwchal/HwcICS.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* vim:set ts=4 sw=4 sts=4 et: */
-/*
- * Copyright (c) 2015 The Linux Foundation. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef mozilla_HwcICS
-#define mozilla_HwcICS
-
-#include "HwcHALBase.h"
-
-namespace mozilla {
-
-class HwcICS final : public HwcHALBase {
-public:
- explicit HwcICS();
-
- virtual ~HwcICS();
-
- virtual bool HasHwc() const override { return static_cast<bool>(mHwc); }
-
- virtual void SetEGLInfo(hwc_display_t aEGLDisplay,
- hwc_surface_t aEGLSurface) override;
-
- virtual bool Query(QueryType aType) override;
-
- virtual int Set(HwcList *aList,
- uint32_t aDisp) override;
-
- virtual int ResetHwc() override;
-
- virtual int Prepare(HwcList *aList,
- uint32_t aDisp,
- hwc_rect_t aDispRect,
- buffer_handle_t aHandle,
- int aFenceFd) override;
-
- virtual bool SupportTransparency() const override;
-
- virtual uint32_t GetGeometryChangedFlag(bool aGeometryChanged) const override;
-
- virtual void SetCrop(HwcLayer &aLayer,
- const hwc_rect_t &aSrcCrop) const override;
-
- virtual bool EnableVsync(bool aEnable) override;
-
- virtual bool RegisterHwcEventCallback(const HwcHALProcs_t &aProcs) override;
-
-private:
- HwcDevice *mHwc = nullptr;
- hwc_display_t mEGLDisplay = nullptr;
- hwc_surface_t mEGLSurface = nullptr;
-};
-
-} // namespace mozilla
-
-#endif // mozilla_HwcICS
deleted file mode 100644
--- a/widget/gonk/libdisplay/GonkDisplayICS.cpp
+++ /dev/null
@@ -1,232 +0,0 @@
-/* Copyright 2013 Mozilla Foundation and Mozilla contributors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "GonkDisplayICS.h"
-#include <ui/FramebufferNativeWindow.h>
-
-#include <hardware/hardware.h>
-#include <hardware/gralloc.h>
-#include <hardware/hwcomposer.h>
-#include <hardware_legacy/power.h>
-#include <cutils/log.h>
-#include <fcntl.h>
-
-#include "mozilla/Assertions.h"
-#include "mozilla/FileUtils.h"
-#include "mozilla/FileUtils.h"
-
-using namespace android;
-
-
-namespace {
-static const char* kSleepFile = "/sys/power/wait_for_fb_sleep";
-static const char* kWakeFile = "/sys/power/wait_for_fb_wake";
-static mozilla::GonkDisplay::OnEnabledCallbackType sEnabledCallback;
-static pthread_t sFramebufferWatchThread;
-
-static void *
-frameBufferWatcher(void *)
-{
- int len = 0;
- char buf;
-
- while (true) {
- // Cannot use epoll here because kSleepFile and kWakeFile are
- // always ready to read and blocking.
- {
- mozilla::ScopedClose fd(open(kSleepFile, O_RDONLY, 0));
- do {
- len = read(fd.get(), &buf, 1);
- } while (len < 0 && errno == EINTR);
- NS_WARN_IF_FALSE(len >= 0, "WAIT_FOR_FB_SLEEP failed");
- }
- sEnabledCallback(false);
-
- {
- mozilla::ScopedClose fd(open(kWakeFile, O_RDONLY, 0));
- do {
- len = read(fd.get(), &buf, 1);
- } while (len < 0 && errno == EINTR);
- NS_WARN_IF_FALSE(len >= 0, "WAIT_FOR_FB_WAKE failed");
- }
- sEnabledCallback(true);
- }
-
- return nullptr;
-}
-
-} // namespace
-
-
-namespace mozilla {
-
-static GonkDisplayICS* sGonkDisplay = nullptr;
-
-static int
-FramebufferNativeWindowCancelBufferNoop(ANativeWindow* aWindow,
- android_native_buffer_t* aBuffer)
-{
- return 0;
-}
-
-GonkDisplayICS::GonkDisplayICS()
- : mModule(nullptr)
- , mHwc(nullptr)
-{
- // Some gralloc HALs need this in order to open the
- // framebuffer device after we restart with the screen off.
- //
- // this *must* run BEFORE allocating the
- // FramebufferNativeWindow.
- set_screen_state(1);
-
- // For some devices, it takes a while for the framebuffer to become
- // usable. So we wait until the framebuffer has woken up before we
- // try to open it.
- {
- char buf;
- int len = 0;
- ScopedClose fd(open("/sys/power/wait_for_fb_wake", O_RDONLY, 0));
- do {
- len = read(fd.get(), &buf, 1);
- } while (len < 0 && errno == EINTR);
- if (len < 0) {
- LOGE("wait_for_fb_sleep failed errno: %d", errno);
- }
- }
-
- mFBSurface = new FramebufferNativeWindow();
-
- // ICS FramebufferNativeWindow doesn't set the |cancelBuffer|
- // function pointer.
- // It will crash when deleting the EGL window surface.
- if (!mFBSurface->cancelBuffer) {
- mFBSurface->cancelBuffer = FramebufferNativeWindowCancelBufferNoop;
- }
-
- int err = hw_get_module(HWC_HARDWARE_MODULE_ID, &mModule);
- LOGW_IF(err, "%s module not found", HWC_HARDWARE_MODULE_ID);
- if (!err) {
- err = hwc_open(mModule, &mHwc);
- LOGE_IF(err, "%s device failed to initialize (%s)",
- HWC_HARDWARE_COMPOSER, strerror(-err));
- }
-
- xdpi = mFBSurface->xdpi;
-
- const framebuffer_device_t *fbdev = mFBSurface->getDevice();
- surfaceformat = fbdev->format;
-}
-
-GonkDisplayICS::~GonkDisplayICS()
-{
- if (mHwc)
- hwc_close(mHwc);
-}
-
-void
-GonkDisplayICS::SetEnabled(bool enabled)
-{
- set_screen_state(enabled);
-}
-
-void
-GonkDisplayICS::OnEnabled(OnEnabledCallbackType callback)
-{
- if (sEnabledCallback)
- return;
- sEnabledCallback = callback;
-
- // Watching screen on/off state by using a pthread
- // which implicitly calls exit() when the main thread ends
- if (pthread_create(&sFramebufferWatchThread, NULL, frameBufferWatcher, NULL)) {
- NS_RUNTIMEABORT("Failed to create framebufferWatcherThread, aborting...");
- }
-}
-
-
-void*
-GonkDisplayICS::GetHWCDevice()
-{
- return mHwc;
-}
-
-bool
-GonkDisplayICS::SwapBuffers(EGLDisplay dpy, EGLSurface sur)
-{
- // Should be called when composition rendering is complete for a frame.
- // Only HWC v1.0 needs this call. ICS gonk always needs the call.
- mFBSurface->compositionComplete();
-
- if (!mHwc) {
- if (sur != EGL_NO_SURFACE) {
- return eglSwapBuffers(dpy, sur);
- }
- return true;
- }
-
- mHwc->prepare(mHwc, nullptr);
- return !mHwc->set(mHwc, dpy, sur, 0);
-}
-
-ANativeWindowBuffer*
-GonkDisplayICS::DequeueBuffer()
-{
- ANativeWindow *window = static_cast<ANativeWindow *>(mFBSurface.get());
- ANativeWindowBuffer *buf = nullptr;
- window->dequeueBuffer(window, &buf);
- return buf;
-}
-
-bool
-GonkDisplayICS::QueueBuffer(ANativeWindowBuffer *buf)
-{
- ANativeWindow *window = static_cast<ANativeWindow *>(mFBSurface.get());
- return !window->queueBuffer(window, buf);
-}
-
-void
-GonkDisplayICS::UpdateDispSurface(EGLDisplay dpy, EGLSurface sur)
-{
-}
-
-void
-GonkDisplayICS::SetDispReleaseFd(int fd)
-{
-}
-
-GonkDisplay::NativeData
-GonkDisplayICS::GetNativeData(GonkDisplay::DisplayType aDisplayType,
- android::IGraphicBufferProducer* aSink)
-{
- MOZ_ASSERT(aDisplayType == DISPLAY_PRIMARY, "ICS gonk supports primary display only.");
-
- NativeData data;
- data.mNativeWindow = static_cast<ANativeWindow *>(mFBSurface.get());
- data.mXdpi = xdpi;
-
- return data;
-}
-
-__attribute__ ((visibility ("default")))
-GonkDisplay*
-GetGonkDisplay()
-{
- if (!sGonkDisplay)
- sGonkDisplay = new GonkDisplayICS();
- return sGonkDisplay;
-}
-
-} // namespace mozilla
deleted file mode 100644
--- a/widget/gonk/libdisplay/GonkDisplayICS.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/* Copyright 2013 Mozilla Foundation and Mozilla contributors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef GONKDISPLAYICS_H
-#define GONKDISPLAYICS_H
-
-#include <string.h>
-
-#include "GonkDisplay.h"
-#include "ui/FramebufferNativeWindow.h"
-#include "hardware/hwcomposer.h"
-#include "utils/RefBase.h"
-
-namespace android {
-class IGraphicBufferProducer;
-}
-
-namespace mozilla {
-
-class MOZ_EXPORT GonkDisplayICS : public GonkDisplay {
-public:
- GonkDisplayICS();
- ~GonkDisplayICS();
-
- virtual void SetEnabled(bool enabled);
-
- virtual void OnEnabled(OnEnabledCallbackType callback);
-
- virtual void* GetHWCDevice();
-
- virtual bool SwapBuffers(EGLDisplay dpy, EGLSurface sur);
-
- virtual ANativeWindowBuffer* DequeueBuffer();
-
- virtual bool QueueBuffer(ANativeWindowBuffer* handle);
-
- virtual void UpdateDispSurface(EGLDisplay dpy, EGLSurface sur);
-
- virtual void SetDispReleaseFd(int fd);
-
- virtual int GetPrevDispAcquireFd()
- {
- return -1;
- }
-
- virtual NativeData GetNativeData(
- GonkDisplay::DisplayType aDisplayType,
- android::IGraphicBufferProducer* aSink = nullptr);
-
- virtual void NotifyBootAnimationStopped() {}
-
-private:
- hw_module_t const* mModule;
- hwc_composer_device_t* mHwc;
- android::sp<android::FramebufferNativeWindow> mFBSurface;
-};
-
-}
-
-#endif /* GONKDISPLAYICS_H */
--- a/widget/gonk/libdisplay/moz.build
+++ b/widget/gonk/libdisplay/moz.build
@@ -30,40 +30,30 @@ elif CONFIG['ANDROID_VERSION'] == '18':
'GonkDisplayJB.cpp',
]
elif CONFIG['ANDROID_VERSION'] == '17':
SOURCES += [
'FramebufferSurface.cpp',
'GonkDisplayJB.cpp',
'GraphicBufferAlloc.cpp',
]
-elif CONFIG['ANDROID_VERSION'] == '15':
- SOURCES += [
- 'GonkDisplayICS.cpp'
- ]
elif CONFIG['ANDROID_VERSION'] and CONFIG['COMPILE_ENVIRONMENT']:
error('Unsupported platform version: %s' % (CONFIG['ANDROID_VERSION']))
Library('display')
include('/ipc/chromium/chromium-config.mozbuild')
FORCE_STATIC_LIB = True
DEFINES['XPCOM_GLUE'] = True
DISABLE_STL_WRAPPING = True
-if CONFIG['ANDROID_VERSION'] > '15':
- LOCAL_INCLUDES += [
- '%' + '%s/%s' % (CONFIG['ANDROID_SOURCE'], d) for d in [
- 'frameworks/native/include/gui',
- 'frameworks/native/opengl/include',
- 'system/core/libsuspend/include',
- ]
- ]
-
LOCAL_INCLUDES += [
'%' + '%s/%s' % (CONFIG['ANDROID_SOURCE'], d) for d in [
+ 'frameworks/native/include/gui',
+ 'frameworks/native/opengl/include',
'hardware/libhardware/include',
'hardware/libhardware_legacy/include',
+ 'system/core/libsuspend/include',
]
]
--- a/widget/gonk/moz.build
+++ b/widget/gonk/moz.build
@@ -45,20 +45,16 @@ SOURCES += ['libui/' + src for src in [
'VirtualKeyMap.cpp',
]]
# HwcHAL files
if CONFIG['ANDROID_VERSION'] >= '17':
SOURCES += [
'hwchal/HwcHAL.cpp',
]
-elif CONFIG['ANDROID_VERSION'] == '15':
- SOURCES += [
- 'hwchal/HwcICS.cpp',
- ]
SOURCES += [
'GeckoTouchDispatcher.cpp',
'GfxInfo.cpp',
'GonkClipboardData.cpp',
'GonkMemoryPressureMonitoring.cpp',
'GonkPermission.cpp',
'HwcComposer2D.cpp',
@@ -84,26 +80,20 @@ LOCAL_INCLUDES += [
'/gfx/skia/skia/include/config',
'/gfx/skia/skia/include/core',
'/image',
'/widget',
]
DEFINES['HAVE_OFF64_T'] = True
DEFINES['SK_BUILD_FOR_ANDROID_NDK'] = True
-
-if CONFIG['ANDROID_VERSION'] != '15':
- DEFINES['HAVE_POSIX_CLOCKS'] = True
+DEFINES['HAVE_POSIX_CLOCKS'] = True
if CONFIG['MOZ_OMX_DECODER']:
DEFINES['MOZ_OMX_DECODER'] = True
-if CONFIG['ANDROID_VERSION'] > '15':
- LOCAL_INCLUDES += [
- '%' + '%s/frameworks/native/opengl/include' % CONFIG['ANDROID_SOURCE'],
- ]
-
LOCAL_INCLUDES += [
'%' + '%s/%s' % (CONFIG['ANDROID_SOURCE'], d) for d in [
+ 'frameworks/native/opengl/include',
'hardware/libhardware/include',
'hardware/libhardware_legacy/include',
]
]
--- a/widget/gonk/nativewindow/GonkNativeWindow.h
+++ b/widget/gonk/nativewindow/GonkNativeWindow.h
@@ -14,11 +14,9 @@
*/
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 21
# include "GonkNativeWindowLL.h"
#elif defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 19
# include "GonkNativeWindowKK.h"
#elif defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
# include "GonkNativeWindowJB.h"
-#elif defined(MOZ_WIDGET_GONK) && ANDROID_VERSION == 15
-# include "GonkNativeWindowICS.h"
#endif
deleted file mode 100644
--- a/widget/gonk/nativewindow/GonkNativeWindowICS.cpp
+++ /dev/null
@@ -1,673 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/*
- * Copyright (C) 2010 The Android Open Source Project
- * Copyright (C) 2012-2013 Mozilla Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "base/basictypes.h"
-#include "mozilla/layers/GrallocTextureClient.h"
-#include "mozilla/layers/ImageBridgeChild.h"
-#include "mozilla/layers/ShadowLayers.h"
-#include "mozilla/layers/ShadowLayerUtilsGralloc.h"
-#include "GonkNativeWindow.h"
-#include "nsDebug.h"
-
-/**
- * DOM_CAMERA_LOGI() is enabled in debug builds, and turned on by setting
- * MOZ_LOG=Camera:N environment variable, where N >= 3.
- *
- * CNW_LOGE() is always enabled.
- */
-#define CNW_LOGD(...) DOM_CAMERA_LOGI(__VA_ARGS__)
-#define CNW_LOGE(...) {(void)printf_stderr(__VA_ARGS__);}
-
-using namespace android;
-using namespace mozilla;
-using namespace mozilla::gfx;
-using namespace mozilla::layers;
-
-GonkNativeWindow::GonkNativeWindow() :
- mAbandoned(false),
- mDefaultWidth(1),
- mDefaultHeight(1),
- mPixelFormat(PIXEL_FORMAT_RGBA_8888),
- mBufferCount(MIN_BUFFER_SLOTS + 1),
- mConnectedApi(NO_CONNECTED_API),
- mFrameCounter(0),
- mNewFrameCallback(nullptr) {
-}
-
-GonkNativeWindow::~GonkNativeWindow() {
- freeAllBuffersLocked();
-}
-
-void GonkNativeWindow::abandon()
-{
- CNW_LOGD("abandon");
- Mutex::Autolock lock(mMutex);
- mQueue.clear();
- mAbandoned = true;
- freeAllBuffersLocked();
- mDequeueCondition.signal();
-}
-
-void GonkNativeWindow::freeAllBuffersLocked()
-{
- CNW_LOGD("freeAllBuffersLocked");
-
- for (int i = 0; i < NUM_BUFFER_SLOTS; ++i) {
- if (mSlots[i].mGraphicBuffer != NULL) {
- if (mSlots[i].mTextureClient) {
- mSlots[i].mTextureClient->ClearRecycleCallback();
- // release TextureClient in ImageBridge thread
- RefPtr<TextureClientReleaseTask> task =
- MakeAndAddRef<TextureClientReleaseTask>(mSlots[i].mTextureClient);
- mSlots[i].mTextureClient = NULL;
- ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(task.forget());
- }
- mSlots[i].mGraphicBuffer = NULL;
- mSlots[i].mBufferState = BufferSlot::FREE;
- mSlots[i].mFrameNumber = 0;
- }
- }
-}
-
-void GonkNativeWindow::clearRenderingStateBuffersLocked()
-{
- CNW_LOGD("clearRenderingStateBuffersLocked");
-
- for (int i = 0; i < NUM_BUFFER_SLOTS; ++i) {
- if (mSlots[i].mGraphicBuffer != NULL) {
- // Clear RENDERING state buffer
- if (mSlots[i].mBufferState == BufferSlot::RENDERING) {
- if (mSlots[i].mTextureClient) {
- mSlots[i].mTextureClient->ClearRecycleCallback();
- // release TextureClient in ImageBridge thread
- RefPtr<TextureClientReleaseTask> task =
- MakeAndAddRef<TextureClientReleaseTask>(mSlots[i].mTextureClient);
- mSlots[i].mTextureClient = NULL;
- ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(task.forget());
- }
- mSlots[i].mGraphicBuffer = NULL;
- mSlots[i].mBufferState = BufferSlot::FREE;
- mSlots[i].mFrameNumber = 0;
- }
- }
- }
-}
-
-status_t GonkNativeWindow::setBufferCount(int bufferCount)
-{
- CNW_LOGD("setBufferCount: count=%d", bufferCount);
- Mutex::Autolock lock(mMutex);
-
- if (mAbandoned) {
- CNW_LOGE("setBufferCount: GonkNativeWindow has been abandoned!");
- return NO_INIT;
- }
-
- if (bufferCount > NUM_BUFFER_SLOTS) {
- CNW_LOGE("setBufferCount: bufferCount larger than slots available");
- return BAD_VALUE;
- }
-
- if (bufferCount < MIN_BUFFER_SLOTS) {
- CNW_LOGE("setBufferCount: requested buffer count (%d) is less than "
- "minimum (%d)", bufferCount, MIN_BUFFER_SLOTS);
- return BAD_VALUE;
- }
-
- // Error out if the user has dequeued buffers.
- for (int i=0 ; i<mBufferCount ; i++) {
- if (mSlots[i].mBufferState == BufferSlot::DEQUEUED) {
- CNW_LOGE("setBufferCount: client owns some buffers");
- return -EINVAL;
- }
- }
-
- if (bufferCount >= mBufferCount) {
- mBufferCount = bufferCount;
- //clear only buffers in RENDERING state.
- clearRenderingStateBuffersLocked();
- mQueue.clear();
- mDequeueCondition.signal();
- return OK;
- }
-
- // here we're guaranteed that the client doesn't have dequeued buffers
- // and will release all of its buffer references.
- freeAllBuffersLocked();
- mBufferCount = bufferCount;
- mQueue.clear();
- mDequeueCondition.signal();
- return OK;
-}
-
-status_t GonkNativeWindow::setDefaultBufferSize(uint32_t w, uint32_t h)
-{
- CNW_LOGD("setDefaultBufferSize: w=%d, h=%d", w, h);
- if (!w || !h) {
- CNW_LOGE("setDefaultBufferSize: dimensions cannot be 0 (w=%d, h=%d)",
- w, h);
- return BAD_VALUE;
- }
-
- Mutex::Autolock lock(mMutex);
- mDefaultWidth = w;
- mDefaultHeight = h;
- return OK;
-}
-
-status_t GonkNativeWindow::requestBuffer(int slot, sp<GraphicBuffer>* buf)
-{
- CNW_LOGD("requestBuffer: slot=%d", slot);
- Mutex::Autolock lock(mMutex);
- if (mAbandoned) {
- CNW_LOGE("requestBuffer: GonkNativeWindow has been abandoned!");
- return NO_INIT;
- }
- if (slot < 0 || mBufferCount <= slot) {
- CNW_LOGE("requestBuffer: slot index out of range [0, %d]: %d",
- mBufferCount, slot);
- return BAD_VALUE;
- }
- mSlots[slot].mRequestBufferCalled = true;
- *buf = mSlots[slot].mGraphicBuffer;
- return NO_ERROR;
-}
-
-status_t GonkNativeWindow::dequeueBuffer(int *outBuf, uint32_t w, uint32_t h,
- uint32_t format, uint32_t usage)
-{
- if ((w && !h) || (!w && h)) {
- CNW_LOGE("dequeueBuffer: invalid size: w=%u, h=%u", w, h);
- return BAD_VALUE;
- }
-
- status_t returnFlags(OK);
- bool updateFormat = false;
- bool alloc = false;
- int buf = INVALID_BUFFER_SLOT;
-
- {
- Mutex::Autolock lock(mMutex);
-
- int found = -1;
- int dequeuedCount = 0;
- int renderingCount = 0;
- bool tryAgain = true;
-
- CNW_LOGD("dequeueBuffer: E");
- while (tryAgain) {
- if (mAbandoned) {
- CNW_LOGE("dequeueBuffer: GonkNativeWindow has been abandoned!");
- return NO_INIT;
- }
- // look for a free buffer to give to the client
- found = INVALID_BUFFER_SLOT;
- dequeuedCount = 0;
- renderingCount = 0;
- for (int i = 0; i < mBufferCount; i++) {
- const int state = mSlots[i].mBufferState;
- switch (state) {
- case BufferSlot::DEQUEUED:
- CNW_LOGD("dequeueBuffer: slot %d is DEQUEUED\n", i);
- dequeuedCount++;
- break;
-
- case BufferSlot::RENDERING:
- CNW_LOGD("dequeueBuffer: slot %d is RENDERING\n", i);
- renderingCount++;
- break;
-
- case BufferSlot::FREE:
- CNW_LOGD("dequeueBuffer: slot %d is FREE\n", i);
- /* We return the oldest of the free buffers to avoid
- * stalling the producer if possible. This is because
- * the consumer may still have pending reads of the
- * buffers in flight.
- */
- if (found < 0 ||
- mSlots[i].mFrameNumber < mSlots[found].mFrameNumber) {
- found = i;
- }
- break;
-
- default:
- CNW_LOGD("dequeueBuffer: slot %d is %d\n", i, state);
- break;
- }
- }
-
- // See whether a buffer has been in RENDERING state since the last
- // setBufferCount so we know whether to perform the
- // MIN_UNDEQUEUED_BUFFERS check below.
- if (renderingCount > 0) {
- // make sure the client is not trying to dequeue more buffers
- // than allowed.
- const int avail = mBufferCount - (dequeuedCount + 1);
- if (avail < MIN_UNDEQUEUED_BUFFERS) {
- CNW_LOGE("dequeueBuffer: MIN_UNDEQUEUED_BUFFERS=%d exceeded "
- "(dequeued=%d)",
- MIN_UNDEQUEUED_BUFFERS,
- dequeuedCount);
- return -EBUSY;
- }
- }
-
- // we're in synchronous mode and didn't find a buffer, we need to
- // wait for some buffers to be consumed
- tryAgain = (found == INVALID_BUFFER_SLOT);
- if (tryAgain) {
- CNW_LOGD("dequeueBuffer: Try again");
- mDequeueCondition.wait(mMutex);
- CNW_LOGD("dequeueBuffer: Now");
- }
- }
-
- if (found == INVALID_BUFFER_SLOT) {
- // This should not happen.
- CNW_LOGE("dequeueBuffer: no available buffer slots");
- return -EBUSY;
- }
-
- buf = found;
- *outBuf = found;
-
- const bool useDefaultSize = !w && !h;
- if (useDefaultSize) {
- // use the default size
- w = mDefaultWidth;
- h = mDefaultHeight;
- }
-
- updateFormat = (format != 0);
- if (!updateFormat) {
- // keep the current (or default) format
- format = mPixelFormat;
- }
-
- mSlots[buf].mBufferState = BufferSlot::DEQUEUED;
-
- const sp<GraphicBuffer>& gbuf(mSlots[buf].mGraphicBuffer);
- if ((gbuf == NULL) ||
- ((uint32_t(gbuf->width) != w) ||
- (uint32_t(gbuf->height) != h) ||
- (uint32_t(gbuf->format) != format) ||
- ((uint32_t(gbuf->usage) & usage) != usage))) {
- mSlots[buf].mGraphicBuffer = NULL;
- mSlots[buf].mRequestBufferCalled = false;
- if (mSlots[buf].mTextureClient) {
- mSlots[buf].mTextureClient->ClearRecycleCallback();
- // release TextureClient in ImageBridge thread
- RefPtr<TextureClientReleaseTask> task =
- MakeAndAddRef<TextureClientReleaseTask>(mSlots[buf].mTextureClient);
- mSlots[buf].mTextureClient = NULL;
- ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(task.forget());
- }
- alloc = true;
- }
- } // end lock scope
-
- if (alloc) {
- ClientIPCAllocator* allocator = ImageBridgeChild::GetSingleton();
- usage |= GraphicBuffer::USAGE_HW_TEXTURE;
- GrallocTextureData* texData = GrallocTextureData::Create(IntSize(w, h), format,
- gfx::BackendType::NONE, usage,
- allocator);
- if (!texData) {
- return -ENOMEM;
- }
-
- RefPtr<TextureClient> textureClient = new TextureClient(texData, TextureFlags::RECYCLE | TextureFlags::DEALLOCATE_CLIENT, allocator);
-
- { // Scope for the lock
- Mutex::Autolock lock(mMutex);
-
- if (mAbandoned) {
- CNW_LOGE("dequeueBuffer: SurfaceTexture has been abandoned!");
- return NO_INIT;
- }
-
- if (updateFormat) {
- mPixelFormat = format;
- }
- mSlots[buf].mGraphicBuffer = texData->GetGraphicBuffer();
- mSlots[buf].mTextureClient = textureClient;
-
- returnFlags |= ISurfaceTexture::BUFFER_NEEDS_REALLOCATION;
-
- CNW_LOGD("dequeueBuffer: returning slot=%d buf=%p ", buf,
- mSlots[buf].mGraphicBuffer->handle);
- }
- }
-
- CNW_LOGD("dequeueBuffer: returning slot=%d buf=%p ", buf,
- mSlots[buf].mGraphicBuffer->handle );
-
- CNW_LOGD("dequeueBuffer: X");
- return returnFlags;
-}
-
-status_t GonkNativeWindow::setSynchronousMode(bool enabled)
-{
- return NO_ERROR;
-}
-
-int GonkNativeWindow::getSlotFromBufferLocked(
- android_native_buffer_t* buffer) const
-{
- if (buffer == NULL) {
- CNW_LOGE("getSlotFromBufferLocked: encountered NULL buffer");
- return BAD_VALUE;
- }
-
- for (int i = 0; i < NUM_BUFFER_SLOTS; i++) {
- if (mSlots[i].mGraphicBuffer != NULL && mSlots[i].mGraphicBuffer->handle == buffer->handle) {
- return i;
- }
- }
- CNW_LOGE("getSlotFromBufferLocked: unknown buffer: %p", buffer->handle);
- return BAD_VALUE;
-}
-
-int GonkNativeWindow::getSlotFromTextureClientLocked(
- TextureClient* client) const
-{
- if (client == NULL) {
- CNW_LOGE("getSlotFromBufferLocked: encountered NULL buffer");
- return BAD_VALUE;
- }
-
- for (int i = 0; i < NUM_BUFFER_SLOTS; i++) {
- if (mSlots[i].mTextureClient == client) {
- return i;
- }
- }
- CNW_LOGE("getSlotFromBufferLocked: unknown TextureClient: %p", client);
- return BAD_VALUE;
-}
-
-already_AddRefed<TextureClient>
-GonkNativeWindow::getTextureClientFromBuffer(ANativeWindowBuffer* buffer)
-{
- int buf = getSlotFromBufferLocked(buffer);
- if (buf < 0 || buf >= mBufferCount ||
- mSlots[buf].mBufferState != BufferSlot::DEQUEUED) {
- return nullptr;
- }
-
- RefPtr<TextureClient> client(mSlots[buf].mTextureClient);
- return client.forget();
-}
-
-status_t GonkNativeWindow::queueBuffer(int buf, int64_t timestamp,
- uint32_t* outWidth, uint32_t* outHeight, uint32_t* outTransform)
-{
- {
- Mutex::Autolock lock(mMutex);
- CNW_LOGD("queueBuffer: E");
- CNW_LOGD("queueBuffer: buf=%d", buf);
-
- if (mAbandoned) {
- CNW_LOGE("queueBuffer: GonkNativeWindow has been abandoned!");
- return NO_INIT;
- }
- if (buf < 0 || buf >= mBufferCount) {
- CNW_LOGE("queueBuffer: slot index out of range [0, %d]: %d",
- mBufferCount, buf);
- return -EINVAL;
- } else if (mSlots[buf].mBufferState != BufferSlot::DEQUEUED) {
- CNW_LOGE("queueBuffer: slot %d is not owned by the client "
- "(state=%d)", buf, mSlots[buf].mBufferState);
- return -EINVAL;
- } else if (!mSlots[buf].mRequestBufferCalled) {
- CNW_LOGE("queueBuffer: slot %d was enqueued without requesting a "
- "buffer", buf);
- return -EINVAL;
- }
-
- mQueue.push_back(buf);
-
- mSlots[buf].mBufferState = BufferSlot::QUEUED;
- mSlots[buf].mTimestamp = timestamp;
- mFrameCounter++;
- mSlots[buf].mFrameNumber = mFrameCounter;
-
- mDequeueCondition.signal();
-
- *outWidth = mDefaultWidth;
- *outHeight = mDefaultHeight;
- *outTransform = 0;
- }
-
- // OnNewFrame might call lockCurrentBuffer so we must release the
- // mutex first.
- if (mNewFrameCallback) {
- mNewFrameCallback->OnNewFrame();
- }
- CNW_LOGD("queueBuffer: X");
- return OK;
-}
-
-
-already_AddRefed<TextureClient>
-GonkNativeWindow::getCurrentBuffer() {
- CNW_LOGD("GonkNativeWindow::getCurrentBuffer");
- Mutex::Autolock lock(mMutex);
-
- if (mAbandoned) {
- CNW_LOGE("getCurrentBuffer: GonkNativeWindow has been abandoned!");
- return NULL;
- }
-
- if(mQueue.empty()) {
- mDequeueCondition.signal();
- return nullptr;
- }
-
- Fifo::iterator front(mQueue.begin());
- int buf = *front;
- CNW_LOGD("getCurrentBuffer: buf=%d", buf);
-
- mSlots[buf].mBufferState = BufferSlot::RENDERING;
-
- mQueue.erase(front);
- mDequeueCondition.signal();
-
- mSlots[buf].mTextureClient->SetRecycleCallback(GonkNativeWindow::RecycleCallback, this);
- RefPtr<TextureClient> client(mSlots[buf].mTextureClient);
- return client.forget();
-}
-
-
-/* static */ void
-GonkNativeWindow::RecycleCallback(TextureClient* client, void* closure) {
- GonkNativeWindow* nativeWindow =
- static_cast<GonkNativeWindow*>(closure);
-
- MOZ_ASSERT(client && !client->IsDead());
- client->ClearRecycleCallback();
- nativeWindow->returnBuffer(client);
-}
-
-void GonkNativeWindow::returnBuffer(TextureClient* client) {
- CNW_LOGD("GonkNativeWindow::returnBuffer");
- Mutex::Autolock lock(mMutex);
-
- if (mAbandoned) {
- CNW_LOGD("returnBuffer: GonkNativeWindow has been abandoned!");
- return;
- }
-
- int index = getSlotFromTextureClientLocked(client);
- if (index < 0 || index >= mBufferCount) {
- CNW_LOGE("returnBuffer: slot index out of range [0, %d]: %d",
- mBufferCount, index);
- return;
- }
-
- if (mSlots[index].mBufferState != BufferSlot::RENDERING) {
- CNW_LOGE("returnBuffer: slot %d is not owned by the compositor (state=%d)",
- index, mSlots[index].mBufferState);
- return;
- }
-
- mSlots[index].mBufferState = BufferSlot::FREE;
- mDequeueCondition.signal();
- return;
-}
-
-void GonkNativeWindow::cancelBuffer(int buf) {
- CNW_LOGD("cancelBuffer: slot=%d", buf);
- Mutex::Autolock lock(mMutex);
-
- if (mAbandoned) {
- CNW_LOGD("cancelBuffer: GonkNativeWindow has been abandoned!");
- return;
- }
-
- if (buf < 0 || buf >= mBufferCount) {
- CNW_LOGE("cancelBuffer: slot index out of range [0, %d]: %d",
- mBufferCount, buf);
- return;
- } else if (mSlots[buf].mBufferState != BufferSlot::DEQUEUED) {
- CNW_LOGE("cancelBuffer: slot %d is not owned by the client (state=%d)",
- buf, mSlots[buf].mBufferState);
- return;
- }
- mSlots[buf].mBufferState = BufferSlot::FREE;
- mSlots[buf].mFrameNumber = 0;
- mDequeueCondition.signal();
-}
-
-status_t GonkNativeWindow::setCrop(const Rect& crop) {
- return OK;
-}
-
-status_t GonkNativeWindow::setTransform(uint32_t transform) {
- return OK;
-}
-
-status_t GonkNativeWindow::connect(int api,
- uint32_t* outWidth, uint32_t* outHeight, uint32_t* outTransform) {
- CNW_LOGD("connect: api=%d", api);
- Mutex::Autolock lock(mMutex);
-
- if (mAbandoned) {
- CNW_LOGE("connect: GonkNativeWindow has been abandoned!");
- return NO_INIT;
- }
-
- int err = NO_ERROR;
- switch (api) {
- case NATIVE_WINDOW_API_EGL:
- case NATIVE_WINDOW_API_CPU:
- case NATIVE_WINDOW_API_MEDIA:
- case NATIVE_WINDOW_API_CAMERA:
- if (mConnectedApi != NO_CONNECTED_API) {
- CNW_LOGE("connect: already connected (cur=%d, req=%d)",
- mConnectedApi, api);
- err = -EINVAL;
- } else {
- mConnectedApi = api;
- *outWidth = mDefaultWidth;
- *outHeight = mDefaultHeight;
- *outTransform = 0;
- }
- break;
- default:
- err = -EINVAL;
- break;
- }
- return err;
-}
-
-status_t GonkNativeWindow::disconnect(int api) {
- CNW_LOGD("disconnect: api=%d", api);
-
- int err = NO_ERROR;
- Mutex::Autolock lock(mMutex);
-
- if (mAbandoned) {
- // it is not really an error to disconnect after the surface
- // has been abandoned, it should just be a no-op.
- return NO_ERROR;
- }
-
- switch (api) {
- case NATIVE_WINDOW_API_EGL:
- case NATIVE_WINDOW_API_CPU:
- case NATIVE_WINDOW_API_MEDIA:
- case NATIVE_WINDOW_API_CAMERA:
- if (mConnectedApi == api) {
- mQueue.clear();
- freeAllBuffersLocked();
- mConnectedApi = NO_CONNECTED_API;
- mDequeueCondition.signal();
- } else {
- CNW_LOGE("disconnect: connected to another api (cur=%d, req=%d)",
- mConnectedApi, api);
- err = -EINVAL;
- }
- break;
- default:
- CNW_LOGE("disconnect: unknown API %d", api);
- err = -EINVAL;
- break;
- }
- return err;
-}
-
-status_t GonkNativeWindow::setScalingMode(int mode) {
- return OK;
-}
-
-void GonkNativeWindow::setNewFrameCallback(
- GonkNativeWindowNewFrameCallback* aCallback) {
- CNW_LOGD("setNewFrameCallback");
- Mutex::Autolock lock(mMutex);
- mNewFrameCallback = aCallback;
-}
-
-int GonkNativeWindow::query(int what, int* outValue)
-{
- Mutex::Autolock lock(mMutex);
-
- if (mAbandoned) {
- CNW_LOGE("query: GonkNativeWindow has been abandoned!");
- return NO_INIT;
- }
-
- int value;
- switch (what) {
- case NATIVE_WINDOW_WIDTH:
- value = mDefaultWidth;
- break;
- case NATIVE_WINDOW_HEIGHT:
- value = mDefaultHeight;
- break;
- case NATIVE_WINDOW_FORMAT:
- value = mPixelFormat;
- break;
- case NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS:
- value = MIN_UNDEQUEUED_BUFFERS;
- break;
- default:
- return BAD_VALUE;
- }
- outValue[0] = value;
- return NO_ERROR;
-}
deleted file mode 100644
--- a/widget/gonk/nativewindow/GonkNativeWindowICS.h
+++ /dev/null
@@ -1,296 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- * Copyright (C) 2012 Mozilla Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef NATIVEWINDOW_GONKNATIVEWINDOW_ICS_H
-#define NATIVEWINDOW_GONKNATIVEWINDOW_ICS_H
-
-#include <stdint.h>
-#include <sys/types.h>
-
-#include <gui/ISurfaceTexture.h>
-#include <ui/egl/android_natives.h>
-#include <ui/GraphicBuffer.h>
-#include <ui/Rect.h>
-#include <utils/Errors.h>
-#include <utils/RefBase.h>
-#include <utils/String8.h>
-#include <utils/threads.h>
-
-#include "CameraCommon.h"
-#include "GrallocImages.h"
-#include "mozilla/layers/LayersSurfaces.h"
-#include "mozilla/layers/TextureClient.h"
-
-namespace android {
-
-// The user of GonkNativeWindow who wants to receive notification of
-// new frames should implement this interface.
-class GonkNativeWindowNewFrameCallback {
-public:
- virtual void OnNewFrame() = 0;
-};
-
-class GonkNativeWindow : public BnSurfaceTexture
-{
- friend class GonkNativeWindowClient;
-
- typedef mozilla::layers::TextureClient TextureClient;
-
-public:
- enum { MIN_UNDEQUEUED_BUFFERS = 2 };
- enum { MIN_BUFFER_SLOTS = MIN_UNDEQUEUED_BUFFERS };
- enum { NUM_BUFFER_SLOTS = 32 };
- enum { NO_CONNECTED_API = 0 };
- enum { NATIVE_WINDOW_SET_BUFFERS_SIZE = 0x10000000 };
-
- GonkNativeWindow();
- ~GonkNativeWindow(); // this class cannot be overloaded
-
- // Get next frame from the queue and mark it as RENDERING, caller
- // owns the returned buffer.
- already_AddRefed<TextureClient> getCurrentBuffer();
-
- // Return the buffer to the queue and mark it as FREE. After that
- // the buffer is useable again for the decoder.
- void returnBuffer(TextureClient* client);
-
- // setBufferCount updates the number of available buffer slots. After
- // calling this all buffer slots are owned by the GonkNativeWindow object
- // (i.e. they are not owned by the client).
- virtual status_t setBufferCount(int bufferCount);
-
- // requestBuffer requests a new buffer for the given index.
- virtual status_t requestBuffer(int slot, sp<GraphicBuffer>* buf);
-
- // dequeueBuffer gets the next buffer slot index for the client to use. If a
- // buffer slot is available then that slot index is written to the location
- // pointed to by the buf argument and a status of OK is returned. If no
- // slot is available then a status of -EBUSY is returned and buf is
- // unmodified.
- virtual status_t dequeueBuffer(int *buf, uint32_t width, uint32_t height,
- uint32_t format, uint32_t usage);
-
- // queueBuffer returns a filled buffer to the GonkNativeWindow. In addition,
- // a timestamp must be provided for the buffer. The timestamp is in
- // nanoseconds, and must be monotonically increasing. Its other semantics
- // (zero point, etc) are client-dependent and should be documented by the
- // client.
- virtual status_t queueBuffer(int buf, int64_t timestamp,
- uint32_t* outWidth, uint32_t* outHeight, uint32_t* outTransform);
- virtual void cancelBuffer(int buf);
- virtual status_t setCrop(const Rect& reg);
- virtual status_t setTransform(uint32_t transform);
- virtual status_t setScalingMode(int mode);
-
- virtual int query(int what, int* value);
-
- // Qcom specific function
- virtual int performQcomOperation(int operation, int arg1, int arg2, int arg3) {
- return OK;
- }
-
- // GonkNativeWindow do not implement the function and always works in
- // synchronous mode.
- virtual status_t setSynchronousMode(bool enabled);
-
- // connect attempts to connect a client API to the GonkNativeWindow.
- //
- // This method will fail if the connect was previously called on the
- // GonkNativeWindow and no corresponding disconnect call was made.
- virtual status_t connect(int api,
- uint32_t* outWidth, uint32_t* outHeight, uint32_t* outTransform);
-
- // disconnect attempts to disconnect a client API from the GonkNativeWindow.
- // This method will fail if the the GonkNativeWindow is not currently
- // connected to the specified client API.
- virtual status_t disconnect(int api);
-
- void setNewFrameCallback(GonkNativeWindowNewFrameCallback* aCallback);
-
- // setDefaultBufferSize is used to set the size of buffers returned by
- // requestBuffers when a with and height of zero is requested.
- // A call to setDefaultBufferSize() may trigger requestBuffers() to
- // be called from the client.
- status_t setDefaultBufferSize(uint32_t width, uint32_t height);
-
- // abandon frees all the buffers and puts the GonkNativeWindow into the
- // 'abandoned' state. Once put in this state the GonkNativeWindow can never
- // leave it. When in the 'abandoned' state, all methods of the
- // ISurfaceTexture interface will fail with the NO_INIT error.
- //
- // Note that while calling this method causes all the buffers to be freed
- // from the perspective of the the GonkNativeWindow, if there are additional
- // references on the buffers (e.g. if a buffer is referenced by a client)
- // then those buffer will remain allocated.
- void abandon();
-
- already_AddRefed<TextureClient> getTextureClientFromBuffer(ANativeWindowBuffer* buffer);
-
- static void RecycleCallback(TextureClient* client, void* closure);
-
-protected:
-
- // freeAllBuffersLocked frees the resources (both GraphicBuffer and
- // EGLImage) for all slots by removing them from the slots and appending
- // then to the freeList. This must be called with mMutex locked.
- void freeAllBuffersLocked();
-
- // clearRenderingStateBuffersLocked clear the resources in RENDERING state;
- // But do not destroy the gralloc buffer. It is still in the video stream
- // awaiting rendering.
- // this must be called with mMutex locked.
- void clearRenderingStateBuffersLocked();
-
-private:
- void init();
-
- int getSlotFromBufferLocked(android_native_buffer_t* buffer) const;
-
- int getSlotFromTextureClientLocked(TextureClient* client) const;
-
- enum { INVALID_BUFFER_SLOT = -1 };
-
- struct BufferSlot {
-
- BufferSlot()
- : mBufferState(BufferSlot::FREE),
- mTimestamp(0),
- mFrameNumber(0){
- }
-
- // mGraphicBuffer points to the buffer allocated for this slot or is NULL
- // if no buffer has been allocated.
- sp<GraphicBuffer> mGraphicBuffer;
-
- // mTextureClient is a thin abstraction over remotely allocated GraphicBuffer.
- RefPtr<TextureClient> mTextureClient;
-
- // BufferState represents the different states in which a buffer slot
- // can be.
- enum BufferState {
- // FREE indicates that the buffer is not currently being used and
- // will not be used in the future until it gets dequeued and
- // subsequently queued by the client.
- FREE = 0,
-
- // DEQUEUED indicates that the buffer has been dequeued by the
- // client, but has not yet been queued or canceled. The buffer is
- // considered 'owned' by the client, and the server should not use
- // it for anything.
- //
- // Note that when in synchronous-mode (mSynchronousMode == true),
- // the buffer that's currently attached to the texture may be
- // dequeued by the client. That means that the current buffer can
- // be in either the DEQUEUED or QUEUED state. In asynchronous mode,
- // however, the current buffer is always in the QUEUED state.
- DEQUEUED = 1,
-
- // QUEUED indicates that the buffer has been queued by the client,
- // and has not since been made available for the client to dequeue.
- // Attaching the buffer to the texture does NOT transition the
- // buffer away from the QUEUED state. However, in Synchronous mode
- // the current buffer may be dequeued by the client under some
- // circumstances. See the note about the current buffer in the
- // documentation for DEQUEUED.
- QUEUED = 2,
-
- // RENDERING indicates that the buffer has been sent to
- // the compositor, and has not yet available for the
- // client to dequeue. When the compositor has finished its
- // job, the buffer will be returned to FREE state.
- RENDERING = 3,
- };
-
- // mBufferState is the current state of this buffer slot.
- BufferState mBufferState;
-
- // mRequestBufferCalled is used for validating that the client did
- // call requestBuffer() when told to do so. Technically this is not
- // needed but useful for debugging and catching client bugs.
- bool mRequestBufferCalled;
-
- // mTimestamp is the current timestamp for this buffer slot. This gets
- // to set by queueBuffer each time this slot is queued.
- int64_t mTimestamp;
-
- // mFrameNumber is the number of the queued frame for this slot.
- uint64_t mFrameNumber;
- };
-
- // mSlots is the array of buffer slots that must be mirrored on the client
- // side. This allows buffer ownership to be transferred between the client
- // and server without sending a GraphicBuffer over binder. The entire array
- // is initialized to NULL at construction time, and buffers are allocated
- // for a slot when requestBuffer is called with that slot's index.
- BufferSlot mSlots[NUM_BUFFER_SLOTS];
-
- // mDequeueCondition condition used for dequeueBuffer in synchronous mode
- mutable Condition mDequeueCondition;
-
- // mAbandoned indicates that the GonkNativeWindow will no longer be used to
- // consume buffers pushed to it.
- // It is initialized to false, and set to true in the abandon method. A
- // GonkNativeWindow that has been abandoned will return the NO_INIT error
- // from all control methods capable of returning an error.
- bool mAbandoned;
-
- // mTimestamp is the timestamp that will be used for the next buffer queue
- // operation. It defaults to NATIVE_WINDOW_TIMESTAMP_AUTO, which means that
- // a timestamp is auto-generated when queueBuffer is called.
- int64_t mTimestamp;
-
- // mDefaultWidth holds the default width of allocated buffers. It is used
- // in requestBuffers() if a width and height of zero is specified.
- uint32_t mDefaultWidth;
-
- // mDefaultHeight holds the default height of allocated buffers. It is used
- // in requestBuffers() if a width and height of zero is specified.
- uint32_t mDefaultHeight;
-
- // mPixelFormat holds the pixel format of allocated buffers. It is used
- // in requestBuffers() if a format of zero is specified.
- uint32_t mPixelFormat;
-
- // mBufferCount is the number of buffer slots that the client and server
- // must maintain. It defaults to MIN_BUFFER_SLOTS + 1 and can be changed
- // by calling setBufferCount or setBufferCountServer
- int mBufferCount;
-
- // mConnectedApi indicates the API that is currently connected to this
- // GonkNativeWindow. It defaults to NO_CONNECTED_API (= 0), and gets updated
- // by the connect and disconnect methods.
- int mConnectedApi;
-
- // mQueue is a FIFO of queued buffers used in synchronous mode
- // GonkNativeWindow always works in synchronous mode
- typedef Vector<int> Fifo;
- Fifo mQueue;
-
- // mMutex is the mutex used to prevent concurrent access to the member
- // variables of GonkNativeWindow objects. It must be locked whenever the
- // member variables are accessed.
- mutable Mutex mMutex;
-
- // mFrameCounter is the free running counter, incremented for every buffer queued
- uint64_t mFrameCounter;
-
- GonkNativeWindowNewFrameCallback* mNewFrameCallback;
-};
-
-}; // namespace android
-
-#endif // NATIVEWINDOW_GONKNATIVEWINDOW_ICS_H
--- a/widget/gonk/nativewindow/moz.build
+++ b/widget/gonk/nativewindow/moz.build
@@ -42,20 +42,16 @@ elif CONFIG['ANDROID_VERSION'] >= '19':
'IGonkGraphicBufferConsumerKK.h',
]
elif CONFIG['ANDROID_VERSION'] in ('17', '18'):
EXPORTS += [
'GonkBufferQueueJB.h',
'GonkConsumerBaseJB.h',
'GonkNativeWindowJB.h',
]
-elif CONFIG['ANDROID_VERSION'] == '15':
- EXPORTS += [
- 'GonkNativeWindowICS.h',
- ]
if CONFIG['MOZ_B2G_CAMERA'] or CONFIG['MOZ_OMX_DECODER'] or CONFIG['MOZ_WEBRTC']:
if CONFIG['ANDROID_VERSION'] >= '21':
SOURCES += [
'GonkBufferQueueLL/GonkBufferItem.cpp',
'GonkBufferQueueLL/GonkBufferQueueConsumer.cpp',
'GonkBufferQueueLL/GonkBufferQueueCore.cpp',
'GonkBufferQueueLL/GonkBufferQueueLL.cpp',
@@ -73,20 +69,16 @@ if CONFIG['MOZ_B2G_CAMERA'] or CONFIG['M
'IGonkGraphicBufferConsumerKK.cpp',
]
elif CONFIG['ANDROID_VERSION'] in ('17', '18'):
SOURCES += [
'GonkBufferQueueJB.cpp',
'GonkConsumerBaseJB.cpp',
'GonkNativeWindowJB.cpp',
]
- elif CONFIG['ANDROID_VERSION'] == '15':
- SOURCES += [
- 'GonkNativeWindowICS.cpp',
- ]
if CONFIG['ANDROID_VERSION'] >= '18':
SOURCES += [
'FakeSurfaceComposer.cpp',
]
include('/ipc/chromium/chromium-config.mozbuild')