summaryrefslogtreecommitdiffstats
path: root/thirdparty/libktx/lib/texture.h
blob: e415a09d6a44ae3d6f51ce96a8caea1242bfee6c (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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/* -*- tab-width: 4; -*- */
/* vi: set sw=2 ts=4 expandtab textwidth=70: */

/*
 * Copyright 2019-2020 The Khronos Group Inc.
 * SPDX-License-Identifier: Apache-2.0
 */

/**
 * @internal
 * @file texture.h
 * @~English
 *
 * @brief Declare internal ktxTexture functions for sharing between
 *        compilation units.
 *
 * These functions are private and should not be used outside the library.
 */

#ifndef _TEXTURE_H_
#define _TEXTURE_H_

#include "ktx.h"
#include "formatsize.h"

#define DECLARE_PRIVATE(class) class ## _private* private = This->_private
#define DECLARE_PROTECTED(class) class ## _protected* prtctd = This->_protected;

#ifdef __cplusplus
extern "C" {
#endif

typedef enum {
    KTX_FORMAT_VERSION_ONE = 1,
    KTX_FORMAT_VERSION_TWO = 2
} ktxFormatVersionEnum;

typedef ktx_size_t (* PFNCALCDATASIZELEVELS)(ktxTexture* This,
                                             ktx_uint32_t levels);
typedef ktx_size_t (* PFNCALCFACELODSIZE)(ktxTexture* This, ktx_uint32_t level);
typedef ktx_size_t (* PFNCALCLEVELOFFSET)(ktxTexture* This, ktx_uint32_t level);
typedef struct ktxTexture_vtblInt {
    PFNCALCDATASIZELEVELS calcDataSizeLevels;
    PFNCALCFACELODSIZE calcFaceLodSize;
    PFNCALCLEVELOFFSET calcLevelOffset;
} ktxTexture_vtblInt;

#define ktxTexture_calcDataSizeLevels(This, levels) \
            This->_protected->_vtbl.calcDataSizeLevels(This, levels);
#define ktxTexture_calcFaceLodSize(This, level) \
            This->_protected->_vtbl.calcFaceLodSize(This, level);
#define ktxTexture_calcLevelOffset(This, level) \
            This->_protected->_vtbl.calcLevelOffset(This, level);

/**
 * @memberof ktxTexture
 * @~English
 *
 * @brief protected members of ktxTexture.
 */
typedef struct ktxTexture_protected {
    ktxTexture_vtblInt _vtbl;
    ktxFormatSize _formatSize;
    ktx_uint32_t _typeSize;
    ktxStream _stream;
} ktxTexture_protected;

#define ktxTexture_getStream(t) ((ktxStream*)(&(t)->_protected->_stream))
#define ktxTexture1_getStream(t1) ktxTexture_getStream((ktxTexture*)t1)
#define ktxTexture2_getStream(t2) ktxTexture_getStream((ktxTexture*)t2)

KTX_error_code
ktxTexture_iterateLoadedImages(ktxTexture* This, PFNKTXITERCB iterCb,
                               void* userdata);
KTX_error_code
ktxTexture_iterateSourceImages(ktxTexture* This, PFNKTXITERCB iterCb,
                               void* userdata);

ktx_size_t ktxTexture_calcDataSizeTexture(ktxTexture* This);
ktx_size_t ktxTexture_calcImageSize(ktxTexture* This, ktx_uint32_t level,
                                    ktxFormatVersionEnum fv);
ktx_bool_t ktxTexture_isActiveStream(ktxTexture* This);
ktx_size_t ktxTexture_calcLevelSize(ktxTexture* This, ktx_uint32_t level,
                                    ktxFormatVersionEnum fv);
ktx_size_t ktxTexture_doCalcFaceLodSize(ktxTexture* This, ktx_uint32_t level,
                                        ktxFormatVersionEnum fv);
ktx_size_t ktxTexture_layerSize(ktxTexture* This, ktx_uint32_t level,
                                ktxFormatVersionEnum fv);
void ktxTexture_rowInfo(ktxTexture* This, ktx_uint32_t level,
                        ktx_uint32_t* numRows, ktx_uint32_t* rowBytes,
                        ktx_uint32_t* rowPadding);
KTX_error_code
ktxTexture_construct(ktxTexture* This, ktxTextureCreateInfo* createInfo,
                     ktxFormatSize* formatSize);

KTX_error_code
ktxTexture_constructFromStream(ktxTexture* This, ktxStream* pStream,
                               ktxTextureCreateFlags createFlags);

void
ktxTexture_destruct(ktxTexture* This);

#ifdef __cplusplus
}
#endif

#endif /* _TEXTURE_H_ */