OpenGL ES SDK for Android
ARM Developer Center
Home
Pages
Namespaces
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
ETCHeader.cpp
Go to the documentation of this file.
1
/* Copyright (c) 2012-2017, ARM Limited and Contributors
2
*
3
* SPDX-License-Identifier: MIT
4
*
5
* Permission is hereby granted, free of charge,
6
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
7
* to deal in the Software without restriction, including without limitation the rights to
8
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
9
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
10
*
11
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12
*
13
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
14
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
17
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19
*/
20
21
#include "ETCHeader.h"
22
23
namespace
MaliSDK
24
{
25
ETCHeader::ETCHeader
()
26
{
27
28
}
29
30
ETCHeader::ETCHeader
(
unsigned
char
*
data
)
31
{
32
/*
33
* Load from a ETC compressed pkm image file.
34
* First 6 bytes are the name of the file format and version/packing type.
35
* Bytes 7 and 8 are blank.
36
*/
37
/* Beware endianess issues with most/least significant bits of the height and width. */
38
paddedWidthMSB
= data[8];
39
paddedWidthLSB
= data[9];
40
paddedHeightMSB
= data[10];
41
paddedHeightLSB
= data[11];
42
widthMSB
= data[12];
43
widthLSB
= data[13];
44
heightMSB
= data[14];
45
heightLSB
= data[15];
46
}
47
48
unsigned
short
ETCHeader::getWidth
(
void
)
49
{
50
return
(
widthMSB
<< 8) |
widthLSB
;
51
}
52
53
unsigned
short
ETCHeader::getHeight
(
void
)
54
{
55
return
(
heightMSB
<< 8) |
heightLSB
;
56
}
57
58
unsigned
short
ETCHeader::getPaddedWidth
(
void
)
59
{
60
return
(
paddedWidthMSB
<< 8) |
paddedWidthLSB
;
61
}
62
63
unsigned
short
ETCHeader::getPaddedHeight
(
void
)
64
{
65
return
(
paddedHeightMSB
<< 8) |
paddedHeightLSB
;
66
}
67
68
#if GLES_VERSION == 2
69
GLsizei
ETCHeader::getSize
(
GLenum
internalFormat)
70
{
71
return
(
getPaddedWidth
() *
getPaddedHeight
());
72
}
73
#elif GLES_VERSION == 3
74
GLsizei
ETCHeader::getSize
(
GLenum
internalFormat)
75
{
76
if
(internalFormat != GL_COMPRESSED_RG11_EAC && internalFormat != GL_COMPRESSED_SIGNED_RG11_EAC &&
77
internalFormat != GL_COMPRESSED_RGBA8_ETC2_EAC && internalFormat != GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC)
78
{
79
return
(
getPaddedWidth
() *
getPaddedHeight
()) >> 1;
80
}
81
else
82
{
83
return
(
getPaddedWidth
() *
getPaddedHeight
());
84
}
85
}
86
#endif
87
}
MaliSDK::ETCHeader::getPaddedHeight
unsigned short getPaddedHeight(void)
The height of the compressed texture with the padding added.
Definition:
ETCHeader.cpp:63
MaliSDK::ETCHeader::heightLSB
unsigned char heightLSB
Definition:
ETCHeader.h:48
MaliSDK::ETCHeader::paddedHeightMSB
unsigned char paddedHeightMSB
Definition:
ETCHeader.h:43
MaliSDK::ETCHeader::paddedWidthLSB
unsigned char paddedWidthLSB
Definition:
ETCHeader.h:42
MaliSDK::ETCHeader::getHeight
unsigned short getHeight(void)
The height of the original texture.
Definition:
ETCHeader.cpp:53
data
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
Definition:
gl2ext.h:179
MaliSDK::ETCHeader::heightMSB
unsigned char heightMSB
Definition:
ETCHeader.h:47
MaliSDK::ETCHeader::getPaddedWidth
unsigned short getPaddedWidth(void)
The width of the compressed texture with the padding added.
Definition:
ETCHeader.cpp:58
MaliSDK::ETCHeader::widthMSB
unsigned char widthMSB
Definition:
ETCHeader.h:45
MaliSDK::ETCHeader::widthLSB
unsigned char widthLSB
Definition:
ETCHeader.h:46
MaliSDK::ETCHeader::paddedWidthMSB
unsigned char paddedWidthMSB
Definition:
ETCHeader.h:41
GLenum
typedef GLenum(GL_APIENTRYP PFNGLGETGRAPHICSRESETSTATUSKHRPROC)(void)
MaliSDK::ETCHeader::getWidth
unsigned short getWidth(void)
The width of the original texture.
Definition:
ETCHeader.cpp:48
MaliSDK::ETCHeader::getSize
GLsizei getSize(GLenum internalFormat)
The size of the compressed texture with the padding added.
Definition:
ETCHeader.cpp:66
MaliSDK::ETCHeader::paddedHeightLSB
unsigned char paddedHeightLSB
Definition:
ETCHeader.h:44
MaliSDK::ETCHeader::ETCHeader
ETCHeader()
Default constructor.
Definition:
ETCHeader.cpp:25
samples
advanced_samples
common_native
src
ETCHeader.cpp
(C) ARM Ltd. 2017