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