Bug 929973 - Implement android::IGraphicBufferAlloc in B2G. r=mwu, r=mikeh

This commit is contained in:
Sotaro Ikeda 2013-11-21 16:03:27 -05:00
parent 76016117aa
commit a17c7b7508
5 changed files with 206 additions and 3 deletions

View File

@ -71,6 +71,10 @@ GonkCameraHardware::OnNewFrame()
return;
}
nsRefPtr<GraphicBufferLocked> buffer = mNativeWindow->getCurrentBuffer();
if (!buffer) {
DOM_CAMERA_LOGW("received null frame");
return;
}
ReceiveFrame(mTarget, buffer);
}

View File

@ -0,0 +1,104 @@
/*
* Copyright (C) 2007 The Android Open Source Project
* Copyright (C) 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 <stdint.h>
#include <sys/types.h>
#include <errno.h>
#include <cutils/log.h>
#include <gui/IDisplayEventConnection.h>
#include <gui/GraphicBufferAlloc.h>
#include "FakeSurfaceComposer.h"
namespace android {
/* static */
void FakeSurfaceComposer::instantiate() {
defaultServiceManager()->addService(
String16("SurfaceFlinger"), new FakeSurfaceComposer());
}
FakeSurfaceComposer::FakeSurfaceComposer()
: BnSurfaceComposer()
{
}
FakeSurfaceComposer::~FakeSurfaceComposer()
{
}
sp<ISurfaceComposerClient> FakeSurfaceComposer::createConnection()
{
return nullptr;
}
sp<IGraphicBufferAlloc> FakeSurfaceComposer::createGraphicBufferAlloc()
{
sp<GraphicBufferAlloc> gba(new GraphicBufferAlloc());
return gba;
}
sp<IBinder> FakeSurfaceComposer::createDisplay(const String8& displayName,
bool secure)
{
return nullptr;
}
sp<IBinder> FakeSurfaceComposer::getBuiltInDisplay(int32_t id) {
return nullptr;
}
void FakeSurfaceComposer::setTransactionState(
const Vector<ComposerState>& state,
const Vector<DisplayState>& displays,
uint32_t flags)
{
}
void FakeSurfaceComposer::bootFinished()
{
}
bool FakeSurfaceComposer::authenticateSurfaceTexture(
const sp<IGraphicBufferProducer>& bufferProducer) const {
return false;
}
sp<IDisplayEventConnection> FakeSurfaceComposer::createDisplayEventConnection() {
return nullptr;
}
status_t FakeSurfaceComposer::captureScreen(const sp<IBinder>& display,
const sp<IGraphicBufferProducer>& producer,
uint32_t reqWidth, uint32_t reqHeight,
uint32_t minLayerZ, uint32_t maxLayerZ,
bool isCpuConsumer) {
return INVALID_OPERATION;
}
void FakeSurfaceComposer::blank(const sp<IBinder>& display) {
}
void FakeSurfaceComposer::unblank(const sp<IBinder>& display) {
}
status_t FakeSurfaceComposer::getDisplayInfo(const sp<IBinder>& display, DisplayInfo* info) {
return INVALID_OPERATION;
}
}; // namespace android

View File

@ -0,0 +1,82 @@
/*
* Copyright (C) 2007 The Android Open Source Project
* Copyright (C) 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.
*/
#ifndef NATIVEWINDOW_FAKE_SURFACE_COMPOSER_H
#define NATIVEWINDOW_FAKE_SURFACE_COMPOSER_H
#include <stdint.h>
#include <sys/types.h>
#include <utils/Errors.h>
#include <binder/BinderService.h>
#include <gui/ISurfaceComposer.h>
#include <gui/ISurfaceComposerClient.h>
namespace android {
// ---------------------------------------------------------------------------
class IGraphicBufferAlloc;
class FakeSurfaceComposer : public BinderService<FakeSurfaceComposer>,
public BnSurfaceComposer
{
public:
static char const* getServiceName() {
return "FakeSurfaceComposer";
}
// Instantiate MediaResourceManagerService and register to service manager.
// If service manager is not present, wait until service manager becomes present.
static void instantiate();
private:
FakeSurfaceComposer();
// We're reference counted, never destroy FakeSurfaceComposer directly
virtual ~FakeSurfaceComposer();
/* ------------------------------------------------------------------------
* ISurfaceComposer interface
*/
virtual sp<ISurfaceComposerClient> createConnection();
virtual sp<IGraphicBufferAlloc> createGraphicBufferAlloc();
virtual sp<IBinder> createDisplay(const String8& displayName, bool secure);
virtual sp<IBinder> getBuiltInDisplay(int32_t id);
virtual void setTransactionState(const Vector<ComposerState>& state,
const Vector<DisplayState>& displays, uint32_t flags);
virtual void bootFinished();
virtual bool authenticateSurfaceTexture(
const sp<IGraphicBufferProducer>& bufferProducer) const;
virtual sp<IDisplayEventConnection> createDisplayEventConnection();
virtual status_t captureScreen(const sp<IBinder>& display,
const sp<IGraphicBufferProducer>& producer,
uint32_t reqWidth, uint32_t reqHeight,
uint32_t minLayerZ, uint32_t maxLayerZ, bool isCpuConsumer);
// called when screen needs to turn off
virtual void blank(const sp<IBinder>& display);
// called when screen is turning back on
virtual void unblank(const sp<IBinder>& display);
virtual status_t getDisplayInfo(const sp<IBinder>& display, DisplayInfo* info);
};
// ---------------------------------------------------------------------------
}; // namespace android
#endif // NATIVEWINDOW_FAKE_SURFACE_COMPOSER_H

View File

@ -46,6 +46,12 @@ if CONFIG['MOZ_B2G_CAMERA'] or CONFIG['MOZ_OMX_DECODER']:
'GonkNativeWindowICS.cpp',
]
if CONFIG['MOZ_B2G_CAMERA'] or CONFIG['MOZ_OMX_DECODER']:
if CONFIG['ANDROID_VERSION'] >= '18':
SOURCES += [
'FakeSurfaceComposer.cpp',
]
FAIL_ON_WARNINGS = True
include('/ipc/chromium/chromium-config.mozbuild')

View File

@ -40,6 +40,9 @@
#include "mozilla/Mutex.h"
#include "mozilla/Services.h"
#include "mozilla/TextEvents.h"
#if ANDROID_VERSION >= 18
#include "nativewindow/FakeSurfaceComposer.h"
#endif
#include "nsAppShell.h"
#include "mozilla/dom/Touch.h"
#include "nsGkAtoms.h"
@ -748,11 +751,15 @@ nsAppShell::Init()
InitGonkMemoryPressureMonitoring();
#ifdef MOZ_OMX_DECODER
if (XRE_GetProcessType() == GeckoProcessType_Default) {
android::MediaResourceManagerService::instantiate();
}
#ifdef MOZ_OMX_DECODER
android::MediaResourceManagerService::instantiate();
#endif
#if ANDROID_VERSION >= 18
android::FakeSurfaceComposer::instantiate();
#endif
}
nsCOMPtr<nsIObserverService> obsServ = GetObserverService();
if (obsServ) {
obsServ->AddObserver(this, "browser-ui-startup-complete", false);