Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/mozilla/layers/SingleTiledContentClient.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 MOZILLA_GFX_SINGLETILEDCONTENTCLIENT_H
8
#define MOZILLA_GFX_SINGLETILEDCONTENTCLIENT_H
9
10
#include "TiledContentClient.h"
11
12
namespace mozilla {
13
namespace layers {
14
15
class ClientTiledPaintedLayer;
16
class ClientLayerManager;
17
18
/**
19
 * Provide an instance of TiledLayerBuffer backed by drawable TextureClients.
20
 * This buffer provides an implementation of ValidateTile using a
21
 * thebes callback and can support painting using a single paint buffer.
22
 * Whether a single paint buffer is used is controlled by
23
 * gfxPrefs::PerTileDrawing().
24
 */
25
class ClientSingleTiledLayerBuffer
26
  : public ClientTiledLayerBuffer
27
  , public TextureClientAllocator
28
{
29
0
  virtual ~ClientSingleTiledLayerBuffer() {}
30
public:
31
  ClientSingleTiledLayerBuffer(ClientTiledPaintedLayer& aPaintedLayer,
32
                               CompositableClient& aCompositableClient,
33
                               ClientLayerManager* aManager);
34
35
  // TextureClientAllocator
36
  already_AddRefed<TextureClient> GetTextureClient() override;
37
0
  void ReturnTextureClientDeferred(TextureClient* aClient) override {}
38
0
  void ReportClientLost() override {}
39
40
  // ClientTiledLayerBuffer
41
  void PaintThebes(const nsIntRegion& aNewValidRegion,
42
                   const nsIntRegion& aPaintRegion,
43
                   const nsIntRegion& aDirtyRegion,
44
                   LayerManager::DrawPaintedLayerCallback aCallback,
45
                   void* aCallbackData,
46
                   TilePaintFlags aFlags = TilePaintFlags::None) override;
47
48
0
  bool SupportsProgressiveUpdate() override { return false; }
49
  bool ProgressiveUpdate(const nsIntRegion& aValidRegion,
50
                         const nsIntRegion& aInvalidRegion,
51
                         const nsIntRegion& aOldValidRegion,
52
                         nsIntRegion& aOutDrawnRegion,
53
                         BasicTiledLayerPaintData* aPaintData,
54
                         LayerManager::DrawPaintedLayerCallback aCallback,
55
                         void* aCallbackData) override
56
0
  {
57
0
    MOZ_ASSERT(false, "ProgressiveUpdate not supported!");
58
0
    return false;
59
0
  }
60
61
0
  void ResetPaintedAndValidState() override {
62
0
    mValidRegion.SetEmpty();
63
0
    mTile.DiscardBuffers();
64
0
  }
65
66
0
  const nsIntRegion& GetValidRegion() override {
67
0
    return mValidRegion;
68
0
  }
69
70
0
  bool IsLowPrecision() const override {
71
0
    return false;
72
0
  }
73
74
  void ReleaseTiles();
75
76
  void DiscardBuffers();
77
78
  SurfaceDescriptorTiles GetSurfaceDescriptorTiles();
79
80
private:
81
  TileClient mTile;
82
83
  RefPtr<ClientLayerManager> mManager;
84
85
  nsIntRegion mValidRegion;
86
  bool mWasLastPaintProgressive;
87
88
  /**
89
   * While we're adding tiles, this is used to keep track of the position of
90
   * the top-left of the top-left-most tile.  When we come to wrap the tiles in
91
   * TiledDrawTarget we subtract the value of this member from each tile's
92
   * offset so that all the tiles have a positive offset, then add a
93
   * translation to the TiledDrawTarget to compensate.  This is important so
94
   * that the mRect of the TiledDrawTarget is always at a positive x/y
95
   * position, otherwise its GetSize() methods will be broken.
96
   */
97
  gfx::IntPoint mTilingOrigin;
98
  gfx::IntSize mSize;
99
  gfxImageFormat mFormat;
100
};
101
102
class SingleTiledContentClient : public TiledContentClient
103
{
104
public:
105
  SingleTiledContentClient(ClientTiledPaintedLayer& aPaintedLayer,
106
                           ClientLayerManager* aManager);
107
108
protected:
109
  ~SingleTiledContentClient()
110
0
  {
111
0
    MOZ_COUNT_DTOR(SingleTiledContentClient);
112
0
113
0
    mTiledBuffer->ReleaseTiles();
114
0
  }
115
116
public:
117
  static bool ClientSupportsLayerSize(const gfx::IntSize& aSize, ClientLayerManager* aManager);
118
119
  virtual void ClearCachedResources() override;
120
121
  virtual void UpdatedBuffer(TiledBufferType aType) override;
122
123
0
  virtual ClientTiledLayerBuffer* GetTiledBuffer() override { return mTiledBuffer; }
124
0
  virtual ClientTiledLayerBuffer* GetLowPrecisionTiledBuffer() override { return nullptr; }
125
126
private:
127
  RefPtr<ClientSingleTiledLayerBuffer> mTiledBuffer;
128
};
129
130
}
131
}
132
133
#endif