Skip to content

Commit 5e40f5e

Browse files
authored
remove tiff (#20047)
1 parent 19ce984 commit 5e40f5e

File tree

12 files changed

+5
-265
lines changed

12 files changed

+5
-265
lines changed

cocos/base/ccConfig.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -303,12 +303,6 @@ THE SOFTWARE.
303303
#define CC_USE_JPEG 1
304304
#endif // CC_USE_JPEG
305305

306-
/** Support TIFF or not. If your application don't use TIFF format picture, you can undefine this macro to save package size.
307-
*/
308-
#ifndef CC_USE_TIFF
309-
#define CC_USE_TIFF 1
310-
#endif // CC_USE_TIFF
311-
312306
/** Support webp or not. If your application don't use webp format picture, you can undefine this macro to save package size.
313307
*/
314308
#ifndef CC_USE_WEBP

cocos/platform/CCImage.cpp

Lines changed: 1 addition & 194 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ THE SOFTWARE.
3131
#include <ctype.h>
3232

3333
#include "base/CCData.h"
34-
#include "base/ccConfig.h" // CC_USE_JPEG, CC_USE_TIFF, CC_USE_WEBP
34+
#include "base/ccConfig.h" // CC_USE_JPEG, CC_USE_WEBP
3535

3636
extern "C"
3737
{
@@ -82,10 +82,6 @@ extern "C"
8282
#include "png.h"
8383
#endif //CC_USE_PNG
8484

85-
#if CC_USE_TIFF
86-
#include "tiffio.h"
87-
#endif //CC_USE_TIFF
88-
8985
#include "base/etc1.h"
9086

9187
#if CC_USE_JPEG
@@ -572,9 +568,6 @@ bool Image::initWithImageData(const unsigned char * data, ssize_t dataLen)
572568
case Format::JPG:
573569
ret = initWithJpgData(unpackedData, unpackedLen);
574570
break;
575-
case Format::TIFF:
576-
ret = initWithTiffData(unpackedData, unpackedLen);
577-
break;
578571
case Format::WEBP:
579572
ret = initWithWebpData(unpackedData, unpackedLen);
580573
break;
@@ -672,20 +665,6 @@ bool Image::isJpg(const unsigned char * data, ssize_t dataLen)
672665
return memcmp(data, JPG_SOI, 2) == 0;
673666
}
674667

675-
bool Image::isTiff(const unsigned char * data, ssize_t dataLen)
676-
{
677-
if (dataLen <= 4)
678-
{
679-
return false;
680-
}
681-
682-
static const char* TIFF_II = "II";
683-
static const char* TIFF_MM = "MM";
684-
685-
return (memcmp(data, TIFF_II, 2) == 0 && *(static_cast<const unsigned char*>(data) + 2) == 42 && *(static_cast<const unsigned char*>(data) + 3) == 0) ||
686-
(memcmp(data, TIFF_MM, 2) == 0 && *(static_cast<const unsigned char*>(data) + 2) == 0 && *(static_cast<const unsigned char*>(data) + 3) == 42);
687-
}
688-
689668
bool Image::isWebp(const unsigned char * data, ssize_t dataLen)
690669
{
691670
if (dataLen <= 12)
@@ -723,10 +702,6 @@ Image::Format Image::detectFormat(const unsigned char * data, ssize_t dataLen)
723702
{
724703
return Format::JPG;
725704
}
726-
else if (isTiff(data, dataLen))
727-
{
728-
return Format::TIFF;
729-
}
730705
else if (isWebp(data, dataLen))
731706
{
732707
return Format::WEBP;
@@ -1077,174 +1052,6 @@ bool Image::initWithPngData(const unsigned char * data, ssize_t dataLen)
10771052
#endif //CC_USE_PNG
10781053
}
10791054

1080-
#if CC_USE_TIFF
1081-
namespace
1082-
{
1083-
static tmsize_t tiffReadProc(thandle_t fd, void* buf, tmsize_t size)
1084-
{
1085-
tImageSource* isource = (tImageSource*)fd;
1086-
uint8* ma;
1087-
uint64 mb;
1088-
unsigned long n;
1089-
unsigned long o;
1090-
tmsize_t p;
1091-
ma=(uint8*)buf;
1092-
mb=size;
1093-
p=0;
1094-
while (mb>0)
1095-
{
1096-
n=0x80000000UL;
1097-
if ((uint64)n>mb)
1098-
n=(unsigned long)mb;
1099-
1100-
1101-
if ((int)(isource->offset + n) <= isource->size)
1102-
{
1103-
memcpy(ma, isource->data+isource->offset, n);
1104-
isource->offset += n;
1105-
o = n;
1106-
}
1107-
else
1108-
{
1109-
return 0;
1110-
}
1111-
1112-
ma+=o;
1113-
mb-=o;
1114-
p+=o;
1115-
if (o!=n)
1116-
{
1117-
break;
1118-
}
1119-
}
1120-
return p;
1121-
}
1122-
1123-
static tmsize_t tiffWriteProc(thandle_t /*fd*/, void* /*buf*/, tmsize_t /*size*/)
1124-
{
1125-
return 0;
1126-
}
1127-
1128-
1129-
static uint64 tiffSeekProc(thandle_t fd, uint64 off, int whence)
1130-
{
1131-
tImageSource* isource = (tImageSource*)fd;
1132-
uint64 ret = -1;
1133-
do
1134-
{
1135-
if (whence == SEEK_SET)
1136-
{
1137-
CC_BREAK_IF(off >= (uint64)isource->size);
1138-
ret = isource->offset = (uint32)off;
1139-
}
1140-
else if (whence == SEEK_CUR)
1141-
{
1142-
CC_BREAK_IF(isource->offset + off >= (uint64)isource->size);
1143-
ret = isource->offset += (uint32)off;
1144-
}
1145-
else if (whence == SEEK_END)
1146-
{
1147-
CC_BREAK_IF(off >= (uint64)isource->size);
1148-
ret = isource->offset = (uint32)(isource->size-1 - off);
1149-
}
1150-
else
1151-
{
1152-
CC_BREAK_IF(off >= (uint64)isource->size);
1153-
ret = isource->offset = (uint32)off;
1154-
}
1155-
} while (0);
1156-
1157-
return ret;
1158-
}
1159-
1160-
static uint64 tiffSizeProc(thandle_t fd)
1161-
{
1162-
tImageSource* imageSrc = (tImageSource*)fd;
1163-
return imageSrc->size;
1164-
}
1165-
1166-
static int tiffCloseProc(thandle_t /*fd*/)
1167-
{
1168-
return 0;
1169-
}
1170-
1171-
static int tiffMapProc(thandle_t /*fd*/, void** /*base*/, toff_t* /*size*/)
1172-
{
1173-
return 0;
1174-
}
1175-
1176-
static void tiffUnmapProc(thandle_t /*fd*/, void* /*base*/, toff_t /*size*/)
1177-
{
1178-
}
1179-
}
1180-
#endif // CC_USE_TIFF
1181-
1182-
bool Image::initWithTiffData(const unsigned char * data, ssize_t dataLen)
1183-
{
1184-
#if CC_USE_TIFF
1185-
bool ret = false;
1186-
do
1187-
{
1188-
// set the read call back function
1189-
tImageSource imageSource;
1190-
imageSource.data = data;
1191-
imageSource.size = dataLen;
1192-
imageSource.offset = 0;
1193-
1194-
TIFF* tif = TIFFClientOpen("file.tif", "r", (thandle_t)&imageSource,
1195-
tiffReadProc, tiffWriteProc,
1196-
tiffSeekProc, tiffCloseProc, tiffSizeProc,
1197-
tiffMapProc,
1198-
tiffUnmapProc);
1199-
1200-
CC_BREAK_IF(nullptr == tif);
1201-
1202-
uint32 w = 0, h = 0;
1203-
uint16 bitsPerSample = 0, samplePerPixel = 0, planarConfig = 0;
1204-
size_t npixels = 0;
1205-
1206-
TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w);
1207-
TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h);
1208-
TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &bitsPerSample);
1209-
TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &samplePerPixel);
1210-
TIFFGetField(tif, TIFFTAG_PLANARCONFIG, &planarConfig);
1211-
1212-
npixels = w * h;
1213-
1214-
_pixelFormat = backend::PixelFormat::RGBA8888;
1215-
_width = w;
1216-
_height = h;
1217-
1218-
_dataLen = npixels * sizeof (uint32);
1219-
_data = static_cast<unsigned char*>(malloc(_dataLen * sizeof(unsigned char)));
1220-
1221-
uint32* raster = (uint32*) _TIFFmalloc(npixels * sizeof (uint32));
1222-
if (raster != nullptr)
1223-
{
1224-
if (TIFFReadRGBAImageOriented(tif, w, h, raster, ORIENTATION_TOPLEFT, 0))
1225-
{
1226-
/* the raster data is pre-multiplied by the alpha component
1227-
after invoking TIFFReadRGBAImageOriented*/
1228-
_hasPremultipliedAlpha = true;
1229-
1230-
memcpy(_data, raster, npixels*sizeof (uint32));
1231-
}
1232-
1233-
_TIFFfree(raster);
1234-
}
1235-
1236-
1237-
TIFFClose(tif);
1238-
1239-
ret = true;
1240-
} while (0);
1241-
return ret;
1242-
#else
1243-
CCLOG("tiff is not enabled, please enable it in ccConfig.h");
1244-
return false;
1245-
#endif //CC_USE_TIFF
1246-
}
1247-
12481055
namespace
12491056
{
12501057
bool testFormatForPvr2TCSupport(PVR2TexturePixelFormat /*format*/)

cocos/platform/CCImage.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ class CC_DLL Image : public Ref
7777
JPG,
7878
//! PNG
7979
PNG,
80-
//! TIFF
81-
TIFF,
8280
//! WebP
8381
WEBP,
8482
//! PVR
@@ -161,7 +159,6 @@ class CC_DLL Image : public Ref
161159
protected:
162160
bool initWithJpgData(const unsigned char * data, ssize_t dataLen);
163161
bool initWithPngData(const unsigned char * data, ssize_t dataLen);
164-
bool initWithTiffData(const unsigned char * data, ssize_t dataLen);
165162
bool initWithWebpData(const unsigned char * data, ssize_t dataLen);
166163
bool initWithPVRData(const unsigned char * data, ssize_t dataLen);
167164
bool initWithPVRv2Data(const unsigned char * data, ssize_t dataLen);
@@ -218,7 +215,6 @@ class CC_DLL Image : public Ref
218215
Format detectFormat(const unsigned char * data, ssize_t dataLen);
219216
bool isPng(const unsigned char * data, ssize_t dataLen);
220217
bool isJpg(const unsigned char * data, ssize_t dataLen);
221-
bool isTiff(const unsigned char * data, ssize_t dataLen);
222218
bool isWebp(const unsigned char * data, ssize_t dataLen);
223219
bool isPvr(const unsigned char * data, ssize_t dataLen);
224220
bool isEtc(const unsigned char * data, ssize_t dataLen);

cocos/renderer/CCTextureCache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class CC_DLL TextureCache : public Ref
8989
* If the filename was not previously loaded, it will create a new Texture2D.
9090
* Object and it will return it. It will use the filename as a key.
9191
* Otherwise it will return a reference of a previously loaded image.
92-
* Supported image extensions: .png, .bmp, .tiff, .jpeg, .pvr.
92+
* Supported image extensions: .png, .bmp, .jpeg, .pvr.
9393
@param filepath The file path.
9494
*/
9595
Texture2D* addImage(const std::string &filepath);

external/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "metal-support-10",
2+
"version": "metal-support-11",
33
"zip_file_size": "146254799",
44
"repo_name": "cocos2d-x-3rd-party-libs-bin",
55
"repo_parent": "https://github.com/cocos2d/",

templates/lua-template-default/cocos-project-template.json

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,7 @@
9090
"include": [
9191
"*.dll"
9292
]
93-
},
94-
{
95-
"from": "external/tiff/prebuilt/win32",
96-
"to": "runtime/win32",
97-
"include": [
98-
"*.dll"
99-
]
10093
}
101-
10294
]
10395
},
10496
"do_add_native_support": {

tests/cpp-tests/Classes/ActionsEaseTest/ActionsEaseTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1031,7 +1031,7 @@ void EaseSpriteDemo::onEnter()
10311031
{
10321032
TestCase::onEnter();
10331033

1034-
// Or you can create an sprite using a filename. PNG and BMP files are supported. Probably TIFF too
1034+
// Or you can create an sprite using a filename. PNG and BMP files are supported.
10351035
_grossini = Sprite::create(s_pathGrossini); _grossini->retain();
10361036
_tamara = Sprite::create(s_pathSister1); _tamara->retain();
10371037
_kathia = Sprite::create(s_pathSister2); _kathia->retain();

tests/cpp-tests/Classes/ActionsTest/ActionsTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ void ActionsDemo::onEnter()
106106
{
107107
TestCase::onEnter();
108108

109-
// Or you can create an sprite using a filename. only PNG is supported now. Probably TIFF too
109+
// Or you can create an sprite using a filename. only PNG is supported now.
110110
_grossini = Sprite::create(s_pathGrossini);
111111
_grossini->retain();
112112

tests/cpp-tests/Classes/Texture2dTest/Texture2dTest.cpp

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ Texture2DTests::Texture2DTests()
7878
ADD_TEST_CASE(TexturePVRBadEncoding);
7979
ADD_TEST_CASE(TexturePNG);
8080
ADD_TEST_CASE(TextureJPEG);
81-
ADD_TEST_CASE(TextureTIFF);
8281
ADD_TEST_CASE(TextureTGA);
8382
ADD_TEST_CASE(TextureWEBP);
8483
ADD_TEST_CASE(TextureWEBPNoAlpha)
@@ -132,29 +131,6 @@ TextureDemo::~TextureDemo()
132131
log("%s\n", textureCache->getCachedTextureInfo().c_str());
133132
}
134133

135-
//------------------------------------------------------------------
136-
//
137-
// TextureTIFF
138-
//
139-
//------------------------------------------------------------------
140-
141-
void TextureTIFF::onEnter()
142-
{
143-
TextureDemo::onEnter();
144-
auto s = Director::getInstance()->getWinSize();
145-
146-
auto img = Sprite::create("Images/test_image.tiff");
147-
img->setPosition(Vec2( s.width/2.0f, s.height/2.0f));
148-
this->addChild(img);
149-
150-
log("%s\n", Director::getInstance()->getTextureCache()->getCachedTextureInfo().c_str());
151-
}
152-
153-
std::string TextureTIFF::title() const
154-
{
155-
return "TIFF Test";
156-
}
157-
158134

159135
//------------------------------------------------------------------
160136
//

tests/cpp-tests/Classes/Texture2dTest/Texture2dTest.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,6 @@ class TextureDemo : public TestCase
3838
virtual void onEnter() override;
3939
};
4040

41-
class TextureTIFF : public TextureDemo
42-
{
43-
public:
44-
CREATE_FUNC(TextureTIFF);
45-
virtual std::string title() const override;
46-
virtual void onEnter() override;
47-
};
48-
4941

5042
class TextureTGA : public TextureDemo
5143
{

0 commit comments

Comments
 (0)