Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/gfx/layers/client/ClientPaintedLayer.h
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
3
/* This Source Code Form is subject to the terms of the Mozilla Public
4
 * License, v. 2.0. If a copy of the MPL was not distributed with this
5
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
#ifndef GFX_CLIENTPAINTEDLAYER_H
8
#define GFX_CLIENTPAINTEDLAYER_H
9
10
#include "ClientLayerManager.h"         // for ClientLayerManager, etc
11
#include "Layers.h"                     // for PaintedLayer, etc
12
#include "RotatedBuffer.h"              // for RotatedBuffer, etc
13
#include "mozilla/Attributes.h"         // for override
14
#include "mozilla/RefPtr.h"             // for RefPtr
15
#include "mozilla/layers/ContentClient.h"  // for ContentClient
16
#include "mozilla/mozalloc.h"           // for operator delete
17
#include "nsDebug.h"                    // for NS_ASSERTION
18
#include "nsISupportsImpl.h"            // for MOZ_COUNT_CTOR, etc
19
#include "nsRegion.h"                   // for nsIntRegion
20
#include "mozilla/layers/PLayerTransaction.h" // for PaintedLayerAttributes
21
22
namespace mozilla {
23
namespace gfx {
24
class DrawEventRecorderMemory;
25
class DrawTargetCapture;
26
};
27
28
namespace layers {
29
class CompositableClient;
30
class ShadowableLayer;
31
class SpecificLayerAttributes;
32
33
class ClientPaintedLayer : public PaintedLayer,
34
                           public ClientLayer {
35
public:
36
  typedef ContentClient::PaintState PaintState;
37
  typedef ContentClient::ContentType ContentType;
38
39
  explicit ClientPaintedLayer(ClientLayerManager* aLayerManager,
40
                             LayerManager::PaintedLayerCreationHint aCreationHint = LayerManager::NONE) :
41
    PaintedLayer(aLayerManager, static_cast<ClientLayer*>(this), aCreationHint),
42
    mContentClient(nullptr)
43
0
  {
44
0
    MOZ_COUNT_CTOR(ClientPaintedLayer);
45
0
  }
46
47
protected:
48
  virtual ~ClientPaintedLayer()
49
0
  {
50
0
    if (mContentClient) {
51
0
      mContentClient->OnDetach();
52
0
      mContentClient = nullptr;
53
0
    }
54
0
    MOZ_COUNT_DTOR(ClientPaintedLayer);
55
0
  }
56
57
public:
58
  virtual void SetVisibleRegion(const LayerIntRegion& aRegion) override
59
0
  {
60
0
    NS_ASSERTION(ClientManager()->InConstruction(),
61
0
                 "Can only set properties in construction phase");
62
0
    PaintedLayer::SetVisibleRegion(aRegion);
63
0
  }
64
  virtual void InvalidateRegion(const nsIntRegion& aRegion) override
65
0
  {
66
0
    NS_ASSERTION(ClientManager()->InConstruction(),
67
0
                 "Can only set properties in construction phase");
68
0
    mInvalidRegion.Add(aRegion);
69
0
    UpdateValidRegionAfterInvalidRegionChanged();
70
0
  }
71
72
0
  virtual void RenderLayer() override { RenderLayerWithReadback(nullptr); }
73
74
  virtual void RenderLayerWithReadback(ReadbackProcessor *aReadback) override;
75
76
  virtual void ClearCachedResources() override
77
0
  {
78
0
    if (mContentClient) {
79
0
      mContentClient->Clear();
80
0
    }
81
0
    ClearValidRegion();
82
0
    DestroyBackBuffer();
83
0
  }
84
85
  virtual void HandleMemoryPressure() override
86
0
  {
87
0
    if (mContentClient) {
88
0
      mContentClient->HandleMemoryPressure();
89
0
    }
90
0
  }
91
92
  virtual void FillSpecificAttributes(SpecificLayerAttributes& aAttrs) override
93
0
  {
94
0
    aAttrs = PaintedLayerAttributes(GetValidRegion());
95
0
  }
96
  
97
  ClientLayerManager* ClientManager()
98
0
  {
99
0
    return static_cast<ClientLayerManager*>(mManager);
100
0
  }
101
  
102
0
  virtual Layer* AsLayer() override { return this; }
103
0
  virtual ShadowableLayer* AsShadowableLayer() override { return this; }
104
105
  virtual CompositableClient* GetCompositableClient() override
106
0
  {
107
0
    return mContentClient;
108
0
  }
109
110
  virtual void Disconnect() override
111
0
  {
112
0
    mContentClient = nullptr;
113
0
  }
114
115
protected:
116
  void RecordThebes();
117
  bool HasMaskLayers();
118
  bool EnsureContentClient();
119
  uint32_t GetPaintFlags(ReadbackProcessor* aReadback);
120
  void UpdateContentClient(PaintState& aState);
121
  bool UpdatePaintRegion(PaintState& aState);
122
  void FinishPaintState(PaintState& aState);
123
124
  virtual void PrintInfo(std::stringstream& aStream, const char* aPrefix) override;
125
126
  void DestroyBackBuffer()
127
0
  {
128
0
    mContentClient = nullptr;
129
0
  }
130
131
  RefPtr<ContentClient> mContentClient;
132
};
133
134
} // namespace layers
135
} // namespace mozilla
136
137
#endif