summaryrefslogtreecommitdiff
path: root/Source/ThirdParty/ANGLE/src/libANGLE/renderer/Format.cpp
blob: 2443d33757d5e40357231f2190c85eddc1d9b321 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//
// Copyright 2016 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Format:
//   A universal description of texture storage. Across multiple
//   renderer back-ends, there are common formats and some distinct
//   permutations, this enum encapsulates them all.

#include "libANGLE/renderer/Format.h"

#include "image_util/copyimage.h"

using namespace rx;

namespace angle
{

namespace
{

const FastCopyFunctionMap &GetFastCopyFunctionsMap(Format::ID formatID)
{
    switch (formatID)
    {
        case Format::ID::B8G8R8A8_UNORM:
        {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wexit-time-destructors"
            static FastCopyFunctionMap fastCopyMap;
#pragma clang diagnostic pop
            if (fastCopyMap.empty())
            {
                fastCopyMap[gl::FormatType(GL_RGBA, GL_UNSIGNED_BYTE)] = CopyBGRA8ToRGBA8;
            }
            return fastCopyMap;
        }
        default:
        {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wexit-time-destructors"
            static FastCopyFunctionMap emptyMap;
#pragma clang diagnostic pop
            return emptyMap;
        }
    }
}

}  // anonymous namespace

Format::Format(ID id,
               GLenum glFormat,
               GLenum fboFormat,
               MipGenerationFunction mipGen,
               ColorReadFunction colorRead,
               GLenum componentType,
               GLuint redBits,
               GLuint greenBits,
               GLuint blueBits,
               GLuint alphaBits,
               GLuint depthBits,
               GLuint stencilBits)
    : id(id),
      glInternalFormat(glFormat),
      fboImplementationInternalFormat(fboFormat),
      mipGenerationFunction(mipGen),
      colorReadFunction(colorRead),
      fastCopyFunctions(GetFastCopyFunctionsMap(id)),
      componentType(componentType),
      redBits(redBits),
      greenBits(greenBits),
      blueBits(blueBits),
      alphaBits(alphaBits),
      depthBits(depthBits),
      stencilBits(stencilBits)
{
}

}  // namespace angle