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