--- a/gfx/doc/Silk.md
+++ b/gfx/doc/Silk.md
@@ -43,17 +43,16 @@ Each **CompositorVsyncDispatcher** is no
It is the responsibility of the **CompositorVsyncDispatcher** to notify the **Compositor** that is awaiting vsync notifications.
The **Display** will then notify the associated **RefreshTimerVsyncDispatcher**, which should notify all active **RefreshDrivers** to tick.
All **Display** objects are encapsulated in a **VsyncSource** object.
The **VsyncSource** object lives in **gfxPlatform** and is instantiated only on the parent process when **gfxPlatform** is created.
The **VsyncSource** is destroyed when **gfxPlatform** is destroyed.
There is only one **VsyncSource** object throughout the entire lifetime of Firefox.
Each platform is expected to implement their own **VsyncSource** to manage vsync events.
-On Firefox OS, this is through the **HwcComposer2D**.
On OS X, this is through **CVDisplayLinkRef**.
On Windows, it should be through **DwmGetCompositionTimingInfo**.
#Compositor
When the **CompositorVsyncDispatcher** is notified of the vsync event, the **CompositorVsyncScheduler::Observer** associated with the **CompositorVsyncDispatcher** begins execution.
Since the **CompositorVsyncDispatcher** executes on the *Hardware Vsync Thread* and the **Compositor** composites on the *CompositorThread*, the **CompositorVsyncScheduler::Observer** posts a task to the *CompositorThread*.
The **CompositorBridgeParent** then composites.
The model where the **CompositorVsyncDispatcher** notifies components on the *Hardware Vsync Thread*, and the component schedules the task on the appropriate thread is used everywhere.
--- a/gfx/thebes/gfxAndroidPlatform.cpp
+++ b/gfx/thebes/gfxAndroidPlatform.cpp
@@ -23,17 +23,16 @@
#include "nsServiceManagerUtils.h"
#include "gfxPrefs.h"
#include "cairo.h"
#include "VsyncSource.h"
#ifdef MOZ_WIDGET_GONK
#include <cutils/properties.h>
#include "mozilla/layers/CompositorBridgeParent.h"
-#include "HwcComposer2D.h"
#endif
#include "ft2build.h"
#include FT_FREETYPE_H
#include FT_MODULE_H
using namespace mozilla;
using namespace mozilla::dom;
@@ -389,26 +388,24 @@ public:
}
virtual void EnableVsync() override
{
MOZ_ASSERT(NS_IsMainThread());
if (IsVsyncEnabled()) {
return;
}
- mVsyncEnabled = HwcComposer2D::GetInstance()->EnableVsync(true);
}
virtual void DisableVsync() override
{
MOZ_ASSERT(NS_IsMainThread());
if (!IsVsyncEnabled()) {
return;
}
- mVsyncEnabled = HwcComposer2D::GetInstance()->EnableVsync(false);
}
virtual bool IsVsyncEnabled() override
{
MOZ_ASSERT(NS_IsMainThread());
return mVsyncEnabled;
}
private:
deleted file mode 100644
--- a/widget/gonk/HwcComposer2D.cpp
+++ /dev/null
@@ -1,971 +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) 2012, 2013 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 <android/log.h>
-#include <string.h>
-
-#include "gfxPrefs.h"
-#include "ImageLayers.h"
-#include "libdisplay/GonkDisplay.h"
-#include "HwcComposer2D.h"
-#include "LayerScope.h"
-#include "Units.h"
-#include "mozilla/ClearOnShutdown.h"
-#include "mozilla/layers/CompositorBridgeParent.h"
-#include "mozilla/layers/LayerManagerComposite.h"
-#include "mozilla/layers/PLayerTransaction.h"
-#include "mozilla/layers/ShadowLayerUtilsGralloc.h"
-#include "mozilla/layers/TextureHostOGL.h" // for TextureHostOGL
-#include "mozilla/StaticPtr.h"
-#include "nsThreadUtils.h"
-#include "cutils/properties.h"
-#include "gfx2DGlue.h"
-#include "gfxPlatform.h"
-#include "VsyncSource.h"
-#include "nsScreenManagerGonk.h"
-#include "nsWindow.h"
-
-#if ANDROID_VERSION >= 17
-#include "libdisplay/DisplaySurface.h"
-#endif
-
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-#define LOG_TAG "HWComposer"
-
-/*
- * By default the debug message of hwcomposer (LOG_DEBUG level) are undefined,
- * but can be enabled by uncommenting HWC_DEBUG below.
- */
-//#define HWC_DEBUG
-
-#ifdef HWC_DEBUG
-#define LOGD(args...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, ## args)
-#else
-#define LOGD(args...) ((void)0)
-#endif
-
-#define LOGI(args...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, ## args)
-#define LOGE(args...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, ## args)
-
-#define LAYER_COUNT_INCREMENTS 5
-
-using namespace android;
-using namespace mozilla::gfx;
-using namespace mozilla::layers;
-
-namespace mozilla {
-
-static void
-HookInvalidate(const struct hwc_procs* aProcs)
-{
- HwcComposer2D::GetInstance()->Invalidate();
-}
-
-static void
-HookVsync(const struct hwc_procs* aProcs, int aDisplay,
- int64_t aTimestamp)
-{
- HwcComposer2D::GetInstance()->Vsync(aDisplay, aTimestamp);
-}
-
-static void
-HookHotplug(const struct hwc_procs* aProcs, int aDisplay,
- int aConnected)
-{
- HwcComposer2D::GetInstance()->Hotplug(aDisplay, aConnected);
-}
-
-static StaticRefPtr<HwcComposer2D> sInstance;
-
-HwcComposer2D::HwcComposer2D()
- : mList(nullptr)
- , mMaxLayerCount(0)
- , mColorFill(false)
- , mRBSwapSupport(false)
- , mPrepared(false)
- , mHasHWVsync(false)
- , mLock("mozilla.HwcComposer2D.mLock")
-{
- mHal = HwcHALBase::CreateHwcHAL();
- if (!mHal->HasHwc()) {
- LOGD("no hwc support");
- return;
- }
-
- RegisterHwcEventCallback();
-
- nsIntSize screenSize;
-
- GonkDisplay::NativeData data = GetGonkDisplay()->GetNativeData(GonkDisplay::DISPLAY_PRIMARY);
- ANativeWindow *win = data.mNativeWindow.get();
- win->query(win, NATIVE_WINDOW_WIDTH, &screenSize.width);
- win->query(win, NATIVE_WINDOW_HEIGHT, &screenSize.height);
- mScreenRect = gfx::IntRect(gfx::IntPoint(0, 0), screenSize);
-
- mColorFill = mHal->Query(HwcHALBase::QueryType::COLOR_FILL);
- mRBSwapSupport = mHal->Query(HwcHALBase::QueryType::RB_SWAP);
-}
-
-HwcComposer2D::~HwcComposer2D()
-{
- free(mList);
-}
-
-HwcComposer2D*
-HwcComposer2D::GetInstance()
-{
- if (!sInstance) {
-#ifdef HWC_DEBUG
- // Make sure only create once
- static int timesCreated = 0;
- ++timesCreated;
- MOZ_ASSERT(timesCreated == 1);
-#endif
- LOGI("Creating new instance");
- sInstance = new HwcComposer2D();
-
- // If anyone uses the compositor thread to create HwcComposer2D,
- // we just skip this function.
- // If ClearOnShutdown() can handle objects in other threads
- // in the future, we can remove this check.
- if (NS_IsMainThread()) {
- // If we create HwcComposer2D by the main thread, we can use
- // ClearOnShutdown() to make sure it will be nullified properly.
- ClearOnShutdown(&sInstance);
- }
- }
- return sInstance;
-}
-
-bool
-HwcComposer2D::EnableVsync(bool aEnable)
-{
- MOZ_ASSERT(NS_IsMainThread());
- if (!mHasHWVsync) {
- return false;
- }
- return mHal->EnableVsync(aEnable) && aEnable;
-}
-
-bool
-HwcComposer2D::RegisterHwcEventCallback()
-{
- const HwcHALProcs_t cHWCProcs = {
- &HookInvalidate, // 1st: void (*invalidate)(...)
- &HookVsync, // 2nd: void (*vsync)(...)
- &HookHotplug // 3rd: void (*hotplug)(...)
- };
- mHasHWVsync = mHal->RegisterHwcEventCallback(cHWCProcs);
- return mHasHWVsync;
-}
-
-void
-HwcComposer2D::Vsync(int aDisplay, nsecs_t aVsyncTimestamp)
-{
- // Only support hardware vsync on kitkat, L and up due to inaccurate timings
- // with JellyBean.
-#if (ANDROID_VERSION == 19 || ANDROID_VERSION >= 21)
- TimeStamp vsyncTime = mozilla::TimeStamp::FromSystemTime(aVsyncTimestamp);
- gfxPlatform::GetPlatform()->GetHardwareVsync()->GetGlobalDisplay().NotifyVsync(vsyncTime);
-#else
- // If this device doesn't support vsync, this function should not be used.
- MOZ_ASSERT(false);
-#endif
-}
-
-// Called on the "invalidator" thread (run from HAL).
-void
-HwcComposer2D::Invalidate()
-{
- if (!mHal->HasHwc()) {
- LOGE("HwcComposer2D::Invalidate failed!");
- return;
- }
-
- MutexAutoLock lock(mLock);
- if (mCompositorBridgeParent) {
- mCompositorBridgeParent->ScheduleRenderOnCompositorThread();
- }
-}
-
-namespace {
-class HotplugEvent : public Runnable {
-public:
- HotplugEvent(GonkDisplay::DisplayType aType, bool aConnected)
- : mType(aType)
- , mConnected(aConnected)
- {
- }
-
- NS_IMETHOD Run()
- {
- RefPtr<nsScreenManagerGonk> screenManager =
- nsScreenManagerGonk::GetInstance();
- if (mConnected) {
- screenManager->AddScreen(mType);
- } else {
- screenManager->RemoveScreen(mType);
- }
- return NS_OK;
- }
-private:
- GonkDisplay::DisplayType mType;
- bool mConnected;
-};
-} // namespace
-
-void
-HwcComposer2D::Hotplug(int aDisplay, int aConnected)
-{
- NS_DispatchToMainThread(new HotplugEvent(GonkDisplay::DISPLAY_EXTERNAL,
- aConnected));
-}
-
-void
-HwcComposer2D::SetCompositorBridgeParent(CompositorBridgeParent* aCompositorBridgeParent)
-{
- MutexAutoLock lock(mLock);
- mCompositorBridgeParent = aCompositorBridgeParent;
-}
-
-bool
-HwcComposer2D::ReallocLayerList()
-{
- int size = sizeof(HwcList) +
- ((mMaxLayerCount + LAYER_COUNT_INCREMENTS) * sizeof(HwcLayer));
-
- HwcList* listrealloc = (HwcList*)realloc(mList, size);
-
- if (!listrealloc) {
- return false;
- }
-
- if (!mList) {
- //first alloc, initialize
- listrealloc->numHwLayers = 0;
- listrealloc->flags = 0;
- }
-
- mList = listrealloc;
- mMaxLayerCount += LAYER_COUNT_INCREMENTS;
- return true;
-}
-
-bool
-HwcComposer2D::PrepareLayerList(Layer* aLayer,
- const nsIntRect& aClip,
- const Matrix& aParentTransform,
- bool aFindSidebandStreams)
-{
- // NB: we fall off this path whenever there are container layers
- // that require intermediate surfaces. That means all the
- // GetEffective*() coordinates are relative to the framebuffer.
-
- bool fillColor = false;
-
- const nsIntRegion visibleRegion = aLayer->GetLocalVisibleRegion().ToUnknownRegion();
- if (visibleRegion.IsEmpty()) {
- return true;
- }
-
- uint8_t opacity = std::min(0xFF, (int)(aLayer->GetEffectiveOpacity() * 256.0));
- if (opacity == 0) {
- LOGD("%s Layer has zero opacity; skipping", aLayer->Name());
- return true;
- }
-
- if (!mHal->SupportTransparency() && opacity < 0xFF && !aFindSidebandStreams) {
- LOGD("%s Layer has planar semitransparency which is unsupported by hwcomposer", aLayer->Name());
- return false;
- }
-
- if (aLayer->GetMaskLayer() && !aFindSidebandStreams) {
- LOGD("%s Layer has MaskLayer which is unsupported by hwcomposer", aLayer->Name());
- return false;
- }
-
- nsIntRect clip;
- nsIntRect layerClip = aLayer->GetLocalClipRect().valueOr(ParentLayerIntRect()).ToUnknownRect();
- nsIntRect* layerClipPtr = aLayer->GetLocalClipRect() ? &layerClip : nullptr;
- if (!HwcUtils::CalculateClipRect(aParentTransform,
- layerClipPtr,
- aClip,
- &clip))
- {
- LOGD("%s Clip rect is empty. Skip layer", aLayer->Name());
- return true;
- }
-
- // HWC supports only the following 2D transformations:
- //
- // Scaling via the sourceCrop and displayFrame in HwcLayer
- // Translation via the sourceCrop and displayFrame in HwcLayer
- // Rotation (in square angles only) via the HWC_TRANSFORM_ROT_* flags
- // Reflection (horizontal and vertical) via the HWC_TRANSFORM_FLIP_* flags
- //
- // A 2D transform with PreservesAxisAlignedRectangles() has all the attributes
- // above
- Matrix layerTransform;
- if (!aLayer->GetEffectiveTransform().Is2D(&layerTransform) ||
- !layerTransform.PreservesAxisAlignedRectangles()) {
- LOGD("Layer EffectiveTransform has a 3D transform or a non-square angle rotation");
- return false;
- }
-
- Matrix layerBufferTransform;
- if (!aLayer->GetEffectiveTransformForBuffer().Is2D(&layerBufferTransform) ||
- !layerBufferTransform.PreservesAxisAlignedRectangles()) {
- LOGD("Layer EffectiveTransformForBuffer has a 3D transform or a non-square angle rotation");
- return false;
- }
-
- if (ContainerLayer* container = aLayer->AsContainerLayer()) {
- if (container->UseIntermediateSurface() && !aFindSidebandStreams) {
- LOGD("Container layer needs intermediate surface");
- return false;
- }
- AutoTArray<Layer*, 12> children;
- container->SortChildrenBy3DZOrder(children);
-
- for (uint32_t i = 0; i < children.Length(); i++) {
- if (!PrepareLayerList(children[i], clip, layerTransform, aFindSidebandStreams) &&
- !aFindSidebandStreams) {
- return false;
- }
- }
- return true;
- }
-
- LayerRenderState state = aLayer->GetRenderState();
-
-#if ANDROID_VERSION >= 21
- if (!state.GetGrallocBuffer() && !state.GetSidebandStream().IsValid()) {
-#else
- if (!state.GetGrallocBuffer()) {
-#endif
- if (aLayer->AsColorLayer() && mColorFill) {
- fillColor = true;
- } else {
- LOGD("%s Layer doesn't have a gralloc buffer", aLayer->Name());
- return false;
- }
- }
-
- nsIntRect visibleRect = visibleRegion.GetBounds();
-
- nsIntRect bufferRect;
- if (fillColor) {
- bufferRect = nsIntRect(visibleRect);
- } else {
- nsIntRect layerRect;
- if (state.mHasOwnOffset) {
- bufferRect = nsIntRect(state.mOffset.x, state.mOffset.y,
- state.mSize.width, state.mSize.height);
- layerRect = bufferRect;
- } else {
- //Since the buffer doesn't have its own offset, assign the whole
- //surface size as its buffer bounds
- bufferRect = nsIntRect(0, 0, state.mSize.width, state.mSize.height);
- layerRect = bufferRect;
- if (aLayer->GetType() == Layer::TYPE_IMAGE) {
- ImageLayer* imageLayer = static_cast<ImageLayer*>(aLayer);
- if(imageLayer->GetScaleMode() != ScaleMode::SCALE_NONE) {
- layerRect = nsIntRect(0, 0, imageLayer->GetScaleToSize().width, imageLayer->GetScaleToSize().height);
- }
- }
- }
- // In some cases the visible rect assigned to the layer can be larger
- // than the layer's surface, e.g., an ImageLayer with a small Image
- // in it.
- visibleRect.IntersectRect(visibleRect, layerRect);
- }
-
- // Buffer rotation is not to be confused with the angled rotation done by a transform matrix
- // It's a fancy PaintedLayer feature used for scrolling
- if (state.BufferRotated()) {
- LOGD("%s Layer has a rotated buffer", aLayer->Name());
- return false;
- }
-
- const bool needsYFlip = state.OriginBottomLeft() ? true
- : false;
-
- hwc_rect_t sourceCrop, displayFrame;
- if(!HwcUtils::PrepareLayerRects(visibleRect,
- layerTransform,
- layerBufferTransform,
- clip,
- bufferRect,
- needsYFlip,
- &(sourceCrop),
- &(displayFrame)))
- {
- return true;
- }
-
- // OK! We can compose this layer with hwc.
- int current = mList ? mList->numHwLayers : 0;
-
- // Do not compose any layer below full-screen Opaque layer
- // Note: It can be generalized to non-fullscreen Opaque layers.
- bool isOpaque = opacity == 0xFF &&
- (state.mFlags & LayerRenderStateFlags::OPAQUE);
- // Currently we perform opacity calculation using the *bounds* of the layer.
- // We can only make this assumption if we're not dealing with a complex visible region.
- bool isSimpleVisibleRegion = visibleRegion.Contains(visibleRect);
- if (current && isOpaque && isSimpleVisibleRegion) {
- nsIntRect displayRect = nsIntRect(displayFrame.left, displayFrame.top,
- displayFrame.right - displayFrame.left, displayFrame.bottom - displayFrame.top);
- if (displayRect.Contains(mScreenRect)) {
- // In z-order, all previous layers are below
- // the current layer. We can ignore them now.
- mList->numHwLayers = current = 0;
- mHwcLayerMap.Clear();
- }
- }
-
- if (!mList || current >= mMaxLayerCount) {
- if (!ReallocLayerList() || current >= mMaxLayerCount) {
- LOGE("PrepareLayerList failed! Could not increase the maximum layer count");
- return false;
- }
- }
-
- HwcLayer& hwcLayer = mList->hwLayers[current];
- hwcLayer.displayFrame = displayFrame;
- mHal->SetCrop(hwcLayer, sourceCrop);
- buffer_handle_t handle = nullptr;
-#if ANDROID_VERSION >= 21
- if (state.GetSidebandStream().IsValid()) {
- handle = state.GetSidebandStream().GetRawNativeHandle();
- } else if (state.GetGrallocBuffer()) {
- handle = state.GetGrallocBuffer()->getNativeBuffer()->handle;
- }
-#else
- if (state.GetGrallocBuffer()) {
- handle = state.GetGrallocBuffer()->getNativeBuffer()->handle;
- }
-#endif
- hwcLayer.handle = handle;
-
- hwcLayer.flags = 0;
- hwcLayer.hints = 0;
- hwcLayer.blending = isOpaque ? HWC_BLENDING_NONE : HWC_BLENDING_PREMULT;
-#if ANDROID_VERSION >= 17
- hwcLayer.compositionType = HWC_FRAMEBUFFER;
-#if ANDROID_VERSION >= 21
- if (state.GetSidebandStream().IsValid()) {
- hwcLayer.compositionType = HWC_SIDEBAND;
- }
-#endif
- hwcLayer.acquireFenceFd = -1;
- hwcLayer.releaseFenceFd = -1;
-#if ANDROID_VERSION >= 18
- hwcLayer.planeAlpha = opacity;
-#endif
-#else
- hwcLayer.compositionType = HwcUtils::HWC_USE_COPYBIT;
-#endif
-
- if (!fillColor) {
- if (state.FormatRBSwapped()) {
- if (!mRBSwapSupport) {
- LOGD("No R/B swap support in H/W Composer");
- return false;
- }
- hwcLayer.flags |= HwcUtils::HWC_FORMAT_RB_SWAP;
- }
-
- // Translation and scaling have been addressed in PrepareLayerRects().
- // Given the above and that we checked for PreservesAxisAlignedRectangles()
- // the only possible transformations left to address are
- // square angle rotation and horizontal/vertical reflection.
- //
- // The rotation and reflection permutations total 16 but can be
- // reduced to 8 transformations after eliminating redundancies.
- //
- // All matrices represented here are in the form
- //
- // | xx xy |
- // | yx yy |
- //
- // And ignore scaling.
- //
- // Reflection is applied before rotation
- gfx::Matrix rotation = layerTransform;
- // Compute fuzzy zero like PreservesAxisAlignedRectangles()
- if (fabs(rotation._11) < 1e-6) {
- if (rotation._21 < 0) {
- if (rotation._12 > 0) {
- // 90 degree rotation
- //
- // | 0 -1 |
- // | 1 0 |
- //
- hwcLayer.transform = HWC_TRANSFORM_ROT_90;
- LOGD("Layer rotated 90 degrees");
- }
- else {
- // Horizontal reflection then 90 degree rotation
- //
- // | 0 -1 | | -1 0 | = | 0 -1 |
- // | 1 0 | | 0 1 | | -1 0 |
- //
- // same as vertical reflection then 270 degree rotation
- //
- // | 0 1 | | 1 0 | = | 0 -1 |
- // | -1 0 | | 0 -1 | | -1 0 |
- //
- hwcLayer.transform = HWC_TRANSFORM_ROT_90 | HWC_TRANSFORM_FLIP_H;
- LOGD("Layer vertically reflected then rotated 270 degrees");
- }
- } else {
- if (rotation._12 < 0) {
- // 270 degree rotation
- //
- // | 0 1 |
- // | -1 0 |
- //
- hwcLayer.transform = HWC_TRANSFORM_ROT_270;
- LOGD("Layer rotated 270 degrees");
- }
- else {
- // Vertical reflection then 90 degree rotation
- //
- // | 0 1 | | -1 0 | = | 0 1 |
- // | -1 0 | | 0 1 | | 1 0 |
- //
- // Same as horizontal reflection then 270 degree rotation
- //
- // | 0 -1 | | 1 0 | = | 0 1 |
- // | 1 0 | | 0 -1 | | 1 0 |
- //
- hwcLayer.transform = HWC_TRANSFORM_ROT_90 | HWC_TRANSFORM_FLIP_V;
- LOGD("Layer horizontally reflected then rotated 270 degrees");
- }
- }
- } else if (rotation._11 < 0) {
- if (rotation._22 > 0) {
- // Horizontal reflection
- //
- // | -1 0 |
- // | 0 1 |
- //
- hwcLayer.transform = HWC_TRANSFORM_FLIP_H;
- LOGD("Layer rotated 180 degrees");
- }
- else {
- // 180 degree rotation
- //
- // | -1 0 |
- // | 0 -1 |
- //
- // Same as horizontal and vertical reflection
- //
- // | -1 0 | | 1 0 | = | -1 0 |
- // | 0 1 | | 0 -1 | | 0 -1 |
- //
- hwcLayer.transform = HWC_TRANSFORM_ROT_180;
- LOGD("Layer rotated 180 degrees");
- }
- } else {
- if (rotation._22 < 0) {
- // Vertical reflection
- //
- // | 1 0 |
- // | 0 -1 |
- //
- hwcLayer.transform = HWC_TRANSFORM_FLIP_V;
- LOGD("Layer rotated 180 degrees");
- }
- else {
- // No rotation or reflection
- //
- // | 1 0 |
- // | 0 1 |
- //
- hwcLayer.transform = 0;
- }
- }
-
- const bool needsYFlip = state.OriginBottomLeft() ? true
- : false;
-
- if (needsYFlip) {
- // Invert vertical reflection flag if it was already set
- hwcLayer.transform ^= HWC_TRANSFORM_FLIP_V;
- }
- hwc_region_t region;
- if (visibleRegion.GetNumRects() > 1) {
- mVisibleRegions.push_back(HwcUtils::RectVector());
- HwcUtils::RectVector* visibleRects = &(mVisibleRegions.back());
- bool isVisible = false;
- if(!HwcUtils::PrepareVisibleRegion(visibleRegion,
- layerTransform,
- layerBufferTransform,
- clip,
- bufferRect,
- visibleRects,
- isVisible)) {
- LOGD("A region of layer is too small to be rendered by HWC");
- return false;
- }
- if (!isVisible) {
- // Layer is not visible, no need to render it
- return true;
- }
- region.numRects = visibleRects->size();
- region.rects = &((*visibleRects)[0]);
- } else {
- region.numRects = 1;
- region.rects = &(hwcLayer.displayFrame);
- }
- hwcLayer.visibleRegionScreen = region;
- } else {
- hwcLayer.flags |= HwcUtils::HWC_COLOR_FILL;
- ColorLayer* colorLayer = aLayer->AsColorLayer();
- if (colorLayer->GetColor().a < 1.0) {
- LOGD("Color layer has semitransparency which is unsupported");
- return false;
- }
- hwcLayer.transform = colorLayer->GetColor().ToABGR();
- }
-
-#if ANDROID_VERSION >= 21
- if (aFindSidebandStreams && hwcLayer.compositionType == HWC_SIDEBAND) {
- mCachedSidebandLayers.AppendElement(hwcLayer);
- }
-#endif
-
- mHwcLayerMap.AppendElement(static_cast<LayerComposite*>(aLayer->ImplData()));
- mList->numHwLayers++;
- return true;
-}
-
-
-#if ANDROID_VERSION >= 17
-bool
-HwcComposer2D::TryHwComposition(nsScreenGonk* aScreen)
-{
- DisplaySurface* dispSurface = aScreen->GetDisplaySurface();
-
- if (!(dispSurface && dispSurface->lastHandle)) {
- LOGD("H/W Composition failed. DispSurface not initialized.");
- return false;
- }
-
- // Add FB layer
- int idx = mList->numHwLayers++;
- if (idx >= mMaxLayerCount) {
- if (!ReallocLayerList() || idx >= mMaxLayerCount) {
- LOGE("TryHwComposition failed! Could not add FB layer");
- return false;
- }
- }
-
- Prepare(dispSurface->lastHandle, -1, aScreen);
-
- /* Possible composition paths, after hwc prepare:
- 1. GPU Composition
- 2. BLIT Composition
- 3. Full OVERLAY Composition
- 4. Partial OVERLAY Composition (GPU + OVERLAY) */
-
- bool gpuComposite = false;
- bool blitComposite = false;
- bool overlayComposite = true;
-
- for (int j=0; j < idx; j++) {
- if (mList->hwLayers[j].compositionType == HWC_FRAMEBUFFER ||
- mList->hwLayers[j].compositionType == HWC_BLIT) {
- // Full OVERLAY composition is not possible on this frame
- // It is either GPU / BLIT / partial OVERLAY composition.
- overlayComposite = false;
- break;
- }
- }
-
- if (!overlayComposite) {
- for (int k=0; k < idx; k++) {
- switch (mList->hwLayers[k].compositionType) {
- case HWC_FRAMEBUFFER:
- gpuComposite = true;
- break;
- case HWC_BLIT:
- blitComposite = true;
- break;
-#if ANDROID_VERSION >= 21
- case HWC_SIDEBAND:
-#endif
- case HWC_OVERLAY: {
- // HWC will compose HWC_OVERLAY layers in partial
- // Overlay Composition, set layer composition flag
- // on mapped LayerComposite to skip GPU composition
- mHwcLayerMap[k]->SetLayerComposited(true);
-
- uint8_t opacity = std::min(0xFF, (int)(mHwcLayerMap[k]->GetLayer()->GetEffectiveOpacity() * 256.0));
- if ((mList->hwLayers[k].hints & HWC_HINT_CLEAR_FB) &&
- (opacity == 0xFF)) {
- // Clear visible rect on FB with transparent pixels.
- hwc_rect_t r = mList->hwLayers[k].displayFrame;
- mHwcLayerMap[k]->SetClearRect(nsIntRect(r.left, r.top,
- r.right - r.left,
- r.bottom - r.top));
- }
- break;
- }
- default:
- break;
- }
- }
-
- if (gpuComposite) {
- // GPU or partial OVERLAY Composition
- return false;
- } else if (blitComposite) {
- // BLIT Composition, flip DispSurface target
- GetGonkDisplay()->UpdateDispSurface(aScreen->GetEGLDisplay(), aScreen->GetEGLSurface());
- DisplaySurface* dispSurface = aScreen->GetDisplaySurface();
- if (!dispSurface) {
- LOGE("H/W Composition failed. NULL DispSurface.");
- return false;
- }
- mList->hwLayers[idx].handle = dispSurface->lastHandle;
- mList->hwLayers[idx].acquireFenceFd = dispSurface->GetPrevDispAcquireFd();
- }
- }
-
- // BLIT or full OVERLAY Composition
- return Commit(aScreen);
-}
-
-bool
-HwcComposer2D::Render(nsIWidget* aWidget)
-{
- nsScreenGonk* screen = static_cast<nsWindow*>(aWidget)->GetScreen();
-
- // HWC module does not exist or mList is not created yet.
- if (!mHal->HasHwc() || !mList) {
- return GetGonkDisplay()->SwapBuffers(screen->GetEGLDisplay(), screen->GetEGLSurface());
- } else if (!mList && !ReallocLayerList()) {
- LOGE("Cannot realloc layer list");
- return false;
- }
-
- DisplaySurface* dispSurface = screen->GetDisplaySurface();
- if (!dispSurface) {
- LOGE("H/W Composition failed. DispSurface not initialized.");
- return false;
- }
-
- if (mPrepared) {
- // No mHwc prepare, if already prepared in current draw cycle
- mList->hwLayers[mList->numHwLayers - 1].handle = dispSurface->lastHandle;
- mList->hwLayers[mList->numHwLayers - 1].acquireFenceFd = dispSurface->GetPrevDispAcquireFd();
- } else {
- // Update screen rect to handle a case that TryRenderWithHwc() is not called.
- mScreenRect = screen->GetNaturalBounds().ToUnknownRect();
-
- mList->flags = HWC_GEOMETRY_CHANGED;
- mList->numHwLayers = 2;
- mList->hwLayers[0].hints = 0;
- mList->hwLayers[0].compositionType = HWC_FRAMEBUFFER;
- mList->hwLayers[0].flags = HWC_SKIP_LAYER;
- mList->hwLayers[0].backgroundColor = {0};
- mList->hwLayers[0].acquireFenceFd = -1;
- mList->hwLayers[0].releaseFenceFd = -1;
- mList->hwLayers[0].displayFrame = {0, 0, mScreenRect.width, mScreenRect.height};
-
-#if ANDROID_VERSION >= 21
- // Prepare layers for sideband streams
- const uint32_t len = mCachedSidebandLayers.Length();
- for (uint32_t i = 0; i < len; ++i) {
- ++mList->numHwLayers;
- mList->hwLayers[i+1] = mCachedSidebandLayers[i];
- }
-#endif
- Prepare(dispSurface->lastHandle, dispSurface->GetPrevDispAcquireFd(), screen);
- }
-
- // GPU or partial HWC Composition
- return Commit(screen);
-}
-
-void
-HwcComposer2D::Prepare(buffer_handle_t dispHandle, int fence, nsScreenGonk* screen)
-{
- if (mPrepared) {
- LOGE("Multiple hwc prepare calls!");
- }
- hwc_rect_t dispRect = {0, 0, mScreenRect.width, mScreenRect.height};
- mHal->Prepare(mList, screen->GetDisplayType(), dispRect, dispHandle, fence);
- mPrepared = true;
-}
-
-bool
-HwcComposer2D::Commit(nsScreenGonk* aScreen)
-{
- for (uint32_t j=0; j < (mList->numHwLayers - 1); j++) {
- mList->hwLayers[j].acquireFenceFd = -1;
- if (mHwcLayerMap.IsEmpty() ||
- (mList->hwLayers[j].compositionType == HWC_FRAMEBUFFER)) {
- continue;
- }
- LayerRenderState state = mHwcLayerMap[j]->GetLayer()->GetRenderState();
- if (!state.mTexture) {
- continue;
- }
- FenceHandle fence = state.mTexture->GetAndResetAcquireFenceHandle();
- if (fence.IsValid()) {
- RefPtr<FenceHandle::FdObj> fdObj = fence.GetAndResetFdObj();
- mList->hwLayers[j].acquireFenceFd = fdObj->GetAndResetFd();
- }
- }
-
- int err = mHal->Set(mList, aScreen->GetDisplayType());
-
- mPrevRetireFence.TransferToAnotherFenceHandle(mPrevDisplayFence);
-
- for (uint32_t j=0; j < (mList->numHwLayers - 1); j++) {
- if (mList->hwLayers[j].releaseFenceFd >= 0) {
- int fd = mList->hwLayers[j].releaseFenceFd;
- mList->hwLayers[j].releaseFenceFd = -1;
- RefPtr<FenceHandle::FdObj> fdObj = new FenceHandle::FdObj(fd);
- FenceHandle fence(fdObj);
-
- LayerRenderState state = mHwcLayerMap[j]->GetLayer()->GetRenderState();
- if (!state.mTexture) {
- continue;
- }
- state.mTexture->SetReleaseFenceHandle(fence);
- }
- }
-
- if (mList->retireFenceFd >= 0) {
- mPrevRetireFence = FenceHandle(new FenceHandle::FdObj(mList->retireFenceFd));
- }
-
- // Set DisplaySurface layer fence
- DisplaySurface* displaySurface = aScreen->GetDisplaySurface();
- displaySurface->setReleaseFenceFd(mList->hwLayers[mList->numHwLayers - 1].releaseFenceFd);
- mList->hwLayers[mList->numHwLayers - 1].releaseFenceFd = -1;
-
- mPrepared = false;
- return !err;
-}
-#else
-bool
-HwcComposer2D::TryHwComposition(nsScreenGonk* aScreen)
-{
- mHal->SetEGLInfo(aScreen->GetEGLDisplay(), aScreen->GetEGLSurface());
- return !mHal->Set(mList, aScreen->GetDisplayType());
-}
-
-bool
-HwcComposer2D::Render(nsIWidget* aWidget)
-{
- nsScreenGonk* screen = static_cast<nsWindow*>(aWidget)->GetScreen();
- return GetGonkDisplay()->SwapBuffers(screen->GetEGLDisplay(), screen->GetEGLSurface());
-}
-#endif
-
-bool
-HwcComposer2D::TryRenderWithHwc(Layer* aRoot,
- nsIWidget* aWidget,
- bool aGeometryChanged,
- bool aHasImageHostOverlays)
-{
- if (!mHal->HasHwc()) {
- return false;
- }
-
- nsScreenGonk* screen = static_cast<nsWindow*>(aWidget)->GetScreen();
-
- if (mList) {
- mList->flags = mHal->GetGeometryChangedFlag(aGeometryChanged);
- mList->numHwLayers = 0;
- mHwcLayerMap.Clear();
- }
-
- if (mPrepared) {
- mHal->ResetHwc();
- mPrepared = false;
- }
-
- // XXX: The clear() below means all rect vectors will be have to be
- // reallocated. We may want to avoid this if possible
- mVisibleRegions.clear();
-
- mScreenRect = screen->GetNaturalBounds().ToUnknownRect();
- MOZ_ASSERT(mHwcLayerMap.IsEmpty());
- mCachedSidebandLayers.Clear();
- if (!PrepareLayerList(aRoot,
- mScreenRect,
- gfx::Matrix(),
- /* aFindSidebandStreams */ false))
- {
- mHwcLayerMap.Clear();
- LOGD("Render aborted. Fallback to GPU Composition");
- if (aHasImageHostOverlays) {
- LOGD("Prepare layers of SidebandStreams");
- // Failed to create a layer list for hwc. But we need the list
- // only for handling sideband streams. Traverse layer tree without
- // some early returns to make sure we can find all the layers.
- // It is the best wrong thing that we can do.
- PrepareLayerList(aRoot,
- mScreenRect,
- gfx::Matrix(),
- /* aFindSidebandStreams */ true);
- // Reset mPrepared to false, since we already fell back to
- // gpu composition.
- mPrepared = false;
- }
- return false;
- }
-
- // Send data to LayerScope for debugging
- SendtoLayerScope();
-
- if (!TryHwComposition(screen)) {
- LOGD("Full HWC Composition failed. Fallback to GPU Composition or partial OVERLAY Composition");
- LayerScope::CleanLayer();
- return false;
- }
-
- LOGD("Frame rendered");
- return true;
-}
-
-void
-HwcComposer2D::SendtoLayerScope()
-{
- if (!LayerScope::CheckSendable()) {
- return;
- }
-
- const int len = mList->numHwLayers;
- for (int i = 0; i < len; ++i) {
- LayerComposite* layer = mHwcLayerMap[i];
- const hwc_rect_t r = mList->hwLayers[i].displayFrame;
- LayerScope::SendLayer(layer, r.right - r.left, r.bottom - r.top);
- }
-}
-
-} // namespace mozilla
deleted file mode 100644
--- a/widget/gonk/HwcComposer2D.h
+++ /dev/null
@@ -1,123 +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) 2012, 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_HwcComposer2D
-#define mozilla_HwcComposer2D
-
-#include "Composer2D.h"
-#include "hwchal/HwcHALBase.h" // for HwcHAL
-#include "HwcUtils.h" // for RectVector
-#include "Layers.h"
-#include "mozilla/Mutex.h"
-#include "mozilla/layers/FenceUtils.h" // for FenceHandle
-#include "mozilla/UniquePtr.h" // for HwcHAL
-
-#include <vector>
-#include <list>
-
-#include <utils/Timers.h>
-
-class nsScreenGonk;
-
-namespace mozilla {
-
-namespace gl {
- class GLContext;
-}
-
-namespace layers {
-class CompositorBridgeParent;
-class Layer;
-}
-
-/*
- * HwcComposer2D provides a way for gecko to render frames
- * using hwcomposer.h in the AOSP HAL.
- *
- * hwcomposer.h defines an interface for display composition
- * using dedicated hardware. This hardware is usually faster
- * or more power efficient than the GPU. However, in exchange
- * for better performance, generality has to be sacrificed:
- * no 3d transforms, no intermediate surfaces, no special shader effects,
- * and loss of other goodies depending on the platform.
- *
- * In general, when hwc is enabled gecko tries to compose
- * its frames using HwcComposer2D first. Then if HwcComposer2D is
- * unable to compose a frame then it falls back to compose it
- * using the GPU with OpenGL.
- *
- */
-class HwcComposer2D : public mozilla::layers::Composer2D {
-public:
- HwcComposer2D();
- virtual ~HwcComposer2D();
-
- static HwcComposer2D* GetInstance();
-
- // Returns TRUE if the container has been succesfully rendered
- // Returns FALSE if the container cannot be fully rendered
- // by this composer so nothing was rendered at all
- virtual bool TryRenderWithHwc(layers::Layer* aRoot,
- nsIWidget* aWidget,
- bool aGeometryChanged,
- bool aHasImageHostOverlays) override;
-
- virtual bool Render(nsIWidget* aWidget) override;
-
- virtual bool HasHwc() override { return mHal->HasHwc(); }
-
- bool EnableVsync(bool aEnable);
- bool RegisterHwcEventCallback();
- void Vsync(int aDisplay, int64_t aTimestamp);
- void Invalidate();
- void Hotplug(int aDisplay, int aConnected);
- void SetCompositorBridgeParent(layers::CompositorBridgeParent* aCompositorBridgeParent);
-
-private:
- void Reset();
- void Prepare(buffer_handle_t dispHandle, int fence, nsScreenGonk* screen);
- bool Commit(nsScreenGonk* aScreen);
- bool TryHwComposition(nsScreenGonk* aScreen);
- bool ReallocLayerList();
- bool PrepareLayerList(layers::Layer* aContainer, const nsIntRect& aClip,
- const gfx::Matrix& aParentTransform,
- bool aFindSidebandStreams);
- void SendtoLayerScope();
-
- UniquePtr<HwcHALBase> mHal;
- HwcList* mList;
- nsIntRect mScreenRect;
- int mMaxLayerCount;
- bool mColorFill;
- bool mRBSwapSupport;
- //Holds all the dynamically allocated RectVectors needed
- //to render the current frame
- std::list<HwcUtils::RectVector> mVisibleRegions;
- layers::FenceHandle mPrevRetireFence;
- layers::FenceHandle mPrevDisplayFence;
- nsTArray<HwcLayer> mCachedSidebandLayers;
- nsTArray<layers::LayerComposite*> mHwcLayerMap;
- bool mPrepared;
- bool mHasHWVsync;
- layers::CompositorBridgeParent* mCompositorBridgeParent;
- Mutex mLock;
-};
-
-} // namespace mozilla
-
-#endif // mozilla_HwcComposer2D
deleted file mode 100644
--- a/widget/gonk/HwcUtils.cpp
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Copyright (c) 2013 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 <android/log.h>
-#include "HwcUtils.h"
-#include "gfxUtils.h"
-#include "gfx2DGlue.h"
-
-#define LOG_TAG "HwcUtils"
-
-#if (LOG_NDEBUG == 0)
-#define LOGD(args...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, ## args)
-#else
-#define LOGD(args...) ((void)0)
-#endif
-
-#define LOGE(args...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, ## args)
-
-
-namespace mozilla {
-
-/* Utility functions for HwcComposer */
-
-
-
-/* static */ bool
-HwcUtils::PrepareLayerRects(nsIntRect aVisible,
- const gfx::Matrix& aLayerTransform,
- const gfx::Matrix& aLayerBufferTransform,
- nsIntRect aClip, nsIntRect aBufferRect,
- bool aYFlipped,
- hwc_rect_t* aSourceCrop, hwc_rect_t* aVisibleRegionScreen) {
-
- gfxMatrix aTransform = gfx::ThebesMatrix(aLayerTransform);
- gfxRect visibleRect(ThebesRect(aVisible));
- gfxRect clip(ThebesRect(aClip));
- gfxRect visibleRectScreen = aTransform.TransformBounds(visibleRect);
- // |clip| is guaranteed to be integer
- visibleRectScreen.IntersectRect(visibleRectScreen, clip);
-
- if (visibleRectScreen.IsEmpty()) {
- return false;
- }
-
- gfxMatrix inverse = gfx::ThebesMatrix(aLayerBufferTransform);
- inverse.Invert();
- gfxRect crop = inverse.TransformBounds(visibleRectScreen);
-
- //clip to buffer size
- crop.IntersectRect(crop, ThebesRect(aBufferRect));
- crop.Round();
-
- if (crop.IsEmpty()) {
- return false;
- }
-
- //propagate buffer clipping back to visible rect
- gfxMatrix layerBufferTransform = gfx::ThebesMatrix(aLayerBufferTransform);
- visibleRectScreen = layerBufferTransform.TransformBounds(crop);
- visibleRectScreen.Round();
-
- // Map from layer space to buffer space
- crop -= aBufferRect.TopLeft();
- if (aYFlipped) {
- crop.y = aBufferRect.height - (crop.y + crop.height);
- }
-
- aSourceCrop->left = crop.x;
- aSourceCrop->top = crop.y;
- aSourceCrop->right = crop.x + crop.width;
- aSourceCrop->bottom = crop.y + crop.height;
-
- aVisibleRegionScreen->left = visibleRectScreen.x;
- aVisibleRegionScreen->top = visibleRectScreen.y;
- aVisibleRegionScreen->right = visibleRectScreen.x + visibleRectScreen.width;
- aVisibleRegionScreen->bottom = visibleRectScreen.y + visibleRectScreen.height;
-
- return true;
-}
-
-/* static */ bool
-HwcUtils::PrepareVisibleRegion(const nsIntRegion& aVisible,
- const gfx::Matrix& aLayerTransform,
- const gfx::Matrix& aLayerBufferTransform,
- nsIntRect aClip, nsIntRect aBufferRect,
- RectVector* aVisibleRegionScreen,
- bool& aIsVisible) {
- const float MIN_SRC_WIDTH = 2.f;
- const float MIN_SRC_HEIGHT = 2.f;
-
- gfxMatrix layerTransform = gfx::ThebesMatrix(aLayerTransform);
- gfxMatrix layerBufferTransform = gfx::ThebesMatrix(aLayerBufferTransform);
- gfxRect bufferRect =
- layerBufferTransform.TransformBounds(ThebesRect(aBufferRect));
- gfxMatrix inverse = gfx::ThebesMatrix(aLayerBufferTransform);
- inverse.Invert();
- aIsVisible = false;
-
- for (auto iter = aVisible.RectIter(); !iter.Done(); iter.Next()) {
- gfxRect screenRect =
- layerTransform.TransformBounds(ThebesRect(iter.Get()));
- screenRect.IntersectRect(screenRect, bufferRect);
- screenRect.IntersectRect(screenRect, ThebesRect(aClip));
- screenRect.Round();
- if (screenRect.IsEmpty()) {
- continue;
- }
-
- hwc_rect_t visibleRectScreen;
- visibleRectScreen.left = screenRect.x;
- visibleRectScreen.top = screenRect.y;
- visibleRectScreen.right = screenRect.XMost();
- visibleRectScreen.bottom = screenRect.YMost();
-
- gfxRect srcCrop = inverse.TransformBounds(screenRect);
- // When src crop is very small, HWC could not render correctly in some cases.
- // See Bug 1169093
- if(srcCrop.Width() < MIN_SRC_WIDTH || srcCrop.Height() < MIN_SRC_HEIGHT) {
- return false;
- }
-
- aVisibleRegionScreen->push_back(visibleRectScreen);
- aIsVisible = true;
- }
-
- return true;
-}
-
-/* static */ bool
-HwcUtils::CalculateClipRect(const gfx::Matrix& transform,
- const nsIntRect* aLayerClip,
- nsIntRect aParentClip, nsIntRect* aRenderClip) {
-
- gfxMatrix aTransform = gfx::ThebesMatrix(transform);
- *aRenderClip = aParentClip;
-
- if (!aLayerClip) {
- return true;
- }
-
- if (aLayerClip->IsEmpty()) {
- return false;
- }
-
- nsIntRect clip = *aLayerClip;
-
- gfxRect r = ThebesRect(clip);
- gfxRect trClip = aTransform.TransformBounds(r);
- trClip.Round();
- gfxUtils::GfxRectToIntRect(trClip, &clip);
-
- aRenderClip->IntersectRect(*aRenderClip, clip);
- return true;
-}
-
-} // namespace mozilla
deleted file mode 100644
--- a/widget/gonk/HwcUtils.h
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright (c) 2013, 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_HwcUtils
-#define mozilla_HwcUtils
-
-#include "Layers.h"
-#include <vector>
-#include "hardware/hwcomposer.h"
-
-namespace mozilla {
-
-namespace gfx {
-class Matrix;
-}
-
-class HwcUtils {
-public:
-
-enum {
- HWC_USE_GPU = HWC_FRAMEBUFFER,
- HWC_USE_OVERLAY = HWC_OVERLAY,
- HWC_USE_COPYBIT
-};
-
-// HWC layer flags
-enum {
- // Draw a solid color rectangle
- // The color should be set on the transform member of the hwc_layer_t struct
- // The expected format is a 32 bit ABGR with 8 bits per component
- HWC_COLOR_FILL = 0x8,
- // Swap the RB pixels of gralloc buffer, like RGBA<->BGRA or RGBX<->BGRX
- // The flag will be set inside LayerRenderState
- HWC_FORMAT_RB_SWAP = 0x40
-};
-
-typedef std::vector<hwc_rect_t> RectVector;
-
-/* Utility functions - implemented in HwcUtils.cpp */
-
-/**
- * Calculates the layer's clipping rectangle
- *
- * @param aTransform Input. A transformation matrix
- * It transforms the clip rect to screen space
- * @param aLayerClip Input. The layer's internal clipping rectangle.
- * This may be NULL which means the layer has no internal clipping
- * The origin is the top-left corner of the layer
- * @param aParentClip Input. The parent layer's rendering clipping rectangle
- * The origin is the top-left corner of the screen
- * @param aRenderClip Output. The layer's rendering clipping rectangle
- * The origin is the top-left corner of the screen
- * @return true if the layer should be rendered.
- * false if the layer can be skipped
- */
-static bool CalculateClipRect(const gfx::Matrix& aTransform,
- const nsIntRect* aLayerClip,
- nsIntRect aParentClip, nsIntRect* aRenderClip);
-
-
-/**
- * Prepares hwc layer visible region required for hwc composition
- *
- * @param aVisible Input. Layer's unclipped visible region
- * The origin is the top-left corner of the layer
- * @param aLayerTransform Input. Layer's transformation matrix
- * It transforms from layer space to screen space
- * @param aLayerBufferTransform Input. Layer buffer's transformation matrix
- * It transforms from layer buffer's space to screen space
- * @param aClip Input. A clipping rectangle.
- * The origin is the top-left corner of the screen
- * @param aBufferRect Input. The layer's buffer bounds
- * The origin is the top-left corner of the layer
- * @param aVisibleRegionScreen Output. Visible region in screen space.
- * The origin is the top-left corner of the screen
- * @param aIsVisible Output. true if region is visible
- * false if region is not visible
- * @return true if region can be rendered by HWC.
- * false if region should not be rendered by HWC
- */
-static bool PrepareVisibleRegion(const nsIntRegion& aVisible,
- const gfx::Matrix& aLayerTransform,
- const gfx::Matrix& aLayerBufferTransform,
- nsIntRect aClip, nsIntRect aBufferRect,
- RectVector* aVisibleRegionScreen,
- bool& aIsVisible);
-
-
-/**
- * Sets hwc layer rectangles required for hwc composition
- *
- * @param aVisible Input. Layer's unclipped visible rectangle
- * The origin is the top-left corner of the layer
- * @param aLayerTransform Input. Layer's transformation matrix
- * It transforms from layer space to screen space
- * @param aLayerBufferTransform Input. Layer buffer's transformation matrix
- * It transforms from layer buffer's space to screen space
- * @param aClip Input. A clipping rectangle.
- * The origin is the top-left corner of the screen
- * @param aBufferRect Input. The layer's buffer bounds
- * The origin is the top-left corner of the layer
- * @param aYFlipped Input. true if the buffer is rendered as Y flipped
- * @param aSurceCrop Output. Area of the source to consider,
- * the origin is the top-left corner of the buffer
- * @param aVisibleRegionScreen Output. Visible region in screen space.
- * The origin is the top-left corner of the screen
- * @return true if the layer should be rendered.
- * false if the layer can be skipped
- */
-static bool PrepareLayerRects(nsIntRect aVisible,
- const gfx::Matrix& aLayerTransform,
- const gfx::Matrix& aLayerBufferTransform,
- nsIntRect aClip, nsIntRect aBufferRect,
- bool aYFlipped,
- hwc_rect_t* aSourceCrop,
- hwc_rect_t* aVisibleRegionScreen);
-
-};
-
-} // namespace mozilla
-
-#endif // mozilla_HwcUtils
deleted file mode 100644
--- a/widget/gonk/hwchal/HwcHAL.cpp
+++ /dev/null
@@ -1,214 +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 "HwcHAL.h"
-#include "libdisplay/GonkDisplay.h"
-#include "mozilla/Assertions.h"
-
-namespace mozilla {
-
-HwcHAL::HwcHAL()
- : HwcHALBase()
-{
- // Some HALs don't want to open hwc twice.
- // If GetDisplay already load hwc module, we don't need to load again
- mHwc = (HwcDevice*)GetGonkDisplay()->GetHWCDevice();
- if (!mHwc) {
- printf_stderr("HwcHAL Error: Cannot load hwcomposer");
- return;
- }
-}
-
-HwcHAL::~HwcHAL()
-{
- mHwc = nullptr;
-}
-
-bool
-HwcHAL::Query(QueryType aType)
-{
- if (!mHwc || !mHwc->query) {
- return false;
- }
-
- bool value = false;
- int supported = 0;
- if (mHwc->query(mHwc, static_cast<int>(aType), &supported) == 0/*android::NO_ERROR*/) {
- value = !!supported;
- }
- return value;
-}
-
-int
-HwcHAL::Set(HwcList *aList,
- uint32_t aDisp)
-{
- MOZ_ASSERT(mHwc);
- if (!mHwc) {
- return -1;
- }
-
- HwcList *displays[HWC_NUM_DISPLAY_TYPES] = { nullptr };
- displays[aDisp] = aList;
- return mHwc->set(mHwc, HWC_NUM_DISPLAY_TYPES, displays);
-}
-
-int
-HwcHAL::ResetHwc()
-{
- return Set(nullptr, HWC_DISPLAY_PRIMARY);
-}
-
-int
-HwcHAL::Prepare(HwcList *aList,
- uint32_t aDisp,
- hwc_rect_t aDispRect,
- buffer_handle_t aHandle,
- int aFenceFd)
-{
- MOZ_ASSERT(mHwc);
- if (!mHwc) {
- printf_stderr("HwcHAL Error: HwcDevice doesn't exist. A fence might be leaked.");
- return -1;
- }
-
- HwcList *displays[HWC_NUM_DISPLAY_TYPES] = { nullptr };
- displays[aDisp] = aList;
-#if ANDROID_VERSION >= 18
- aList->outbufAcquireFenceFd = -1;
- aList->outbuf = nullptr;
-#endif
- aList->retireFenceFd = -1;
-
- const auto idx = aList->numHwLayers - 1;
- aList->hwLayers[idx].hints = 0;
- aList->hwLayers[idx].flags = 0;
- aList->hwLayers[idx].transform = 0;
- aList->hwLayers[idx].handle = aHandle;
- aList->hwLayers[idx].blending = HWC_BLENDING_PREMULT;
- aList->hwLayers[idx].compositionType = HWC_FRAMEBUFFER_TARGET;
- SetCrop(aList->hwLayers[idx], aDispRect);
- aList->hwLayers[idx].displayFrame = aDispRect;
- aList->hwLayers[idx].visibleRegionScreen.numRects = 1;
- aList->hwLayers[idx].visibleRegionScreen.rects = &aList->hwLayers[idx].displayFrame;
- aList->hwLayers[idx].acquireFenceFd = aFenceFd;
- aList->hwLayers[idx].releaseFenceFd = -1;
-#if ANDROID_VERSION >= 18
- aList->hwLayers[idx].planeAlpha = 0xFF;
-#endif
- return mHwc->prepare(mHwc, HWC_NUM_DISPLAY_TYPES, displays);
-}
-
-bool
-HwcHAL::SupportTransparency() const
-{
-#if ANDROID_VERSION >= 18
- return true;
-#endif
- return false;
-}
-
-uint32_t
-HwcHAL::GetGeometryChangedFlag(bool aGeometryChanged) const
-{
-#if ANDROID_VERSION >= 19
- return aGeometryChanged ? HWC_GEOMETRY_CHANGED : 0;
-#else
- return HWC_GEOMETRY_CHANGED;
-#endif
-}
-
-void
-HwcHAL::SetCrop(HwcLayer &aLayer,
- const hwc_rect_t &aSrcCrop) const
-{
- if (GetAPIVersion() >= HwcAPIVersion(1, 3)) {
-#if ANDROID_VERSION >= 19
- aLayer.sourceCropf.left = aSrcCrop.left;
- aLayer.sourceCropf.top = aSrcCrop.top;
- aLayer.sourceCropf.right = aSrcCrop.right;
- aLayer.sourceCropf.bottom = aSrcCrop.bottom;
-#endif
- } else {
- aLayer.sourceCrop = aSrcCrop;
- }
-}
-
-bool
-HwcHAL::EnableVsync(bool aEnable)
-{
- // Only support hardware vsync on kitkat, L and up due to inaccurate timings
- // with JellyBean.
-#if (ANDROID_VERSION == 19 || ANDROID_VERSION >= 21)
- if (!mHwc) {
- return false;
- }
- return !mHwc->eventControl(mHwc,
- HWC_DISPLAY_PRIMARY,
- HWC_EVENT_VSYNC,
- aEnable);
-#else
- return false;
-#endif
-}
-
-bool
-HwcHAL::RegisterHwcEventCallback(const HwcHALProcs_t &aProcs)
-{
- if (!mHwc || !mHwc->registerProcs) {
- printf_stderr("Failed to get hwc\n");
- return false;
- }
-
- // Disable Vsync first, and then register callback functions.
- mHwc->eventControl(mHwc,
- HWC_DISPLAY_PRIMARY,
- HWC_EVENT_VSYNC,
- false);
- static const hwc_procs_t sHwcJBProcs = {aProcs.invalidate,
- aProcs.vsync,
- aProcs.hotplug};
- mHwc->registerProcs(mHwc, &sHwcJBProcs);
-
- // Only support hardware vsync on kitkat, L and up due to inaccurate timings
- // with JellyBean.
-#if (ANDROID_VERSION == 19 || ANDROID_VERSION >= 21)
- return true;
-#else
- return false;
-#endif
-}
-
-uint32_t
-HwcHAL::GetAPIVersion() const
-{
- if (!mHwc) {
- // default value: HWC_MODULE_API_VERSION_0_1
- return 1;
- }
- return mHwc->common.version;
-}
-
-// Create HwcHAL
-UniquePtr<HwcHALBase>
-HwcHALBase::CreateHwcHAL()
-{
- return Move(MakeUnique<HwcHAL>());
-}
-
-} // namespace mozilla
deleted file mode 100644
--- a/widget/gonk/hwchal/HwcHAL.h
+++ /dev/null
@@ -1,70 +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_HwcHAL
-#define mozilla_HwcHAL
-
-#include "HwcHALBase.h"
-
-namespace mozilla {
-
-class HwcHAL final : public HwcHALBase {
-public:
- explicit HwcHAL();
-
- virtual ~HwcHAL();
-
- virtual bool HasHwc() const override { return static_cast<bool>(mHwc); }
-
- virtual void SetEGLInfo(hwc_display_t aDpy,
- hwc_surface_t aSur) 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:
- uint32_t GetAPIVersion() const;
-
-private:
- HwcDevice *mHwc = nullptr;
-};
-
-} // namespace mozilla
-
-#endif // mozilla_HwcHAL
deleted file mode 100644
--- a/widget/gonk/hwchal/HwcHALBase.h
+++ /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.
- */
-
-#ifndef mozilla_HwcHALBase
-#define mozilla_HwcHALBase
-
-#include "mozilla/UniquePtr.h"
-#include "nsRect.h"
-
-#include <hardware/hwcomposer.h>
-
-#ifndef HWC_BLIT
-#if ANDROID_VERSION >= 21
-#define HWC_BLIT 0xFF
-#elif ANDROID_VERSION >= 17
-#define HWC_BLIT (HWC_FRAMEBUFFER_TARGET + 1)
-#else
-// ICS didn't support this. However, we define this
-// for passing compilation
-#define HWC_BLIT 0xFF
-#endif // #if ANDROID_VERSION
-#endif // #ifndef HWC_BLIT
-
-namespace mozilla {
-
-#if ANDROID_VERSION >= 17
-using HwcDevice = hwc_composer_device_1_t;
-using HwcList = hwc_display_contents_1_t;
-using HwcLayer = hwc_layer_1_t;
-#else
-using HwcDevice = hwc_composer_device_t;
-using HwcList = hwc_layer_list_t;
-using HwcLayer = hwc_layer_t;
-#endif
-
-// HwcHAL definition for HwcEvent callback types
-// Note: hwc_procs is different between ICS and later,
-// and the signature of invalidate is also different.
-// Use this wrap struct to hide the detail. BTW,
-// we don't have to register callback functions on ICS, so
-// there is no callbacks for ICS in HwcHALProcs.
-typedef struct HwcHALProcs {
- void (*invalidate)(const struct hwc_procs* procs);
- void (*vsync)(const struct hwc_procs* procs, int disp, int64_t timestamp);
- void (*hotplug)(const struct hwc_procs* procs, int disp, int connected);
-} HwcHALProcs_t;
-
-// HwcHAL class
-// This class handle all the HAL related work
-// The purpose of HwcHAL is to make HwcComposer2D simpler.
-class HwcHALBase {
-
-public:
- // Query Types. We can add more types easily in the future
- enum class QueryType {
- COLOR_FILL = 0x8,
- RB_SWAP = 0x40
- };
-
-public:
- explicit HwcHALBase() = default;
-
- virtual ~HwcHALBase() {}
-
- // Create HwcHAL module, Only HwcComposer2D calls this.
- // If other modules want to use HwcHAL, please use APIs in
- // HwcComposer2D
- static UniquePtr<HwcHALBase> CreateHwcHAL();
-
- // Check if mHwc exists
- virtual bool HasHwc() const = 0;
-
- // Set EGL info (only ICS need this info)
- virtual void SetEGLInfo(hwc_display_t aEGLDisplay,
- hwc_surface_t aEGLSurface) = 0;
-
- // HwcDevice query properties
- virtual bool Query(QueryType aType) = 0;
-
- // HwcDevice set
- virtual int Set(HwcList *aList,
- uint32_t aDisp) = 0;
-
- // Reset HwcDevice
- virtual int ResetHwc() = 0;
-
- // HwcDevice prepare
- virtual int Prepare(HwcList *aList,
- uint32_t aDisp,
- hwc_rect_t aDispRect,
- buffer_handle_t aHandle,
- int aFenceFd) = 0;
-
- // Check transparency support
- virtual bool SupportTransparency() const = 0;
-
- // Get a geometry change flag
- virtual uint32_t GetGeometryChangedFlag(bool aGeometryChanged) const = 0;
-
- // Set crop help
- virtual void SetCrop(HwcLayer &aLayer,
- const hwc_rect_t &aSrcCrop) const = 0;
-
- // Enable HW Vsync
- virtual bool EnableVsync(bool aEnable) = 0;
-
- // Register HW event callback functions
- virtual bool RegisterHwcEventCallback(const HwcHALProcs_t &aProcs) = 0;
-
-protected:
- constexpr static uint32_t HwcAPIVersion(uint32_t aMaj, uint32_t aMin) {
- // HARDWARE_MAKE_API_VERSION_2, from Android hardware.h
- return (((aMaj & 0xff) << 24) | ((aMin & 0xff) << 16) | (1 & 0xffff));
- }
-};
-
-} // namespace mozilla
-
-#endif // mozilla_HwcHALBase
--- a/widget/gonk/moz.build
+++ b/widget/gonk/moz.build
@@ -40,30 +40,22 @@ SOURCES += ['libui/' + src for src in [
'sha1.c',
'SpriteController.cpp',
'Tokenizer.cpp',
'VelocityControl.cpp',
'VelocityTracker.cpp',
'VirtualKeyMap.cpp',
]]
-# HwcHAL files
-if CONFIG['ANDROID_VERSION'] >= '17':
- SOURCES += [
- 'hwchal/HwcHAL.cpp',
- ]
-
SOURCES += [
'GeckoTouchDispatcher.cpp',
'GfxInfo.cpp',
'GonkClipboardData.cpp',
'GonkMemoryPressureMonitoring.cpp',
'GonkPermission.cpp',
- 'HwcComposer2D.cpp',
- 'HwcUtils.cpp',
'nsAppShell.cpp',
'nsClipboard.cpp',
'nsIdleServiceGonk.cpp',
'nsLookAndFeel.cpp',
'nsScreenManagerGonk.cpp',
'nsWidgetFactory.cpp',
'nsWindow.cpp',
'OrientationObserver.cpp',
--- a/widget/gonk/nsScreenManagerGonk.cpp
+++ b/widget/gonk/nsScreenManagerGonk.cpp
@@ -19,17 +19,16 @@
#include "gfxUtils.h"
#include "mozilla/MouseEvents.h"
#include "mozilla/TouchEvents.h"
#include "mozilla/Hal.h"
#include "libdisplay/BootAnimation.h"
#include "libdisplay/GonkDisplay.h"
#include "nsScreenManagerGonk.h"
#include "nsThreadUtils.h"
-#include "HwcComposer2D.h"
#include "VsyncSource.h"
#include "nsWindow.h"
#include "mozilla/ClearOnShutdown.h"
#include "mozilla/layers/CompositorBridgeParent.h"
#include "mozilla/layers/CompositorThread.h"
#include "mozilla/Services.h"
#include "mozilla/ProcessPriorityManager.h"
#include "nsIdleService.h"
--- a/widget/gonk/nsWindow.cpp
+++ b/widget/gonk/nsWindow.cpp
@@ -42,17 +42,16 @@
#include "mozilla/gfx/2D.h"
#include "mozilla/gfx/Logging.h"
#include "mozilla/layers/APZCTreeManager.h"
#include "mozilla/layers/APZThreadUtils.h"
#include "mozilla/layers/CompositorBridgeParent.h"
#include "mozilla/layers/CompositorThread.h"
#include "mozilla/layers/CompositorSession.h"
#include "mozilla/TouchEvents.h"
-#include "HwcComposer2D.h"
#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "Gonk" , ## args)
#define LOGW(args...) __android_log_print(ANDROID_LOG_WARN, "Gonk", ## args)
#define LOGE(args...) __android_log_print(ANDROID_LOG_ERROR, "Gonk", ## args)
#define IS_TOPLEVEL() (mWindowType == eWindowType_toplevel || mWindowType == eWindowType_dialog)
using namespace mozilla;
@@ -81,19 +80,16 @@ nsWindow::nsWindow()
gfxPlatform::GetPlatform();
if (!ShouldUseOffMainThreadCompositing()) {
MOZ_CRASH("How can we render apps, then?");
}
}
nsWindow::~nsWindow()
{
- if (mScreen->IsPrimaryScreen()) {
- mComposer2D->SetCompositorBridgeParent(nullptr);
- }
}
void
nsWindow::DoDraw(void)
{
if (!hal::GetScreenEnabled()) {
gDrawRequest = true;
return;
@@ -311,18 +307,16 @@ nsWindow::Create(nsIWidget* aParent,
mParent = (nsWindow *)aParent;
mVisible = false;
if (!aParent) {
mBounds = mScreen->GetRect();
}
- mComposer2D = HwcComposer2D::GetInstance();
-
if (!IS_TOPLEVEL()) {
return NS_OK;
}
mScreen->RegisterWindow(this);
Resize(0, 0, mBounds.width, mBounds.height, false);
@@ -648,33 +642,26 @@ nsWindow::GetLayerManager(PLayerTransact
if (!topWindow) {
LOGW(" -- no topwindow\n");
return nullptr;
}
CreateCompositor();
if (RefPtr<CompositorBridgeParent> bridge = GetCompositorBridgeParent()) {
mScreen->SetCompositorBridgeParent(bridge);
- if (mScreen->IsPrimaryScreen()) {
- mComposer2D->SetCompositorBridgeParent(bridge);
- }
}
MOZ_ASSERT(mLayerManager);
return mLayerManager;
}
void
nsWindow::DestroyCompositor()
{
if (RefPtr<CompositorBridgeParent> bridge = GetCompositorBridgeParent()) {
mScreen->SetCompositorBridgeParent(nullptr);
- if (mScreen->IsPrimaryScreen()) {
- // Unset CompositorBridgeParent
- mComposer2D->SetCompositorBridgeParent(nullptr);
- }
}
nsBaseWidget::DestroyCompositor();
}
void
nsWindow::BringToTop()
{
const nsTArray<nsWindow*>& windows = mScreen->GetTopWindows();
@@ -733,23 +720,13 @@ bool
nsWindow::NeedsPaint()
{
if (!mLayerManager) {
return false;
}
return nsIWidget::NeedsPaint();
}
-Composer2D*
-nsWindow::GetComposer2D()
-{
- if (mScreen->GetDisplayType() == GonkDisplay::DISPLAY_VIRTUAL) {
- return nullptr;
- }
-
- return mComposer2D;
-}
-
CompositorBridgeParent*
nsWindow::GetCompositorBridgeParent() const
{
return mCompositorSession ? mCompositorSession->GetInProcessBridge() : nullptr;
}
--- a/widget/gonk/nsWindow.h
+++ b/widget/gonk/nsWindow.h
@@ -25,20 +25,16 @@
class ANativeWindowBuffer;
namespace widget {
struct InputContext;
struct InputContextAction;
}
-namespace mozilla {
-class HwcComposer2D;
-}
-
class nsScreenGonk;
class nsWindow : public nsBaseWidget
{
public:
nsWindow();
NS_DECL_ISUPPORTS_INHERITED
@@ -120,18 +116,16 @@ public:
const InputContextAction& aAction);
NS_IMETHOD_(InputContext) GetInputContext();
virtual uint32_t GetGLFrameBufferFormat() override;
virtual LayoutDeviceIntRect GetNaturalBounds() override;
virtual bool NeedsPaint();
- virtual Composer2D* GetComposer2D() override;
-
void ConfigureAPZControllerThread() override;
nsScreenGonk* GetScreen();
protected:
nsWindow* mParent;
bool mVisible;
InputContext mInputContext;
@@ -151,13 +145,11 @@ protected:
CompositorBridgeParent* GetCompositorBridgeParent() const;
private:
// This is used by SynthesizeNativeTouchPoint to maintain state between
// multiple synthesized points
mozilla::UniquePtr<mozilla::MultiTouchInput> mSynthesizedTouchInput;
RefPtr<nsScreenGonk> mScreen;
-
- RefPtr<mozilla::HwcComposer2D> mComposer2D;
};
#endif /* nsWindow_h */