mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 771653 - Use HWComposer instead of swapBuffer where appropriate, r=cjones
Some vendors provide a hw composer module which should be used instead of swapBuffers on hardware surfaces. Based on romaxa's patch.
This commit is contained in:
parent
c2e71774f4
commit
d881e202dd
@ -19,6 +19,7 @@
|
|||||||
#define GET_NATIVE_WINDOW(aWidget) (EGLNativeWindowType)static_cast<QWidget*>(aWidget->GetNativeData(NS_NATIVE_SHELLWIDGET))->winId()
|
#define GET_NATIVE_WINDOW(aWidget) (EGLNativeWindowType)static_cast<QWidget*>(aWidget->GetNativeData(NS_NATIVE_SHELLWIDGET))->winId()
|
||||||
#elif defined(MOZ_WIDGET_GONK)
|
#elif defined(MOZ_WIDGET_GONK)
|
||||||
#define GET_NATIVE_WINDOW(aWidget) ((EGLNativeWindowType)aWidget->GetNativeData(NS_NATIVE_WINDOW))
|
#define GET_NATIVE_WINDOW(aWidget) ((EGLNativeWindowType)aWidget->GetNativeData(NS_NATIVE_WINDOW))
|
||||||
|
#include "HWComposer.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(MOZ_X11)
|
#if defined(MOZ_X11)
|
||||||
@ -267,6 +268,15 @@ public:
|
|||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf_stderr("Initializing context %p surface %p on display %p\n", mContext, mSurface, EGL_DISPLAY());
|
printf_stderr("Initializing context %p surface %p on display %p\n", mContext, mSurface, EGL_DISPLAY());
|
||||||
|
#endif
|
||||||
|
#ifdef MOZ_WIDGET_GONK
|
||||||
|
if (!aIsOffscreen)
|
||||||
|
mHwc = new HWComposer();
|
||||||
|
|
||||||
|
if (mHwc && mHwc->init()) {
|
||||||
|
NS_WARNING("HWComposer initialization failed!");
|
||||||
|
mHwc = nullptr;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -567,7 +577,13 @@ public:
|
|||||||
bool SwapBuffers()
|
bool SwapBuffers()
|
||||||
{
|
{
|
||||||
if (mSurface && !mPlatformContext) {
|
if (mSurface && !mPlatformContext) {
|
||||||
return sEGLLibrary.fSwapBuffers(EGL_DISPLAY(), mSurface);
|
#ifdef MOZ_WIDGET_GONK
|
||||||
|
if (mHwc)
|
||||||
|
return !mHwc->swapBuffers((hwc_display_t)EGL_DISPLAY(),
|
||||||
|
(hwc_surface_t)mSurface);
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
return sEGLLibrary.fSwapBuffers(EGL_DISPLAY(), mSurface);
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -679,6 +695,9 @@ protected:
|
|||||||
bool mIsDoubleBuffered;
|
bool mIsDoubleBuffered;
|
||||||
bool mCanBindToTexture;
|
bool mCanBindToTexture;
|
||||||
bool mShareWithEGLImage;
|
bool mShareWithEGLImage;
|
||||||
|
#ifdef MOZ_WIDGET_GONK
|
||||||
|
nsAutoPtr<HWComposer> mHwc;
|
||||||
|
#endif
|
||||||
|
|
||||||
// A dummy texture ID that can be used when we need a texture object whose
|
// A dummy texture ID that can be used when we need a texture object whose
|
||||||
// images we're going to define with EGLImageTargetTexture2D.
|
// images we're going to define with EGLImageTargetTexture2D.
|
||||||
|
@ -86,6 +86,7 @@ endif
|
|||||||
|
|
||||||
ifeq ($(MOZ_WIDGET_TOOLKIT),gonk)
|
ifeq ($(MOZ_WIDGET_TOOLKIT),gonk)
|
||||||
GL_PROVIDER = EGL
|
GL_PROVIDER = EGL
|
||||||
|
LOCAL_INCLUDES = -I$(topsrcdir)/widget/gonk
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifdef MOZ_GL_PROVIDER
|
ifdef MOZ_GL_PROVIDER
|
||||||
|
66
widget/gonk/HWComposer.cpp
Normal file
66
widget/gonk/HWComposer.cpp
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2010 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* 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 <string.h>
|
||||||
|
#include "HWComposer.h"
|
||||||
|
#include <hardware/hardware.h>
|
||||||
|
#include <EGL/egl.h>
|
||||||
|
|
||||||
|
namespace android {
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
HWComposer::HWComposer()
|
||||||
|
: mModule(0), mHwc(0),
|
||||||
|
mDpy(EGL_NO_DISPLAY), mSur(EGL_NO_SURFACE)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
HWComposer::~HWComposer() {
|
||||||
|
if (mHwc) {
|
||||||
|
hwc_close(mHwc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int HWComposer::init() {
|
||||||
|
int err = hw_get_module(HWC_HARDWARE_MODULE_ID, &mModule);
|
||||||
|
LOGW_IF(err, "%s module not found", HWC_HARDWARE_MODULE_ID);
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
|
||||||
|
err = hwc_open(mModule, &mHwc);
|
||||||
|
LOGE_IF(err, "%s device failed to initialize (%s)",
|
||||||
|
HWC_HARDWARE_COMPOSER, strerror(-err));
|
||||||
|
if (err) {
|
||||||
|
mHwc = NULL;
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mHwc->registerProcs) {
|
||||||
|
mCBContext.hwc = this;
|
||||||
|
mHwc->registerProcs(mHwc, &mCBContext.procs);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
status_t HWComposer::swapBuffers(hwc_display_t dpy, hwc_surface_t surf) const {
|
||||||
|
mHwc->prepare(mHwc, NULL);
|
||||||
|
int err = mHwc->set(mHwc, dpy, surf, 0);
|
||||||
|
return (status_t)err;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
}; // namespace android
|
58
widget/gonk/HWComposer.h
Normal file
58
widget/gonk/HWComposer.h
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2010 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* 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 ANDROID_SF_HWCOMPOSER_H
|
||||||
|
#define ANDROID_SF_HWCOMPOSER_H
|
||||||
|
|
||||||
|
#include <hardware/hwcomposer.h>
|
||||||
|
#include <utils/Vector.h>
|
||||||
|
|
||||||
|
namespace android {
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class String8;
|
||||||
|
|
||||||
|
class HWComposer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
HWComposer();
|
||||||
|
~HWComposer();
|
||||||
|
|
||||||
|
int init();
|
||||||
|
|
||||||
|
// swap buffers using vendor specific implementation
|
||||||
|
status_t swapBuffers(hwc_display_t dpy, hwc_surface_t surf) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
struct cb_context {
|
||||||
|
hwc_procs_t procs;
|
||||||
|
HWComposer* hwc;
|
||||||
|
};
|
||||||
|
void invalidate();
|
||||||
|
|
||||||
|
hw_module_t const* mModule;
|
||||||
|
hwc_composer_device_t* mHwc;
|
||||||
|
hwc_display_t mDpy;
|
||||||
|
hwc_surface_t mSur;
|
||||||
|
cb_context mCBContext;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
}; // namespace android
|
||||||
|
|
||||||
|
#endif // ANDROID_SF_HWCOMPOSER_H
|
@ -34,6 +34,7 @@ LIBXUL_LIBRARY = 1
|
|||||||
|
|
||||||
CPPSRCS = \
|
CPPSRCS = \
|
||||||
Framebuffer.cpp \
|
Framebuffer.cpp \
|
||||||
|
HWComposer.cpp \
|
||||||
nsAppShell.cpp \
|
nsAppShell.cpp \
|
||||||
nsWidgetFactory.cpp \
|
nsWidgetFactory.cpp \
|
||||||
nsWindow.cpp \
|
nsWindow.cpp \
|
||||||
|
Loading…
Reference in New Issue
Block a user