2015-06-23 06:03:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* vim:set ts=4 sw=4 sts=4 et: */
|
2012-11-19 09:58:37 -08:00
|
|
|
/*
|
|
|
|
* 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"
|
2015-06-23 06:03:00 -07:00
|
|
|
#include "hwchal/HwcHALBase.h" // for HwcHAL
|
|
|
|
#include "HwcUtils.h" // for RectVector
|
2012-11-19 09:58:37 -08:00
|
|
|
#include "Layers.h"
|
2014-09-24 06:50:45 -07:00
|
|
|
#include "mozilla/Mutex.h"
|
2015-06-23 06:03:00 -07:00
|
|
|
#include "mozilla/layers/FenceUtils.h" // for FenceHandle
|
|
|
|
#include "mozilla/UniquePtr.h" // for HwcHAL
|
2014-09-24 06:50:45 -07:00
|
|
|
|
2013-04-29 17:21:54 -07:00
|
|
|
#include <vector>
|
|
|
|
#include <list>
|
2012-11-19 09:58:37 -08:00
|
|
|
|
2014-11-05 14:16:52 -08:00
|
|
|
#include <utils/Timers.h>
|
2013-09-11 06:10:33 -07:00
|
|
|
|
2015-06-04 20:29:30 -07:00
|
|
|
class nsScreenGonk;
|
|
|
|
|
2012-11-19 09:58:37 -08:00
|
|
|
namespace mozilla {
|
|
|
|
|
2014-06-30 13:01:24 -07:00
|
|
|
namespace gl {
|
|
|
|
class GLContext;
|
|
|
|
}
|
|
|
|
|
2012-11-19 09:58:37 -08:00
|
|
|
namespace layers {
|
2014-09-24 06:50:45 -07:00
|
|
|
class CompositorParent;
|
2012-11-19 09:58:37 -08:00
|
|
|
class Layer;
|
|
|
|
}
|
|
|
|
|
2014-03-18 07:53:09 -07:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*/
|
2013-05-07 20:58:22 -07:00
|
|
|
class HwcComposer2D : public mozilla::layers::Composer2D {
|
2012-11-19 09:58:37 -08:00
|
|
|
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
|
2015-04-17 09:28:41 -07:00
|
|
|
virtual bool TryRenderWithHwc(layers::Layer* aRoot,
|
2015-06-04 20:29:30 -07:00
|
|
|
nsIWidget* aWidget,
|
2016-01-18 20:52:32 -08:00
|
|
|
bool aGeometryChanged,
|
|
|
|
bool aHasImageHostOverlays) override;
|
2012-11-19 09:58:37 -08:00
|
|
|
|
2015-06-04 20:29:30 -07:00
|
|
|
virtual bool Render(nsIWidget* aWidget) override;
|
2015-04-17 09:28:41 -07:00
|
|
|
|
2015-06-23 06:03:00 -07:00
|
|
|
virtual bool HasHwc() override { return mHal->HasHwc(); }
|
2013-10-08 08:29:35 -07:00
|
|
|
|
2014-12-17 21:25:09 -08:00
|
|
|
bool EnableVsync(bool aEnable);
|
2014-08-26 22:17:00 -07:00
|
|
|
bool RegisterHwcEventCallback();
|
|
|
|
void Vsync(int aDisplay, int64_t aTimestamp);
|
2014-09-24 06:50:45 -07:00
|
|
|
void Invalidate();
|
2015-06-04 20:29:30 -07:00
|
|
|
void Hotplug(int aDisplay, int aConnected);
|
2014-09-24 06:50:45 -07:00
|
|
|
void SetCompositorParent(layers::CompositorParent* aCompositorParent);
|
2014-08-26 22:17:00 -07:00
|
|
|
|
2012-11-19 09:58:37 -08:00
|
|
|
private:
|
2013-12-11 12:37:25 -08:00
|
|
|
void Reset();
|
2015-06-04 20:29:30 -07:00
|
|
|
void Prepare(buffer_handle_t dispHandle, int fence, nsScreenGonk* screen);
|
|
|
|
bool Commit(nsScreenGonk* aScreen);
|
|
|
|
bool TryHwComposition(nsScreenGonk* aScreen);
|
2012-11-19 09:58:37 -08:00
|
|
|
bool ReallocLayerList();
|
2013-01-17 13:34:01 -08:00
|
|
|
bool PrepareLayerList(layers::Layer* aContainer, const nsIntRect& aClip,
|
2016-01-18 20:52:32 -08:00
|
|
|
const gfx::Matrix& aParentTransform,
|
|
|
|
bool aFindSidebandStreams);
|
2014-07-02 16:17:00 -07:00
|
|
|
void SendtoLayerScope();
|
2012-11-19 09:58:37 -08:00
|
|
|
|
2015-06-23 06:03:00 -07:00
|
|
|
UniquePtr<HwcHALBase> mHal;
|
2013-09-11 06:10:33 -07:00
|
|
|
HwcList* mList;
|
2013-01-17 13:34:01 -08:00
|
|
|
nsIntRect mScreenRect;
|
2012-11-19 09:58:37 -08:00
|
|
|
int mMaxLayerCount;
|
2013-01-09 04:56:37 -08:00
|
|
|
bool mColorFill;
|
2013-09-27 13:37:19 -07:00
|
|
|
bool mRBSwapSupport;
|
2013-04-29 17:21:54 -07:00
|
|
|
//Holds all the dynamically allocated RectVectors needed
|
|
|
|
//to render the current frame
|
2015-06-23 06:03:00 -07:00
|
|
|
std::list<HwcUtils::RectVector> mVisibleRegions;
|
2015-05-12 15:37:00 -07:00
|
|
|
layers::FenceHandle mPrevRetireFence;
|
|
|
|
layers::FenceHandle mPrevDisplayFence;
|
2016-01-18 20:52:32 -08:00
|
|
|
nsTArray<HwcLayer> mCachedSidebandLayers;
|
2013-10-15 14:01:42 -07:00
|
|
|
nsTArray<layers::LayerComposite*> mHwcLayerMap;
|
2013-12-11 12:37:25 -08:00
|
|
|
bool mPrepared;
|
2014-08-26 22:17:00 -07:00
|
|
|
bool mHasHWVsync;
|
2015-07-24 11:28:28 -07:00
|
|
|
layers::CompositorParent* mCompositorParent;
|
2014-09-24 06:50:45 -07:00
|
|
|
Mutex mLock;
|
2012-11-19 09:58:37 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_HwcComposer2D
|