2013-05-01 09:03:25 +04:00
|
|
|
/* -*- 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/. */
|
|
|
|
|
2014-09-26 21:06:08 +04:00
|
|
|
#ifndef GFX_CLIENTPAINTEDLAYER_H
|
|
|
|
#define GFX_CLIENTPAINTEDLAYER_H
|
2013-05-01 09:03:25 +04:00
|
|
|
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "ClientLayerManager.h" // for ClientLayerManager, etc
|
2014-09-26 21:06:08 +04:00
|
|
|
#include "Layers.h" // for PaintedLayer, etc
|
2013-11-27 04:29:46 +04:00
|
|
|
#include "RotatedBuffer.h" // for RotatedContentBuffer, etc
|
2015-03-21 19:28:04 +03:00
|
|
|
#include "mozilla/Attributes.h" // for override
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "mozilla/RefPtr.h" // for RefPtr
|
|
|
|
#include "mozilla/layers/ContentClient.h" // for ContentClient
|
|
|
|
#include "mozilla/mozalloc.h" // for operator delete
|
|
|
|
#include "nsDebug.h" // for NS_ASSERTION
|
2014-02-27 01:36:35 +04:00
|
|
|
#include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "nsRegion.h" // for nsIntRegion
|
2014-09-26 21:06:08 +04:00
|
|
|
#include "mozilla/layers/PLayerTransaction.h" // for PaintedLayerAttributes
|
2013-08-12 03:17:23 +04:00
|
|
|
|
2013-05-01 09:03:25 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
2013-08-12 03:17:23 +04:00
|
|
|
class CompositableClient;
|
|
|
|
class ShadowableLayer;
|
|
|
|
class SpecificLayerAttributes;
|
|
|
|
|
2014-09-26 21:06:08 +04:00
|
|
|
class ClientPaintedLayer : public PaintedLayer,
|
2015-03-27 21:52:19 +03:00
|
|
|
public ClientLayer {
|
2013-05-01 09:03:25 +04:00
|
|
|
public:
|
2013-11-27 04:29:46 +04:00
|
|
|
typedef RotatedContentBuffer::PaintState PaintState;
|
|
|
|
typedef RotatedContentBuffer::ContentType ContentType;
|
2013-05-01 09:03:25 +04:00
|
|
|
|
2014-09-26 21:06:08 +04:00
|
|
|
explicit ClientPaintedLayer(ClientLayerManager* aLayerManager,
|
|
|
|
LayerManager::PaintedLayerCreationHint aCreationHint = LayerManager::NONE) :
|
2015-01-07 08:39:46 +03:00
|
|
|
PaintedLayer(aLayerManager, static_cast<ClientLayer*>(this), aCreationHint),
|
2013-05-01 09:03:25 +04:00
|
|
|
mContentClient(nullptr)
|
|
|
|
{
|
2014-09-26 21:06:08 +04:00
|
|
|
MOZ_COUNT_CTOR(ClientPaintedLayer);
|
2013-05-01 09:03:25 +04:00
|
|
|
}
|
2014-07-15 19:37:45 +04:00
|
|
|
|
|
|
|
protected:
|
2014-09-26 21:06:08 +04:00
|
|
|
virtual ~ClientPaintedLayer()
|
2013-05-01 09:03:25 +04:00
|
|
|
{
|
2013-07-30 13:59:51 +04:00
|
|
|
if (mContentClient) {
|
2013-08-08 16:53:12 +04:00
|
|
|
mContentClient->OnDetach();
|
2013-07-30 13:59:51 +04:00
|
|
|
mContentClient = nullptr;
|
|
|
|
}
|
2014-09-26 21:06:08 +04:00
|
|
|
MOZ_COUNT_DTOR(ClientPaintedLayer);
|
2013-05-01 09:03:25 +04:00
|
|
|
}
|
|
|
|
|
2014-07-15 19:37:45 +04:00
|
|
|
public:
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void SetVisibleRegion(const nsIntRegion& aRegion) override
|
2013-05-01 09:03:25 +04:00
|
|
|
{
|
|
|
|
NS_ASSERTION(ClientManager()->InConstruction(),
|
|
|
|
"Can only set properties in construction phase");
|
2014-09-26 21:06:08 +04:00
|
|
|
PaintedLayer::SetVisibleRegion(aRegion);
|
2013-05-01 09:03:25 +04:00
|
|
|
}
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void InvalidateRegion(const nsIntRegion& aRegion) override
|
2013-05-01 09:03:25 +04:00
|
|
|
{
|
|
|
|
NS_ASSERTION(ClientManager()->InConstruction(),
|
|
|
|
"Can only set properties in construction phase");
|
|
|
|
mInvalidRegion.Or(mInvalidRegion, aRegion);
|
2014-04-28 08:17:31 +04:00
|
|
|
mInvalidRegion.SimplifyOutward(20);
|
2013-05-01 09:03:25 +04:00
|
|
|
mValidRegion.Sub(mValidRegion, mInvalidRegion);
|
|
|
|
}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void RenderLayer() override { RenderLayerWithReadback(nullptr); }
|
2014-07-30 17:38:47 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void RenderLayerWithReadback(ReadbackProcessor *aReadback) override;
|
2013-05-01 09:03:25 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void ClearCachedResources() override
|
2013-05-01 09:03:25 +04:00
|
|
|
{
|
|
|
|
if (mContentClient) {
|
|
|
|
mContentClient->Clear();
|
|
|
|
}
|
|
|
|
mValidRegion.SetEmpty();
|
|
|
|
DestroyBackBuffer();
|
|
|
|
}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void FillSpecificAttributes(SpecificLayerAttributes& aAttrs) override
|
2013-05-01 09:03:25 +04:00
|
|
|
{
|
2014-09-26 21:06:08 +04:00
|
|
|
aAttrs = PaintedLayerAttributes(GetValidRegion());
|
2013-05-01 09:03:25 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
ClientLayerManager* ClientManager()
|
|
|
|
{
|
|
|
|
return static_cast<ClientLayerManager*>(mManager);
|
|
|
|
}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual Layer* AsLayer() override { return this; }
|
|
|
|
virtual ShadowableLayer* AsShadowableLayer() override { return this; }
|
2013-05-01 09:03:25 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual CompositableClient* GetCompositableClient() override
|
2013-05-01 09:03:25 +04:00
|
|
|
{
|
|
|
|
return mContentClient;
|
|
|
|
}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void Disconnect() override
|
2013-05-01 09:03:25 +04:00
|
|
|
{
|
|
|
|
mContentClient = nullptr;
|
|
|
|
ClientLayer::Disconnect();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void PaintThebes();
|
2014-12-18 21:32:45 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void PrintInfo(std::stringstream& aStream, const char* aPrefix) override;
|
2014-12-18 21:32:45 +03:00
|
|
|
|
2013-05-01 09:03:25 +04:00
|
|
|
void DestroyBackBuffer()
|
|
|
|
{
|
|
|
|
mContentClient = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
RefPtr<ContentClient> mContentClient;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|