1/* -*- tab-width: 4; -*- */
2/* vi: set sw=2 ts=4 expandtab textwidth=70: */
3
4/*
5 * Copyright 2019-2020 The Khronos Group Inc.
6 * SPDX-License-Identifier: Apache-2.0
7 */
8
9/**
10 * @internal
11 * @file texture.h
12 * @~English
13 *
14 * @brief Declare internal ktxTexture functions for sharing between
15 * compilation units.
16 *
17 * These functions are private and should not be used outside the library.
18 */
19
20#ifndef _TEXTURE_H_
21#define _TEXTURE_H_
22
23#include "ktx.h"
24#include "formatsize.h"
25
26#define DECLARE_PRIVATE(class) class ## _private* private = This->_private
27#define DECLARE_PROTECTED(class) class ## _protected* prtctd = This->_protected;
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33typedef enum {
34 KTX_FORMAT_VERSION_ONE = 1,
35 KTX_FORMAT_VERSION_TWO = 2
36} ktxFormatVersionEnum;
37
38typedef ktx_size_t (* PFNCALCDATASIZELEVELS)(ktxTexture* This,
39 ktx_uint32_t levels);
40typedef ktx_size_t (* PFNCALCFACELODSIZE)(ktxTexture* This, ktx_uint32_t level);
41typedef ktx_size_t (* PFNCALCLEVELOFFSET)(ktxTexture* This, ktx_uint32_t level);
42typedef struct ktxTexture_vtblInt {
43 PFNCALCDATASIZELEVELS calcDataSizeLevels;
44 PFNCALCFACELODSIZE calcFaceLodSize;
45 PFNCALCLEVELOFFSET calcLevelOffset;
46} ktxTexture_vtblInt;
47
48#define ktxTexture_calcDataSizeLevels(This, levels) \
49 This->_protected->_vtbl.calcDataSizeLevels(This, levels);
50#define ktxTexture_calcFaceLodSize(This, level) \
51 This->_protected->_vtbl.calcFaceLodSize(This, level);
52#define ktxTexture_calcLevelOffset(This, level) \
53 This->_protected->_vtbl.calcLevelOffset(This, level);
54
55/**
56 * @memberof ktxTexture
57 * @~English
58 *
59 * @brief protected members of ktxTexture.
60 */
61typedef struct ktxTexture_protected {
62 ktxTexture_vtblInt _vtbl;
63 ktxFormatSize _formatSize;
64 ktx_uint32_t _typeSize;
65 ktxStream _stream;
66} ktxTexture_protected;
67
68#define ktxTexture_getStream(t) ((ktxStream*)(&(t)->_protected->_stream))
69#define ktxTexture1_getStream(t1) ktxTexture_getStream((ktxTexture*)t1)
70#define ktxTexture2_getStream(t2) ktxTexture_getStream((ktxTexture*)t2)
71
72KTX_error_code
73ktxTexture_iterateLoadedImages(ktxTexture* This, PFNKTXITERCB iterCb,
74 void* userdata);
75KTX_error_code
76ktxTexture_iterateSourceImages(ktxTexture* This, PFNKTXITERCB iterCb,
77 void* userdata);
78
79ktx_size_t ktxTexture_calcDataSizeTexture(ktxTexture* This);
80ktx_size_t ktxTexture_calcImageSize(ktxTexture* This, ktx_uint32_t level,
81 ktxFormatVersionEnum fv);
82ktx_bool_t ktxTexture_isActiveStream(ktxTexture* This);
83ktx_size_t ktxTexture_calcLevelSize(ktxTexture* This, ktx_uint32_t level,
84 ktxFormatVersionEnum fv);
85ktx_size_t ktxTexture_doCalcFaceLodSize(ktxTexture* This, ktx_uint32_t level,
86 ktxFormatVersionEnum fv);
87ktx_size_t ktxTexture_layerSize(ktxTexture* This, ktx_uint32_t level,
88 ktxFormatVersionEnum fv);
89void ktxTexture_rowInfo(ktxTexture* This, ktx_uint32_t level,
90 ktx_uint32_t* numRows, ktx_uint32_t* rowBytes,
91 ktx_uint32_t* rowPadding);
92KTX_error_code
93ktxTexture_construct(ktxTexture* This, ktxTextureCreateInfo* createInfo,
94 ktxFormatSize* formatSize);
95
96KTX_error_code
97ktxTexture_constructFromStream(ktxTexture* This, ktxStream* pStream,
98 ktxTextureCreateFlags createFlags);
99
100void
101ktxTexture_destruct(ktxTexture* This);
102
103#ifdef __cplusplus
104}
105#endif
106
107#endif /* _TEXTURE_H_ */
108