Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/layout/painting/BorderCache.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_BorderCache_h_
8
#define mozilla_BorderCache_h_
9
10
#include "mozilla/gfx/2D.h"
11
#include "mozilla/HashFunctions.h"
12
#include "nsDataHashtable.h"
13
#include "PLDHashTable.h"
14
15
namespace mozilla {
16
// Cache for best overlap and best dashLength.
17
18
struct FourFloats
19
{
20
  typedef mozilla::gfx::Float Float;
21
22
  Float n[4];
23
24
  FourFloats()
25
0
  {
26
0
    n[0] = 0.0f;
27
0
    n[1] = 0.0f;
28
0
    n[2] = 0.0f;
29
0
    n[3] = 0.0f;
30
0
  }
31
32
  FourFloats(Float a, Float b, Float c, Float d)
33
0
  {
34
0
    n[0] = a;
35
0
    n[1] = b;
36
0
    n[2] = c;
37
0
    n[3] = d;
38
0
  }
39
40
  bool operator==(const FourFloats& aOther) const
41
0
  {
42
0
    return n[0] == aOther.n[0] && n[1] == aOther.n[1] && n[2] == aOther.n[2] &&
43
0
           n[3] == aOther.n[3];
44
0
  }
45
};
46
47
class FourFloatsHashKey : public PLDHashEntryHdr
48
{
49
public:
50
  typedef const FourFloats& KeyType;
51
  typedef const FourFloats* KeyTypePointer;
52
53
  explicit FourFloatsHashKey(KeyTypePointer aKey)
54
    : mValue(*aKey)
55
0
  {
56
0
  }
57
  FourFloatsHashKey(const FourFloatsHashKey& aToCopy)
58
    : mValue(aToCopy.mValue)
59
0
  {
60
0
  }
61
  ~FourFloatsHashKey() = default;
62
63
0
  KeyType GetKey() const { return mValue; }
64
0
  bool KeyEquals(KeyTypePointer aKey) const { return *aKey == mValue; }
65
66
0
  static KeyTypePointer KeyToPointer(KeyType aKey) { return &aKey; }
67
  static PLDHashNumber HashKey(KeyTypePointer aKey)
68
0
  {
69
0
    return HashBytes(aKey->n, sizeof(mozilla::gfx::Float) * 4);
70
0
  }
71
  enum
72
  {
73
    ALLOW_MEMMOVE = true
74
  };
75
76
private:
77
  const FourFloats mValue;
78
};
79
80
} // namespace mozilla
81
82
#endif /* mozilla_BorderCache_h_ */