From 5f8de423f190bbb79a62f804151bc24824fa32d8 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Fri, 2 Feb 2018 04:16:08 -0500 Subject: Add m-esr52 at 52.6.0 --- gfx/layers/client/ClientPaintedLayer.h | 127 +++++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 gfx/layers/client/ClientPaintedLayer.h (limited to 'gfx/layers/client/ClientPaintedLayer.h') diff --git a/gfx/layers/client/ClientPaintedLayer.h b/gfx/layers/client/ClientPaintedLayer.h new file mode 100644 index 000000000..949f746ae --- /dev/null +++ b/gfx/layers/client/ClientPaintedLayer.h @@ -0,0 +1,127 @@ +/* -*- 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/. */ + +#ifndef GFX_CLIENTPAINTEDLAYER_H +#define GFX_CLIENTPAINTEDLAYER_H + +#include "ClientLayerManager.h" // for ClientLayerManager, etc +#include "Layers.h" // for PaintedLayer, etc +#include "RotatedBuffer.h" // for RotatedContentBuffer, etc +#include "mozilla/Attributes.h" // for override +#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 +#include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc +#include "nsRegion.h" // for nsIntRegion +#include "mozilla/layers/PLayerTransaction.h" // for PaintedLayerAttributes + +namespace mozilla { +namespace layers { + +class CompositableClient; +class ShadowableLayer; +class SpecificLayerAttributes; + +class ClientPaintedLayer : public PaintedLayer, + public ClientLayer { +public: + typedef RotatedContentBuffer::PaintState PaintState; + typedef RotatedContentBuffer::ContentType ContentType; + + explicit ClientPaintedLayer(ClientLayerManager* aLayerManager, + LayerManager::PaintedLayerCreationHint aCreationHint = LayerManager::NONE) : + PaintedLayer(aLayerManager, static_cast(this), aCreationHint), + mContentClient(nullptr) + { + MOZ_COUNT_CTOR(ClientPaintedLayer); + } + +protected: + virtual ~ClientPaintedLayer() + { + if (mContentClient) { + mContentClient->OnDetach(); + mContentClient = nullptr; + } + MOZ_COUNT_DTOR(ClientPaintedLayer); + } + +public: + virtual void SetVisibleRegion(const LayerIntRegion& aRegion) override + { + NS_ASSERTION(ClientManager()->InConstruction(), + "Can only set properties in construction phase"); + PaintedLayer::SetVisibleRegion(aRegion); + } + virtual void InvalidateRegion(const nsIntRegion& aRegion) override + { + NS_ASSERTION(ClientManager()->InConstruction(), + "Can only set properties in construction phase"); + mInvalidRegion.Add(aRegion); + mValidRegion.Sub(mValidRegion, mInvalidRegion.GetRegion()); + } + + virtual void RenderLayer() override { RenderLayerWithReadback(nullptr); } + + virtual void RenderLayerWithReadback(ReadbackProcessor *aReadback) override; + + virtual void ClearCachedResources() override + { + if (mContentClient) { + mContentClient->Clear(); + } + mValidRegion.SetEmpty(); + DestroyBackBuffer(); + } + + virtual void HandleMemoryPressure() override + { + if (mContentClient) { + mContentClient->HandleMemoryPressure(); + } + } + + virtual void FillSpecificAttributes(SpecificLayerAttributes& aAttrs) override + { + aAttrs = PaintedLayerAttributes(GetValidRegion()); + } + + ClientLayerManager* ClientManager() + { + return static_cast(mManager); + } + + virtual Layer* AsLayer() override { return this; } + virtual ShadowableLayer* AsShadowableLayer() override { return this; } + + virtual CompositableClient* GetCompositableClient() override + { + return mContentClient; + } + + virtual void Disconnect() override + { + mContentClient = nullptr; + ClientLayer::Disconnect(); + } + +protected: + void PaintThebes(); + + virtual void PrintInfo(std::stringstream& aStream, const char* aPrefix) override; + + void DestroyBackBuffer() + { + mContentClient = nullptr; + } + + RefPtr mContentClient; +}; + +} // namespace layers +} // namespace mozilla + +#endif -- cgit v1.2.3