Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/gfx/layers/mlgpu/CanvasLayerMLGPU.cpp
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
#include "CanvasLayerMLGPU.h"
8
#include "composite/CompositableHost.h"  // for CompositableHost
9
#include "gfx2DGlue.h"                  // for ToFilter
10
#include "gfxEnv.h"                     // for gfxEnv, etc
11
#include "mozilla/gfx/Matrix.h"         // for Matrix4x4
12
#include "mozilla/gfx/Point.h"          // for Point
13
#include "mozilla/gfx/Rect.h"           // for Rect
14
#include "mozilla/layers/Compositor.h"  // for Compositor
15
#include "mozilla/layers/Effects.h"     // for EffectChain
16
#include "mozilla/layers/ImageHost.h"
17
#include "mozilla/mozalloc.h"           // for operator delete
18
#include "nsAString.h"
19
#include "mozilla/RefPtr.h"                   // for nsRefPtr
20
#include "MaskOperation.h"
21
#include "nsISupportsImpl.h"            // for MOZ_COUNT_CTOR, etc
22
#include "nsString.h"                   // for nsAutoCString
23
24
namespace mozilla {
25
namespace layers {
26
27
using namespace mozilla::gfx;
28
29
CanvasLayerMLGPU::CanvasLayerMLGPU(LayerManagerMLGPU* aManager)
30
  : CanvasLayer(aManager, nullptr)
31
  , TexturedLayerMLGPU(aManager)
32
0
{
33
0
}
34
35
CanvasLayerMLGPU::~CanvasLayerMLGPU()
36
0
{
37
0
  CleanupResources();
38
0
}
39
40
Layer*
41
CanvasLayerMLGPU::GetLayer()
42
0
{
43
0
  return this;
44
0
}
45
46
gfx::SamplingFilter
47
CanvasLayerMLGPU::GetSamplingFilter()
48
0
{
49
0
  gfx::SamplingFilter filter = mSamplingFilter;
50
#ifdef ANDROID
51
  // Bug 691354
52
  // Using the LINEAR filter we get unexplained artifacts.
53
  // Use NEAREST when no scaling is required.
54
  Matrix matrix;
55
  bool is2D = GetEffectiveTransform().Is2D(&matrix);
56
  if (is2D && !ThebesMatrix(matrix).HasNonTranslationOrFlip()) {
57
    filter = SamplingFilter::POINT;
58
  }
59
#endif
60
  return filter;
61
0
}
62
63
void
64
CanvasLayerMLGPU::PrintInfo(std::stringstream& aStream, const char* aPrefix)
65
0
{
66
0
  CanvasLayer::PrintInfo(aStream, aPrefix);
67
0
  aStream << "\n";
68
0
  if (mHost && mHost->IsAttached()) {
69
0
    nsAutoCString pfx(aPrefix);
70
0
    pfx += "  ";
71
0
    mHost->PrintInfo(aStream, pfx.get());
72
0
  }
73
0
}
74
75
void
76
CanvasLayerMLGPU::CleanupResources()
77
0
{
78
0
  if (mHost) {
79
0
    mHost->Detach(this);
80
0
  }
81
0
  mTexture = nullptr;
82
0
  mBigImageTexture = nullptr;
83
0
  mHost = nullptr;
84
0
}
85
86
void
87
CanvasLayerMLGPU::Disconnect()
88
0
{
89
0
  CleanupResources();
90
0
}
91
92
void
93
CanvasLayerMLGPU::ClearCachedResources()
94
0
{
95
0
  CleanupResources();
96
0
}
97
98
void
99
CanvasLayerMLGPU::SetRenderRegion(LayerIntRegion&& aRegion)
100
0
{
101
0
  aRegion.AndWith(LayerIntRect::FromUnknownRect(mPictureRect));
102
0
  LayerMLGPU::SetRenderRegion(std::move(aRegion));
103
0
}
104
105
} // namespace layers
106
} // namespace mozilla