Bug 1143575. Avoid including Android's GraphicBuffer.h from LayersTypes.h. r=nical
On some Android versions, GraphicBuffer.h ends up including libui's
hardware.h, which #defines the symbols version_minor and version_major, which
are used as field names in Ogg Theora's th_info struct. Later patches will
require some files to include both Theora headers and LayerTypes.h.
new file mode 100644
--- /dev/null
+++ b/gfx/layers/LayersTypes.cpp
@@ -0,0 +1,58 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "LayersTypes.h"
+
+#ifdef MOZ_WIDGET_GONK
+#include <ui/GraphicBuffer.h>
+#endif
+
+namespace mozilla {
+namespace layers {
+
+LayerRenderState::LayerRenderState()
+ : mFlags(LayerRenderStateFlags::LAYER_RENDER_STATE_DEFAULT)
+ , mHasOwnOffset(false)
+#ifdef MOZ_WIDGET_GONK
+ , mSurface(nullptr)
+ , mOverlayId(INVALID_OVERLAY)
+ , mTexture(nullptr)
+#endif
+{
+}
+
+LayerRenderState::LayerRenderState(const LayerRenderState& aOther)
+ : mFlags(aOther.mFlags)
+ , mHasOwnOffset(aOther.mHasOwnOffset)
+ , mOffset(aOther.mOffset)
+#ifdef MOZ_WIDGET_GONK
+ , mSurface(aOther.mSurface)
+ , mOverlayId(aOther.mOverlayId)
+ , mSize(aOther.mSize)
+ , mTexture(aOther.mTexture)
+#endif
+{
+}
+
+LayerRenderState::~LayerRenderState()
+{
+}
+
+#ifdef MOZ_WIDGET_GONK
+LayerRenderState::LayerRenderState(android::GraphicBuffer* aSurface,
+ const gfx::IntSize& aSize,
+ LayerRenderStateFlags aFlags,
+ TextureHost* aTexture)
+ : mFlags(aFlags)
+ , mHasOwnOffset(false)
+ , mSurface(aSurface)
+ , mOverlayId(INVALID_OVERLAY)
+ , mSize(aSize)
+ , mTexture(aTexture)
+{}
+#endif
+
+} // namespace
+} // namespace
--- a/gfx/layers/LayersTypes.h
+++ b/gfx/layers/LayersTypes.h
@@ -8,32 +8,32 @@
#include <stdint.h> // for uint32_t
#include "mozilla/gfx/Point.h" // for IntPoint
#include "nsRegion.h"
#include "mozilla/TypedEnumBits.h"
#ifdef MOZ_WIDGET_GONK
-#include <ui/GraphicBuffer.h>
+#include <utils/RefBase.h>
#endif
#include <stdio.h> // FILE
#include "mozilla/Logging.h" // for PR_LOG
#ifndef MOZ_LAYERS_HAVE_LOG
# define MOZ_LAYERS_HAVE_LOG
#endif
#define MOZ_LAYERS_LOG(_args) \
MOZ_LOG(LayerManager::GetLog(), LogLevel::Debug, _args)
#define MOZ_LAYERS_LOG_IF_SHADOWABLE(layer, _args) \
do { if (layer->AsShadowableLayer()) { MOZ_LOG(LayerManager::GetLog(), LogLevel::Debug, _args); } } while (0)
#define INVALID_OVERLAY -1
namespace android {
-class GraphicBuffer;
+class MOZ_EXPORT GraphicBuffer;
}
namespace mozilla {
namespace layers {
class TextureHost;
#undef NONE
@@ -80,38 +80,29 @@ enum class LayerRenderStateFlags : int8_
// of surfaces over time (e.g. video frames).
OPAQUE = 1 << 3
};
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(LayerRenderStateFlags)
// The 'ifdef MOZ_WIDGET_GONK' sadness here is because we don't want to include
// android::sp unless we have to.
struct LayerRenderState {
- LayerRenderState()
-#ifdef MOZ_WIDGET_GONK
- : mFlags(LayerRenderStateFlags::LAYER_RENDER_STATE_DEFAULT)
- , mHasOwnOffset(false)
- , mSurface(nullptr)
- , mOverlayId(INVALID_OVERLAY)
- , mTexture(nullptr)
-#endif
- {}
+ // Constructors and destructor are defined in LayersTypes.cpp so we don't
+ // have to pull in a definition for GraphicBuffer.h here. In KK at least,
+ // that results in nasty pollution such as libui's hardware.h #defining
+ // 'version_major' and 'version_minor' which conflict with Theora's codec.c...
+ LayerRenderState();
+ LayerRenderState(const LayerRenderState& aOther);
+ ~LayerRenderState();
#ifdef MOZ_WIDGET_GONK
LayerRenderState(android::GraphicBuffer* aSurface,
const gfx::IntSize& aSize,
LayerRenderStateFlags aFlags,
- TextureHost* aTexture)
- : mFlags(aFlags)
- , mHasOwnOffset(false)
- , mSurface(aSurface)
- , mOverlayId(INVALID_OVERLAY)
- , mSize(aSize)
- , mTexture(aTexture)
- {}
+ TextureHost* aTexture);
bool OriginBottomLeft() const
{ return bool(mFlags & LayerRenderStateFlags::ORIGIN_BOTTOM_LEFT); }
bool BufferRotated() const
{ return bool(mFlags & LayerRenderStateFlags::BUFFER_ROTATION); }
bool FormatRBSwapped() const
@@ -128,16 +119,18 @@ struct LayerRenderState {
}
// see LayerRenderStateFlags
LayerRenderStateFlags mFlags;
// true if mOffset is applicable
bool mHasOwnOffset;
// the location of the layer's origin on mSurface
nsIntPoint mOffset;
+ // The 'ifdef MOZ_WIDGET_GONK' sadness here is because we don't want to include
+ // android::sp unless we have to.
#ifdef MOZ_WIDGET_GONK
// surface to render
android::sp<android::GraphicBuffer> mSurface;
int32_t mOverlayId;
// size of mSurface
gfx::IntSize mSize;
TextureHost* mTexture;
#endif
--- a/gfx/layers/moz.build
+++ b/gfx/layers/moz.build
@@ -311,16 +311,17 @@ UNIFIED_SOURCES += [
'ipc/ShadowLayers.cpp',
'ipc/SharedBufferManagerChild.cpp',
'ipc/SharedBufferManagerParent.cpp',
'ipc/SharedPlanarYCbCrImage.cpp',
'ipc/SharedRGBImage.cpp',
'LayerScope.cpp',
'LayersLogging.cpp',
'LayerSorter.cpp',
+ 'LayersTypes.cpp',
'opengl/CompositingRenderTargetOGL.cpp',
'opengl/CompositorOGL.cpp',
'opengl/CompositorOGLVR.cpp',
'opengl/GLBlitTextureImageHelper.cpp',
'opengl/OGLShaderProgram.cpp',
'opengl/TextureClientOGL.cpp',
'opengl/TextureHostOGL.cpp',
'opengl/TexturePoolOGL.cpp',
--- a/widget/gonk/nsScreenManagerGonk.h
+++ b/widget/gonk/nsScreenManagerGonk.h
@@ -21,16 +21,18 @@
#include "cutils/properties.h"
#include "hardware/hwcomposer.h"
#include "libdisplay/GonkDisplay.h"
#include "nsBaseScreen.h"
#include "nsCOMPtr.h"
#include "nsIScreenManager.h"
+#include <android/native_window.h>
+
class nsRunnable;
class nsWindow;
namespace android {
class DisplaySurface;
class IGraphicBufferProducer;
};