Line data Source code
1 : /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 : * This Source Code Form is subject to the terms of the Mozilla Public
3 : * License, v. 2.0. If a copy of the MPL was not distributed with this
4 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 :
6 : #ifndef MOZILLA_GFX_PAINTEDLAYERMLGPU_H
7 : #define MOZILLA_GFX_PAINTEDLAYERMLGPU_H
8 :
9 : #include "LayerManagerMLGPU.h"
10 : #include "mozilla/layers/ContentHost.h"
11 : #include "nsRegionFwd.h"
12 : #include <functional>
13 :
14 : namespace mozilla {
15 : namespace layers {
16 :
17 : class PaintedLayerMLGPU final
18 : : public PaintedLayer,
19 : public LayerMLGPU
20 : {
21 : public:
22 : explicit PaintedLayerMLGPU(LayerManagerMLGPU* aManager);
23 : ~PaintedLayerMLGPU() override;
24 :
25 : // Layer
26 0 : HostLayer* AsHostLayer() override { return this; }
27 0 : PaintedLayerMLGPU* AsPaintedLayerMLGPU() override { return this; }
28 0 : virtual Layer* GetLayer() override { return this; }
29 : bool SetCompositableHost(CompositableHost*) override;
30 : CompositableHost* GetCompositableHost() override;
31 : void Disconnect() override;
32 : bool IsContentOpaque() override;
33 :
34 : // PaintedLayer
35 0 : void InvalidateRegion(const nsIntRegion& aRegion) override {
36 0 : MOZ_CRASH("PaintedLayerMLGPU can't fill invalidated regions");
37 : }
38 :
39 0 : bool HasComponentAlpha() const {
40 0 : return !!mTextureOnWhite;
41 : }
42 0 : TextureSource* GetTexture() const {
43 0 : return mTexture;
44 : }
45 0 : TextureSource* GetTextureOnWhite() const {
46 0 : MOZ_ASSERT(HasComponentAlpha());
47 0 : return mTextureOnWhite;
48 : }
49 :
50 0 : ContentHostTexture* GetContentHost() const {
51 0 : return mHost;
52 : }
53 :
54 0 : nsIntRegion GetRenderRegion() const {
55 0 : nsIntRegion region = GetShadowVisibleRegion().ToUnknownRegion();
56 0 : region.AndWith(gfx::IntRect(region.GetBounds().TopLeft(), mTexture->GetSize()));
57 0 : return region;
58 : }
59 :
60 0 : MOZ_LAYER_DECL_NAME("PaintedLayerMLGPU", TYPE_PAINTED)
61 :
62 : void CleanupCachedResources();
63 :
64 : protected:
65 : void PrintInfo(std::stringstream& aStream, const char* aPrefix) override;
66 : bool OnPrepareToRender(FrameBuilder* aBuilder) override;
67 :
68 : void CleanupResources();
69 :
70 : private:
71 : RefPtr<ContentHostTexture> mHost;
72 : RefPtr<TextureSource> mTexture;
73 : RefPtr<TextureSource> mTextureOnWhite;
74 : gfx::IntRegion mLocalDrawRegion;
75 : gfx::IntRegion mTextureRegion;
76 : };
77 :
78 : } // namespace layers
79 : } // namespace mozilla
80 :
81 : #endif
|