mirror of https://github.com/axmolengine/axmol.git
Merge remote-tracking branch 'cocos2d/develop' into new_develop_merge
Conflicts: cocos2d_libs.xcodeproj/project.pbxproj cocos2dx/include/ccTypes.h samples/samples.xcodeproj/project.pbxproj
This commit is contained in:
commit
b2579987e5
12
AUTHORS
12
AUTHORS
|
@ -70,7 +70,8 @@ Developers:
|
||||||
Refactoring network extension and fixing unlikely memory leaks.
|
Refactoring network extension and fixing unlikely memory leaks.
|
||||||
Adding PUT/DELETE methods for CCHttpRequest.
|
Adding PUT/DELETE methods for CCHttpRequest.
|
||||||
Adding project part for QtCreator.
|
Adding project part for QtCreator.
|
||||||
Implemented pitch, pan and gain
|
Implemented pitch, pan and gain.
|
||||||
|
Using SDL backend instead of glfw for Linux.
|
||||||
|
|
||||||
savdalion
|
savdalion
|
||||||
Added example for russian language in TestCpp
|
Added example for russian language in TestCpp
|
||||||
|
@ -417,6 +418,8 @@ Developers:
|
||||||
Creation of CCDeprecated-ext.h
|
Creation of CCDeprecated-ext.h
|
||||||
Use of a single emscripten HTML template file.
|
Use of a single emscripten HTML template file.
|
||||||
Added some guards in fileutils. Fixed a bug in emscripten file utils.
|
Added some guards in fileutils. Fixed a bug in emscripten file utils.
|
||||||
|
Added emscripten keyboard support
|
||||||
|
Clang support for Linux
|
||||||
|
|
||||||
elmiro
|
elmiro
|
||||||
Correction of passed buffer size to readlink and verification of result return by readlink.
|
Correction of passed buffer size to readlink and verification of result return by readlink.
|
||||||
|
@ -543,6 +546,9 @@ Developers:
|
||||||
|
|
||||||
metalbass
|
metalbass
|
||||||
Fixing an issue that sigslot::_connection_base# (from 0 to 8) don't have virtual destructors.
|
Fixing an issue that sigslot::_connection_base# (from 0 to 8) don't have virtual destructors.
|
||||||
|
|
||||||
|
thp
|
||||||
|
Port Cocos2D-X to Qt 5
|
||||||
|
|
||||||
Retired Core Developers:
|
Retired Core Developers:
|
||||||
WenSheng Yang
|
WenSheng Yang
|
||||||
|
@ -564,6 +570,10 @@ Retired Core Developers:
|
||||||
|
|
||||||
metadao
|
metadao
|
||||||
make create_project.py more pythonic and fix some typoes
|
make create_project.py more pythonic and fix some typoes
|
||||||
|
|
||||||
|
timothyqiu
|
||||||
|
Project creator: use absolute path for json config files
|
||||||
|
Documentation fixes
|
||||||
|
|
||||||
|
|
||||||
Cocos2d-x can not grow so fast without the active community.
|
Cocos2d-x can not grow so fast without the active community.
|
||||||
|
|
89
CHANGELOG
89
CHANGELOG
|
@ -1,6 +1,91 @@
|
||||||
cocos2d-x-3.0alpha0-pre @Jul.24 2013
|
cocos2d-x-3.0alpha0-pre @Jul.30 2013
|
||||||
[all platforms]
|
[all platforms]
|
||||||
Feature #XXXX: Add support for std::function<> in CCMemuItem and CCCallFunc
|
[FIX] #2124: Image::initWithImageFileThreadSafe is not thread safe
|
||||||
|
[FIX] #2230: Node::onEnterTransitionDidFinish was called twice when a node is added in Node::onEnter
|
||||||
|
[FIX] #2237: calculation offset in font rendering
|
||||||
|
[FIX] #2303: missing precision when getting strokeColor and fontFillColor
|
||||||
|
[FIX] #2312: WebSocket can not parse url like "ws://domain.com/websocket"
|
||||||
|
[FIX] #2327: implement Node::isScheduled
|
||||||
|
[FIX] #2338: ccbRootPath is not passed to sub ccb nodes
|
||||||
|
[FIX] #2346: OpenGL error 0x0502 in TextureAtlas::drawNumberOfQuads
|
||||||
|
[FIX] #2359: Sprite will become white block when using ControlSwitch
|
||||||
|
[FIX] #2361: some bug fixed of the Set class
|
||||||
|
[FIX] #2366: text shadow
|
||||||
|
[FIX] #2367: ClippingNode works differently on different platforms
|
||||||
|
[FIX] #2370: Pivotjoint constructor and pointQueryFirst in Space class will return false instead of invalid shape object
|
||||||
|
[FIX] #2381: ControlSwitch wasn't displayed correctly when adding more than one switch
|
||||||
|
[FIX] #2384: The submenu of ExtensionTest in TestCpp can't scroll
|
||||||
|
[FIX] #2386: ClippingNode works wrongly when being set as a child
|
||||||
|
[FIX] #2396: Scale9Sprite::setInsetLeft/XXX can't work for rotated sprite frame
|
||||||
|
[FIX] #2401: LabelBMFont crashes in glDrawElements of CCTextureAtlas::drawNumberOfQuads randombly
|
||||||
|
[FIX] #2410: Black screen appears on android randomly
|
||||||
|
[FIX] #2411: Opacity option for shadow in CCLabelTTF is not working
|
||||||
|
[FIX] #2406: Color and Opacity of Scale9Sprite will not be changed when it's added to NodeRGBA and run with FadeIn/Out actions
|
||||||
|
[FIX] #2415: Warning of AL_INVALID_NAME and AL_INVALID_OPERATION in SimpleAudioEngineOpenAL.cpp
|
||||||
|
[FIX] #2418: Unused spriteframes also need to be removed when purgeCachedData
|
||||||
|
[FIX] #2431: Potential crash when loading js files
|
||||||
|
[FIX] #2229: Explicitly initialising CCAcceleration structure
|
||||||
|
[FIX] #2234: Add destructor to CCGLBufferedNode
|
||||||
|
[Feature] #2232: adding Norwegian language support
|
||||||
|
[Feature] #2235: Ability to save/retrieve CCData into/from CCUserDefault
|
||||||
|
[Feature] #2250: add support for std::function<> in CCMemuItem and CCCallFunc
|
||||||
|
[Feature] #2273: Hardware keyboard support
|
||||||
|
[Feature] #2278: Adds CALLBACK_0, CALLBACK_1 and CALLBACK_2 macros for MenuItems
|
||||||
|
[Feature] #2279: Updates chipmunk2d to v6.1.5
|
||||||
|
[Feature] #2283: Adds Polish language support
|
||||||
|
[Feature] #2289: Uses clone() pattern for actions
|
||||||
|
[Feature] #2332: Adding project for QtCreator
|
||||||
|
[Feature] #2364: Adds DrawPrimitives::DrawSolidCircle
|
||||||
|
[Feature] #2365: Adds Rect::unionWithRect
|
||||||
|
[Feature] #2385: Implemented pitch, pan and gain for SimpleAudioEngine
|
||||||
|
[Feature] #2389: Adding cookie support for HttpClient
|
||||||
|
[Feature] #2392: Adds append() function for String class
|
||||||
|
[Feature] #2395: Adds Scale9SpriteTest for TestCpp
|
||||||
|
[Feature] #2399: Adds SocketIO support
|
||||||
|
[Feature] #2408: Adds String::componentsSeparatedByString function for splitting string
|
||||||
|
[Feature] #2414: Bindings-generator could bind std::function<> argument
|
||||||
|
[Refactor] #2129: Removes Hungarian notation from ivars. Removes CC and cc prefixes from name classes and free functions.
|
||||||
|
[Refactor] #2242: Enables c++11
|
||||||
|
[Refactor] #2300: Using clone() pattern instead of 'copyWithZone' pattern
|
||||||
|
[Refactor] #2305: Use std::thread instead of pthread
|
||||||
|
[Refactor] #2328: ETC support for all platforms
|
||||||
|
[Refactor] #2373: Change some member functions to const
|
||||||
|
[Refactor] #2378: Remove the usage of CC_PROPERTY_XXX in engine code
|
||||||
|
[Refactor] #2388: Creating a default texture for CCSprite if setTexture(nullptr) is invoked
|
||||||
|
[Refactor] #2397: Singleton refactor, sharedXXX --> getInstance, purgeXXX --> destroyInstance
|
||||||
|
[Refactor] #2404: Move all deprecated global functions and variables into CCDeprecated.h
|
||||||
|
[Refactor] #2430: Uses strongly typed enums (enum class) instead of simple enums
|
||||||
|
[iOS]
|
||||||
|
[FIX] #2274: compile and run for iOS7 and Xcode5
|
||||||
|
[Refactor] #2371: use one single Xcode project for iOS and Mac projects
|
||||||
|
[Android]
|
||||||
|
[FIX] #2306: CCLabelTTF::setString crash
|
||||||
|
[Refactor] #2329: use Android "asset manager" to improve file system read performance
|
||||||
|
[Refactor] #2400: use onWindowFocusChanged(bool) instead of onResume()/onPause()
|
||||||
|
[OS X]
|
||||||
|
[FIX] #2275: LabelTTF vertical alignment
|
||||||
|
[FIX] #2398: Add support for initializing Image with raw data
|
||||||
|
[windows]
|
||||||
|
[FIX] #2322: link error becasue of using multiply inheritance
|
||||||
|
[javascript binding]
|
||||||
|
[FIX] #2307: PhysicsSprite::getCPBody return wrong type
|
||||||
|
[FIX] #2313: bind cc.ClippingNode
|
||||||
|
[FIX] #2315: iterating through cc.Node children crash
|
||||||
|
[Feature] #2285: bind MontionStreak
|
||||||
|
[Feature] #2340: Updates SpiderMonekey to Firefox v22 (JS Bindings)
|
||||||
|
[Feature] #2427: bind FileUtils.getInstance().createDictionaryWithContentsOfFile
|
||||||
|
[lua binding]
|
||||||
|
[Feature] #2276: Add CCScrollView lua binding and corresponding test sample
|
||||||
|
[Feature] #2277: Add OpenGL lua binding and corresponding test sample
|
||||||
|
[Feature] #2324: Add OpenGL lua module
|
||||||
|
[Feature] #2343: Redesign the mechanism of invoking lua func from c++
|
||||||
|
[Feature] #2344: make some execute functions into one function in ScriptEngineProtocol
|
||||||
|
[Feature] #2426: Add DrawPrimitives test sample
|
||||||
|
[Feature] #2429: LuaWebSocket supports sending binary string
|
||||||
|
[plugin-x]
|
||||||
|
[FIX] #2348: event will not be sent to server when paramMap argument of logEvent function is nil
|
||||||
|
[Emscript]
|
||||||
|
[Feature] #2289: Asynchronous Image loading
|
||||||
|
|
||||||
|
|
||||||
2.1rc0-x-2.1.4 @Jnue.12 2013
|
2.1rc0-x-2.1.4 @Jnue.12 2013
|
||||||
|
|
|
@ -74,7 +74,7 @@ SimpleAudioEngine::SimpleAudioEngine()
|
||||||
|
|
||||||
const char* deviceModel = methodInfo.env->GetStringUTFChars(jstr, NULL);
|
const char* deviceModel = methodInfo.env->GetStringUTFChars(jstr, NULL);
|
||||||
|
|
||||||
LOGD(deviceModel);
|
LOGD("%s", deviceModel);
|
||||||
|
|
||||||
if (strcmp(I9100_MODEL, deviceModel) == 0)
|
if (strcmp(I9100_MODEL, deviceModel) == 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -371,7 +371,7 @@ void OpenSLEngine::createEngine(void* pHandle)
|
||||||
const char* errorInfo = dlerror();
|
const char* errorInfo = dlerror();
|
||||||
if (errorInfo)
|
if (errorInfo)
|
||||||
{
|
{
|
||||||
LOGD(errorInfo);
|
LOGD("%s", errorInfo);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ bool SimpleAudioEngineOpenSL::initEngine()
|
||||||
const char* errorInfo = dlerror();
|
const char* errorInfo = dlerror();
|
||||||
if (errorInfo)
|
if (errorInfo)
|
||||||
{
|
{
|
||||||
LOGD(errorInfo);
|
LOGD("%s", errorInfo);
|
||||||
bRet = false;
|
bRet = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
|
||||||
|
include(../../cocos2dx/proj.qt5/common.pri)
|
||||||
|
|
||||||
|
TEMPLATE = lib
|
||||||
|
|
||||||
|
SOURCES += $$files(../qt5/*.cpp)
|
||||||
|
|
||||||
|
INCLUDEPATH += ..
|
||||||
|
INCLUDEPATH += ../include
|
||||||
|
|
||||||
|
TARGET = $${LIB_OUTPUT_DIR}/cocosdenshion
|
||||||
|
|
||||||
|
INSTALLS += target
|
||||||
|
target.path = $${LIB_INSTALL_DIR}
|
||||||
|
|
|
@ -0,0 +1,407 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Cocos2D-X Qt 5 Platform
|
||||||
|
*
|
||||||
|
* Copyright (C) 2013 Jolla Ltd.
|
||||||
|
* Contact: Thomas Perl <thomas.perl@jollamobile.com>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
|
||||||
|
|
||||||
|
#include "SimpleAudioEngine.h"
|
||||||
|
|
||||||
|
#include "platform/CCCommon.h"
|
||||||
|
#include "platform/CCFileUtils.h"
|
||||||
|
|
||||||
|
#include <QMap>
|
||||||
|
#include <QMediaPlayer>
|
||||||
|
|
||||||
|
USING_NS_CC;
|
||||||
|
|
||||||
|
namespace CocosDenshion {
|
||||||
|
|
||||||
|
static QString
|
||||||
|
fullPath(const char *filename)
|
||||||
|
{
|
||||||
|
return QString::fromStdString(FileUtils::getInstance()->fullPathForFilename(filename));
|
||||||
|
}
|
||||||
|
|
||||||
|
class CocosQt5AudioBackend {
|
||||||
|
public:
|
||||||
|
static void cleanup();
|
||||||
|
static void gcEffects();
|
||||||
|
|
||||||
|
static QMediaPlayer *player() {
|
||||||
|
if (background_music == NULL) {
|
||||||
|
background_music = new QMediaPlayer;
|
||||||
|
}
|
||||||
|
|
||||||
|
return background_music;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void setEffectsVolume(float volume)
|
||||||
|
{
|
||||||
|
effects_volume = volume;
|
||||||
|
|
||||||
|
foreach (QMediaPlayer *effect, effects.values()) {
|
||||||
|
effect->setVolume(volume * 100.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static QMap<int,QMediaPlayer*> effects;
|
||||||
|
static QMediaPlayer *background_music;
|
||||||
|
static int next_effect_id;
|
||||||
|
static float effects_volume;
|
||||||
|
};
|
||||||
|
|
||||||
|
QMap<int,QMediaPlayer*>
|
||||||
|
CocosQt5AudioBackend::effects;
|
||||||
|
|
||||||
|
QMediaPlayer *
|
||||||
|
CocosQt5AudioBackend::background_music = NULL;
|
||||||
|
|
||||||
|
int
|
||||||
|
CocosQt5AudioBackend::next_effect_id = 0;
|
||||||
|
|
||||||
|
float
|
||||||
|
CocosQt5AudioBackend::effects_volume = 1.0;
|
||||||
|
|
||||||
|
void
|
||||||
|
CocosQt5AudioBackend::cleanup()
|
||||||
|
{
|
||||||
|
foreach (QMediaPlayer *effect, effects.values()) {
|
||||||
|
delete effect;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (background_music != NULL) {
|
||||||
|
delete background_music;
|
||||||
|
background_music = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
CocosQt5AudioBackend::gcEffects()
|
||||||
|
{
|
||||||
|
foreach (int id, effects.keys()) {
|
||||||
|
QMediaPlayer *effect = effects[id];
|
||||||
|
if (effect->state() == QMediaPlayer::StoppedState) {
|
||||||
|
delete effect;
|
||||||
|
effects.remove(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Singleton object */
|
||||||
|
static SimpleAudioEngine *
|
||||||
|
simple_audio_engine = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Get the shared Engine object,it will new one when first time be called
|
||||||
|
*/
|
||||||
|
SimpleAudioEngine *
|
||||||
|
SimpleAudioEngine::getInstance()
|
||||||
|
{
|
||||||
|
if (simple_audio_engine == NULL) {
|
||||||
|
simple_audio_engine = new SimpleAudioEngine;
|
||||||
|
}
|
||||||
|
|
||||||
|
return simple_audio_engine;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Release the shared Engine object
|
||||||
|
@warning It must be called before the application exit, or a memroy leak will be casued.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
SimpleAudioEngine::end()
|
||||||
|
{
|
||||||
|
if (simple_audio_engine != NULL) {
|
||||||
|
delete simple_audio_engine;
|
||||||
|
simple_audio_engine = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SimpleAudioEngine::SimpleAudioEngine()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
SimpleAudioEngine::~SimpleAudioEngine()
|
||||||
|
{
|
||||||
|
// Free sound effects and stop background music
|
||||||
|
CocosQt5AudioBackend::cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Preload background music
|
||||||
|
@param pszFilePath The path of the background music file,or the FileName of T_SoundResInfo
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
SimpleAudioEngine::preloadBackgroundMusic(const char* pszFilePath)
|
||||||
|
{
|
||||||
|
QString filename = fullPath(pszFilePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Play background music
|
||||||
|
@param pszFilePath The path of the background music file,or the FileName of T_SoundResInfo
|
||||||
|
@param bLoop Whether the background music loop or not
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
SimpleAudioEngine::playBackgroundMusic(const char* pszFilePath, bool bLoop)
|
||||||
|
{
|
||||||
|
QString filename = fullPath(pszFilePath);
|
||||||
|
|
||||||
|
CocosQt5AudioBackend::player()->setMedia(QUrl::fromLocalFile(filename));
|
||||||
|
if (bLoop) {
|
||||||
|
// TODO: Set QMediaPlayer to loop infinitely
|
||||||
|
}
|
||||||
|
CocosQt5AudioBackend::player()->play();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Stop playing background music
|
||||||
|
@param bReleaseData If release the background music data or not.As default value is false
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
SimpleAudioEngine::stopBackgroundMusic(bool bReleaseData)
|
||||||
|
{
|
||||||
|
CocosQt5AudioBackend::player()->stop();
|
||||||
|
|
||||||
|
if (bReleaseData) {
|
||||||
|
CocosQt5AudioBackend::player()->setMedia(QMediaContent());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Pause playing background music
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
SimpleAudioEngine::pauseBackgroundMusic()
|
||||||
|
{
|
||||||
|
CocosQt5AudioBackend::player()->pause();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Resume playing background music
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
SimpleAudioEngine::resumeBackgroundMusic()
|
||||||
|
{
|
||||||
|
CocosQt5AudioBackend::player()->play();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Rewind playing background music
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
SimpleAudioEngine::rewindBackgroundMusic()
|
||||||
|
{
|
||||||
|
CocosQt5AudioBackend::player()->stop();
|
||||||
|
CocosQt5AudioBackend::player()->setPosition(0);
|
||||||
|
CocosQt5AudioBackend::player()->play();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
SimpleAudioEngine::willPlayBackgroundMusic()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Whether the background music is playing
|
||||||
|
@return If is playing return true,or return false
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
SimpleAudioEngine::isBackgroundMusicPlaying()
|
||||||
|
{
|
||||||
|
return (CocosQt5AudioBackend::player()->state() == QMediaPlayer::PlayingState);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief The volume of the background music max value is 1.0,the min value is 0.0
|
||||||
|
*/
|
||||||
|
float
|
||||||
|
SimpleAudioEngine::getBackgroundMusicVolume()
|
||||||
|
{
|
||||||
|
return (float)(CocosQt5AudioBackend::player()->volume()) / 100.;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief set the volume of background music
|
||||||
|
@param volume must be in 0.0~1.0
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
SimpleAudioEngine::setBackgroundMusicVolume(float volume)
|
||||||
|
{
|
||||||
|
CocosQt5AudioBackend::player()->setVolume(100. * volume);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief The volume of the effects max value is 1.0,the min value is 0.0
|
||||||
|
*/
|
||||||
|
float
|
||||||
|
SimpleAudioEngine::getEffectsVolume()
|
||||||
|
{
|
||||||
|
return CocosQt5AudioBackend::effects_volume;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief set the volume of sound effecs
|
||||||
|
@param volume must be in 0.0~1.0
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
SimpleAudioEngine::setEffectsVolume(float volume)
|
||||||
|
{
|
||||||
|
CocosQt5AudioBackend::setEffectsVolume(volume);
|
||||||
|
}
|
||||||
|
|
||||||
|
// for sound effects
|
||||||
|
/**
|
||||||
|
@brief Play sound effect
|
||||||
|
@param pszFilePath The path of the effect file,or the FileName of T_SoundResInfo
|
||||||
|
@bLoop Whether to loop the effect playing, default value is false
|
||||||
|
*/
|
||||||
|
unsigned int
|
||||||
|
SimpleAudioEngine::playEffect(const char* pszFilePath, bool bLoop,
|
||||||
|
float pitch, float pan, float gain)
|
||||||
|
{
|
||||||
|
// TODO: Handle pitch, pan and gain
|
||||||
|
|
||||||
|
CocosQt5AudioBackend::gcEffects();
|
||||||
|
|
||||||
|
QString filename = fullPath(pszFilePath);
|
||||||
|
int id = CocosQt5AudioBackend::next_effect_id++;
|
||||||
|
|
||||||
|
QMediaPlayer *effect = new QMediaPlayer;
|
||||||
|
effect->setMedia(QUrl::fromLocalFile(filename));
|
||||||
|
effect->setVolume(CocosQt5AudioBackend::effects_volume * 100.0);
|
||||||
|
if (bLoop) {
|
||||||
|
// TODO: Set QMediaPlayer to loop infinitely
|
||||||
|
}
|
||||||
|
effect->play();
|
||||||
|
|
||||||
|
CocosQt5AudioBackend::effects[id] = effect;
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Pause playing sound effect
|
||||||
|
@param nSoundId The return value of function playEffect
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
SimpleAudioEngine::pauseEffect(unsigned int nSoundId)
|
||||||
|
{
|
||||||
|
if (CocosQt5AudioBackend::effects.contains(nSoundId)) {
|
||||||
|
QMediaPlayer *effect = CocosQt5AudioBackend::effects[nSoundId];
|
||||||
|
effect->pause();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Pause all playing sound effect
|
||||||
|
@param nSoundId The return value of function playEffect
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
SimpleAudioEngine::pauseAllEffects()
|
||||||
|
{
|
||||||
|
foreach (QMediaPlayer *effect, CocosQt5AudioBackend::effects.values()) {
|
||||||
|
effect->pause();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Resume playing sound effect
|
||||||
|
@param nSoundId The return value of function playEffect
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
SimpleAudioEngine::resumeEffect(unsigned int nSoundId)
|
||||||
|
{
|
||||||
|
if (CocosQt5AudioBackend::effects.contains(nSoundId)) {
|
||||||
|
QMediaPlayer *effect = CocosQt5AudioBackend::effects[nSoundId];
|
||||||
|
effect->play();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Resume all playing sound effect
|
||||||
|
@param nSoundId The return value of function playEffect
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
SimpleAudioEngine::resumeAllEffects()
|
||||||
|
{
|
||||||
|
foreach (QMediaPlayer *effect, CocosQt5AudioBackend::effects.values()) {
|
||||||
|
if (effect->state() == QMediaPlayer::PausedState) {
|
||||||
|
effect->play();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Stop playing sound effect
|
||||||
|
@param nSoundId The return value of function playEffect
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
SimpleAudioEngine::stopEffect(unsigned int nSoundId)
|
||||||
|
{
|
||||||
|
if (CocosQt5AudioBackend::effects.contains(nSoundId)) {
|
||||||
|
QMediaPlayer *effect = CocosQt5AudioBackend::effects[nSoundId];
|
||||||
|
CocosQt5AudioBackend::effects.remove(nSoundId);
|
||||||
|
delete effect;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Stop all playing sound effects
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
SimpleAudioEngine::stopAllEffects()
|
||||||
|
{
|
||||||
|
foreach (QMediaPlayer *effect, CocosQt5AudioBackend::effects.values()) {
|
||||||
|
delete effect;
|
||||||
|
}
|
||||||
|
CocosQt5AudioBackend::effects.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief preload a compressed audio file
|
||||||
|
@details the compressed audio will be decode to wave, then write into an
|
||||||
|
internal buffer in SimpleAudioEngine
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
SimpleAudioEngine::preloadEffect(const char* pszFilePath)
|
||||||
|
{
|
||||||
|
QString filename = fullPath(pszFilePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief unload the preloaded effect from internal buffer
|
||||||
|
@param[in] pszFilePath The path of the effect file,or the FileName of T_SoundResInfo
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
SimpleAudioEngine::unloadEffect(const char* pszFilePath)
|
||||||
|
{
|
||||||
|
QString filename = fullPath(pszFilePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
} /* end namespace CocosDenshion */
|
|
@ -1 +1 @@
|
||||||
cc411a26f60628d0276f802f1ba3b98137c2d3ba
|
2be27e9efb6c86c102b456842fc79a7b397910e0
|
|
@ -0,0 +1,19 @@
|
||||||
|
|
||||||
|
TEMPLATE = subdirs
|
||||||
|
|
||||||
|
CONFIG += ordered
|
||||||
|
|
||||||
|
# Cocos2D-X Core Library
|
||||||
|
SUBDIRS += external/chipmunk/proj.qt5/chipmunk.pro
|
||||||
|
SUBDIRS += external/Box2D/proj.qt5/box2d.pro
|
||||||
|
SUBDIRS += cocos2dx/proj.qt5/cocos2dx.pro
|
||||||
|
|
||||||
|
# Cocos2D-X Additional Libraries
|
||||||
|
SUBDIRS += CocosDenshion/proj.qt5/cocosdenshion.pro
|
||||||
|
SUBDIRS += extensions/proj.qt5/extensions.pro
|
||||||
|
|
||||||
|
# Examples
|
||||||
|
SUBDIRS += samples/Cpp/HelloCpp/proj.qt5/HelloCpp.pro
|
||||||
|
SUBDIRS += samples/Cpp/SimpleGame/proj.qt5/SimpleGame.pro
|
||||||
|
SUBDIRS += samples/Cpp/TestCpp/proj.qt5/TestCpp.pro
|
||||||
|
|
|
@ -79,7 +79,6 @@ particle_nodes/CCParticleExamples.cpp \
|
||||||
particle_nodes/CCParticleSystem.cpp \
|
particle_nodes/CCParticleSystem.cpp \
|
||||||
particle_nodes/CCParticleBatchNode.cpp \
|
particle_nodes/CCParticleBatchNode.cpp \
|
||||||
particle_nodes/CCParticleSystemQuad.cpp \
|
particle_nodes/CCParticleSystemQuad.cpp \
|
||||||
platform/CCImageCommonWebp.cpp \
|
|
||||||
platform/CCSAXParser.cpp \
|
platform/CCSAXParser.cpp \
|
||||||
platform/CCThread.cpp \
|
platform/CCThread.cpp \
|
||||||
platform/CCFileUtils.cpp \
|
platform/CCFileUtils.cpp \
|
||||||
|
@ -131,9 +130,7 @@ text_input_node/CCTextFieldTTF.cpp \
|
||||||
textures/CCTexture2D.cpp \
|
textures/CCTexture2D.cpp \
|
||||||
textures/CCTextureAtlas.cpp \
|
textures/CCTextureAtlas.cpp \
|
||||||
textures/CCTextureCache.cpp \
|
textures/CCTextureCache.cpp \
|
||||||
textures/CCTextureETC.cpp \
|
platform/third_party/common/etc/etc1.cpp\
|
||||||
textures/CCTexturePVR.cpp \
|
|
||||||
textures/etc/etc1.cpp\
|
|
||||||
tilemap_parallax_nodes/CCParallaxNode.cpp \
|
tilemap_parallax_nodes/CCParallaxNode.cpp \
|
||||||
tilemap_parallax_nodes/CCTMXLayer.cpp \
|
tilemap_parallax_nodes/CCTMXLayer.cpp \
|
||||||
tilemap_parallax_nodes/CCTMXObjectGroup.cpp \
|
tilemap_parallax_nodes/CCTMXObjectGroup.cpp \
|
||||||
|
@ -147,12 +144,15 @@ touch_dispatcher/CCTouch.cpp
|
||||||
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) \
|
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) \
|
||||||
$(LOCAL_PATH)/include \
|
$(LOCAL_PATH)/include \
|
||||||
$(LOCAL_PATH)/kazmath/include \
|
$(LOCAL_PATH)/kazmath/include \
|
||||||
$(LOCAL_PATH)/platform/android
|
$(LOCAL_PATH)/platform/android \
|
||||||
|
$(LOCAL_PATH)/platform/third_party/common/etc
|
||||||
|
|
||||||
LOCAL_C_INCLUDES := $(LOCAL_PATH) \
|
LOCAL_C_INCLUDES := $(LOCAL_PATH) \
|
||||||
$(LOCAL_PATH)/include \
|
$(LOCAL_PATH)/include \
|
||||||
$(LOCAL_PATH)/kazmath/include \
|
$(LOCAL_PATH)/kazmath/include \
|
||||||
$(LOCAL_PATH)/platform/android
|
$(LOCAL_PATH)/platform/android \
|
||||||
|
$(LOCAL_PATH)/platform/third_party/common/etc
|
||||||
|
|
||||||
|
|
||||||
LOCAL_LDLIBS := -lGLESv2 \
|
LOCAL_LDLIBS := -lGLESv2 \
|
||||||
-llog \
|
-llog \
|
||||||
|
|
|
@ -106,7 +106,7 @@ Director::Director(void)
|
||||||
|
|
||||||
bool Director::init(void)
|
bool Director::init(void)
|
||||||
{
|
{
|
||||||
setDefaultValues();
|
setDefaultValues();
|
||||||
|
|
||||||
// scenes
|
// scenes
|
||||||
_runningScene = NULL;
|
_runningScene = NULL;
|
||||||
|
@ -253,6 +253,11 @@ void Director::drawScene(void)
|
||||||
// calculate "global" dt
|
// calculate "global" dt
|
||||||
calculateDeltaTime();
|
calculateDeltaTime();
|
||||||
|
|
||||||
|
if (_openGLView)
|
||||||
|
{
|
||||||
|
_openGLView->pollInputEvents();
|
||||||
|
}
|
||||||
|
|
||||||
//tick before glClear: issue #533
|
//tick before glClear: issue #533
|
||||||
if (! _paused)
|
if (! _paused)
|
||||||
{
|
{
|
||||||
|
@ -645,7 +650,7 @@ void Director::popToSceneStackLevel(int level)
|
||||||
// pop stack until reaching desired level
|
// pop stack until reaching desired level
|
||||||
while (c > level)
|
while (c > level)
|
||||||
{
|
{
|
||||||
Scene *current = (Scene*)_scenesStack->lastObject();
|
Scene *current = (Scene*)_scenesStack->lastObject();
|
||||||
|
|
||||||
if (current->isRunning())
|
if (current->isRunning())
|
||||||
{
|
{
|
||||||
|
@ -658,7 +663,7 @@ void Director::popToSceneStackLevel(int level)
|
||||||
c--;
|
c--;
|
||||||
}
|
}
|
||||||
|
|
||||||
_nextScene = (Scene*)_scenesStack->lastObject();
|
_nextScene = (Scene*)_scenesStack->lastObject();
|
||||||
_sendCleanupToScene = false;
|
_sendCleanupToScene = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1273,7 +1273,7 @@ void JumpTo::startWithTarget(Node *target)
|
||||||
|
|
||||||
// Bezier cubic formula:
|
// Bezier cubic formula:
|
||||||
// ((1 - t) + t)3 = 1
|
// ((1 - t) + t)3 = 1
|
||||||
// Expands to¡
|
// Expands to ...
|
||||||
// (1 - t)3 + 3t(1-t)2 + 3t2(1 - t) + t3 = 1
|
// (1 - t)3 + 3t(1-t)2 + 3t2(1 - t) + t3 = 1
|
||||||
static inline float bezierat( float a, float b, float c, float d, float t )
|
static inline float bezierat( float a, float b, float c, float d, float t )
|
||||||
{
|
{
|
||||||
|
@ -1987,11 +1987,11 @@ Animate* Animate::create(Animation *pAnimation)
|
||||||
}
|
}
|
||||||
|
|
||||||
Animate::Animate()
|
Animate::Animate()
|
||||||
: _animation(NULL)
|
: _splitTimes(new std::vector<float>)
|
||||||
, _splitTimes(new std::vector<float>)
|
|
||||||
, _nextFrame(0)
|
, _nextFrame(0)
|
||||||
, _origFrame(NULL)
|
, _origFrame(NULL)
|
||||||
, _executedLoops(0)
|
, _executedLoops(0)
|
||||||
|
, _animation(NULL)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2155,8 +2155,8 @@ Animate* Animate::reverse() const
|
||||||
// TargetedAction
|
// TargetedAction
|
||||||
|
|
||||||
TargetedAction::TargetedAction()
|
TargetedAction::TargetedAction()
|
||||||
: _forcedTarget(NULL)
|
: _action(NULL)
|
||||||
, _action(NULL)
|
, _forcedTarget(NULL)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,6 +64,11 @@ Node::Node(void)
|
||||||
, _anchorPoint(Point::ZERO)
|
, _anchorPoint(Point::ZERO)
|
||||||
, _contentSize(Size::ZERO)
|
, _contentSize(Size::ZERO)
|
||||||
, _additionalTransform(AffineTransformMakeIdentity())
|
, _additionalTransform(AffineTransformMakeIdentity())
|
||||||
|
, _transform(AffineTransformMakeIdentity())
|
||||||
|
, _inverse(AffineTransformMakeIdentity())
|
||||||
|
, _additionalTransformDirty(false)
|
||||||
|
, _transformDirty(true)
|
||||||
|
, _inverseDirty(true)
|
||||||
, _camera(NULL)
|
, _camera(NULL)
|
||||||
// children (lazy allocs)
|
// children (lazy allocs)
|
||||||
// lazy alloc
|
// lazy alloc
|
||||||
|
@ -79,9 +84,6 @@ Node::Node(void)
|
||||||
, _shaderProgram(NULL)
|
, _shaderProgram(NULL)
|
||||||
, _orderOfArrival(0)
|
, _orderOfArrival(0)
|
||||||
, _running(false)
|
, _running(false)
|
||||||
, _transformDirty(true)
|
|
||||||
, _inverseDirty(true)
|
|
||||||
, _additionalTransformDirty(false)
|
|
||||||
, _visible(true)
|
, _visible(true)
|
||||||
, _ignoreAnchorPointForPosition(false)
|
, _ignoreAnchorPointForPosition(false)
|
||||||
, _reorderChildDirty(false)
|
, _reorderChildDirty(false)
|
||||||
|
|
|
@ -224,9 +224,9 @@ public:
|
||||||
*
|
*
|
||||||
* The deafult value is 1.0 if you haven't changed it before
|
* The deafult value is 1.0 if you haven't changed it before
|
||||||
*
|
*
|
||||||
* @param fScaleX The scale factor on X axis.
|
* @param scaleX The scale factor on X axis.
|
||||||
*/
|
*/
|
||||||
virtual void setScaleX(float fScaleX);
|
virtual void setScaleX(float scaleX);
|
||||||
/**
|
/**
|
||||||
* Returns the scale factor on X axis of this node
|
* Returns the scale factor on X axis of this node
|
||||||
*
|
*
|
||||||
|
@ -242,9 +242,9 @@ public:
|
||||||
*
|
*
|
||||||
* The Default value is 1.0 if you haven't changed it before.
|
* The Default value is 1.0 if you haven't changed it before.
|
||||||
*
|
*
|
||||||
* @param fScaleY The scale factor on Y axis.
|
* @param scaleY The scale factor on Y axis.
|
||||||
*/
|
*/
|
||||||
virtual void setScaleY(float fScaleY);
|
virtual void setScaleY(float scaleY);
|
||||||
/**
|
/**
|
||||||
* Returns the scale factor on Y axis of this node
|
* Returns the scale factor on Y axis of this node
|
||||||
*
|
*
|
||||||
|
@ -699,7 +699,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Changes a grid object that is used when applying effects
|
* Changes a grid object that is used when applying effects
|
||||||
*
|
*
|
||||||
* @param A Grid object that is used when applying effects
|
* @param grid A Grid object that is used when applying effects
|
||||||
*/
|
*/
|
||||||
virtual void setGrid(GridBase *grid);
|
virtual void setGrid(GridBase *grid);
|
||||||
|
|
||||||
|
@ -748,7 +748,7 @@ public:
|
||||||
*
|
*
|
||||||
* Please refer to getTag for the sample code.
|
* Please refer to getTag for the sample code.
|
||||||
*
|
*
|
||||||
* @param A interger that indentifies the node.
|
* @param tag A interger that indentifies the node.
|
||||||
*/
|
*/
|
||||||
virtual void setTag(int tag);
|
virtual void setTag(int tag);
|
||||||
|
|
||||||
|
@ -769,7 +769,7 @@ public:
|
||||||
* @warning Don't forget to release the memroy manually,
|
* @warning Don't forget to release the memroy manually,
|
||||||
* especially before you change this data pointer, and before this node is autoreleased.
|
* especially before you change this data pointer, and before this node is autoreleased.
|
||||||
*
|
*
|
||||||
* @param A custom user data pointer
|
* @param userData A custom user data pointer
|
||||||
*/
|
*/
|
||||||
virtual void setUserData(void *userData);
|
virtual void setUserData(void *userData);
|
||||||
|
|
||||||
|
@ -791,7 +791,7 @@ public:
|
||||||
* and the previous UserObject (if existed) will be relese.
|
* and the previous UserObject (if existed) will be relese.
|
||||||
* The UserObject will be released in Node's destructure.
|
* The UserObject will be released in Node's destructure.
|
||||||
*
|
*
|
||||||
* @param A user assigned Object
|
* @param userObject A user assigned Object
|
||||||
*/
|
*/
|
||||||
virtual void setUserObject(Object *userObject);
|
virtual void setUserObject(Object *userObject);
|
||||||
|
|
||||||
|
@ -817,7 +817,7 @@ public:
|
||||||
* node->setShaderProgram(ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR));
|
* node->setShaderProgram(ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR));
|
||||||
* @endcode
|
* @endcode
|
||||||
*
|
*
|
||||||
* @param The shader program which fetchs from ShaderCache.
|
* @param shaderProgram The shader program which fetchs from ShaderCache.
|
||||||
*/
|
*/
|
||||||
virtual void setShaderProgram(GLProgram *shaderProgram);
|
virtual void setShaderProgram(GLProgram *shaderProgram);
|
||||||
/// @} end of Shader Program
|
/// @} end of Shader Program
|
||||||
|
@ -961,14 +961,14 @@ public:
|
||||||
/**
|
/**
|
||||||
* Stops and removes an action from the running action list.
|
* Stops and removes an action from the running action list.
|
||||||
*
|
*
|
||||||
* @param An action object to be removed.
|
* @param action The action object to be removed.
|
||||||
*/
|
*/
|
||||||
void stopAction(Action* action);
|
void stopAction(Action* action);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes an action from the running action list by its tag.
|
* Removes an action from the running action list by its tag.
|
||||||
*
|
*
|
||||||
* @param A tag that indicates the action to be removed.
|
* @param tag A tag that indicates the action to be removed.
|
||||||
*/
|
*/
|
||||||
void stopActionByTag(int tag);
|
void stopActionByTag(int tag);
|
||||||
|
|
||||||
|
|
|
@ -51,14 +51,14 @@ class Data;
|
||||||
*
|
*
|
||||||
* Use cases:
|
* Use cases:
|
||||||
* - data serialization,
|
* - data serialization,
|
||||||
* - pretty printing of \a Object *
|
* - pretty printing of Object *
|
||||||
* - safe value reading from \a Array, \a Dictionary, \a Set
|
* - safe value reading from Array, Dictionary, Set
|
||||||
*
|
*
|
||||||
* Usage:
|
* Usage:
|
||||||
* 1. subclass DataVisitor
|
* 1. subclass DataVisitor
|
||||||
* 2. overload visit() methods for object that you need to handle
|
* 2. overload visit() methods for object that you need to handle
|
||||||
* 3. handle other objects in \a visitObject()
|
* 3. handle other objects in visitObject()
|
||||||
* 4. pass your visitor to \a Object::acceptVisitor()
|
* 4. pass your visitor to Object::acceptVisitor()
|
||||||
*/
|
*/
|
||||||
class CC_DLL DataVisitor
|
class CC_DLL DataVisitor
|
||||||
{
|
{
|
||||||
|
|
|
@ -63,7 +63,7 @@ public:
|
||||||
Point();
|
Point();
|
||||||
Point(float x, float y);
|
Point(float x, float y);
|
||||||
Point(const Point& other);
|
Point(const Point& other);
|
||||||
Point(const Size& size);
|
explicit Point(const Size& size);
|
||||||
Point& operator= (const Point& other);
|
Point& operator= (const Point& other);
|
||||||
Point& operator= (const Size& size);
|
Point& operator= (const Size& size);
|
||||||
Point operator+(const Point& right) const;
|
Point operator+(const Point& right) const;
|
||||||
|
@ -295,7 +295,7 @@ public:
|
||||||
Size();
|
Size();
|
||||||
Size(float width, float height);
|
Size(float width, float height);
|
||||||
Size(const Size& other);
|
Size(const Size& other);
|
||||||
Size(const Point& point);
|
explicit Size(const Point& point);
|
||||||
Size& operator= (const Size& other);
|
Size& operator= (const Size& other);
|
||||||
Size& operator= (const Point& point);
|
Size& operator= (const Point& point);
|
||||||
Size operator+(const Size& right) const;
|
Size operator+(const Size& right) const;
|
||||||
|
|
|
@ -119,7 +119,8 @@ bool GridBase::initWithSize(const Size& gridSize)
|
||||||
// we only use rgba8888
|
// we only use rgba8888
|
||||||
Texture2D::PixelFormat format = Texture2D::PixelFormat::RGBA8888;
|
Texture2D::PixelFormat format = Texture2D::PixelFormat::RGBA8888;
|
||||||
|
|
||||||
void *data = calloc((int)(POTWide * POTHigh * 4), 1);
|
int dataLen = (int)(POTWide * POTHigh * 4);
|
||||||
|
void *data = calloc(dataLen, 1);
|
||||||
if (! data)
|
if (! data)
|
||||||
{
|
{
|
||||||
CCLOG("cocos2d: Grid: not enough memory.");
|
CCLOG("cocos2d: Grid: not enough memory.");
|
||||||
|
@ -128,7 +129,7 @@ bool GridBase::initWithSize(const Size& gridSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
Texture2D *texture = new Texture2D();
|
Texture2D *texture = new Texture2D();
|
||||||
texture->initWithData(data, format, POTWide, POTHigh, s);
|
texture->initWithData(data, dataLen, format, POTWide, POTHigh, s);
|
||||||
|
|
||||||
free(data);
|
free(data);
|
||||||
|
|
||||||
|
|
|
@ -882,8 +882,8 @@ CC_DEPRECATED_ATTRIBUTE const Texture2D::PixelFormat kCCTexture2DPixelFormat_I8
|
||||||
CC_DEPRECATED_ATTRIBUTE const Texture2D::PixelFormat kCCTexture2DPixelFormat_AI88 = Texture2D::PixelFormat::AI88;
|
CC_DEPRECATED_ATTRIBUTE const Texture2D::PixelFormat kCCTexture2DPixelFormat_AI88 = Texture2D::PixelFormat::AI88;
|
||||||
CC_DEPRECATED_ATTRIBUTE const Texture2D::PixelFormat kCCTexture2DPixelFormat_RGBA4444 = Texture2D::PixelFormat::RGBA4444;
|
CC_DEPRECATED_ATTRIBUTE const Texture2D::PixelFormat kCCTexture2DPixelFormat_RGBA4444 = Texture2D::PixelFormat::RGBA4444;
|
||||||
CC_DEPRECATED_ATTRIBUTE const Texture2D::PixelFormat kCCTexture2DPixelFormat_RGB5A1 = Texture2D::PixelFormat::RGB5A1;
|
CC_DEPRECATED_ATTRIBUTE const Texture2D::PixelFormat kCCTexture2DPixelFormat_RGB5A1 = Texture2D::PixelFormat::RGB5A1;
|
||||||
CC_DEPRECATED_ATTRIBUTE const Texture2D::PixelFormat kCCTexture2DPixelFormat_PVRTC4 = Texture2D::PixelFormat::PRVTC4;
|
CC_DEPRECATED_ATTRIBUTE const Texture2D::PixelFormat kCCTexture2DPixelFormat_PVRTC4 = Texture2D::PixelFormat::PVRTC4;
|
||||||
CC_DEPRECATED_ATTRIBUTE const Texture2D::PixelFormat kCCTexture2DPixelFormat_PVRTC2 = Texture2D::PixelFormat::PRVTC2;
|
CC_DEPRECATED_ATTRIBUTE const Texture2D::PixelFormat kCCTexture2DPixelFormat_PVRTC2 = Texture2D::PixelFormat::PVRTC2;
|
||||||
CC_DEPRECATED_ATTRIBUTE const Texture2D::PixelFormat kCCTexture2DPixelFormat_Default = Texture2D::PixelFormat::DEFAULT;
|
CC_DEPRECATED_ATTRIBUTE const Texture2D::PixelFormat kCCTexture2DPixelFormat_Default = Texture2D::PixelFormat::DEFAULT;
|
||||||
|
|
||||||
CC_DEPRECATED_ATTRIBUTE typedef Texture2D::PixelFormat CCTexture2DPixelFormat;
|
CC_DEPRECATED_ATTRIBUTE typedef Texture2D::PixelFormat CCTexture2DPixelFormat;
|
||||||
|
|
|
@ -186,7 +186,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Sets a new label using an string
|
* Sets a new label using an string
|
||||||
*
|
*
|
||||||
* @param A null terminated string
|
* @param label A null terminated string
|
||||||
*/
|
*/
|
||||||
virtual void setString(const char *label) = 0;
|
virtual void setString(const char *label) = 0;
|
||||||
|
|
||||||
|
|
|
@ -412,8 +412,8 @@ public:
|
||||||
: _fontSize(0)
|
: _fontSize(0)
|
||||||
, _alignment(TextHAlignment::CENTER)
|
, _alignment(TextHAlignment::CENTER)
|
||||||
, _vertAlignment(TextVAlignment::TOP)
|
, _vertAlignment(TextVAlignment::TOP)
|
||||||
|
, _dimensions(Size::ZERO)
|
||||||
, _fontFillColor(Color3B::WHITE)
|
, _fontFillColor(Color3B::WHITE)
|
||||||
, _dimensions(Size::ZERO)
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
// font name
|
// font name
|
||||||
|
|
|
@ -217,6 +217,14 @@ THE SOFTWARE.
|
||||||
#include "platform/tizen/CCStdC.h"
|
#include "platform/tizen/CCStdC.h"
|
||||||
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_TIZEN
|
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_TIZEN
|
||||||
|
|
||||||
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_QT5)
|
||||||
|
#include "platform/qt5/CCAccelerometer.h"
|
||||||
|
#include "platform/qt5/CCApplication.h"
|
||||||
|
#include "platform/qt5/CCEGLView.h"
|
||||||
|
#include "platform/qt5/CCGL.h"
|
||||||
|
#include "platform/qt5/CCStdC.h"
|
||||||
|
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_QT5
|
||||||
|
|
||||||
// script_support
|
// script_support
|
||||||
#include "script_support/CCScriptSupport.h"
|
#include "script_support/CCScriptSupport.h"
|
||||||
|
|
||||||
|
@ -251,7 +259,6 @@ THE SOFTWARE.
|
||||||
#include "textures/CCTexture2D.h"
|
#include "textures/CCTexture2D.h"
|
||||||
#include "textures/CCTextureAtlas.h"
|
#include "textures/CCTextureAtlas.h"
|
||||||
#include "textures/CCTextureCache.h"
|
#include "textures/CCTextureCache.h"
|
||||||
#include "textures/CCTexturePVR.h"
|
|
||||||
|
|
||||||
// tilemap_parallax_nodes
|
// tilemap_parallax_nodes
|
||||||
#include "tilemap_parallax_nodes/CCParallaxNode.h"
|
#include "tilemap_parallax_nodes/CCParallaxNode.h"
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#define __NEON_MATRIX_IMPL_H__
|
#define __NEON_MATRIX_IMPL_H__
|
||||||
|
|
||||||
#ifdef __arm__
|
#ifdef __arm__
|
||||||
#if defined(__QNX__) || defined(ANDROID) || defined(I3D_ARCH_ARM) || defined(__native_client__) || defined(TIZEN) // MARMALADE CHANGE: Added for Marmalade support
|
#if defined(__QNX__) || defined(CC_TARGET_QT5)|| defined(ANDROID) || defined(I3D_ARCH_ARM) || defined(__native_client__) || defined(TIZEN) // MARMALADE CHANGE: Added for Marmalade support
|
||||||
// blackberry and android don't have arm/arch.h but it defines __arm__
|
// blackberry and android don't have arm/arch.h but it defines __arm__
|
||||||
#else
|
#else
|
||||||
#include "arm/arch.h"
|
#include "arm/arch.h"
|
||||||
|
|
|
@ -128,8 +128,8 @@ public:
|
||||||
static MenuItemLabel* create(Node *label);
|
static MenuItemLabel* create(Node *label);
|
||||||
|
|
||||||
MenuItemLabel()
|
MenuItemLabel()
|
||||||
: _label(NULL)
|
: _originalScale(0.0)
|
||||||
, _originalScale(0.0)
|
, _label(NULL)
|
||||||
{}
|
{}
|
||||||
virtual ~MenuItemLabel();
|
virtual ~MenuItemLabel();
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@ MotionStreak::MotionStreak()
|
||||||
: _fastMode(false)
|
: _fastMode(false)
|
||||||
, _startingPositionInitialized(false)
|
, _startingPositionInitialized(false)
|
||||||
, _texture(NULL)
|
, _texture(NULL)
|
||||||
|
, _blendFunc(BlendFunc::ALPHA_NON_PREMULTIPLIED)
|
||||||
, _positionR(Point::ZERO)
|
, _positionR(Point::ZERO)
|
||||||
, _stroke(0.0f)
|
, _stroke(0.0f)
|
||||||
, _fadeDelta(0.0f)
|
, _fadeDelta(0.0f)
|
||||||
|
@ -49,7 +50,6 @@ MotionStreak::MotionStreak()
|
||||||
, _vertices(NULL)
|
, _vertices(NULL)
|
||||||
, _colorPointer(NULL)
|
, _colorPointer(NULL)
|
||||||
, _texCoords(NULL)
|
, _texCoords(NULL)
|
||||||
, _blendFunc(BlendFunc::ALPHA_NON_PREMULTIPLIED)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,12 +46,12 @@ const char kProgressTextureCoords = 0x4b;
|
||||||
|
|
||||||
ProgressTimer::ProgressTimer()
|
ProgressTimer::ProgressTimer()
|
||||||
:_type(Type::RADIAL)
|
:_type(Type::RADIAL)
|
||||||
|
,_midpoint(0,0)
|
||||||
|
,_barChangeRate(0,0)
|
||||||
,_percentage(0.0f)
|
,_percentage(0.0f)
|
||||||
,_sprite(NULL)
|
,_sprite(NULL)
|
||||||
,_vertexDataCount(0)
|
,_vertexDataCount(0)
|
||||||
,_vertexData(NULL)
|
,_vertexData(NULL)
|
||||||
,_midpoint(0,0)
|
|
||||||
,_barChangeRate(0,0)
|
|
||||||
,_reverseDirection(false)
|
,_reverseDirection(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
|
@ -44,8 +44,7 @@ NS_CC_BEGIN
|
||||||
|
|
||||||
// implementation RenderTexture
|
// implementation RenderTexture
|
||||||
RenderTexture::RenderTexture()
|
RenderTexture::RenderTexture()
|
||||||
: _sprite(NULL)
|
: _FBO(0)
|
||||||
, _FBO(0)
|
|
||||||
, _depthRenderBufffer(0)
|
, _depthRenderBufffer(0)
|
||||||
, _oldFBO(0)
|
, _oldFBO(0)
|
||||||
, _texture(0)
|
, _texture(0)
|
||||||
|
@ -57,6 +56,7 @@ RenderTexture::RenderTexture()
|
||||||
, _clearDepth(0.0f)
|
, _clearDepth(0.0f)
|
||||||
, _clearStencil(0)
|
, _clearStencil(0)
|
||||||
, _autoDraw(false)
|
, _autoDraw(false)
|
||||||
|
, _sprite(NULL)
|
||||||
{
|
{
|
||||||
#if CC_ENABLE_CACHE_TEXTURE_DATA
|
#if CC_ENABLE_CACHE_TEXTURE_DATA
|
||||||
// Listen this event to save render texture before come to background.
|
// Listen this event to save render texture before come to background.
|
||||||
|
@ -102,11 +102,11 @@ void RenderTexture::listenToBackground(cocos2d::Object *obj)
|
||||||
if (_UITextureImage)
|
if (_UITextureImage)
|
||||||
{
|
{
|
||||||
const Size& s = _texture->getContentSizeInPixels();
|
const Size& s = _texture->getContentSizeInPixels();
|
||||||
VolatileTexture::addDataTexture(_texture, _UITextureImage->getData(), Texture2D::PixelFormat::RGBA8888, s);
|
VolatileTexture::addDataTexture(_texture, _UITextureImage->getData(), s.width * s.height * 4, Texture2D::PixelFormat::RGBA8888, s);
|
||||||
|
|
||||||
if ( _textureCopy )
|
if ( _textureCopy )
|
||||||
{
|
{
|
||||||
VolatileTexture::addDataTexture(_textureCopy, _UITextureImage->getData(), Texture2D::PixelFormat::RGBA8888, s);
|
VolatileTexture::addDataTexture(_textureCopy, _UITextureImage->getData(), s.width * s.height * 4, Texture2D::PixelFormat::RGBA8888, s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -212,16 +212,17 @@ bool RenderTexture::initWithWidthAndHeight(int w, int h, Texture2D::PixelFormat
|
||||||
powH = ccNextPOT(h);
|
powH = ccNextPOT(h);
|
||||||
}
|
}
|
||||||
|
|
||||||
data = malloc((int)(powW * powH * 4));
|
int dataLen = (int)(powW * powH * 4);
|
||||||
|
data = malloc(dataLen);
|
||||||
CC_BREAK_IF(! data);
|
CC_BREAK_IF(! data);
|
||||||
|
|
||||||
memset(data, 0, (int)(powW * powH * 4));
|
memset(data, 0, dataLen);
|
||||||
_pixelFormat = eFormat;
|
_pixelFormat = eFormat;
|
||||||
|
|
||||||
_texture = new Texture2D();
|
_texture = new Texture2D();
|
||||||
if (_texture)
|
if (_texture)
|
||||||
{
|
{
|
||||||
_texture->initWithData(data, (Texture2D::PixelFormat)_pixelFormat, powW, powH, Size((float)w, (float)h));
|
_texture->initWithData(data, dataLen, (Texture2D::PixelFormat)_pixelFormat, powW, powH, Size((float)w, (float)h));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -235,7 +236,7 @@ bool RenderTexture::initWithWidthAndHeight(int w, int h, Texture2D::PixelFormat
|
||||||
_textureCopy = new Texture2D();
|
_textureCopy = new Texture2D();
|
||||||
if (_textureCopy)
|
if (_textureCopy)
|
||||||
{
|
{
|
||||||
_textureCopy->initWithData(data, (Texture2D::PixelFormat)_pixelFormat, powW, powH, Size((float)w, (float)h));
|
_textureCopy->initWithData(data, dataLen, (Texture2D::PixelFormat)_pixelFormat, powW, powH, Size((float)w, (float)h));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -623,11 +624,11 @@ Image* RenderTexture::newImage(bool fliimage)
|
||||||
nSavedBufferWidth * 4);
|
nSavedBufferWidth * 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
image->initWithImageData(pBuffer, nSavedBufferWidth * nSavedBufferHeight * 4, Image::Format::RAW_DATA, nSavedBufferWidth, nSavedBufferHeight, 8);
|
image->initWithRawData(pBuffer, nSavedBufferWidth * nSavedBufferHeight * 4, nSavedBufferWidth, nSavedBufferHeight, 8);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
image->initWithImageData(pTempData, nSavedBufferWidth * nSavedBufferHeight * 4, Image::Format::RAW_DATA, nSavedBufferWidth, nSavedBufferHeight, 8);
|
image->initWithRawData(pTempData, nSavedBufferWidth * nSavedBufferHeight * 4, nSavedBufferWidth, nSavedBufferHeight, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
} while (0);
|
} while (0);
|
||||||
|
|
|
@ -47,7 +47,7 @@ static Texture2D* getDefaultTexture()
|
||||||
|
|
||||||
pImage = new Image();
|
pImage = new Image();
|
||||||
CC_BREAK_IF(NULL == pImage);
|
CC_BREAK_IF(NULL == pImage);
|
||||||
bRet = pImage->initWithImageData((void*)__firePngData, sizeof(__firePngData), Image::Format::PNG);
|
bRet = pImage->initWithImageData((void*)__firePngData, sizeof(__firePngData));
|
||||||
CC_BREAK_IF(!bRet);
|
CC_BREAK_IF(!bRet);
|
||||||
|
|
||||||
texture = TextureCache::getInstance()->addUIImage(pImage, key);
|
texture = TextureCache::getInstance()->addUIImage(pImage, key);
|
||||||
|
|
|
@ -81,7 +81,9 @@ NS_CC_BEGIN
|
||||||
//
|
//
|
||||||
|
|
||||||
ParticleSystem::ParticleSystem()
|
ParticleSystem::ParticleSystem()
|
||||||
: _plistFile("")
|
: _isBlendAdditive(false)
|
||||||
|
, _isAutoRemoveOnFinish(false)
|
||||||
|
, _plistFile("")
|
||||||
, _elapsed(0)
|
, _elapsed(0)
|
||||||
, _particles(NULL)
|
, _particles(NULL)
|
||||||
, _emitCounter(0)
|
, _emitCounter(0)
|
||||||
|
@ -99,6 +101,7 @@ ParticleSystem::ParticleSystem()
|
||||||
, _lifeVar(0)
|
, _lifeVar(0)
|
||||||
, _angle(0)
|
, _angle(0)
|
||||||
, _angleVar(0)
|
, _angleVar(0)
|
||||||
|
, _emitterMode(Mode::GRAVITY)
|
||||||
, _startSize(0)
|
, _startSize(0)
|
||||||
, _startSizeVar(0)
|
, _startSizeVar(0)
|
||||||
, _endSize(0)
|
, _endSize(0)
|
||||||
|
@ -110,12 +113,9 @@ ParticleSystem::ParticleSystem()
|
||||||
, _emissionRate(0)
|
, _emissionRate(0)
|
||||||
, _totalParticles(0)
|
, _totalParticles(0)
|
||||||
, _texture(NULL)
|
, _texture(NULL)
|
||||||
, _opacityModifyRGB(false)
|
|
||||||
, _isBlendAdditive(false)
|
|
||||||
, _positionType(PositionType::FREE)
|
|
||||||
, _isAutoRemoveOnFinish(false)
|
|
||||||
, _emitterMode(Mode::GRAVITY)
|
|
||||||
, _blendFunc(BlendFunc::ALPHA_PREMULTIPLIED)
|
, _blendFunc(BlendFunc::ALPHA_PREMULTIPLIED)
|
||||||
|
, _opacityModifyRGB(false)
|
||||||
|
, _positionType(PositionType::FREE)
|
||||||
{
|
{
|
||||||
modeA.gravity = Point::ZERO;
|
modeA.gravity = Point::ZERO;
|
||||||
modeA.speed = 0;
|
modeA.speed = 0;
|
||||||
|
|
|
@ -55,6 +55,10 @@ EGLViewProtocol::~EGLViewProtocol()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EGLViewProtocol::pollInputEvents()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void EGLViewProtocol::setDesignResolutionSize(float width, float height, ResolutionPolicy resolutionPolicy)
|
void EGLViewProtocol::setDesignResolutionSize(float width, float height, ResolutionPolicy resolutionPolicy)
|
||||||
{
|
{
|
||||||
CCASSERT(resolutionPolicy != ResolutionPolicy::UNKNOWN, "should set resolutionPolicy");
|
CCASSERT(resolutionPolicy != ResolutionPolicy::UNKNOWN, "should set resolutionPolicy");
|
||||||
|
|
|
@ -58,6 +58,12 @@ public:
|
||||||
/** Open or close IME keyboard , subclass must implement this method. */
|
/** Open or close IME keyboard , subclass must implement this method. */
|
||||||
virtual void setIMEKeyboardState(bool bOpen) = 0;
|
virtual void setIMEKeyboardState(bool bOpen) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Polls input events. Subclass must implement methods if platform
|
||||||
|
* does not provide event callbacks.
|
||||||
|
*/
|
||||||
|
virtual void pollInputEvents();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the frame size of EGL view.
|
* Get the frame size of EGL view.
|
||||||
* In general, it returns the screen size since the EGL view is a fullscreen view.
|
* In general, it returns the screen size since the EGL view is a fullscreen view.
|
||||||
|
|
|
@ -26,6 +26,7 @@ THE SOFTWARE.
|
||||||
#define __CC_IMAGE_H__
|
#define __CC_IMAGE_H__
|
||||||
|
|
||||||
#include "cocoa/CCObject.h"
|
#include "cocoa/CCObject.h"
|
||||||
|
#include "textures/CCTexture2D.h"
|
||||||
|
|
||||||
// premultiply alpha, or the effect will wrong when want to use other pixel format in Texture2D,
|
// premultiply alpha, or the effect will wrong when want to use other pixel format in Texture2D,
|
||||||
// such as RGB888, RGB5A1
|
// such as RGB888, RGB5A1
|
||||||
|
@ -41,6 +42,14 @@ NS_CC_BEGIN
|
||||||
* @addtogroup platform
|
* @addtogroup platform
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Structure which can tell where mipmap begins and how long is it
|
||||||
|
*/
|
||||||
|
typedef struct _MipmapInfo {
|
||||||
|
unsigned char* address;
|
||||||
|
int len;
|
||||||
|
}MipmapInfo;
|
||||||
|
|
||||||
class CC_DLL Image : public Object
|
class CC_DLL Image : public Object
|
||||||
{
|
{
|
||||||
|
@ -49,6 +58,14 @@ public:
|
||||||
|
|
||||||
Image();
|
Image();
|
||||||
virtual ~Image();
|
virtual ~Image();
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Determine how many mipmaps can we have.
|
||||||
|
Its same as define but it respects namespaces
|
||||||
|
*/
|
||||||
|
enum {
|
||||||
|
CC_MIPMAP_MAX = 16,
|
||||||
|
};
|
||||||
|
|
||||||
/** Supported formats for Image */
|
/** Supported formats for Image */
|
||||||
enum class Format
|
enum class Format
|
||||||
|
@ -61,6 +78,10 @@ public:
|
||||||
TIFF,
|
TIFF,
|
||||||
//! WebP
|
//! WebP
|
||||||
WEBP,
|
WEBP,
|
||||||
|
//! PVR
|
||||||
|
PVR,
|
||||||
|
//! ETC
|
||||||
|
ETC,
|
||||||
//! Raw Data
|
//! Raw Data
|
||||||
RAW_DATA,
|
RAW_DATA,
|
||||||
//! Unknown format
|
//! Unknown format
|
||||||
|
@ -86,26 +107,18 @@ public:
|
||||||
@param imageType the type of image, currently only supporting two types.
|
@param imageType the type of image, currently only supporting two types.
|
||||||
@return true if loaded correctly.
|
@return true if loaded correctly.
|
||||||
*/
|
*/
|
||||||
bool initWithImageFile(const char * strPath, Format imageType = Format::PNG);
|
bool initWithImageFile(const char * strPath);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Load image from stream buffer.
|
@brief Load image from stream buffer.
|
||||||
|
@param data stream buffer which holds the image data.
|
||||||
@warning kFmtRawData only supports RGBA8888.
|
@param dataLen data length expressed in (number of) bytes.
|
||||||
@param pBuffer stream buffer which holds the image data.
|
|
||||||
@param nLength data length expressed in (number of) bytes.
|
|
||||||
@param nWidth, nHeight, nBitsPerComponent are used for kFmtRawData.
|
|
||||||
@return true if loaded correctly.
|
@return true if loaded correctly.
|
||||||
*/
|
*/
|
||||||
bool initWithImageData(void * pData,
|
bool initWithImageData(void * data, int dataLen);
|
||||||
int nDataLen,
|
|
||||||
Format eFmt = Format::UNKOWN,
|
|
||||||
int nWidth = 0,
|
|
||||||
int nHeight = 0,
|
|
||||||
int nBitsPerComponent = 8);
|
|
||||||
|
|
||||||
// @warning kFmtRawData only support RGBA8888
|
// @warning kFmtRawData only support RGBA8888
|
||||||
bool initWithRawData(void *pData, int nDatalen, int nWidth, int nHeight, int nBitsPerComponent, bool bPreMulti);
|
bool initWithRawData(void *data, int dataLen, int nWidth, int nHeight, int nBitsPerComponent = 8, bool bPreMulti = false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Create image with specified string.
|
@brief Create image with specified string.
|
||||||
|
@ -130,7 +143,7 @@ public:
|
||||||
const char * pText,
|
const char * pText,
|
||||||
int nWidth = 0,
|
int nWidth = 0,
|
||||||
int nHeight = 0,
|
int nHeight = 0,
|
||||||
TextAlign eAlignMask = TextAlign::CENTER,
|
TextAlign eAlignMask = TextAlign::CENTER,
|
||||||
const char * pFontName = 0,
|
const char * pFontName = 0,
|
||||||
int nSize = 0,
|
int nSize = 0,
|
||||||
float textTintR = 1,
|
float textTintR = 1,
|
||||||
|
@ -151,6 +164,23 @@ public:
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
// Getters
|
||||||
|
inline unsigned char * getData() { return _data; }
|
||||||
|
inline int getDataLen() { return _dataLen; }
|
||||||
|
inline Format getFileType() {return _fileType; }
|
||||||
|
inline Texture2D::PixelFormat getRenderFormat() { return _renderFormat; }
|
||||||
|
inline int getWidth() { return _width; }
|
||||||
|
inline int getHeight() { return _height; }
|
||||||
|
inline bool isPremultipliedAlpha() { return _preMulti; }
|
||||||
|
inline int getNumberOfMipmaps() { return _numberOfMipmaps; }
|
||||||
|
inline MipmapInfo* getMipmaps() { return _mipmaps; }
|
||||||
|
inline bool hasPremultipliedAlpha() { return _hasPremultipliedAlpha; }
|
||||||
|
|
||||||
|
int getBitPerPixel();
|
||||||
|
bool hasAlpha();
|
||||||
|
bool isCompressed();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Save Image data to the specified file, with specified format.
|
@brief Save Image data to the specified file, with specified format.
|
||||||
|
@ -158,35 +188,35 @@ public:
|
||||||
@param bIsToRGB whether the image is saved as RGB format.
|
@param bIsToRGB whether the image is saved as RGB format.
|
||||||
*/
|
*/
|
||||||
bool saveToFile(const char *pszFilePath, bool bIsToRGB = true);
|
bool saveToFile(const char *pszFilePath, bool bIsToRGB = true);
|
||||||
|
|
||||||
// Getters
|
|
||||||
inline unsigned char * getData() { return _data; }
|
|
||||||
inline int getDataLen() { return _width * _height; }
|
|
||||||
|
|
||||||
inline bool hasAlpha() { return _hasAlpha; }
|
|
||||||
inline bool isPremultipliedAlpha() { return _preMulti; }
|
|
||||||
|
|
||||||
inline unsigned short getWidth() { return _width; };
|
|
||||||
inline unsigned short getHeight() { return _height; };
|
|
||||||
inline int getBitsPerComponent() { return _bitsPerComponent; };
|
|
||||||
//
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool initWithJpgData(void *pData, int nDatalen);
|
bool initWithJpgData(void *data, int dataLen);
|
||||||
bool initWithPngData(void *pData, int nDatalen);
|
bool initWithPngData(void *data, int dataLen);
|
||||||
bool initWithTiffData(void *pData, int nDataLen);
|
bool initWithTiffData(void *data, int dataLen);
|
||||||
bool initWithWebpData(void *pData, int nDataLen);
|
bool initWithWebpData(void *data, int dataLen);
|
||||||
|
bool initWithPVRData(void *data, int dataLen);
|
||||||
|
bool initWithPVRv2Data(void *data, int dataLen);
|
||||||
|
bool initWithPVRv3Data(void *data, int dataLen);
|
||||||
|
bool initWithETCData(void *data, int dataLen);
|
||||||
|
|
||||||
bool saveImageToPNG(const char *pszFilePath, bool bIsToRGB = true);
|
bool saveImageToPNG(const char *pszFilePath, bool bIsToRGB = true);
|
||||||
bool saveImageToJPG(const char *pszFilePath);
|
bool saveImageToJPG(const char *pszFilePath);
|
||||||
|
|
||||||
unsigned short _width;
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
||||||
unsigned short _height;
|
bool iosSaveToFile(const char *pszFilePath, bool bIsToRGB = true);
|
||||||
int _bitsPerComponent;
|
#endif
|
||||||
|
|
||||||
unsigned char *_data;
|
unsigned char *_data;
|
||||||
bool _hasAlpha;
|
int _dataLen;
|
||||||
|
int _width;
|
||||||
|
int _height;
|
||||||
|
Format _fileType;
|
||||||
|
Texture2D::PixelFormat _renderFormat;
|
||||||
bool _preMulti;
|
bool _preMulti;
|
||||||
|
MipmapInfo _mipmaps[CC_MIPMAP_MAX]; // pointer to mipmap images
|
||||||
|
int _numberOfMipmaps;
|
||||||
|
// false if we cann't auto detect the image is premultiplied or not.
|
||||||
|
bool _hasPremultipliedAlpha;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -201,7 +231,17 @@ private:
|
||||||
@param imageType the type of image, currently only supporting two types.
|
@param imageType the type of image, currently only supporting two types.
|
||||||
@return true if loaded correctly.
|
@return true if loaded correctly.
|
||||||
*/
|
*/
|
||||||
bool initWithImageFileThreadSafe(const char *fullpath, Format imageType = Format::PNG);
|
bool initWithImageFileThreadSafe(const char *fullpath);
|
||||||
|
|
||||||
|
Format detectFormat(void* data, int dataLen);
|
||||||
|
bool isPng(void *data, int dataLen);
|
||||||
|
bool isJpg(void *data, int dataLen);
|
||||||
|
bool isTiff(void *data, int dataLen);
|
||||||
|
bool isWebp(void *data, int dataLen);
|
||||||
|
bool isPvr(void *data, int dataLen);
|
||||||
|
bool isEtc(void *data, int dataLen);
|
||||||
|
|
||||||
|
bool testFormatForPvrTCSupport(uint64_t format);
|
||||||
};
|
};
|
||||||
|
|
||||||
// end of platform group
|
// end of platform group
|
||||||
|
|
|
@ -1,77 +0,0 @@
|
||||||
/****************************************************************************
|
|
||||||
Copyright (c) 2010 cocos2d-x.org
|
|
||||||
|
|
||||||
http://www.cocos2d-x.org
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
|
||||||
all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
THE SOFTWARE.
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include "platform/CCImage.h"
|
|
||||||
#include "textures/CCTexture2D.h"
|
|
||||||
#if defined(__native_client__) || defined(EMSCRIPTEN)
|
|
||||||
// TODO(sbc): I'm pretty sure all platforms should be including
|
|
||||||
// webph headers in this way.
|
|
||||||
#include "webp/decode.h"
|
|
||||||
#else
|
|
||||||
#include "decode.h"
|
|
||||||
#endif
|
|
||||||
#include "ccMacros.h"
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
NS_CC_BEGIN
|
|
||||||
|
|
||||||
bool Image::initWithWebpData(void *pData, int nDataLen)
|
|
||||||
{
|
|
||||||
bool bRet = false;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
WebPDecoderConfig config;
|
|
||||||
if (WebPInitDecoderConfig(&config) == 0) break;
|
|
||||||
if (WebPGetFeatures((uint8_t*)pData, nDataLen, &config.input) != VP8_STATUS_OK) break;
|
|
||||||
if (config.input.width == 0 || config.input.height == 0) break;
|
|
||||||
|
|
||||||
config.output.colorspace = MODE_RGBA;
|
|
||||||
_bitsPerComponent = 8;
|
|
||||||
_width = config.input.width;
|
|
||||||
_height = config.input.height;
|
|
||||||
_hasAlpha = true;
|
|
||||||
|
|
||||||
int bufferSize = _width * _height * 4;
|
|
||||||
_data = new unsigned char[bufferSize];
|
|
||||||
|
|
||||||
config.output.u.RGBA.rgba = (uint8_t*)_data;
|
|
||||||
config.output.u.RGBA.stride = _width * 4;
|
|
||||||
config.output.u.RGBA.size = bufferSize;
|
|
||||||
config.output.is_external_memory = 1;
|
|
||||||
|
|
||||||
if (WebPDecode((uint8_t*)pData, nDataLen, &config) != VP8_STATUS_OK)
|
|
||||||
{
|
|
||||||
delete []_data;
|
|
||||||
_data = NULL;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
bRet = true;
|
|
||||||
} while (0);
|
|
||||||
return bRet;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_CC_END
|
|
File diff suppressed because it is too large
Load Diff
|
@ -46,6 +46,7 @@ Config of cocos2d-x project, per target platform.
|
||||||
#define CC_PLATFORM_NACL 9
|
#define CC_PLATFORM_NACL 9
|
||||||
#define CC_PLATFORM_EMSCRIPTEN 10
|
#define CC_PLATFORM_EMSCRIPTEN 10
|
||||||
#define CC_PLATFORM_TIZEN 11
|
#define CC_PLATFORM_TIZEN 11
|
||||||
|
#define CC_PLATFORM_QT5 12
|
||||||
|
|
||||||
// Determine target platform by compile environment macro.
|
// Determine target platform by compile environment macro.
|
||||||
#define CC_TARGET_PLATFORM CC_PLATFORM_UNKNOWN
|
#define CC_TARGET_PLATFORM CC_PLATFORM_UNKNOWN
|
||||||
|
@ -116,6 +117,12 @@ Config of cocos2d-x project, per target platform.
|
||||||
#define CC_TARGET_PLATFORM CC_PLATFORM_TIZEN
|
#define CC_TARGET_PLATFORM CC_PLATFORM_TIZEN
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// qt5
|
||||||
|
#if defined(CC_TARGET_QT5)
|
||||||
|
#undef CC_TARGET_PLATFORM
|
||||||
|
#define CC_TARGET_PLATFORM CC_PLATFORM_QT5
|
||||||
|
#endif
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
// post configure
|
// post configure
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* define a create function for a specific type, such as Layer
|
* define a create function for a specific type, such as Layer
|
||||||
* @__TYPE__ class type to add create(), such as Layer
|
* @param \__TYPE__ class type to add create(), such as Layer
|
||||||
*/
|
*/
|
||||||
#define CREATE_FUNC(__TYPE__) \
|
#define CREATE_FUNC(__TYPE__) \
|
||||||
static __TYPE__* create() \
|
static __TYPE__* create() \
|
||||||
|
@ -54,8 +54,8 @@ static __TYPE__* create() \
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* define a node function for a specific type, such as Layer
|
* define a node function for a specific type, such as Layer
|
||||||
* @__TYPE__ class type to add node(), such as Layer
|
* @param \__TYPE__ class type to add node(), such as Layer
|
||||||
* @deprecated: This interface will be deprecated sooner or later.
|
* @deprecated This interface will be deprecated sooner or later.
|
||||||
*/
|
*/
|
||||||
#define NODE_FUNC(__TYPE__) \
|
#define NODE_FUNC(__TYPE__) \
|
||||||
CC_DEPRECATED_ATTRIBUTE static __TYPE__* node() \
|
CC_DEPRECATED_ATTRIBUTE static __TYPE__* node() \
|
||||||
|
@ -111,12 +111,12 @@ It's new in cocos2d-x since v0.99.5
|
||||||
|
|
||||||
/** CC_PROPERTY_READONLY is used to declare a protected variable.
|
/** CC_PROPERTY_READONLY is used to declare a protected variable.
|
||||||
We can use getter to read the variable.
|
We can use getter to read the variable.
|
||||||
@param varType : the type of variable.
|
@param varType the type of variable.
|
||||||
@param varName : variable name.
|
@param varName variable name.
|
||||||
@param funName : "get + funName" is the name of the getter.
|
@param funName "get + funName" will be the name of the getter.
|
||||||
@warning : The getter is a public virtual function, you should rewrite it first.
|
@warning The getter is a public virtual function, you should rewrite it first.
|
||||||
The variables and methods declared after CC_PROPERTY_READONLY are all public.
|
The variables and methods declared after CC_PROPERTY_READONLY are all public.
|
||||||
If you need protected or private, please declare.
|
If you need protected or private, please declare.
|
||||||
*/
|
*/
|
||||||
#define CC_PROPERTY_READONLY(varType, varName, funName)\
|
#define CC_PROPERTY_READONLY(varType, varName, funName)\
|
||||||
protected: varType varName;\
|
protected: varType varName;\
|
||||||
|
@ -128,13 +128,13 @@ public: virtual const varType& get##funName(void) const;
|
||||||
|
|
||||||
/** CC_PROPERTY is used to declare a protected variable.
|
/** CC_PROPERTY is used to declare a protected variable.
|
||||||
We can use getter to read the variable, and use the setter to change the variable.
|
We can use getter to read the variable, and use the setter to change the variable.
|
||||||
@param varType : the type of variable.
|
@param varType the type of variable.
|
||||||
@param varName : variable name.
|
@param varName variable name.
|
||||||
@param funName : "get + funName" is the name of the getter.
|
@param funName "get + funName" will be the name of the getter.
|
||||||
"set + funName" is the name of the setter.
|
"set + funName" will be the name of the setter.
|
||||||
@warning : The getter and setter are public virtual functions, you should rewrite them first.
|
@warning The getter and setter are public virtual functions, you should rewrite them first.
|
||||||
The variables and methods declared after CC_PROPERTY are all public.
|
The variables and methods declared after CC_PROPERTY are all public.
|
||||||
If you need protected or private, please declare.
|
If you need protected or private, please declare.
|
||||||
*/
|
*/
|
||||||
#define CC_PROPERTY(varType, varName, funName)\
|
#define CC_PROPERTY(varType, varName, funName)\
|
||||||
protected: varType varName;\
|
protected: varType varName;\
|
||||||
|
@ -148,12 +148,12 @@ public: virtual void set##funName(const varType& var);
|
||||||
|
|
||||||
/** CC_SYNTHESIZE_READONLY is used to declare a protected variable.
|
/** CC_SYNTHESIZE_READONLY is used to declare a protected variable.
|
||||||
We can use getter to read the variable.
|
We can use getter to read the variable.
|
||||||
@param varType : the type of variable.
|
@param varType the type of variable.
|
||||||
@param varName : variable name.
|
@param varName variable name.
|
||||||
@param funName : "get + funName" is the name of the getter.
|
@param funName "get + funName" will be the name of the getter.
|
||||||
@warning : The getter is a public inline function.
|
@warning The getter is a public inline function.
|
||||||
The variables and methods declared after CC_SYNTHESIZE_READONLY are all public.
|
The variables and methods declared after CC_SYNTHESIZE_READONLY are all public.
|
||||||
If you need protected or private, please declare.
|
If you need protected or private, please declare.
|
||||||
*/
|
*/
|
||||||
#define CC_SYNTHESIZE_READONLY(varType, varName, funName)\
|
#define CC_SYNTHESIZE_READONLY(varType, varName, funName)\
|
||||||
protected: varType varName;\
|
protected: varType varName;\
|
||||||
|
@ -165,13 +165,13 @@ public: virtual const varType& get##funName(void) const { return varName; }
|
||||||
|
|
||||||
/** CC_SYNTHESIZE is used to declare a protected variable.
|
/** CC_SYNTHESIZE is used to declare a protected variable.
|
||||||
We can use getter to read the variable, and use the setter to change the variable.
|
We can use getter to read the variable, and use the setter to change the variable.
|
||||||
@param varType : the type of variable.
|
@param varType the type of variable.
|
||||||
@param varName : variable name.
|
@param varName variable name.
|
||||||
@param funName : "get + funName" is the name of the getter.
|
@param funName "get + funName" will be the name of the getter.
|
||||||
"set + funName" is the name of the setter.
|
"set + funName" will be the name of the setter.
|
||||||
@warning : The getter and setter are public inline functions.
|
@warning The getter and setter are public inline functions.
|
||||||
The variables and methods declared after CC_SYNTHESIZE are all public.
|
The variables and methods declared after CC_SYNTHESIZE are all public.
|
||||||
If you need protected or private, please declare.
|
If you need protected or private, please declare.
|
||||||
*/
|
*/
|
||||||
#define CC_SYNTHESIZE(varType, varName, funName)\
|
#define CC_SYNTHESIZE(varType, varName, funName)\
|
||||||
protected: varType varName;\
|
protected: varType varName;\
|
||||||
|
|
|
@ -35,14 +35,11 @@ NS_CC_BEGIN
|
||||||
// XXX deprecated
|
// XXX deprecated
|
||||||
void CCLog(const char * pszFormat, ...)
|
void CCLog(const char * pszFormat, ...)
|
||||||
{
|
{
|
||||||
char buf[MAX_LEN];
|
|
||||||
|
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, pszFormat);
|
va_start(args, pszFormat);
|
||||||
vsnprintf(buf, MAX_LEN, pszFormat, args);
|
__android_log_vprint(ANDROID_LOG_DEBUG, "cocos2d-x debug info", pszFormat, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
__android_log_print(ANDROID_LOG_DEBUG, "cocos2d-x debug info", buf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void log(const char * pszFormat, ...)
|
void log(const char * pszFormat, ...)
|
||||||
|
@ -54,7 +51,7 @@ void log(const char * pszFormat, ...)
|
||||||
vsnprintf(buf, MAX_LEN, pszFormat, args);
|
vsnprintf(buf, MAX_LEN, pszFormat, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
__android_log_print(ANDROID_LOG_DEBUG, "cocos2d-x debug info", buf);
|
__android_log_print(ANDROID_LOG_DEBUG, "cocos2d-x debug info", "%s", buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageBox(const char * pszMsg, const char * pszTitle)
|
void MessageBox(const char * pszMsg, const char * pszTitle)
|
||||||
|
@ -64,7 +61,7 @@ void MessageBox(const char * pszMsg, const char * pszTitle)
|
||||||
|
|
||||||
void LuaLog(const char * pszFormat)
|
void LuaLog(const char * pszFormat)
|
||||||
{
|
{
|
||||||
__android_log_print(ANDROID_LOG_DEBUG, "cocos2d-x debug info", pszFormat);
|
__android_log_write(ANDROID_LOG_DEBUG, "cocos2d-x debug info", pszFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
|
@ -228,7 +228,7 @@ unsigned char* FileUtilsAndroid::doGetFileData(const char* filename, const char*
|
||||||
{
|
{
|
||||||
std::string msg = "Get data from file(";
|
std::string msg = "Get data from file(";
|
||||||
msg.append(filename).append(") failed!");
|
msg.append(filename).append(") failed!");
|
||||||
CCLOG(msg.c_str());
|
CCLOG("%s", msg.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
return pData;
|
return pData;
|
||||||
|
|
|
@ -168,9 +168,8 @@ bool Image::initWithString(
|
||||||
|
|
||||||
_width = (short)dc._width;
|
_width = (short)dc._width;
|
||||||
_height = (short)dc._height;
|
_height = (short)dc._height;
|
||||||
_hasAlpha = true;
|
|
||||||
_preMulti = true;
|
_preMulti = true;
|
||||||
_bitsPerComponent = 8;
|
_renderFormat = Texture2D::PixelFormat::RGBA8888;
|
||||||
|
|
||||||
bRet = true;
|
bRet = true;
|
||||||
} while (0);
|
} while (0);
|
||||||
|
@ -220,9 +219,8 @@ bool Image::initWithStringShadowStroke(
|
||||||
|
|
||||||
_width = (short)dc._width;
|
_width = (short)dc._width;
|
||||||
_height = (short)dc._height;
|
_height = (short)dc._height;
|
||||||
_hasAlpha = true;
|
|
||||||
_preMulti = true;
|
_preMulti = true;
|
||||||
_bitsPerComponent = 8;
|
_renderFormat = Texture2D::PixelFormat::RGBA8888;
|
||||||
|
|
||||||
// swap the alpha channel (ARGB to RGBA)
|
// swap the alpha channel (ARGB to RGBA)
|
||||||
swapAlphaChannel((unsigned int *)_data, (_width * _height) );
|
swapAlphaChannel((unsigned int *)_data, (_width * _height) );
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
<classpath>
|
<classpath>
|
||||||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
|
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
|
||||||
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
|
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
|
||||||
|
<classpathentry kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
|
||||||
<classpathentry kind="src" path="src"/>
|
<classpathentry kind="src" path="src"/>
|
||||||
<classpathentry kind="src" path="gen"/>
|
<classpathentry kind="src" path="gen"/>
|
||||||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
|
|
||||||
<classpathentry kind="output" path="bin/classes"/>
|
<classpathentry kind="output" path="bin/classes"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|
|
@ -0,0 +1,442 @@
|
||||||
|
/****************************************************************************
|
||||||
|
Copyright (c) 2010 cocos2d-x.org
|
||||||
|
|
||||||
|
http://www.cocos2d-x.org
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
****************************************************************************/
|
||||||
|
#define __CC_PLATFORM_IMAGE_CPP__
|
||||||
|
#include "platform/CCImageCommon_cpp.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
#include <sstream>
|
||||||
|
#include <algorithm>
|
||||||
|
#include "platform/CCImage.h"
|
||||||
|
#include "platform/CCFileUtils.h"
|
||||||
|
#include "platform/CCCommon.h"
|
||||||
|
#include "CCStdC.h"
|
||||||
|
#include "ft2build.h"
|
||||||
|
#include FT_FREETYPE_H
|
||||||
|
|
||||||
|
#define szFont_kenning 2
|
||||||
|
|
||||||
|
#define SHIFT6(num) (num>>6)
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
struct TextLine {
|
||||||
|
int iLineWidth;
|
||||||
|
wchar_t* text;
|
||||||
|
};
|
||||||
|
|
||||||
|
NS_CC_BEGIN
|
||||||
|
|
||||||
|
class BitmapDC
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
BitmapDC()
|
||||||
|
{
|
||||||
|
libError = FT_Init_FreeType( &library );
|
||||||
|
iInterval = szFont_kenning;
|
||||||
|
_data = NULL;
|
||||||
|
reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
~BitmapDC(void)
|
||||||
|
{
|
||||||
|
FT_Done_FreeType(library);
|
||||||
|
}
|
||||||
|
|
||||||
|
void reset() {
|
||||||
|
iMaxLineWidth = 0;
|
||||||
|
iMaxLineHeight = 0;
|
||||||
|
size_t size = vLines.size();
|
||||||
|
for (int i=0; i<size; ++i) {
|
||||||
|
TextLine line = vLines[i];
|
||||||
|
free(line.text);
|
||||||
|
}
|
||||||
|
vLines.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int utf8(char **p)
|
||||||
|
{
|
||||||
|
if ((**p & 0x80) == 0x00)
|
||||||
|
{
|
||||||
|
int a = *((*p)++);
|
||||||
|
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
if ((**p & 0xE0) == 0xC0)
|
||||||
|
{
|
||||||
|
int a = *((*p)++) & 0x1F;
|
||||||
|
int b = *((*p)++) & 0x3F;
|
||||||
|
|
||||||
|
return (a << 6) | b;
|
||||||
|
}
|
||||||
|
if ((**p & 0xF0) == 0xE0)
|
||||||
|
{
|
||||||
|
int a = *((*p)++) & 0x0F;
|
||||||
|
int b = *((*p)++) & 0x3F;
|
||||||
|
int c = *((*p)++) & 0x3F;
|
||||||
|
|
||||||
|
return (a << 12) | (b << 6) | c;
|
||||||
|
}
|
||||||
|
if ((**p & 0xF8) == 0xF0)
|
||||||
|
{
|
||||||
|
int a = *((*p)++) & 0x07;
|
||||||
|
int b = *((*p)++) & 0x3F;
|
||||||
|
int c = *((*p)++) & 0x3F;
|
||||||
|
int d = *((*p)++) & 0x3F;
|
||||||
|
|
||||||
|
return (a << 18) | (b << 12) | (c << 8) | d;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void buildLine(wchar_t* buf, size_t buf_len, FT_Face face, int iCurXCursor, FT_UInt cLastChar) {
|
||||||
|
TextLine oTempLine;
|
||||||
|
wchar_t* text = (wchar_t*)malloc(sizeof(wchar_t) * (buf_len+1));
|
||||||
|
memcpy(text, buf, sizeof(wchar_t) * buf_len);
|
||||||
|
text[buf_len] = '\0';
|
||||||
|
oTempLine.text = text;
|
||||||
|
|
||||||
|
//get last glyph
|
||||||
|
int iError = FT_Load_Char(face, cLastChar, FT_LOAD_DEFAULT);
|
||||||
|
|
||||||
|
oTempLine.iLineWidth = iCurXCursor - SHIFT6((face->glyph->metrics.horiAdvance - face->glyph->metrics.horiBearingX - face->glyph->metrics.width))/*-iInterval*/;//TODO interval
|
||||||
|
iMaxLineWidth = MAX(iMaxLineWidth, oTempLine.iLineWidth);
|
||||||
|
|
||||||
|
vLines.push_back(oTempLine);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool divideString(FT_Face face, const char* sText, int iMaxWidth, int iMaxHeight) {
|
||||||
|
int iError = 0;
|
||||||
|
int iCurXCursor, iCurYCursor;
|
||||||
|
const char* pText = sText;
|
||||||
|
|
||||||
|
FT_UInt unicode = utf8((char**)&pText);
|
||||||
|
iError = FT_Load_Char(face, unicode, FT_LOAD_DEFAULT);
|
||||||
|
if (iError) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
iCurXCursor = -SHIFT6(face->glyph->metrics.horiBearingX);
|
||||||
|
|
||||||
|
FT_UInt cLastCh = 0;
|
||||||
|
|
||||||
|
pText = sText;
|
||||||
|
size_t text_len = 0;
|
||||||
|
wchar_t* text_buf = (wchar_t*) malloc(sizeof(wchar_t) * strlen(sText));
|
||||||
|
while (unicode=utf8((char**)&pText)) {
|
||||||
|
if (unicode == '\n') {
|
||||||
|
buildLine(text_buf, text_len, face, iCurXCursor, cLastCh);
|
||||||
|
text_len = 0;
|
||||||
|
|
||||||
|
iError = FT_Load_Char(face, unicode, FT_LOAD_DEFAULT);
|
||||||
|
if (iError) {
|
||||||
|
free(text_buf);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
iCurXCursor = -SHIFT6(face->glyph->metrics.horiBearingX);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
iError = FT_Load_Char(face, unicode, FT_LOAD_DEFAULT);
|
||||||
|
|
||||||
|
if (iError) {
|
||||||
|
free(text_buf);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//check its width
|
||||||
|
//divide it when exceeding
|
||||||
|
if ((iMaxWidth > 0
|
||||||
|
&& iCurXCursor + SHIFT6(face->glyph->metrics.width)
|
||||||
|
> iMaxWidth)) {
|
||||||
|
buildLine(text_buf, text_len, face , iCurXCursor, cLastCh);
|
||||||
|
text_len = 0;
|
||||||
|
|
||||||
|
iCurXCursor = -SHIFT6(face->glyph->metrics.horiBearingX);
|
||||||
|
}
|
||||||
|
|
||||||
|
cLastCh = unicode;
|
||||||
|
text_buf[text_len] = unicode;
|
||||||
|
++text_len;
|
||||||
|
iCurXCursor += SHIFT6(face->glyph->metrics.horiAdvance) + iInterval;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (iError) {
|
||||||
|
free(text_buf);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
buildLine(text_buf, text_len, face, iCurXCursor, cLastCh);
|
||||||
|
free(text_buf);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* compute the start pos of every line
|
||||||
|
*
|
||||||
|
* return >0 represent the start x pos of the line
|
||||||
|
* while -1 means fail
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
int computeLineStart(FT_Face face, Image::TextAlign eAlignMask, char cText,
|
||||||
|
int iLineIndex) {
|
||||||
|
int iRet;
|
||||||
|
int iError = FT_Load_Glyph(face, FT_Get_Char_Index(face, cText),
|
||||||
|
FT_LOAD_DEFAULT);
|
||||||
|
if (iError) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (eAlignMask == Image::kAlignCenter) {
|
||||||
|
iRet = (iMaxLineWidth - vLines[iLineIndex].iLineWidth) / 2
|
||||||
|
- SHIFT6(face->glyph->metrics.horiBearingX );
|
||||||
|
|
||||||
|
} else if (eAlignMask == Image::kAlignRight) {
|
||||||
|
iRet = (iMaxLineWidth - vLines[iLineIndex].iLineWidth)
|
||||||
|
- SHIFT6(face->glyph->metrics.horiBearingX );
|
||||||
|
} else {
|
||||||
|
// left or other situation
|
||||||
|
iRet = -SHIFT6(face->glyph->metrics.horiBearingX );
|
||||||
|
}
|
||||||
|
return iRet;
|
||||||
|
}
|
||||||
|
|
||||||
|
int computeLineStartY( FT_Face face, Image::TextAlign eAlignMask, int txtHeight, int borderHeight ){
|
||||||
|
int iRet;
|
||||||
|
if (eAlignMask == Image::kAlignCenter || eAlignMask == Image::kAlignLeft ||
|
||||||
|
eAlignMask == Image::kAlignRight ) {
|
||||||
|
//vertical center
|
||||||
|
iRet = (borderHeight - txtHeight)/2 + SHIFT6(face->size->metrics.ascender);
|
||||||
|
|
||||||
|
} else if (eAlignMask == Image::kAlignBottomRight ||
|
||||||
|
eAlignMask == Image::kAlignBottom ||
|
||||||
|
eAlignMask == Image::kAlignBottomLeft ) {
|
||||||
|
//vertical bottom
|
||||||
|
iRet = borderHeight - txtHeight + SHIFT6(face->size->metrics.ascender);
|
||||||
|
} else {
|
||||||
|
// left or other situation
|
||||||
|
iRet = SHIFT6(face->size->metrics.ascender);
|
||||||
|
}
|
||||||
|
return iRet;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool getBitmap(const char *text, int nWidth, int nHeight, Image::TextAlign eAlignMask, const char * pFontName, float fontSize) {
|
||||||
|
FT_Face face;
|
||||||
|
FT_Error iError;
|
||||||
|
|
||||||
|
const char* pText = text;
|
||||||
|
//data will be deleted by Image
|
||||||
|
// if (_data) {
|
||||||
|
// delete _data;
|
||||||
|
// }
|
||||||
|
|
||||||
|
int iCurXCursor, iCurYCursor;
|
||||||
|
bool bRet = false;
|
||||||
|
if (libError) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
do {
|
||||||
|
//CCLog(" ---- FT_New_Face with pFontName = %s", pFontName);
|
||||||
|
iError = FT_New_Face( library, pFontName, 0, &face );
|
||||||
|
|
||||||
|
if (iError) {
|
||||||
|
//no valid font found use default
|
||||||
|
//CCLog(" ---- no valid font, use default %s", pFontName);
|
||||||
|
iError = FT_New_Face( library, "/usr/fonts/font_repository/monotype/arial.ttf", 0, &face );
|
||||||
|
}
|
||||||
|
CC_BREAK_IF(iError);
|
||||||
|
|
||||||
|
//select utf8 charmap
|
||||||
|
iError = FT_Select_Charmap(face,FT_ENCODING_UNICODE);
|
||||||
|
CC_BREAK_IF(iError);
|
||||||
|
|
||||||
|
iError = FT_Set_Pixel_Sizes(face, fontSize,fontSize);
|
||||||
|
CC_BREAK_IF(iError);
|
||||||
|
|
||||||
|
iError = divideString(face, text, nWidth, nHeight)?0:1;
|
||||||
|
|
||||||
|
//compute the final line width
|
||||||
|
iMaxLineWidth = MAX(iMaxLineWidth, nWidth);
|
||||||
|
|
||||||
|
iMaxLineHeight = (face->size->metrics.ascender >> 6)
|
||||||
|
- (face->size->metrics.descender >> 6);
|
||||||
|
iMaxLineHeight *= vLines.size();
|
||||||
|
|
||||||
|
int txtHeight = iMaxLineHeight;
|
||||||
|
|
||||||
|
//compute the final line height
|
||||||
|
iMaxLineHeight = MAX(iMaxLineHeight, nHeight);
|
||||||
|
_data = new unsigned char[iMaxLineWidth * iMaxLineHeight*4];
|
||||||
|
// iCurYCursor = SHIFT6(face->size->metrics.ascender);
|
||||||
|
iCurYCursor = computeLineStartY( face, eAlignMask, txtHeight, iMaxLineHeight );
|
||||||
|
|
||||||
|
memset(_data,0, iMaxLineWidth * iMaxLineHeight*4);
|
||||||
|
|
||||||
|
size_t lines = vLines.size();
|
||||||
|
for (size_t i = 0; i < lines; i++) {
|
||||||
|
const wchar_t* text_ptr = vLines[i].text;
|
||||||
|
|
||||||
|
//initialize the origin cursor
|
||||||
|
iCurXCursor = computeLineStart(face, eAlignMask, text_ptr[0], i);
|
||||||
|
|
||||||
|
size_t text_len = wcslen(text_ptr);
|
||||||
|
for (size_t i=0; i<text_len; ++i) {
|
||||||
|
int iError = FT_Load_Char(face, text_ptr[i], FT_LOAD_RENDER);
|
||||||
|
if (iError) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// convert glyph to bitmap with 256 gray
|
||||||
|
// and get the bitmap
|
||||||
|
FT_Bitmap& bitmap = face->glyph->bitmap;
|
||||||
|
|
||||||
|
int yoffset = iCurYCursor - (face->glyph->metrics.horiBearingY >> 6);
|
||||||
|
int xoffset = iCurXCursor + (face->glyph->metrics.horiBearingX >> 6);
|
||||||
|
for (int i = 0; i < bitmap.rows; ++i) {
|
||||||
|
for (int j = 0; j < bitmap.width; ++j) {
|
||||||
|
unsigned char cTemp = bitmap.buffer[i * bitmap.width + j];
|
||||||
|
if (cTemp == 0) continue;
|
||||||
|
|
||||||
|
// if it has gray>0 we set show it as 1, o otherwise
|
||||||
|
int iY = yoffset + i;
|
||||||
|
int iX = xoffset + j;
|
||||||
|
|
||||||
|
if (iY>=iMaxLineHeight) {
|
||||||
|
//exceed the height truncate
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// _data[(iY * iMaxLineWidth + iX) * 4 + 3] =
|
||||||
|
// bitmap.buffer[i * bitmap.width + j] ?
|
||||||
|
// 0xff : 0;//alpha
|
||||||
|
// _data[(iY * iMaxLineWidth + iX) * 4 + 1] =
|
||||||
|
// bitmap.buffer[i * bitmap.width + j];//R
|
||||||
|
// _data[(iY * iMaxLineWidth + iX) * 4 + 2] =
|
||||||
|
// bitmap.buffer[i * bitmap.width + j];//G
|
||||||
|
// _data[(iY * iMaxLineWidth + iX) * 4 + 0] =
|
||||||
|
// bitmap.buffer[i * bitmap.width + j];//B
|
||||||
|
|
||||||
|
int iTemp = cTemp << 24 | cTemp << 16 | cTemp << 8 | cTemp;
|
||||||
|
*(int*) &_data[(iY * iMaxLineWidth + iX) * 4 + 0] = iTemp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//step to next glyph
|
||||||
|
iCurXCursor += (face->glyph->metrics.horiAdvance >> 6)
|
||||||
|
+ iInterval;
|
||||||
|
|
||||||
|
pText++;
|
||||||
|
}
|
||||||
|
iCurYCursor += (face->size->metrics.ascender >> 6)
|
||||||
|
- (face->size->metrics.descender >> 6);
|
||||||
|
}
|
||||||
|
//print all image bitmap
|
||||||
|
// for (int i = 0; i < iMaxLineHeight; i++) {
|
||||||
|
// for (int j = 0; j < iMaxLineWidth; j++) {
|
||||||
|
// printf("%d",
|
||||||
|
// _data[(i * iMaxLineWidth + j) * 4] ? 1 : 0);
|
||||||
|
// }
|
||||||
|
// printf("\n");
|
||||||
|
// }
|
||||||
|
|
||||||
|
// free face
|
||||||
|
FT_Done_Face(face);
|
||||||
|
face = NULL;
|
||||||
|
|
||||||
|
//clear all lines
|
||||||
|
vLines.clear();
|
||||||
|
|
||||||
|
//success;
|
||||||
|
if (iError) {
|
||||||
|
bRet = false;
|
||||||
|
} else
|
||||||
|
bRet = true;
|
||||||
|
}while(0);
|
||||||
|
|
||||||
|
return bRet;
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
FT_Library library;
|
||||||
|
unsigned char *_data;
|
||||||
|
int libError;
|
||||||
|
vector<TextLine> vLines;
|
||||||
|
int iInterval;
|
||||||
|
int iMaxLineWidth;
|
||||||
|
int iMaxLineHeight;
|
||||||
|
};
|
||||||
|
|
||||||
|
static BitmapDC& sharedBitmapDC()
|
||||||
|
{
|
||||||
|
static BitmapDC s_BmpDC;
|
||||||
|
return s_BmpDC;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Image::initWithString(
|
||||||
|
const char * pText,
|
||||||
|
int nWidth/* = 0*/,
|
||||||
|
int nHeight/* = 0*/,
|
||||||
|
TextAlign eAlignMask/* = kAlignCenter*/,
|
||||||
|
const char * pFontName/* = nil*/,
|
||||||
|
int nSize/* = 0*/)
|
||||||
|
{
|
||||||
|
bool bRet = false;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
CC_BREAK_IF(! pText);
|
||||||
|
BitmapDC &dc = sharedBitmapDC();
|
||||||
|
|
||||||
|
std::string fullFontName = pFontName;
|
||||||
|
std::string lowerCasePath = fullFontName;
|
||||||
|
std::transform(lowerCasePath.begin(), lowerCasePath.end(), lowerCasePath.begin(), ::tolower);
|
||||||
|
|
||||||
|
if ( lowerCasePath.find(".ttf") != std::string::npos ) {
|
||||||
|
fullFontName = FileUtils::getInstance()->fullPathForFilename(pFontName);
|
||||||
|
}
|
||||||
|
//CCLog("-----pText=%s and Font File is %s nWidth= %d,nHeight=%d",pText,fullFontName.c_str(),nWidth,nHeight);
|
||||||
|
|
||||||
|
CC_BREAK_IF(! dc.getBitmap(pText, nWidth, nHeight, eAlignMask, fullFontName.c_str(), nSize));
|
||||||
|
//CCLog("---- dc.getBitmap is Succesfull...");
|
||||||
|
|
||||||
|
// assign the dc._data to _data in order to save time
|
||||||
|
_data = dc._data;
|
||||||
|
CC_BREAK_IF(! _data);
|
||||||
|
|
||||||
|
_width = (short)dc.iMaxLineWidth;
|
||||||
|
_height = (short)dc.iMaxLineHeight;
|
||||||
|
_preMulti = true;
|
||||||
|
_renderFormat = Texture2D::PixelFormat::RGBA8888;
|
||||||
|
|
||||||
|
bRet = true;
|
||||||
|
|
||||||
|
dc.reset();
|
||||||
|
|
||||||
|
} while (0);
|
||||||
|
|
||||||
|
return bRet;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_CC_END
|
||||||
|
|
|
@ -130,7 +130,7 @@ public:
|
||||||
* while -1 means fail
|
* while -1 means fail
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
int computeLineStart(TTF_Font *face, Image::ETextAlign eAlignMask, char cText,
|
int computeLineStart(TTF_Font *face, Image::TextAlign eAlignMask, char cText,
|
||||||
int iLineIndex) {
|
int iLineIndex) {
|
||||||
return 0;
|
return 0;
|
||||||
/*
|
/*
|
||||||
|
@ -156,7 +156,7 @@ public:
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
int computeLineStartY( TTF_Font *face, Image::ETextAlign eAlignMask, int txtHeight, int borderHeight ){
|
int computeLineStartY( TTF_Font *face, Image::TextAlign eAlignMask, int txtHeight, int borderHeight ){
|
||||||
return 0;
|
return 0;
|
||||||
/*
|
/*
|
||||||
int iRet;
|
int iRet;
|
||||||
|
@ -178,7 +178,7 @@ public:
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
bool getBitmap(const char *text, int nWidth, int nHeight, Image::ETextAlign eAlignMask, const char * pFontName, float fontSize) {
|
bool getBitmap(const char *text, int nWidth, int nHeight, Image::TextAlign eAlignMask, const char * pFontName, float fontSize) {
|
||||||
const char* pText = text;
|
const char* pText = text;
|
||||||
int pxSize = (int)fontSize;
|
int pxSize = (int)fontSize;
|
||||||
|
|
||||||
|
@ -284,7 +284,7 @@ bool Image::initWithString(
|
||||||
const char * pText,
|
const char * pText,
|
||||||
int nWidth/* = 0*/,
|
int nWidth/* = 0*/,
|
||||||
int nHeight/* = 0*/,
|
int nHeight/* = 0*/,
|
||||||
ETextAlign eAlignMask/* = kAlignCenter*/,
|
TextAlign eAlignMask/* = kAlignCenter*/,
|
||||||
const char * pFontName/* = nil*/,
|
const char * pFontName/* = nil*/,
|
||||||
int nSize/* = 0*/)
|
int nSize/* = 0*/)
|
||||||
{
|
{
|
||||||
|
@ -306,9 +306,8 @@ bool Image::initWithString(
|
||||||
|
|
||||||
_width = (short)dc.iMaxLineWidth;
|
_width = (short)dc.iMaxLineWidth;
|
||||||
_height = (short)dc.iMaxLineHeight;
|
_height = (short)dc.iMaxLineHeight;
|
||||||
_hasAlpha = true;
|
|
||||||
_preMulti = true;
|
_preMulti = true;
|
||||||
_bitsPerComponent = 8;
|
_renderFormat = Texture2D::PixelFormat::RGBA8888;
|
||||||
|
|
||||||
bRet = true;
|
bRet = true;
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,8 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
#include "CCImageCommon_cpp.h"
|
||||||
|
|
||||||
#import "CCImage.h"
|
#import "CCImage.h"
|
||||||
#import "CCFileUtils.h"
|
#import "CCFileUtils.h"
|
||||||
#import "CCCommon.h"
|
#import "CCCommon.h"
|
||||||
|
@ -36,8 +38,6 @@ typedef struct
|
||||||
{
|
{
|
||||||
unsigned int height;
|
unsigned int height;
|
||||||
unsigned int width;
|
unsigned int width;
|
||||||
int bitsPerComponent;
|
|
||||||
bool hasAlpha;
|
|
||||||
bool isPremultipliedAlpha;
|
bool isPremultipliedAlpha;
|
||||||
bool hasShadow;
|
bool hasShadow;
|
||||||
CGSize shadowOffset;
|
CGSize shadowOffset;
|
||||||
|
@ -56,91 +56,6 @@ typedef struct
|
||||||
|
|
||||||
} tImageInfo;
|
} tImageInfo;
|
||||||
|
|
||||||
static bool _initWithImage(CGImageRef cgImage, tImageInfo *pImageinfo)
|
|
||||||
{
|
|
||||||
if(cgImage == NULL)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// get image info
|
|
||||||
|
|
||||||
pImageinfo->width = CGImageGetWidth(cgImage);
|
|
||||||
pImageinfo->height = CGImageGetHeight(cgImage);
|
|
||||||
|
|
||||||
CGImageAlphaInfo info = CGImageGetAlphaInfo(cgImage);
|
|
||||||
pImageinfo->hasAlpha = (info == kCGImageAlphaPremultipliedLast)
|
|
||||||
|| (info == kCGImageAlphaPremultipliedFirst)
|
|
||||||
|| (info == kCGImageAlphaLast)
|
|
||||||
|| (info == kCGImageAlphaFirst);
|
|
||||||
|
|
||||||
// If OS version < 5.x, add condition to support jpg
|
|
||||||
float systemVersion = [[[UIDevice currentDevice] systemVersion] floatValue];
|
|
||||||
if(systemVersion < 5.0f)
|
|
||||||
{
|
|
||||||
pImageinfo->hasAlpha = (pImageinfo->hasAlpha || (info == kCGImageAlphaNoneSkipLast));
|
|
||||||
}
|
|
||||||
|
|
||||||
CGColorSpaceRef colorSpace = CGImageGetColorSpace(cgImage);
|
|
||||||
if (colorSpace)
|
|
||||||
{
|
|
||||||
if (pImageinfo->hasAlpha)
|
|
||||||
{
|
|
||||||
info = kCGImageAlphaPremultipliedLast;
|
|
||||||
pImageinfo->isPremultipliedAlpha = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
info = kCGImageAlphaNoneSkipLast;
|
|
||||||
pImageinfo->isPremultipliedAlpha = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// change to RGBA8888
|
|
||||||
pImageinfo->hasAlpha = true;
|
|
||||||
pImageinfo->bitsPerComponent = 8;
|
|
||||||
pImageinfo->data = new unsigned char[pImageinfo->width * pImageinfo->height * 4];
|
|
||||||
colorSpace = CGColorSpaceCreateDeviceRGB();
|
|
||||||
CGContextRef context = CGBitmapContextCreate(pImageinfo->data,
|
|
||||||
pImageinfo->width,
|
|
||||||
pImageinfo->height,
|
|
||||||
8,
|
|
||||||
4 * pImageinfo->width,
|
|
||||||
colorSpace,
|
|
||||||
info | kCGBitmapByteOrder32Big);
|
|
||||||
|
|
||||||
CGContextClearRect(context, CGRectMake(0, 0, pImageinfo->width, pImageinfo->height));
|
|
||||||
//CGContextTranslateCTM(context, 0, 0);
|
|
||||||
CGContextDrawImage(context, CGRectMake(0, 0, pImageinfo->width, pImageinfo->height), cgImage);
|
|
||||||
|
|
||||||
CGContextRelease(context);
|
|
||||||
CFRelease(colorSpace);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool _initWithData(void * pBuffer, int length, tImageInfo *pImageinfo)
|
|
||||||
{
|
|
||||||
bool ret = false;
|
|
||||||
|
|
||||||
if (pBuffer)
|
|
||||||
{
|
|
||||||
CGImageRef CGImage;
|
|
||||||
NSData *data;
|
|
||||||
|
|
||||||
data = [NSData dataWithBytes:pBuffer length:length];
|
|
||||||
CGImage = [[UIImage imageWithData:data] CGImage];
|
|
||||||
|
|
||||||
ret = _initWithImage(CGImage, pImageinfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static CGSize _calculateStringSize(NSString *str, id font, CGSize *constrainSize)
|
static CGSize _calculateStringSize(NSString *str, id font, CGSize *constrainSize)
|
||||||
{
|
{
|
||||||
NSArray *listItems = [str componentsSeparatedByString: @"\n"];
|
NSArray *listItems = [str componentsSeparatedByString: @"\n"];
|
||||||
|
@ -386,9 +301,7 @@ static bool _initWithString(const char * pText, cocos2d::Image::TextAlign eAlign
|
||||||
|
|
||||||
// output params
|
// output params
|
||||||
pInfo->data = data;
|
pInfo->data = data;
|
||||||
pInfo->hasAlpha = true;
|
|
||||||
pInfo->isPremultipliedAlpha = true;
|
pInfo->isPremultipliedAlpha = true;
|
||||||
pInfo->bitsPerComponent = 8;
|
|
||||||
pInfo->width = dim.width;
|
pInfo->width = dim.width;
|
||||||
pInfo->height = dim.height;
|
pInfo->height = dim.height;
|
||||||
bRet = true;
|
bRet = true;
|
||||||
|
@ -400,145 +313,6 @@ static bool _initWithString(const char * pText, cocos2d::Image::TextAlign eAlign
|
||||||
|
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
|
|
||||||
Image::Image()
|
|
||||||
: _width(0)
|
|
||||||
, _height(0)
|
|
||||||
, _bitsPerComponent(0)
|
|
||||||
, _data(0)
|
|
||||||
, _hasAlpha(false)
|
|
||||||
, _preMulti(false)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Image::~Image()
|
|
||||||
{
|
|
||||||
CC_SAFE_DELETE_ARRAY(_data);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Image::initWithImageFile(const char * strPath, Format eImgFmt/* = eFmtPng*/)
|
|
||||||
{
|
|
||||||
bool bRet = false;
|
|
||||||
unsigned long nSize = 0;
|
|
||||||
unsigned char* pBuffer = FileUtils::getInstance()->getFileData(
|
|
||||||
FileUtils::getInstance()->fullPathForFilename(strPath).c_str(),
|
|
||||||
"rb",
|
|
||||||
&nSize);
|
|
||||||
|
|
||||||
if (pBuffer != NULL && nSize > 0)
|
|
||||||
{
|
|
||||||
bRet = initWithImageData(pBuffer, nSize, eImgFmt);
|
|
||||||
}
|
|
||||||
CC_SAFE_DELETE_ARRAY(pBuffer);
|
|
||||||
return bRet;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Image::initWithImageFileThreadSafe(const char *fullpath, Format imageType)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* FileUtils::fullPathFromRelativePath() is not thread-safe.
|
|
||||||
*/
|
|
||||||
bool bRet = false;
|
|
||||||
unsigned long nSize = 0;
|
|
||||||
unsigned char* pBuffer = FileUtils::getInstance()->getFileData(fullpath, "rb", &nSize);
|
|
||||||
if (pBuffer != NULL && nSize > 0)
|
|
||||||
{
|
|
||||||
bRet = initWithImageData(pBuffer, nSize, imageType);
|
|
||||||
}
|
|
||||||
CC_SAFE_DELETE_ARRAY(pBuffer);
|
|
||||||
return bRet;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Image::initWithImageData(void * pData,
|
|
||||||
int nDataLen,
|
|
||||||
Format eFmt,
|
|
||||||
int nWidth,
|
|
||||||
int nHeight,
|
|
||||||
int nBitsPerComponent)
|
|
||||||
{
|
|
||||||
bool bRet = false;
|
|
||||||
tImageInfo info = {0};
|
|
||||||
|
|
||||||
info.hasShadow = false;
|
|
||||||
info.hasStroke = false;
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
CC_BREAK_IF(! pData || nDataLen <= 0);
|
|
||||||
if (eFmt == Format::RAW_DATA)
|
|
||||||
{
|
|
||||||
bRet = initWithRawData(pData, nDataLen, nWidth, nHeight, nBitsPerComponent, false);
|
|
||||||
}
|
|
||||||
else if (eFmt == Format::WEBP)
|
|
||||||
{
|
|
||||||
bRet = initWithWebpData(pData, nDataLen);
|
|
||||||
}
|
|
||||||
else // init with png or jpg file data
|
|
||||||
{
|
|
||||||
bRet = _initWithData(pData, nDataLen, &info);
|
|
||||||
if (bRet)
|
|
||||||
{
|
|
||||||
_height = (short)info.height;
|
|
||||||
_width = (short)info.width;
|
|
||||||
_bitsPerComponent = info.bitsPerComponent;
|
|
||||||
_hasAlpha = info.hasAlpha;
|
|
||||||
_preMulti = info.isPremultipliedAlpha;
|
|
||||||
_data = info.data;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} while (0);
|
|
||||||
|
|
||||||
return bRet;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Image::initWithRawData(void *pData, int nDatalen, int nWidth, int nHeight, int nBitsPerComponent, bool bPreMulti)
|
|
||||||
{
|
|
||||||
bool bRet = false;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
CC_BREAK_IF(0 == nWidth || 0 == nHeight);
|
|
||||||
|
|
||||||
_bitsPerComponent = nBitsPerComponent;
|
|
||||||
_height = (short)nHeight;
|
|
||||||
_width = (short)nWidth;
|
|
||||||
_hasAlpha = true;
|
|
||||||
|
|
||||||
// only RGBA8888 supported
|
|
||||||
int nBytesPerComponent = 4;
|
|
||||||
int nSize = nHeight * nWidth * nBytesPerComponent;
|
|
||||||
_data = new unsigned char[nSize];
|
|
||||||
CC_BREAK_IF(! _data);
|
|
||||||
memcpy(_data, pData, nSize);
|
|
||||||
|
|
||||||
bRet = true;
|
|
||||||
} while (0);
|
|
||||||
return bRet;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Image::initWithJpgData(void *pData, int nDatalen)
|
|
||||||
{
|
|
||||||
assert(0);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Image::initWithPngData(void *pData, int nDatalen)
|
|
||||||
{
|
|
||||||
assert(0);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Image::saveImageToPNG(const char *pszFilePath, bool bIsToRGB)
|
|
||||||
{
|
|
||||||
assert(0);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Image::saveImageToJPG(const char *pszFilePath)
|
|
||||||
{
|
|
||||||
assert(0);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Image::initWithString(
|
bool Image::initWithString(
|
||||||
const char * pText,
|
const char * pText,
|
||||||
int nWidth /* = 0 */,
|
int nWidth /* = 0 */,
|
||||||
|
@ -572,7 +346,7 @@ bool Image::initWithStringShadowStroke(
|
||||||
float strokeSize)
|
float strokeSize)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
tImageInfo info = {0};
|
tImageInfo info = {0};
|
||||||
info.width = nWidth;
|
info.width = nWidth;
|
||||||
|
@ -598,16 +372,14 @@ bool Image::initWithStringShadowStroke(
|
||||||
}
|
}
|
||||||
_height = (short)info.height;
|
_height = (short)info.height;
|
||||||
_width = (short)info.width;
|
_width = (short)info.width;
|
||||||
_bitsPerComponent = info.bitsPerComponent;
|
_renderFormat = Texture2D::PixelFormat::RGBA8888;
|
||||||
_hasAlpha = info.hasAlpha;
|
|
||||||
_preMulti = info.isPremultipliedAlpha;
|
_preMulti = info.isPremultipliedAlpha;
|
||||||
_data = info.data;
|
_data = info.data;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Image::iosSaveToFile(const char *pszFilePath, bool bIsToRGB)
|
||||||
bool Image::saveToFile(const char *pszFilePath, bool bIsToRGB)
|
|
||||||
{
|
{
|
||||||
bool saveToPNG = false;
|
bool saveToPNG = false;
|
||||||
bool needToCopyPixels = false;
|
bool needToCopyPixels = false;
|
||||||
|
@ -618,7 +390,7 @@ bool Image::saveToFile(const char *pszFilePath, bool bIsToRGB)
|
||||||
}
|
}
|
||||||
|
|
||||||
int bitsPerComponent = 8;
|
int bitsPerComponent = 8;
|
||||||
int bitsPerPixel = _hasAlpha ? 32 : 24;
|
int bitsPerPixel = hasAlpha() ? 32 : 24;
|
||||||
if ((! saveToPNG) || bIsToRGB)
|
if ((! saveToPNG) || bIsToRGB)
|
||||||
{
|
{
|
||||||
bitsPerPixel = 24;
|
bitsPerPixel = 24;
|
||||||
|
@ -631,7 +403,7 @@ bool Image::saveToFile(const char *pszFilePath, bool bIsToRGB)
|
||||||
|
|
||||||
// The data has alpha channel, and want to save it with an RGB png file,
|
// The data has alpha channel, and want to save it with an RGB png file,
|
||||||
// or want to save as jpg, remove the alpha channel.
|
// or want to save as jpg, remove the alpha channel.
|
||||||
if ((saveToPNG && _hasAlpha && bIsToRGB)
|
if ((saveToPNG && hasAlpha() && bIsToRGB)
|
||||||
|| (! saveToPNG))
|
|| (! saveToPNG))
|
||||||
{
|
{
|
||||||
pixels = new unsigned char[myDataLength];
|
pixels = new unsigned char[myDataLength];
|
||||||
|
@ -651,7 +423,7 @@ bool Image::saveToFile(const char *pszFilePath, bool bIsToRGB)
|
||||||
|
|
||||||
// make data provider with data.
|
// make data provider with data.
|
||||||
CGBitmapInfo bitmapInfo = kCGBitmapByteOrderDefault;
|
CGBitmapInfo bitmapInfo = kCGBitmapByteOrderDefault;
|
||||||
if (saveToPNG && _hasAlpha && (! bIsToRGB))
|
if (saveToPNG && hasAlpha() && (! bIsToRGB))
|
||||||
{
|
{
|
||||||
bitmapInfo |= kCGImageAlphaPremultipliedLast;
|
bitmapInfo |= kCGImageAlphaPremultipliedLast;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,78 +7,26 @@
|
||||||
|
|
||||||
#include "CCEGLView.h"
|
#include "CCEGLView.h"
|
||||||
#include "CCGL.h"
|
#include "CCGL.h"
|
||||||
#include "GL/glfw.h"
|
|
||||||
#include "ccMacros.h"
|
#include "ccMacros.h"
|
||||||
#include "CCDirector.h"
|
#include "CCDirector.h"
|
||||||
#include "touch_dispatcher/CCTouch.h"
|
#include "touch_dispatcher/CCTouch.h"
|
||||||
#include "touch_dispatcher/CCTouchDispatcher.h"
|
#include "touch_dispatcher/CCTouchDispatcher.h"
|
||||||
#include "text_input_node/CCIMEDispatcher.h"
|
#include "text_input_node/CCIMEDispatcher.h"
|
||||||
#include "keyboard_dispatcher/CCKeyboardDispatcher.h"
|
#include "keyboard_dispatcher/CCKeyboardDispatcher.h"
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
PFNGLGENFRAMEBUFFERSEXTPROC glGenFramebuffersEXT = NULL;
|
bool initExtensions()
|
||||||
PFNGLDELETEFRAMEBUFFERSEXTPROC glDeleteFramebuffersEXT = NULL;
|
{
|
||||||
PFNGLBINDFRAMEBUFFEREXTPROC glBindFramebufferEXT = NULL;
|
// Do nothing, on Linux we use GLEW.
|
||||||
PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC glCheckFramebufferStatusEXT = NULL;
|
|
||||||
PFNGLFRAMEBUFFERTEXTURE2DEXTPROC glFramebufferTexture2DEXT = NULL;
|
|
||||||
PFNGLGENERATEMIPMAPEXTPROC glGenerateMipmapEXT = NULL;
|
|
||||||
|
|
||||||
PFNGLGENBUFFERSARBPROC glGenBuffersARB = NULL;
|
|
||||||
PFNGLBINDBUFFERARBPROC glBindBufferARB = NULL;
|
|
||||||
PFNGLBUFFERDATAARBPROC glBufferDataARB = NULL;
|
|
||||||
PFNGLBUFFERSUBDATAARBPROC glBufferSubDataARB = NULL;
|
|
||||||
PFNGLDELETEBUFFERSARBPROC glDeleteBuffersARB = NULL;
|
|
||||||
|
|
||||||
bool initExtensions() {
|
|
||||||
#define LOAD_EXTENSION_FUNCTION(TYPE, FN) FN = (TYPE)glfwGetProcAddress(#FN);
|
|
||||||
bool bRet = false;
|
|
||||||
do {
|
|
||||||
|
|
||||||
// char* p = (char*) glGetString(GL_EXTENSIONS);
|
|
||||||
// printf(p);
|
|
||||||
|
|
||||||
/* Supports frame buffer? */
|
|
||||||
if (glfwExtensionSupported("GL_EXT_framebuffer_object") != GL_FALSE)
|
|
||||||
{
|
|
||||||
|
|
||||||
/* Loads frame buffer extension functions */
|
|
||||||
LOAD_EXTENSION_FUNCTION(PFNGLGENERATEMIPMAPEXTPROC,
|
|
||||||
glGenerateMipmapEXT);
|
|
||||||
LOAD_EXTENSION_FUNCTION(PFNGLGENFRAMEBUFFERSEXTPROC,
|
|
||||||
glGenFramebuffersEXT);
|
|
||||||
LOAD_EXTENSION_FUNCTION(PFNGLDELETEFRAMEBUFFERSEXTPROC,
|
|
||||||
glDeleteFramebuffersEXT);
|
|
||||||
LOAD_EXTENSION_FUNCTION(PFNGLBINDFRAMEBUFFEREXTPROC,
|
|
||||||
glBindFramebufferEXT);
|
|
||||||
LOAD_EXTENSION_FUNCTION(PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC,
|
|
||||||
glCheckFramebufferStatusEXT);
|
|
||||||
LOAD_EXTENSION_FUNCTION(PFNGLFRAMEBUFFERTEXTURE2DEXTPROC,
|
|
||||||
glFramebufferTexture2DEXT);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (glfwExtensionSupported("GL_ARB_vertex_buffer_object") != GL_FALSE) {
|
|
||||||
LOAD_EXTENSION_FUNCTION(PFNGLGENBUFFERSARBPROC, glGenBuffersARB);
|
|
||||||
LOAD_EXTENSION_FUNCTION(PFNGLBINDBUFFERARBPROC, glBindBufferARB);
|
|
||||||
LOAD_EXTENSION_FUNCTION(PFNGLBUFFERDATAARBPROC, glBufferDataARB);
|
|
||||||
LOAD_EXTENSION_FUNCTION(PFNGLBUFFERSUBDATAARBPROC,
|
|
||||||
glBufferSubDataARB);
|
|
||||||
LOAD_EXTENSION_FUNCTION(PFNGLDELETEBUFFERSARBPROC,
|
|
||||||
glDeleteBuffersARB);
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
bRet = true;
|
|
||||||
} while (0);
|
|
||||||
return bRet;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
|
|
||||||
EGLView::EGLView()
|
EGLView::EGLView()
|
||||||
: bIsInit(false)
|
: _wasInit(false)
|
||||||
, _frameZoomFactor(1.0f)
|
, _frameZoomFactor(1.0f)
|
||||||
|
,_window(nullptr)
|
||||||
|
,_context(nullptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,185 +34,83 @@ EGLView::~EGLView()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void keyEventHandle(int iKeyID,int iKeyState) {
|
static std::string getApplicationName()
|
||||||
if (iKeyState ==GLFW_RELEASE) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (iKeyID == GLFW_KEY_DEL) {
|
|
||||||
IMEDispatcher::sharedDispatcher()->dispatchDeleteBackward();
|
|
||||||
} else if (iKeyID == GLFW_KEY_ENTER) {
|
|
||||||
IMEDispatcher::sharedDispatcher()->dispatchInsertText("\n", 1);
|
|
||||||
} else if (iKeyID == GLFW_KEY_TAB) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void charEventHandle(int iCharID,int iCharState) {
|
|
||||||
if (iCharState ==GLFW_RELEASE) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ascii char
|
|
||||||
IMEDispatcher::sharedDispatcher()->dispatchInsertText((const char *)&iCharID, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void mouseButtonEventHandle(int iMouseID,int iMouseState) {
|
|
||||||
if (iMouseID == GLFW_MOUSE_BUTTON_LEFT) {
|
|
||||||
EGLView* pEGLView = EGLView::getInstance();
|
|
||||||
//get current mouse pos
|
|
||||||
int x,y;
|
|
||||||
glfwGetMousePos(&x, &y);
|
|
||||||
Point oPoint((float)x,(float)y);
|
|
||||||
/*
|
|
||||||
if (!Rect::RectContainsPoint(s_pMainWindow->_rcViewPort,oPoint))
|
|
||||||
{
|
|
||||||
CCLOG("not in the viewport");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
oPoint.x /= pEGLView->_frameZoomFactor;
|
|
||||||
oPoint.y /= pEGLView->_frameZoomFactor;
|
|
||||||
int id = 0;
|
|
||||||
if (iMouseState == GLFW_PRESS) {
|
|
||||||
pEGLView->handleTouchesBegin(1, &id, &oPoint.x, &oPoint.y);
|
|
||||||
|
|
||||||
} else if (iMouseState == GLFW_RELEASE) {
|
|
||||||
pEGLView->handleTouchesEnd(1, &id, &oPoint.x, &oPoint.y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void mousePosEventHandle(int iPosX,int iPosY) {
|
|
||||||
int iButtonState = glfwGetMouseButton(GLFW_MOUSE_BUTTON_LEFT);
|
|
||||||
|
|
||||||
//to test move
|
|
||||||
if (iButtonState == GLFW_PRESS) {
|
|
||||||
EGLView* pEGLView = EGLView::getInstance();
|
|
||||||
int id = 0;
|
|
||||||
float x = (float)iPosX;
|
|
||||||
float y = (float)iPosY;
|
|
||||||
x /= pEGLView->_frameZoomFactor;
|
|
||||||
y /= pEGLView->_frameZoomFactor;
|
|
||||||
pEGLView->handleTouchesMove(1, &id, &x, &y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int closeEventHandle() {
|
|
||||||
Director::getInstance()->end();
|
|
||||||
return GL_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLFWCALL keyboardEventHandle(int keyCode, int action)
|
|
||||||
{
|
{
|
||||||
KeyboardDispatcher *kbDisp = Director::getInstance()->getKeyboardDispatcher();
|
char fullpath[256] = {0};
|
||||||
|
ssize_t length = readlink("/proc/self/exe", fullpath, sizeof(fullpath)-1);
|
||||||
|
|
||||||
switch (action)
|
if (length <= 0) {
|
||||||
{
|
return "Cocos2dx-Linux";
|
||||||
case GLFW_PRESS:
|
}
|
||||||
kbDisp->dispatchKeyboardEvent(keyCode, true);
|
|
||||||
break;
|
fullpath[length] = '\0';
|
||||||
case GLFW_RELEASE:
|
const std::string appPath = fullpath;
|
||||||
kbDisp->dispatchKeyboardEvent(keyCode, false);
|
return appPath.substr(appPath.find_last_of('/') + 1);
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
|
void checkSDLError(int line)
|
||||||
|
{
|
||||||
|
#if COCOS2D_DEBUG > 0
|
||||||
|
const char *error = SDL_GetError();
|
||||||
|
if (*error != '\0')
|
||||||
|
{
|
||||||
|
if (line != -1)
|
||||||
|
CCLOG("SDL Error: %s, line: %i", error, line);
|
||||||
|
else
|
||||||
|
CCLOG("SDL Error: %s", error);
|
||||||
|
SDL_ClearError();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void EGLView::setFrameSize(float width, float height)
|
void EGLView::setFrameSize(float width, float height)
|
||||||
{
|
{
|
||||||
bool eResult = false;
|
bool eResult = false;
|
||||||
int u32GLFWFlags = GLFW_WINDOW;
|
//create the window by SDL2.
|
||||||
//create the window by glfw.
|
|
||||||
|
|
||||||
//check
|
//check
|
||||||
CCAssert(width!=0&&height!=0, "invalid window's size equal 0");
|
CCAssert(width!=0&&height!=0, "invalid window's size equal 0");
|
||||||
|
|
||||||
//Inits GLFW
|
//Inits SDL2
|
||||||
eResult = glfwInit() != GL_FALSE;
|
eResult = SDL_Init(SDL_INIT_VIDEO) == 0;
|
||||||
|
if (!eResult) {
|
||||||
|
CCAssert(0, "fail to init the SDL");
|
||||||
|
}
|
||||||
|
|
||||||
if (!eResult) {
|
const std::string appName = getApplicationName();
|
||||||
CCAssert(0, "fail to init the glfw");
|
const int iDepth = 16; // set default value
|
||||||
}
|
|
||||||
|
|
||||||
/* Updates window hint */
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
|
||||||
glfwOpenWindowHint(GLFW_WINDOW_NO_RESIZE, GL_TRUE);
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
|
||||||
|
|
||||||
int iDepth = 16; // set default value
|
_window = SDL_CreateWindow(appName.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
|
||||||
/* Depending on video depth */
|
width, height, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN);
|
||||||
switch(iDepth)
|
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
||||||
{
|
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, iDepth);
|
||||||
/* 16-bit */
|
checkSDLError(__LINE__);
|
||||||
case 16:
|
|
||||||
{
|
|
||||||
/* Updates video mode */
|
|
||||||
eResult = (glfwOpenWindow(width, height, 5, 6, 5, 0, 16, 8, (int)u32GLFWFlags) != false) ? true : false;
|
|
||||||
|
|
||||||
break;
|
_context = SDL_GL_CreateContext(_window);
|
||||||
}
|
|
||||||
|
|
||||||
/* 24-bit */
|
if (!_window || !_context) {
|
||||||
case 24:
|
CCAssert(0, "Failed to initialize OpenGL context");
|
||||||
{
|
} else {
|
||||||
/* Updates video mode */
|
SDL_GL_SetSwapInterval(1);
|
||||||
eResult = (glfwOpenWindow(width, height, 8, 8, 8, 0, 16, 8, (int)u32GLFWFlags) != false) ? true : false;
|
checkSDLError(__LINE__);
|
||||||
|
_wasInit = true;
|
||||||
|
|
||||||
break;
|
EGLViewProtocol::setFrameSize(width, height);
|
||||||
}
|
initGL();
|
||||||
|
if (!GLEW_ARB_framebuffer_object)
|
||||||
/* 32-bit */
|
CCAssert(0, "fail to init OpenGL extension ARB_framebuffer_object");
|
||||||
default:
|
if (!GLEW_ARB_vertex_buffer_object)
|
||||||
case 32:
|
CCAssert(0, "fail to init OpenGL extension ARB_vertex_buffer_object");
|
||||||
{
|
}
|
||||||
/* Updates video mode */
|
|
||||||
eResult = (glfwOpenWindow(width, height, 8, 8, 8, 8, 16, 8, (int)u32GLFWFlags) != GL_FALSE) ? true :false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Success? */
|
|
||||||
if(eResult)
|
|
||||||
{
|
|
||||||
|
|
||||||
/* Updates actual size */
|
|
||||||
// glfwGetWindowSize(&width, &height);
|
|
||||||
|
|
||||||
EGLViewProtocol::setFrameSize(width, height);
|
|
||||||
|
|
||||||
/* Updates its title */
|
|
||||||
glfwSetWindowTitle("Cocos2dx-Linux");
|
|
||||||
|
|
||||||
//set the init flag
|
|
||||||
bIsInit = true;
|
|
||||||
|
|
||||||
//register the glfw key event
|
|
||||||
glfwSetKeyCallback(keyEventHandle);
|
|
||||||
//register the glfw char event
|
|
||||||
glfwSetCharCallback(charEventHandle);
|
|
||||||
//register the glfw mouse event
|
|
||||||
glfwSetMouseButtonCallback(mouseButtonEventHandle);
|
|
||||||
//register the glfw mouse pos event
|
|
||||||
glfwSetMousePosCallback(mousePosEventHandle);
|
|
||||||
#ifdef CC_KEYBOARD_SUPPORT
|
|
||||||
//register the glfw keyboard event
|
|
||||||
glfwSetKeyCallback(keyboardEventHandle);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
glfwSetWindowCloseCallback(closeEventHandle);
|
|
||||||
|
|
||||||
//Inits extensions
|
|
||||||
eResult = initExtensions();
|
|
||||||
|
|
||||||
if (!eResult) {
|
|
||||||
CCAssert(0, "fail to init the extensions of opengl");
|
|
||||||
}
|
|
||||||
initGL();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EGLView::setFrameZoomFactor(float fZoomFactor)
|
void EGLView::setFrameZoomFactor(float fZoomFactor)
|
||||||
{
|
{
|
||||||
_frameZoomFactor = fZoomFactor;
|
_frameZoomFactor = fZoomFactor;
|
||||||
glfwSetWindowSize(_screenSize.width * fZoomFactor, _screenSize.height * fZoomFactor);
|
SDL_SetWindowSize(_window, _screenSize.width * fZoomFactor, _screenSize.height * fZoomFactor);
|
||||||
Director::getInstance()->setProjection(Director::getInstance()->getProjection());
|
Director::getInstance()->setProjection(Director::getInstance()->getProjection());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -292,26 +138,130 @@ void EGLView::setScissorInPoints(float x , float y , float w , float h)
|
||||||
|
|
||||||
bool EGLView::isOpenGLReady()
|
bool EGLView::isOpenGLReady()
|
||||||
{
|
{
|
||||||
return bIsInit;
|
return _wasInit;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EGLView::end()
|
void EGLView::end()
|
||||||
{
|
{
|
||||||
/* Exits from GLFW */
|
SDL_GL_DeleteContext(_context);
|
||||||
glfwTerminate();
|
SDL_DestroyWindow(_window);
|
||||||
delete this;
|
SDL_Quit();
|
||||||
exit(0);
|
|
||||||
|
delete this;
|
||||||
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EGLView::swapBuffers() {
|
void EGLView::swapBuffers() {
|
||||||
if (bIsInit) {
|
if (_wasInit) {
|
||||||
/* Swap buffers */
|
/* Swap buffers */
|
||||||
glfwSwapBuffers();
|
SDL_GL_SwapWindow(_window);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EGLView::setIMEKeyboardState(bool bOpen) {
|
// Polls events if SDL backend is on.
|
||||||
|
// Note that finger events allow multi-touch on Linux, but libsdl with X11
|
||||||
|
// backend does not support multitouch. However multitouch should work
|
||||||
|
// out of the box on upcoming Weston and Mir display servers.
|
||||||
|
// Also supports mouse touches emulation, keyboard events, text events.
|
||||||
|
void EGLView::pollInputEvents()
|
||||||
|
{
|
||||||
|
SDL_Event event;
|
||||||
|
while (SDL_PollEvent(&event)) {
|
||||||
|
switch (event.type) {
|
||||||
|
case SDL_QUIT:
|
||||||
|
Director::sharedDirector()->end();
|
||||||
|
break;
|
||||||
|
case SDL_MOUSEBUTTONDOWN:
|
||||||
|
if (event.button.button == SDL_BUTTON_LEFT) {
|
||||||
|
int id = event.button.which;
|
||||||
|
_pressedMouseInstances.insert(id);
|
||||||
|
Point oPoint((float)event.button.x, (float)event.button.y);
|
||||||
|
oPoint.x /= _frameZoomFactor;
|
||||||
|
oPoint.y /= _frameZoomFactor;
|
||||||
|
handleTouchesBegin(1, &id, &oPoint.x, &oPoint.y);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SDL_MOUSEBUTTONUP:
|
||||||
|
if (event.button.button == SDL_BUTTON_LEFT) {
|
||||||
|
int id = event.button.which;
|
||||||
|
_pressedMouseInstances.erase(id);
|
||||||
|
Point oPoint((float)event.button.x, (float)event.button.y);
|
||||||
|
oPoint.x /= _frameZoomFactor;
|
||||||
|
oPoint.y /= _frameZoomFactor;
|
||||||
|
handleTouchesEnd(1, &id, &oPoint.x, &oPoint.y);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SDL_MOUSEMOTION:
|
||||||
|
if (_pressedMouseInstances.count(event.motion.which)) {
|
||||||
|
int id = event.motion.which;
|
||||||
|
Point oPoint((float)event.motion.x, (float)event.motion.y);
|
||||||
|
oPoint.x /= _frameZoomFactor;
|
||||||
|
oPoint.y /= _frameZoomFactor;
|
||||||
|
handleTouchesMove(1, &id, &oPoint.x, &oPoint.y);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SDL_FINGERDOWN: {
|
||||||
|
int fingerId = event.tfinger.fingerId;
|
||||||
|
Point oPoint((float)event.tfinger.x, (float)event.tfinger.y);
|
||||||
|
oPoint.x /= _frameZoomFactor;
|
||||||
|
oPoint.y /= _frameZoomFactor;
|
||||||
|
handleTouchesBegin(1, &fingerId, &oPoint.x, &oPoint.y);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SDL_FINGERUP: {
|
||||||
|
int fingerId = event.tfinger.fingerId;
|
||||||
|
Point oPoint((float)event.tfinger.x, (float)event.tfinger.y);
|
||||||
|
oPoint.x /= _frameZoomFactor;
|
||||||
|
oPoint.y /= _frameZoomFactor;
|
||||||
|
handleTouchesEnd(1, &fingerId, &oPoint.x, &oPoint.y);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SDL_FINGERMOTION: {
|
||||||
|
int fingerId = event.tfinger.fingerId;
|
||||||
|
Point oPoint((float)event.tfinger.x, (float)event.tfinger.y);
|
||||||
|
oPoint.x /= _frameZoomFactor;
|
||||||
|
oPoint.y /= _frameZoomFactor;
|
||||||
|
handleTouchesMove(1, &fingerId, &oPoint.x, &oPoint.y);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SDL_TEXTINPUT: {
|
||||||
|
const std::string text = event.text.text;
|
||||||
|
IMEDispatcher::sharedDispatcher()->dispatchInsertText(text.c_str(), text.size());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SDL_TEXTEDITING:
|
||||||
|
// TODO: not implemented.
|
||||||
|
// In SDL text editing is similar to patching. Each patch consists of
|
||||||
|
// selected text range and string that replaces selected text.
|
||||||
|
break;
|
||||||
|
case SDL_KEYDOWN: {
|
||||||
|
if (event.key.keysym.sym == SDLK_BACKSPACE)
|
||||||
|
IMEDispatcher::sharedDispatcher()->dispatchDeleteBackward();
|
||||||
|
Director::sharedDirector()->getKeyboardDispatcher()->dispatchKeyboardEvent(event.key.keysym.sym, true);
|
||||||
|
break;
|
||||||
|
case SDL_KEYUP:
|
||||||
|
Director::sharedDirector()->getKeyboardDispatcher()->dispatchKeyboardEvent(event.key.keysym.sym, false);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void EGLView::setIMEKeyboardState(bool bOpen)
|
||||||
|
{
|
||||||
|
_IMEKeyboardOpened = bOpen;
|
||||||
|
Rect zeroRect(0, 0, 0, 0);
|
||||||
|
IMEKeyboardNotificationInfo info;
|
||||||
|
info.begin = zeroRect;
|
||||||
|
info.end = zeroRect;
|
||||||
|
info.duration = 0;
|
||||||
|
if (bOpen) {
|
||||||
|
IMEDispatcher::sharedDispatcher()->dispatchKeyboardWillShow(info);
|
||||||
|
IMEDispatcher::sharedDispatcher()->dispatchKeyboardDidShow(info);
|
||||||
|
} else {
|
||||||
|
IMEDispatcher::sharedDispatcher()->dispatchKeyboardWillHide(info);
|
||||||
|
IMEDispatcher::sharedDispatcher()->dispatchKeyboardDidHide(info);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EGLView::initGL()
|
bool EGLView::initGL()
|
||||||
|
@ -349,14 +299,6 @@ bool EGLView::initGL()
|
||||||
|
|
||||||
void EGLView::destroyGL()
|
void EGLView::destroyGL()
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
if (_DC != NULL && _RC != NULL)
|
|
||||||
{
|
|
||||||
// deselect rendering context and delete it
|
|
||||||
wglMakeCurrent(_DC, NULL);
|
|
||||||
wglDeleteContext(_RC);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EGLView* EGLView::getInstance()
|
EGLView* EGLView::getInstance()
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
#include "platform/CCCommon.h"
|
#include "platform/CCCommon.h"
|
||||||
#include "cocoa/CCGeometry.h"
|
#include "cocoa/CCGeometry.h"
|
||||||
#include "platform/CCEGLViewProtocol.h"
|
#include "platform/CCEGLViewProtocol.h"
|
||||||
|
#include <SDL2/SDL.h>
|
||||||
|
#include <set>
|
||||||
|
|
||||||
bool initExtensions();
|
bool initExtensions();
|
||||||
|
|
||||||
|
@ -18,32 +20,33 @@ NS_CC_BEGIN
|
||||||
|
|
||||||
class EGLView : public EGLViewProtocol{
|
class EGLView : public EGLViewProtocol{
|
||||||
public:
|
public:
|
||||||
EGLView();
|
EGLView();
|
||||||
virtual ~EGLView();
|
virtual ~EGLView();
|
||||||
|
|
||||||
friend void keyEventHandle(int,int);
|
friend void keyEventHandle(int,int);
|
||||||
friend void mouseButtonEventHandle(int,int);
|
friend void mouseButtonEventHandle(int,int);
|
||||||
friend void mousePosEventHandle(int,int);
|
friend void mousePosEventHandle(int,int);
|
||||||
friend void charEventHandle(int,int);
|
friend void charEventHandle(int,int);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* iPixelWidth, height: the window's size
|
* iPixelWidth, height: the window's size
|
||||||
* iWidth ,height: the point size, which may scale.
|
* iWidth ,height: the point size, which may scale.
|
||||||
* iDepth is not the buffer depth of opengl, it indicate how may bits for a pixel
|
* iDepth is not the buffer depth of opengl, it indicate how may bits for a pixel
|
||||||
*/
|
*/
|
||||||
virtual void setFrameSize(float width, float height);
|
virtual void setFrameSize(float width, float height);
|
||||||
virtual void setViewPortInPoints(float x , float y , float w , float h);
|
virtual void setViewPortInPoints(float x , float y , float w , float h);
|
||||||
virtual void setScissorInPoints(float x , float y , float w , float h);
|
virtual void setScissorInPoints(float x , float y , float w , float h);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set zoom factor for frame. This method is for debugging big resolution (e.g.new ipad) app on desktop.
|
* Set zoom factor for frame. This method is for debugging big resolution (e.g.new ipad) app on desktop.
|
||||||
*/
|
*/
|
||||||
void setFrameZoomFactor(float fZoomFactor);
|
void setFrameZoomFactor(float fZoomFactor);
|
||||||
float getFrameZoomFactor();
|
float getFrameZoomFactor();
|
||||||
virtual bool isOpenGLReady();
|
virtual bool isOpenGLReady();
|
||||||
virtual void end();
|
virtual void end();
|
||||||
virtual void swapBuffers();
|
virtual void swapBuffers();
|
||||||
virtual void setIMEKeyboardState(bool bOpen);
|
virtual void pollInputEvents();
|
||||||
|
virtual void setIMEKeyboardState(bool bOpen);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief get the shared main open gl window
|
@brief get the shared main open gl window
|
||||||
|
@ -54,13 +57,19 @@ public:
|
||||||
CC_DEPRECATED_ATTRIBUTE static EGLView* sharedOpenGLView();
|
CC_DEPRECATED_ATTRIBUTE static EGLView* sharedOpenGLView();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool initGL();
|
bool initGL();
|
||||||
void destroyGL();
|
void destroyGL();
|
||||||
private:
|
|
||||||
//store current mouse point for moving, valid if and only if the mouse pressed
|
//store current mouse point for moving, valid if and only if the mouse pressed
|
||||||
Point _mousePoint;
|
Point _mousePoint;
|
||||||
bool bIsInit;
|
bool _wasInit;
|
||||||
float _frameZoomFactor;
|
float _frameZoomFactor;
|
||||||
|
|
||||||
|
SDL_Window *_window;
|
||||||
|
SDL_GLContext _context;
|
||||||
|
// Several mouse instances are possible.
|
||||||
|
std::set<int> _pressedMouseInstances;
|
||||||
|
bool _IMEKeyboardOpened;
|
||||||
};
|
};
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
|
@ -450,9 +450,8 @@ bool Image::initWithString(
|
||||||
|
|
||||||
_width = (short)dc.iMaxLineWidth;
|
_width = (short)dc.iMaxLineWidth;
|
||||||
_height = (short)dc.iMaxLineHeight;
|
_height = (short)dc.iMaxLineHeight;
|
||||||
_hasAlpha = true;
|
_renderFormat = Texture2D::PixelFormat::RGBA8888;
|
||||||
_preMulti = true;
|
_preMulti = true;
|
||||||
_bitsPerComponent = 8;
|
|
||||||
|
|
||||||
bRet = true;
|
bRet = true;
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,8 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "CCImageCommon_cpp.h"
|
||||||
#include <Foundation/Foundation.h>
|
#include <Foundation/Foundation.h>
|
||||||
#include <Cocoa/Cocoa.h>
|
#include <Cocoa/Cocoa.h>
|
||||||
#include "CCDirector.h"
|
#include "CCDirector.h"
|
||||||
|
@ -39,275 +41,11 @@ typedef struct
|
||||||
{
|
{
|
||||||
unsigned int height;
|
unsigned int height;
|
||||||
unsigned int width;
|
unsigned int width;
|
||||||
int bitsPerComponent;
|
|
||||||
bool hasAlpha;
|
bool hasAlpha;
|
||||||
bool isPremultipliedAlpha;
|
bool isPremultipliedAlpha;
|
||||||
unsigned char* data;
|
unsigned char* data;
|
||||||
} tImageInfo;
|
} tImageInfo;
|
||||||
|
|
||||||
static unsigned int nextPOT(unsigned int x)
|
|
||||||
{
|
|
||||||
x = x - 1;
|
|
||||||
x = x | (x >> 1);
|
|
||||||
x = x | (x >> 2);
|
|
||||||
x = x | (x >> 4);
|
|
||||||
x = x | (x >> 8);
|
|
||||||
x = x | (x >> 16);
|
|
||||||
return x + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool _initPremultipliedATextureWithImage(CGImageRef image, NSUInteger POTWide, NSUInteger POTHigh, tImageInfo *pImageInfo)
|
|
||||||
{
|
|
||||||
NSUInteger i;
|
|
||||||
CGContextRef context = nil;
|
|
||||||
unsigned char* data = nil;;
|
|
||||||
CGColorSpaceRef colorSpace;
|
|
||||||
unsigned char* tempData;
|
|
||||||
unsigned int* inPixel32;
|
|
||||||
unsigned short* outPixel16;
|
|
||||||
bool hasAlpha;
|
|
||||||
CGImageAlphaInfo info;
|
|
||||||
CGSize imageSize;
|
|
||||||
Texture2D::PixelFormat pixelFormat;
|
|
||||||
|
|
||||||
info = CGImageGetAlphaInfo(image);
|
|
||||||
hasAlpha = ((info == kCGImageAlphaPremultipliedLast) || (info == kCGImageAlphaPremultipliedFirst) || (info == kCGImageAlphaLast) || (info == kCGImageAlphaFirst) ? YES : NO);
|
|
||||||
|
|
||||||
size_t bpp = CGImageGetBitsPerComponent(image);
|
|
||||||
colorSpace = CGImageGetColorSpace(image);
|
|
||||||
|
|
||||||
if(colorSpace)
|
|
||||||
{
|
|
||||||
if(hasAlpha || bpp >= 8)
|
|
||||||
{
|
|
||||||
pixelFormat = Texture2D::PixelFormat::DEFAULT;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pixelFormat = Texture2D::PixelFormat::RGB565;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// NOTE: No colorspace means a mask image
|
|
||||||
pixelFormat = Texture2D::PixelFormat::A8;
|
|
||||||
}
|
|
||||||
|
|
||||||
imageSize.width = CGImageGetWidth(image);
|
|
||||||
imageSize.height = CGImageGetHeight(image);
|
|
||||||
|
|
||||||
// Create the bitmap graphics context
|
|
||||||
|
|
||||||
switch(pixelFormat)
|
|
||||||
{
|
|
||||||
case Texture2D::PixelFormat::RGBA8888:
|
|
||||||
case Texture2D::PixelFormat::RGBA4444:
|
|
||||||
case Texture2D::PixelFormat::RGB5A1:
|
|
||||||
colorSpace = CGColorSpaceCreateDeviceRGB();
|
|
||||||
data = new unsigned char[POTHigh * POTWide * 4];
|
|
||||||
info = hasAlpha ? kCGImageAlphaPremultipliedLast : kCGImageAlphaNoneSkipLast;
|
|
||||||
context = CGBitmapContextCreate(data, POTWide, POTHigh, 8, 4 * POTWide, colorSpace, info | kCGBitmapByteOrder32Big);
|
|
||||||
CGColorSpaceRelease(colorSpace);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Texture2D::PixelFormat::RGB565:
|
|
||||||
colorSpace = CGColorSpaceCreateDeviceRGB();
|
|
||||||
data = new unsigned char[POTHigh * POTWide * 4];
|
|
||||||
info = kCGImageAlphaNoneSkipLast;
|
|
||||||
context = CGBitmapContextCreate(data, POTWide, POTHigh, 8, 4 * POTWide, colorSpace, info | kCGBitmapByteOrder32Big);
|
|
||||||
CGColorSpaceRelease(colorSpace);
|
|
||||||
break;
|
|
||||||
case Texture2D::PixelFormat::A8:
|
|
||||||
data = new unsigned char[POTHigh * POTWide];
|
|
||||||
info = kCGImageAlphaOnly;
|
|
||||||
context = CGBitmapContextCreate(data, POTWide, POTHigh, 8, POTWide, NULL, info);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
CGRect rect;
|
|
||||||
rect.size.width = POTWide;
|
|
||||||
rect.size.height = POTHigh;
|
|
||||||
rect.origin.x = 0;
|
|
||||||
rect.origin.y = 0;
|
|
||||||
|
|
||||||
CGContextClearRect(context, rect);
|
|
||||||
CGContextTranslateCTM(context, 0, 0);
|
|
||||||
CGContextDrawImage(context, rect, image);
|
|
||||||
|
|
||||||
// Repack the pixel data into the right format
|
|
||||||
|
|
||||||
if(pixelFormat == Texture2D::PixelFormat::RGB565)
|
|
||||||
{
|
|
||||||
//Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "RRRRRGGGGGGBBBBB"
|
|
||||||
tempData = new unsigned char[POTHigh * POTWide * 2];
|
|
||||||
inPixel32 = (unsigned int*)data;
|
|
||||||
outPixel16 = (unsigned short*)tempData;
|
|
||||||
for(i = 0; i < POTWide * POTHigh; ++i, ++inPixel32)
|
|
||||||
{
|
|
||||||
*outPixel16++ = ((((*inPixel32 >> 0) & 0xFF) >> 3) << 11) | ((((*inPixel32 >> 8) & 0xFF) >> 2) << 5) | ((((*inPixel32 >> 16) & 0xFF) >> 3) << 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
delete []data;
|
|
||||||
data = tempData;
|
|
||||||
|
|
||||||
}
|
|
||||||
else if (pixelFormat == Texture2D::PixelFormat::RGBA4444)
|
|
||||||
{
|
|
||||||
//Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "RRRRGGGGBBBBAAAA"
|
|
||||||
tempData = new unsigned char[POTHigh * POTWide * 2];
|
|
||||||
inPixel32 = (unsigned int*)data;
|
|
||||||
outPixel16 = (unsigned short*)tempData;
|
|
||||||
for(i = 0; i < POTWide * POTHigh; ++i, ++inPixel32)
|
|
||||||
{
|
|
||||||
*outPixel16++ =
|
|
||||||
((((*inPixel32 >> 0) & 0xFF) >> 4) << 12) | // R
|
|
||||||
((((*inPixel32 >> 8) & 0xFF) >> 4) << 8) | // G
|
|
||||||
((((*inPixel32 >> 16) & 0xFF) >> 4) << 4) | // B
|
|
||||||
((((*inPixel32 >> 24) & 0xFF) >> 4) << 0); // A
|
|
||||||
}
|
|
||||||
|
|
||||||
delete []data;
|
|
||||||
data = tempData;
|
|
||||||
|
|
||||||
}
|
|
||||||
else if (pixelFormat == Texture2D::PixelFormat::RGB5A1)
|
|
||||||
{
|
|
||||||
//Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "RRRRRGGGGGBBBBBA"
|
|
||||||
tempData = new unsigned char[POTHigh * POTWide * 2];
|
|
||||||
inPixel32 = (unsigned int*)data;
|
|
||||||
outPixel16 = (unsigned short*)tempData;
|
|
||||||
for(i = 0; i < POTWide * POTHigh; ++i, ++inPixel32)
|
|
||||||
{
|
|
||||||
*outPixel16++ =
|
|
||||||
((((*inPixel32 >> 0) & 0xFF) >> 3) << 11) | // R
|
|
||||||
((((*inPixel32 >> 8) & 0xFF) >> 3) << 6) | // G
|
|
||||||
((((*inPixel32 >> 16) & 0xFF) >> 3) << 1) | // B
|
|
||||||
((((*inPixel32 >> 24) & 0xFF) >> 7) << 0); // A
|
|
||||||
}
|
|
||||||
|
|
||||||
delete []data;
|
|
||||||
data = tempData;
|
|
||||||
}
|
|
||||||
|
|
||||||
// should be after calling super init
|
|
||||||
pImageInfo->isPremultipliedAlpha = true;
|
|
||||||
pImageInfo->hasAlpha = true;
|
|
||||||
pImageInfo->bitsPerComponent = bpp;
|
|
||||||
pImageInfo->width = POTWide;
|
|
||||||
pImageInfo->height = POTHigh;
|
|
||||||
|
|
||||||
if (pImageInfo->data)
|
|
||||||
{
|
|
||||||
delete [] pImageInfo->data;
|
|
||||||
}
|
|
||||||
pImageInfo->data = data;
|
|
||||||
|
|
||||||
CGContextRelease(context);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
// TODO: rename _initWithImage, it also makes a draw call.
|
|
||||||
static bool _initWithImage(CGImageRef CGImage, tImageInfo *pImageinfo, double scaleX, double scaleY)
|
|
||||||
{
|
|
||||||
NSUInteger POTWide, POTHigh;
|
|
||||||
|
|
||||||
if(CGImage == NULL)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//if (cocos2d::Image::getIsScaleEnabled())
|
|
||||||
if( cocos2d::Director::getInstance()->getContentScaleFactor() > 1.0f )
|
|
||||||
{
|
|
||||||
POTWide = CGImageGetWidth(CGImage) * scaleX;
|
|
||||||
POTHigh = CGImageGetHeight(CGImage) * scaleY;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
POTWide = CGImageGetWidth(CGImage);
|
|
||||||
POTHigh = CGImageGetHeight(CGImage);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// load and draw image
|
|
||||||
return _initPremultipliedATextureWithImage(CGImage, POTWide, POTHigh, pImageinfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool _initWithFile(const char* path, tImageInfo *pImageinfo)
|
|
||||||
{
|
|
||||||
CGImageRef CGImage;
|
|
||||||
NSImage *jpg;
|
|
||||||
//NSImage *png;
|
|
||||||
bool ret;
|
|
||||||
|
|
||||||
// convert jpg to png before loading the texture
|
|
||||||
|
|
||||||
NSString *fullPath = [NSString stringWithUTF8String:path];
|
|
||||||
jpg = [[NSImage alloc] initWithContentsOfFile: fullPath];
|
|
||||||
//png = [[NSImage alloc] initWithData:UIImagePNGRepresentation(jpg)];
|
|
||||||
CGImageSourceRef source = CGImageSourceCreateWithData((CFDataRef)[jpg TIFFRepresentation], NULL);
|
|
||||||
CGImage = CGImageSourceCreateImageAtIndex(source, 0, NULL);
|
|
||||||
|
|
||||||
ret = _initWithImage(CGImage, pImageinfo, 1.0, 1.0);
|
|
||||||
|
|
||||||
//[png release];
|
|
||||||
[jpg release];
|
|
||||||
if (CGImage) CFRelease(CGImage);
|
|
||||||
if (source) CFRelease(source);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: rename _initWithData, it also makes a draw call.
|
|
||||||
static bool _initWithData(void * pBuffer, int length, tImageInfo *pImageinfo, double scaleX, double scaleY)
|
|
||||||
{
|
|
||||||
bool ret = false;
|
|
||||||
|
|
||||||
if (pBuffer)
|
|
||||||
{
|
|
||||||
CGImageRef CGImage;
|
|
||||||
NSData *data;
|
|
||||||
|
|
||||||
data = [NSData dataWithBytes:pBuffer length:length];
|
|
||||||
CGImageSourceRef source = CGImageSourceCreateWithData((CFDataRef)data, NULL);
|
|
||||||
CGImage = CGImageSourceCreateImageAtIndex(source, 0, NULL);
|
|
||||||
|
|
||||||
ret = _initWithImage(CGImage, pImageinfo, scaleX, scaleY);
|
|
||||||
if (CGImage) CFRelease(CGImage);
|
|
||||||
if (source) CFRelease(source);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool _isValidFontName(const char *fontName)
|
|
||||||
{
|
|
||||||
bool ret = false;
|
|
||||||
#if 0
|
|
||||||
NSString *fontNameNS = [NSString stringWithUTF8String:fontName];
|
|
||||||
|
|
||||||
for (NSString *familiName in [NSFont familyNames])
|
|
||||||
{
|
|
||||||
if ([familiName isEqualToString:fontNameNS])
|
|
||||||
{
|
|
||||||
ret = true;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(NSString *font in [NSFont fontNamesForFamilyName: familiName])
|
|
||||||
{
|
|
||||||
if ([font isEqualToString: fontNameNS])
|
|
||||||
{
|
|
||||||
ret = true;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
out:
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool _initWithString(const char * pText, cocos2d::Image::TextAlign eAlign, const char * pFontName, int nSize, tImageInfo* pInfo, cocos2d::Color3B* pStrokeColor)
|
static bool _initWithString(const char * pText, cocos2d::Image::TextAlign eAlign, const char * pFontName, int nSize, tImageInfo* pInfo, cocos2d::Color3B* pStrokeColor)
|
||||||
{
|
{
|
||||||
bool bRet = false;
|
bool bRet = false;
|
||||||
|
@ -452,7 +190,6 @@ static bool _initWithString(const char * pText, cocos2d::Image::TextAlign eAlign
|
||||||
pInfo->data = dataNew;
|
pInfo->data = dataNew;
|
||||||
pInfo->hasAlpha = true;
|
pInfo->hasAlpha = true;
|
||||||
pInfo->isPremultipliedAlpha = true;
|
pInfo->isPremultipliedAlpha = true;
|
||||||
pInfo->bitsPerComponent = 8;
|
|
||||||
bRet = true;
|
bRet = true;
|
||||||
}
|
}
|
||||||
[bitmap release];
|
[bitmap release];
|
||||||
|
@ -461,400 +198,6 @@ static bool _initWithString(const char * pText, cocos2d::Image::TextAlign eAlign
|
||||||
return bRet;
|
return bRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool _enabledScale = true;
|
|
||||||
|
|
||||||
bool isFileExists(const char* szFilePath);
|
|
||||||
|
|
||||||
bool isFileExists(const char* szFilePath)
|
|
||||||
{
|
|
||||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
|
|
||||||
//TCHAR dirpath[MAX_PATH];
|
|
||||||
//MultiByteToWideChar(936,0,szFilePath,-1,dirpath,sizeof(dirpath));
|
|
||||||
DWORD dwFileAttr = GetFileAttributesA(szFilePath);
|
|
||||||
if (INVALID_FILE_ATTRIBUTES == dwFileAttr
|
|
||||||
|| (dwFileAttr&FILE_ATTRIBUTE_DIRECTORY)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#elif CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
|
|
||||||
bool bFind = true;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
struct stat buf;
|
|
||||||
int n = stat(szFilePath, &buf);
|
|
||||||
if ((0 != n)
|
|
||||||
|| !(buf.st_mode&S_IFMT))
|
|
||||||
{
|
|
||||||
bFind = false;
|
|
||||||
}
|
|
||||||
} while (0);
|
|
||||||
if (!bFind)
|
|
||||||
{
|
|
||||||
//std::string strFilenName = s_strRelativePath + szFilePath;
|
|
||||||
unsigned char * pBuffer = NULL;
|
|
||||||
unzFile pFile = NULL;
|
|
||||||
unsigned long pSize = 0;
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
pFile = unzOpen(s_strAndroidPackagePath.c_str());
|
|
||||||
if(!pFile)break;
|
|
||||||
|
|
||||||
int nRet = unzLocateFile(pFile, szFilePath, 1);
|
|
||||||
if(UNZ_OK != nRet)
|
|
||||||
bFind = false;
|
|
||||||
else
|
|
||||||
bFind = true;
|
|
||||||
} while (0);
|
|
||||||
|
|
||||||
if (pFile)
|
|
||||||
{
|
|
||||||
unzClose(pFile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return bFind;
|
|
||||||
#else
|
|
||||||
struct stat buf;
|
|
||||||
int n = stat(szFilePath, &buf);
|
|
||||||
if ((0 != n)
|
|
||||||
|| !(buf.st_mode&S_IFMT)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Image::Image()
|
|
||||||
: _width(0)
|
|
||||||
, _height(0)
|
|
||||||
, _bitsPerComponent(0)
|
|
||||||
, _data(0)
|
|
||||||
, _hasAlpha(false)
|
|
||||||
, _preMulti(false)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Image::~Image()
|
|
||||||
{
|
|
||||||
CC_SAFE_DELETE_ARRAY(_data);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Image::initWithImageFile(const char * strPath, Format eImgFmt/* = eFmtPng*/)
|
|
||||||
{
|
|
||||||
std::string strTemp = FileUtils::getInstance()->fullPathForFilename(strPath);
|
|
||||||
if (_enabledScale)
|
|
||||||
{
|
|
||||||
if (!isFileExists(strTemp.c_str()))
|
|
||||||
{
|
|
||||||
if (strTemp.rfind("@2x") == std::string::npos)
|
|
||||||
{
|
|
||||||
int t = strTemp.rfind(".");
|
|
||||||
if (t != std::string::npos)
|
|
||||||
{
|
|
||||||
strTemp.insert(t, "@2x");
|
|
||||||
}
|
|
||||||
/* Size size = Director::getInstance()->getWinSize();
|
|
||||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
|
||||||
_scaleX = size.width/800.0f;
|
|
||||||
_scaleY = size.height/480.0f;
|
|
||||||
#else
|
|
||||||
_scaleX = size.width/960.0f;
|
|
||||||
_scaleY = size.height/640.0f;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// _scaleX = 1.0;
|
|
||||||
// _scaleY = 1.0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// FileData tempData(strTemp.c_str(), "rb");
|
|
||||||
// return initWithImageData(tempData.getBuffer(), tempData.getSize(), eImgFmt);
|
|
||||||
|
|
||||||
unsigned long fileSize = 0;
|
|
||||||
unsigned char* pFileData = FileUtils::getInstance()->getFileData(strTemp.c_str(), "rb", &fileSize);
|
|
||||||
bool ret = initWithImageData(pFileData, fileSize, eImgFmt);
|
|
||||||
delete []pFileData;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Image::initWithImageFileThreadSafe(const char *fullpath, Format imageType)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* FileUtils::fullPathFromRelativePath() is not thread-safe, it use autorelease().
|
|
||||||
*/
|
|
||||||
bool bRet = false;
|
|
||||||
unsigned long nSize = 0;
|
|
||||||
unsigned char* pBuffer = FileUtils::getInstance()->getFileData(fullpath, "rb", &nSize);
|
|
||||||
if (pBuffer != NULL && nSize > 0)
|
|
||||||
{
|
|
||||||
bRet = initWithImageData(pBuffer, nSize, imageType);
|
|
||||||
}
|
|
||||||
CC_SAFE_DELETE_ARRAY(pBuffer);
|
|
||||||
return bRet;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
// please uncomment this and integrate it somehow if you know what your doing, thanks
|
|
||||||
bool Image::potImageData(unsigned int POTWide, unsigned int POTHigh)
|
|
||||||
{
|
|
||||||
unsigned char* data = NULL;
|
|
||||||
unsigned char* tempData =NULL;
|
|
||||||
unsigned int* inPixel32 = NULL;
|
|
||||||
unsigned short* outPixel16 = NULL;
|
|
||||||
bool hasAlpha;
|
|
||||||
Texture2D::PixelFormat pixelFormat;
|
|
||||||
|
|
||||||
hasAlpha = this->hasAlpha();
|
|
||||||
|
|
||||||
size_t bpp = this->getBitsPerComponent();
|
|
||||||
|
|
||||||
// compute pixel format
|
|
||||||
if(hasAlpha)
|
|
||||||
{
|
|
||||||
pixelFormat = Texture2D::defaultAlphaPixelFormat();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (bpp >= 8)
|
|
||||||
{
|
|
||||||
pixelFormat = Texture2D::PixelFormat::RGB888;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
CCLOG("cocos2d: Texture2D: Using RGB565 texture since image has no alpha");
|
|
||||||
pixelFormat = Texture2D::PixelFormat::RGB565;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
switch(pixelFormat) {
|
|
||||||
case Texture2D::PixelFormat::RGBA8888:
|
|
||||||
case Texture2D::PixelFormat::RGBA4444:
|
|
||||||
case Texture2D::PixelFormat::RGB5A1:
|
|
||||||
case Texture2D::PixelFormat::RGB565:
|
|
||||||
case Texture2D::PixelFormat::A8:
|
|
||||||
tempData = (unsigned char*)(this->getData());
|
|
||||||
CCASSERT(tempData != NULL, "NULL image data.");
|
|
||||||
|
|
||||||
if(this->getWidth() == (short)POTWide && this->getHeight() == (short)POTHigh)
|
|
||||||
{
|
|
||||||
data = new unsigned char[POTHigh * POTWide * 4];
|
|
||||||
memcpy(data, tempData, POTHigh * POTWide * 4);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
data = new unsigned char[POTHigh * POTWide * 4];
|
|
||||||
memset(data, 0, POTHigh * POTWide * 4);
|
|
||||||
|
|
||||||
unsigned char* pPixelData = (unsigned char*) tempData;
|
|
||||||
unsigned char* pTargetData = (unsigned char*) data;
|
|
||||||
|
|
||||||
int imageHeight = this->getHeight();
|
|
||||||
for(int y = 0; y < imageHeight; ++y)
|
|
||||||
{
|
|
||||||
memcpy(pTargetData+POTWide*4*y, pPixelData+(this->getWidth())*4*y, (this->getWidth())*4);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
case Texture2D::PixelFormat::RGB888:
|
|
||||||
tempData = (unsigned char*)(this->getData());
|
|
||||||
CCASSERT(tempData != NULL, "NULL image data.");
|
|
||||||
if(this->getWidth() == (short)POTWide && this->getHeight() == (short)POTHigh)
|
|
||||||
{
|
|
||||||
data = new unsigned char[POTHigh * POTWide * 3];
|
|
||||||
memcpy(data, tempData, POTHigh * POTWide * 3);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
data = new unsigned char[POTHigh * POTWide * 3];
|
|
||||||
memset(data, 0, POTHigh * POTWide * 3);
|
|
||||||
|
|
||||||
unsigned char* pPixelData = (unsigned char*) tempData;
|
|
||||||
unsigned char* pTargetData = (unsigned char*) data;
|
|
||||||
|
|
||||||
int imageHeight = this->getHeight();
|
|
||||||
for(int y = 0; y < imageHeight; ++y)
|
|
||||||
{
|
|
||||||
memcpy(pTargetData+POTWide*3*y, pPixelData+(this->getWidth())*3*y, (this->getWidth())*3);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
CCASSERT(0, "Invalid pixel format");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Repack the pixel data into the right format
|
|
||||||
|
|
||||||
if(pixelFormat == Texture2D::PixelFormat::RGB565) {
|
|
||||||
//Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "RRRRRGGGGGGBBBBB"
|
|
||||||
tempData = new unsigned char[POTHigh * POTWide * 2];
|
|
||||||
inPixel32 = (unsigned int*)data;
|
|
||||||
outPixel16 = (unsigned short*)tempData;
|
|
||||||
|
|
||||||
unsigned int length = POTWide * POTHigh;
|
|
||||||
for(unsigned int i = 0; i < length; ++i, ++inPixel32)
|
|
||||||
{
|
|
||||||
*outPixel16++ =
|
|
||||||
((((*inPixel32 >> 0) & 0xFF) >> 3) << 11) | // R
|
|
||||||
((((*inPixel32 >> 8) & 0xFF) >> 2) << 5) | // G
|
|
||||||
((((*inPixel32 >> 16) & 0xFF) >> 3) << 0); // B
|
|
||||||
}
|
|
||||||
|
|
||||||
delete [] data;
|
|
||||||
data = tempData;
|
|
||||||
}
|
|
||||||
else if (pixelFormat == Texture2D::PixelFormat::RGBA4444) {
|
|
||||||
//Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "RRRRGGGGBBBBAAAA"
|
|
||||||
tempData = new unsigned char[POTHigh * POTWide * 2];
|
|
||||||
inPixel32 = (unsigned int*)data;
|
|
||||||
outPixel16 = (unsigned short*)tempData;
|
|
||||||
|
|
||||||
unsigned int length = POTWide * POTHigh;
|
|
||||||
for(unsigned int i = 0; i < length; ++i, ++inPixel32)
|
|
||||||
{
|
|
||||||
*outPixel16++ =
|
|
||||||
((((*inPixel32 >> 0) & 0xFF) >> 4) << 12) | // R
|
|
||||||
((((*inPixel32 >> 8) & 0xFF) >> 4) << 8) | // G
|
|
||||||
((((*inPixel32 >> 16) & 0xFF) >> 4) << 4) | // B
|
|
||||||
((((*inPixel32 >> 24) & 0xFF) >> 4) << 0); // A
|
|
||||||
}
|
|
||||||
|
|
||||||
delete [] data;
|
|
||||||
data = tempData;
|
|
||||||
}
|
|
||||||
else if (pixelFormat == Texture2D::PixelFormat::RGB5A1) {
|
|
||||||
//Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "RRRRRGGGGGBBBBBA"
|
|
||||||
tempData = new unsigned char[POTHigh * POTWide * 2];
|
|
||||||
inPixel32 = (unsigned int*)data;
|
|
||||||
outPixel16 = (unsigned short*)tempData;
|
|
||||||
|
|
||||||
unsigned int length = POTWide * POTHigh;
|
|
||||||
for(unsigned int i = 0; i < length; ++i, ++inPixel32)
|
|
||||||
{
|
|
||||||
*outPixel16++ =
|
|
||||||
((((*inPixel32 >> 0) & 0xFF) >> 3) << 11) | // R
|
|
||||||
((((*inPixel32 >> 8) & 0xFF) >> 3) << 6) | // G
|
|
||||||
((((*inPixel32 >> 16) & 0xFF) >> 3) << 1) | // B
|
|
||||||
((((*inPixel32 >> 24) & 0xFF) >> 7) << 0); // A
|
|
||||||
}
|
|
||||||
|
|
||||||
delete []data;
|
|
||||||
data = tempData;
|
|
||||||
}
|
|
||||||
else if (pixelFormat == Texture2D::PixelFormat::A8)
|
|
||||||
{
|
|
||||||
// fix me, how to convert to A8
|
|
||||||
pixelFormat = Texture2D::PixelFormat::RGBA8888;
|
|
||||||
|
|
||||||
//
|
|
||||||
//The code can not work, how to convert to A8?
|
|
||||||
//
|
|
||||||
//tempData = new unsigned char[POTHigh * POTWide];
|
|
||||||
//inPixel32 = (unsigned int*)data;
|
|
||||||
//outPixel8 = tempData;
|
|
||||||
|
|
||||||
//unsigned int length = POTWide * POTHigh;
|
|
||||||
//for(unsigned int i = 0; i < length; ++i, ++inPixel32)
|
|
||||||
//{
|
|
||||||
// *outPixel8++ = (*inPixel32 >> 24) & 0xFF;
|
|
||||||
//}
|
|
||||||
|
|
||||||
//delete []data;
|
|
||||||
//data = tempData;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data)
|
|
||||||
{
|
|
||||||
CC_SAFE_DELETE_ARRAY(_data);
|
|
||||||
_data = data;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
//bool Image::initWithImageData(void * pData, int nDataLen, EImageFormat eFmt/* = eSrcFmtPng*/)
|
|
||||||
bool Image::initWithImageData(void * pData,
|
|
||||||
int nDataLen,
|
|
||||||
Format eFmt,
|
|
||||||
int nWidth,
|
|
||||||
int nHeight,
|
|
||||||
int nBitsPerComponent)
|
|
||||||
{
|
|
||||||
bool bRet = false;
|
|
||||||
tImageInfo info = {0};
|
|
||||||
do
|
|
||||||
{
|
|
||||||
CC_BREAK_IF(! pData || nDataLen <= 0);
|
|
||||||
|
|
||||||
if (eFmt == Format::RAW_DATA)
|
|
||||||
{
|
|
||||||
bRet = initWithRawData(pData, nDataLen, nWidth, nHeight, nBitsPerComponent, false);
|
|
||||||
}
|
|
||||||
else if (eFmt == Image::Format::WEBP)
|
|
||||||
{
|
|
||||||
bRet = initWithWebpData(pData, nDataLen);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
bRet = _initWithData(pData, nDataLen, &info, 1.0f, 1.0f);//_scaleX, _scaleY);
|
|
||||||
if (bRet)
|
|
||||||
{
|
|
||||||
_height = (short)info.height;
|
|
||||||
_width = (short)info.width;
|
|
||||||
_bitsPerComponent = info.bitsPerComponent;
|
|
||||||
if (eFmt == Format::JPG)
|
|
||||||
{
|
|
||||||
_hasAlpha = true;
|
|
||||||
_preMulti = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_hasAlpha = info.hasAlpha;
|
|
||||||
_preMulti = info.isPremultipliedAlpha;
|
|
||||||
}
|
|
||||||
_data = info.data;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} while (0);
|
|
||||||
|
|
||||||
return bRet;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Image::initWithRawData(void *pData, int nDatalen, int nWidth, int nHeight, int nBitsPerComponent, bool bPreMulti)
|
|
||||||
{
|
|
||||||
bool bRet = false;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
CC_BREAK_IF(0 == nWidth || 0 == nHeight);
|
|
||||||
|
|
||||||
_bitsPerComponent = nBitsPerComponent;
|
|
||||||
_height = (short)nHeight;
|
|
||||||
_width = (short)nWidth;
|
|
||||||
_hasAlpha = true;
|
|
||||||
|
|
||||||
// only RGBA8888 supported
|
|
||||||
int nBytesPerComponent = 4;
|
|
||||||
int nSize = nHeight * nWidth * nBytesPerComponent;
|
|
||||||
_data = new unsigned char[nSize];
|
|
||||||
CC_BREAK_IF(! _data);
|
|
||||||
memcpy(_data, pData, nSize);
|
|
||||||
|
|
||||||
bRet = true;
|
|
||||||
} while (0);
|
|
||||||
return bRet;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Image::initWithString(
|
bool Image::initWithString(
|
||||||
const char * pText,
|
const char * pText,
|
||||||
int nWidth,
|
int nWidth,
|
||||||
|
@ -873,8 +216,7 @@ bool Image::initWithString(
|
||||||
}
|
}
|
||||||
_height = (short)info.height;
|
_height = (short)info.height;
|
||||||
_width = (short)info.width;
|
_width = (short)info.width;
|
||||||
_bitsPerComponent = info.bitsPerComponent;
|
_renderFormat = Texture2D::PixelFormat::RGBA8888;
|
||||||
_hasAlpha = info.hasAlpha;
|
|
||||||
_preMulti = info.isPremultipliedAlpha;
|
_preMulti = info.isPremultipliedAlpha;
|
||||||
if (_data) {
|
if (_data) {
|
||||||
CC_SAFE_DELETE_ARRAY(_data);
|
CC_SAFE_DELETE_ARRAY(_data);
|
||||||
|
@ -884,13 +226,6 @@ bool Image::initWithString(
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Image::saveToFile(const char *pszFilePath, bool bIsToRGB)
|
|
||||||
{
|
|
||||||
assert(false);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
||||||
|
|
|
@ -462,9 +462,8 @@ bool Image::initWithString(
|
||||||
|
|
||||||
_width = (short)dc.iMaxLineWidth;
|
_width = (short)dc.iMaxLineWidth;
|
||||||
_height = (short)dc.iMaxLineHeight;
|
_height = (short)dc.iMaxLineHeight;
|
||||||
_hasAlpha = true;
|
|
||||||
_preMulti = true;
|
_preMulti = true;
|
||||||
_bitsPerComponent = 8;
|
_renderFormat = Texture2D::PixelFormat::RGBA8888;
|
||||||
|
|
||||||
bRet = true;
|
bRet = true;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Cocos2D-X Qt 5 Platform
|
||||||
|
*
|
||||||
|
* Copyright (C) 2013 Jolla Ltd.
|
||||||
|
* Contact: Thomas Perl <thomas.perl@jollamobile.com>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include "AccelerometerListener.h"
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
AccelerometerListener::AccelerometerListener(Accelerometer *accelerometer)
|
||||||
|
: QObject()
|
||||||
|
, m_accelerometer(accelerometer)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
AccelerometerListener::onReadingChanged()
|
||||||
|
{
|
||||||
|
m_accelerometer->readingChanged();
|
||||||
|
}
|
|
@ -0,0 +1,50 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Cocos2D-X Qt 5 Platform
|
||||||
|
*
|
||||||
|
* Copyright (C) 2013 Jolla Ltd.
|
||||||
|
* Contact: Thomas Perl <thomas.perl@jollamobile.com>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
|
||||||
|
#ifndef COCOS2DX_ACCELEROMETER_LISTENER_QT5_H
|
||||||
|
#define COCOS2DX_ACCELEROMETER_LISTENER_QT5_H
|
||||||
|
|
||||||
|
#include "CCAccelerometer.h"
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
USING_NS_CC;
|
||||||
|
|
||||||
|
class AccelerometerListener : public QObject {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
AccelerometerListener(Accelerometer *accelerometer);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void onReadingChanged();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Accelerometer *m_accelerometer;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* COCOS2DX_ACCELEROMETER_LISTENER_QT5_H */
|
|
@ -0,0 +1,100 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Cocos2D-X Qt 5 Platform
|
||||||
|
*
|
||||||
|
* Copyright (C) 2013 Jolla Ltd.
|
||||||
|
* Contact: Thomas Perl <thomas.perl@jollamobile.com>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include "CCAccelerometer.h"
|
||||||
|
#include "AccelerometerListener.h"
|
||||||
|
|
||||||
|
#include <QAccelerometer>
|
||||||
|
#include <QAccelerometerReading>
|
||||||
|
|
||||||
|
NS_CC_BEGIN
|
||||||
|
|
||||||
|
static Accelerometer *
|
||||||
|
shared_accelerometer = NULL;
|
||||||
|
|
||||||
|
Accelerometer::Accelerometer()
|
||||||
|
: m_accelerometer(new QAccelerometer)
|
||||||
|
, m_listener(new AccelerometerListener(this))
|
||||||
|
, m_function(nullptr)
|
||||||
|
{
|
||||||
|
QObject::connect(m_accelerometer, SIGNAL(readingChanged()),
|
||||||
|
m_listener, SLOT(onReadingChanged()));
|
||||||
|
}
|
||||||
|
|
||||||
|
Accelerometer::~Accelerometer()
|
||||||
|
{
|
||||||
|
delete m_listener;
|
||||||
|
delete m_accelerometer;
|
||||||
|
}
|
||||||
|
|
||||||
|
Accelerometer *
|
||||||
|
Accelerometer::sharedAccelerometer()
|
||||||
|
{
|
||||||
|
if (shared_accelerometer == NULL) {
|
||||||
|
shared_accelerometer = new Accelerometer;
|
||||||
|
}
|
||||||
|
|
||||||
|
return shared_accelerometer;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
Accelerometer::setDelegate(std::function<void(Acceleration*)> function)
|
||||||
|
{
|
||||||
|
m_function = function;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Accelerometer::setAccelerometerInterval(float interval)
|
||||||
|
{
|
||||||
|
if (interval == 0.0) {
|
||||||
|
m_accelerometer->setDataRate(0.0);
|
||||||
|
} else {
|
||||||
|
// Interval is specified in seconds
|
||||||
|
m_accelerometer->setDataRate(1.0 / interval);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Accelerometer::readingChanged()
|
||||||
|
{
|
||||||
|
if (m_function == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QAccelerometerReading *reading = m_accelerometer->reading();
|
||||||
|
|
||||||
|
Acceleration accel;
|
||||||
|
accel.x = reading->x();
|
||||||
|
accel.y = reading->y();
|
||||||
|
accel.z = reading->z();
|
||||||
|
accel.timestamp = reading->timestamp();
|
||||||
|
|
||||||
|
m_function(&accel);
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_CC_END
|
|
@ -0,0 +1,62 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Cocos2D-X Qt 5 Platform
|
||||||
|
*
|
||||||
|
* Copyright (C) 2013 Jolla Ltd.
|
||||||
|
* Contact: Thomas Perl <thomas.perl@jollamobile.com>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef CCACCELEROMETER_QT5_H
|
||||||
|
#define CCACCELEROMETER_QT5_H
|
||||||
|
|
||||||
|
#include "platform/CCCommon.h"
|
||||||
|
#include "platform/CCAccelerometerDelegate.h"
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
|
class QAccelerometer;
|
||||||
|
class AccelerometerListener;
|
||||||
|
|
||||||
|
NS_CC_BEGIN
|
||||||
|
|
||||||
|
class Accelerometer {
|
||||||
|
public:
|
||||||
|
Accelerometer();
|
||||||
|
~Accelerometer();
|
||||||
|
|
||||||
|
static Accelerometer *sharedAccelerometer();
|
||||||
|
|
||||||
|
void setDelegate(std::function<void(Acceleration*)> function);
|
||||||
|
void setAccelerometerInterval(float interval);
|
||||||
|
|
||||||
|
/* Functions to be called from AccelerometerListener */
|
||||||
|
void readingChanged();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QAccelerometer *m_accelerometer;
|
||||||
|
AccelerometerListener *m_listener;
|
||||||
|
std::function<void(Acceleration*)> m_function;
|
||||||
|
};
|
||||||
|
|
||||||
|
NS_CC_END
|
||||||
|
|
||||||
|
#endif /* CCACCELEROMETER_QT5_H */
|
|
@ -0,0 +1,204 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Cocos2D-X Qt 5 Platform
|
||||||
|
*
|
||||||
|
* Copyright (C) 2013 Jolla Ltd.
|
||||||
|
* Contact: Thomas Perl <thomas.perl@jollamobile.com>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include "CCApplication.h"
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <string>
|
||||||
|
#include "CCDirector.h"
|
||||||
|
#include "platform/CCFileUtils.h"
|
||||||
|
|
||||||
|
#include <QGuiApplication>
|
||||||
|
#include <QLocale>
|
||||||
|
#include <QObject>
|
||||||
|
#include <QDir>
|
||||||
|
|
||||||
|
class Cocos2DQt5MainloopIntegration : public QObject {
|
||||||
|
public:
|
||||||
|
Cocos2DQt5MainloopIntegration()
|
||||||
|
: QObject()
|
||||||
|
, m_timer(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void setInterval(int interval_ms)
|
||||||
|
{
|
||||||
|
if (m_timer != 0) {
|
||||||
|
killTimer(m_timer);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_timer = startTimer(interval_ms);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void timerEvent(QTimerEvent *event)
|
||||||
|
{
|
||||||
|
cocos2d::Director::getInstance()->mainLoop();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
int m_timer;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
NS_CC_BEGIN
|
||||||
|
|
||||||
|
// Application singleton
|
||||||
|
static Application *
|
||||||
|
application = NULL;
|
||||||
|
|
||||||
|
static int
|
||||||
|
global_fake_argc = 1;
|
||||||
|
|
||||||
|
static char *
|
||||||
|
global_fake_argv[1];
|
||||||
|
|
||||||
|
// @deprecated Use getInstance() instead
|
||||||
|
Application *
|
||||||
|
Application::sharedApplication()
|
||||||
|
{
|
||||||
|
return getInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
Application *
|
||||||
|
Application::getInstance()
|
||||||
|
{
|
||||||
|
CC_ASSERT(application != NULL);
|
||||||
|
return application;
|
||||||
|
}
|
||||||
|
|
||||||
|
Application::Application()
|
||||||
|
: m_application(NULL)
|
||||||
|
, m_animationInterval(1000 / 60)
|
||||||
|
, m_resourceRootPath("")
|
||||||
|
, m_mainloop(new Cocos2DQt5MainloopIntegration)
|
||||||
|
{
|
||||||
|
// Inject argv[0] by resolving /proc/self/exe
|
||||||
|
QString filename = QDir("/proc/self/exe").canonicalPath();
|
||||||
|
QByteArray utf8 = filename.toUtf8();
|
||||||
|
global_fake_argv[0] = strdup(utf8.data());
|
||||||
|
|
||||||
|
m_application = new QGuiApplication(global_fake_argc, global_fake_argv);
|
||||||
|
|
||||||
|
CC_ASSERT(application == NULL);
|
||||||
|
application = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Application::~Application()
|
||||||
|
{
|
||||||
|
delete m_mainloop;
|
||||||
|
delete m_application;
|
||||||
|
|
||||||
|
CC_ASSERT(application == this);
|
||||||
|
application = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
Application::run()
|
||||||
|
{
|
||||||
|
// Initialize instance and cocos2d.
|
||||||
|
if (!applicationDidFinishLaunching()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_mainloop->setInterval(m_animationInterval);
|
||||||
|
|
||||||
|
return m_application->exec();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Application::setAnimationInterval(double interval)
|
||||||
|
{
|
||||||
|
// Interval is expressed in seconds
|
||||||
|
m_animationInterval = interval * 1000;
|
||||||
|
|
||||||
|
m_mainloop->setInterval(m_animationInterval);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Application::setResourceRootPath(const std::string &rootResDir)
|
||||||
|
{
|
||||||
|
m_resourceRootPath = rootResDir;
|
||||||
|
if (m_resourceRootPath[m_resourceRootPath.length() - 1] != '/') {
|
||||||
|
m_resourceRootPath += '/';
|
||||||
|
}
|
||||||
|
FileUtils* pFileUtils = FileUtils::getInstance();
|
||||||
|
std::vector<std::string> searchPaths = pFileUtils->getSearchPaths();
|
||||||
|
searchPaths.insert(searchPaths.begin(), m_resourceRootPath);
|
||||||
|
pFileUtils->setSearchPaths(searchPaths);
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string &
|
||||||
|
Application::getResourceRootPath()
|
||||||
|
{
|
||||||
|
return m_resourceRootPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
TargetPlatform
|
||||||
|
Application::getTargetPlatform()
|
||||||
|
{
|
||||||
|
return kTargetLinux;
|
||||||
|
}
|
||||||
|
|
||||||
|
ccLanguageType
|
||||||
|
Application::getCurrentLanguage()
|
||||||
|
{
|
||||||
|
QLocale locale;
|
||||||
|
|
||||||
|
switch (locale.language()) {
|
||||||
|
case QLocale::English:
|
||||||
|
return kLanguageEnglish;
|
||||||
|
case QLocale::Chinese:
|
||||||
|
return kLanguageChinese;
|
||||||
|
case QLocale::French:
|
||||||
|
return kLanguageFrench;
|
||||||
|
case QLocale::Italian:
|
||||||
|
return kLanguageItalian;
|
||||||
|
case QLocale::German:
|
||||||
|
return kLanguageGerman;
|
||||||
|
case QLocale::Spanish:
|
||||||
|
return kLanguageSpanish;
|
||||||
|
case QLocale::Russian:
|
||||||
|
return kLanguageRussian;
|
||||||
|
case QLocale::Korean:
|
||||||
|
return kLanguageKorean;
|
||||||
|
case QLocale::Japanese:
|
||||||
|
return kLanguageJapanese;
|
||||||
|
case QLocale::Hungarian:
|
||||||
|
return kLanguageHungarian;
|
||||||
|
case QLocale::Portuguese:
|
||||||
|
return kLanguagePortuguese;
|
||||||
|
case QLocale::Arabic:
|
||||||
|
return kLanguageArabic;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return kLanguageEnglish;
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_CC_END
|
|
@ -0,0 +1,95 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Cocos2D-X Qt 5 Platform
|
||||||
|
*
|
||||||
|
* Copyright (C) 2013 Jolla Ltd.
|
||||||
|
* Contact: Thomas Perl <thomas.perl@jollamobile.com>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef CCAPPLICATION_QT5_H
|
||||||
|
#define CCAPPLICATION_QT5_H
|
||||||
|
|
||||||
|
#include "platform/CCCommon.h"
|
||||||
|
#include "platform/CCApplicationProtocol.h"
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
class QGuiApplication;
|
||||||
|
class Cocos2DQt5MainloopIntegration;
|
||||||
|
|
||||||
|
NS_CC_BEGIN
|
||||||
|
|
||||||
|
class Application : public ApplicationProtocol {
|
||||||
|
public:
|
||||||
|
Application();
|
||||||
|
virtual ~Application();
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Callback by Director for limit FPS.
|
||||||
|
@interval The time, which expressed in second in second, between current frame and next.
|
||||||
|
*/
|
||||||
|
void setAnimationInterval(double interval);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Run the message loop.
|
||||||
|
*/
|
||||||
|
int run();
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Get current application instance.
|
||||||
|
@return Current application instance pointer.
|
||||||
|
*/
|
||||||
|
static Application* getInstance();
|
||||||
|
|
||||||
|
/** @deprecated Use getInstance() instead */
|
||||||
|
CC_DEPRECATED_ATTRIBUTE static Application* sharedApplication();
|
||||||
|
|
||||||
|
/* override functions */
|
||||||
|
virtual ccLanguageType getCurrentLanguage();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the Resource root path.
|
||||||
|
* @deprecated Please use CCFileUtils::sharedFileUtils()->setSearchPaths() instead.
|
||||||
|
*/
|
||||||
|
CC_DEPRECATED_ATTRIBUTE void setResourceRootPath(const std::string &rootResDir);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the Resource root path.
|
||||||
|
* @deprecated Please use CCFileUtils::sharedFileUtils()->getSearchPaths() instead.
|
||||||
|
*/
|
||||||
|
CC_DEPRECATED_ATTRIBUTE const std::string &getResourceRootPath();
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Get target platform
|
||||||
|
*/
|
||||||
|
virtual TargetPlatform getTargetPlatform();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
QGuiApplication *m_application;
|
||||||
|
long m_animationInterval;
|
||||||
|
std::string m_resourceRootPath;
|
||||||
|
Cocos2DQt5MainloopIntegration *m_mainloop;
|
||||||
|
};
|
||||||
|
|
||||||
|
NS_CC_END
|
||||||
|
|
||||||
|
#endif /* CCAPPLICATION_QT5_H */
|
|
@ -0,0 +1,87 @@
|
||||||
|
/****************************************************************************
|
||||||
|
Copyright (c) 2010 cocos2d-x.org
|
||||||
|
|
||||||
|
http://www.cocos2d-x.org
|
||||||
|
|
||||||
|
Cocos2D-X Qt 5 Platform
|
||||||
|
Copyright (C) 2013 Jolla Ltd.
|
||||||
|
Contact: Thomas Perl <thomas.perl@jollamobile.com>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "platform/CCCommon.h"
|
||||||
|
#include "CCStdC.h"
|
||||||
|
|
||||||
|
NS_CC_BEGIN
|
||||||
|
|
||||||
|
#define MAX_LEN (cocos2d::kMaxLogLen + 1)
|
||||||
|
|
||||||
|
/* @deprecated, use cocos2d::log() instead (see below) */
|
||||||
|
void CCLog(const char * pszFormat, ...)
|
||||||
|
{
|
||||||
|
char szBuf[MAX_LEN];
|
||||||
|
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, pszFormat);
|
||||||
|
vsnprintf(szBuf, MAX_LEN, pszFormat, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
// Strip any trailing newlines from log message.
|
||||||
|
size_t len = strlen(szBuf);
|
||||||
|
while (len && szBuf[len-1] == '\n')
|
||||||
|
{
|
||||||
|
szBuf[len-1] = '\0';
|
||||||
|
len--;
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stderr, "cocos2d-x debug info [%s]\n", szBuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
void log(const char * pszFormat, ...)
|
||||||
|
{
|
||||||
|
char szBuf[MAX_LEN];
|
||||||
|
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, pszFormat);
|
||||||
|
vsnprintf(szBuf, MAX_LEN, pszFormat, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
// Strip any trailing newlines from log message.
|
||||||
|
size_t len = strlen(szBuf);
|
||||||
|
while (len && szBuf[len-1] == '\n')
|
||||||
|
{
|
||||||
|
szBuf[len-1] = '\0';
|
||||||
|
len--;
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stderr, "cocos2d-x debug info [%s]\n", szBuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MessageBox(const char * pszMsg, const char * pszTitle)
|
||||||
|
{
|
||||||
|
log("%s: %s", pszTitle, pszMsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LuaLog(const char * pszFormat)
|
||||||
|
{
|
||||||
|
puts(pszFormat);
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_CC_END
|
|
@ -0,0 +1,43 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Cocos2D-X Qt 5 Platform
|
||||||
|
*
|
||||||
|
* Copyright (C) 2013 Jolla Ltd.
|
||||||
|
* Contact: Thomas Perl <thomas.perl@jollamobile.com>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
|
||||||
|
|
||||||
|
#include "platform/CCDevice.h"
|
||||||
|
|
||||||
|
#include <QGuiApplication>
|
||||||
|
#include <QScreen>
|
||||||
|
|
||||||
|
NS_CC_BEGIN
|
||||||
|
|
||||||
|
int Device::getDPI()
|
||||||
|
{
|
||||||
|
QGuiApplication *app = static_cast<QGuiApplication*>(QGuiApplication::instance());
|
||||||
|
QScreen *screen = app->primaryScreen();
|
||||||
|
return screen->physicalDotsPerInch();
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_CC_END
|
|
@ -0,0 +1,200 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Cocos2D-X Qt 5 Platform
|
||||||
|
*
|
||||||
|
* Copyright (C) 2013 Jolla Ltd.
|
||||||
|
* Contact: Thomas Perl <thomas.perl@jollamobile.com>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
|
||||||
|
|
||||||
|
#include "CCEGLView.h"
|
||||||
|
#include "CCGL.h"
|
||||||
|
|
||||||
|
#include "ccMacros.h"
|
||||||
|
#include "CCDirector.h"
|
||||||
|
|
||||||
|
#include "touch_dispatcher/CCTouch.h"
|
||||||
|
#include "touch_dispatcher/CCTouchDispatcher.h"
|
||||||
|
#include "text_input_node/CCIMEDispatcher.h"
|
||||||
|
|
||||||
|
#include <QGuiApplication>
|
||||||
|
#include <QWindow>
|
||||||
|
|
||||||
|
#include <QOpenGLContext>
|
||||||
|
#include <QEvent>
|
||||||
|
#include <QTouchEvent>
|
||||||
|
|
||||||
|
#include <QInputMethod>
|
||||||
|
|
||||||
|
NS_CC_BEGIN
|
||||||
|
|
||||||
|
class Cocos2DQt5OpenGLIntegration : public QWindow {
|
||||||
|
public:
|
||||||
|
Cocos2DQt5OpenGLIntegration(EGLView *view, int width, int height);
|
||||||
|
~Cocos2DQt5OpenGLIntegration();
|
||||||
|
|
||||||
|
virtual void touchEvent(QTouchEvent *event);
|
||||||
|
virtual bool event(QEvent *event);
|
||||||
|
|
||||||
|
void swapBuffers();
|
||||||
|
|
||||||
|
private:
|
||||||
|
EGLView *m_egl_view;
|
||||||
|
QOpenGLContext *m_context;
|
||||||
|
};
|
||||||
|
|
||||||
|
Cocos2DQt5OpenGLIntegration::Cocos2DQt5OpenGLIntegration(EGLView *view, int width, int height)
|
||||||
|
: m_egl_view(view)
|
||||||
|
, m_context(NULL)
|
||||||
|
{
|
||||||
|
setSurfaceType(QSurface::OpenGLSurface);
|
||||||
|
resize(width, height);
|
||||||
|
showFullScreen();
|
||||||
|
|
||||||
|
m_context = new QOpenGLContext(this);
|
||||||
|
m_context->create();
|
||||||
|
m_context->makeCurrent(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
Cocos2DQt5OpenGLIntegration::~Cocos2DQt5OpenGLIntegration()
|
||||||
|
{
|
||||||
|
delete m_context;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Cocos2DQt5OpenGLIntegration::touchEvent(QTouchEvent *event)
|
||||||
|
{
|
||||||
|
foreach (QTouchEvent::TouchPoint point, event->touchPoints()) {
|
||||||
|
int id = point.id();
|
||||||
|
QPointF pos = point.pos();
|
||||||
|
float x = pos.x();
|
||||||
|
float y = pos.y();
|
||||||
|
Qt::TouchPointState state = point.state();
|
||||||
|
|
||||||
|
switch (state) {
|
||||||
|
case Qt::TouchPointPressed:
|
||||||
|
m_egl_view->handleTouchesBegin(1, &id, &x, &y);
|
||||||
|
break;
|
||||||
|
case Qt::TouchPointMoved:
|
||||||
|
m_egl_view->handleTouchesMove(1, &id, &x, &y);
|
||||||
|
break;
|
||||||
|
case Qt::TouchPointStationary:
|
||||||
|
// Do nothing
|
||||||
|
break;
|
||||||
|
case Qt::TouchPointReleased:
|
||||||
|
m_egl_view->handleTouchesEnd(1, &id, &x, &y);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// Do nothing
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
Cocos2DQt5OpenGLIntegration::event(QEvent *event)
|
||||||
|
{
|
||||||
|
if (event->type() == QEvent::Close) {
|
||||||
|
Director::getInstance()->end();
|
||||||
|
}
|
||||||
|
|
||||||
|
return QWindow::event(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Cocos2DQt5OpenGLIntegration::swapBuffers()
|
||||||
|
{
|
||||||
|
m_context->swapBuffers(this);
|
||||||
|
m_context->makeCurrent(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Global EGLView singleton for this module */
|
||||||
|
static EGLView *
|
||||||
|
egl_view = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
/** @deprecated Use getInstance() instead */
|
||||||
|
EGLView *
|
||||||
|
EGLView::sharedOpenGLView()
|
||||||
|
{
|
||||||
|
return getInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
EGLView *
|
||||||
|
EGLView::getInstance()
|
||||||
|
{
|
||||||
|
if (egl_view == NULL) {
|
||||||
|
egl_view = new EGLView;
|
||||||
|
}
|
||||||
|
|
||||||
|
return egl_view;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
EGLView::EGLView()
|
||||||
|
: m_integration(NULL)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
EGLView::~EGLView()
|
||||||
|
{
|
||||||
|
if (m_integration) {
|
||||||
|
delete m_integration;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
EGLView::setFrameSize(float width, float height)
|
||||||
|
{
|
||||||
|
if (m_integration == NULL) {
|
||||||
|
m_integration = new Cocos2DQt5OpenGLIntegration(this,
|
||||||
|
(int)width, (int)height);
|
||||||
|
} else {
|
||||||
|
m_integration->resize(width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
EGLViewProtocol::setFrameSize(width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
EGLView::swapBuffers()
|
||||||
|
{
|
||||||
|
if (m_integration != NULL) {
|
||||||
|
m_integration->swapBuffers();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
EGLView::setIMEKeyboardState(bool bOpen)
|
||||||
|
{
|
||||||
|
QGuiApplication *app = static_cast<QGuiApplication*>(QGuiApplication::instance());
|
||||||
|
app->inputMethod()->setVisible(bOpen);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
EGLView::end()
|
||||||
|
{
|
||||||
|
QGuiApplication::exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_CC_END
|
|
@ -0,0 +1,63 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Cocos2D-X Qt 5 Platform
|
||||||
|
*
|
||||||
|
* Copyright (C) 2013 Jolla Ltd.
|
||||||
|
* Contact: Thomas Perl <thomas.perl@jollamobile.com>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef CCEGLVIEW_QT5_H
|
||||||
|
#define CCEGLVIEW_QT5_H
|
||||||
|
|
||||||
|
#include "platform/CCCommon.h"
|
||||||
|
#include "cocoa/CCGeometry.h"
|
||||||
|
#include "platform/CCEGLViewProtocol.h"
|
||||||
|
|
||||||
|
NS_CC_BEGIN
|
||||||
|
|
||||||
|
class Cocos2DQt5OpenGLIntegration;
|
||||||
|
|
||||||
|
class EGLView : public EGLViewProtocol {
|
||||||
|
public:
|
||||||
|
EGLView();
|
||||||
|
virtual ~EGLView();
|
||||||
|
|
||||||
|
static EGLView *getInstance();
|
||||||
|
|
||||||
|
/** @deprecated Use getInstance() instead */
|
||||||
|
CC_DEPRECATED_ATTRIBUTE static EGLView *sharedOpenGLView();
|
||||||
|
|
||||||
|
virtual bool isOpenGLReady() { return (m_integration != NULL); }
|
||||||
|
|
||||||
|
virtual void setFrameSize(float width, float height);
|
||||||
|
virtual void swapBuffers();
|
||||||
|
virtual void setIMEKeyboardState(bool bOpen);
|
||||||
|
virtual void end();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Cocos2DQt5OpenGLIntegration *m_integration;
|
||||||
|
};
|
||||||
|
|
||||||
|
NS_CC_END
|
||||||
|
|
||||||
|
#endif /* CCEGLVIEW_QT5_H */
|
|
@ -0,0 +1,114 @@
|
||||||
|
/****************************************************************************
|
||||||
|
Copyright (c) 2010 cocos2d-x.org
|
||||||
|
|
||||||
|
http://www.cocos2d-x.org
|
||||||
|
|
||||||
|
Cocos2D-X Qt 5 Platform
|
||||||
|
Copyright (C) 2013 Jolla Ltd.
|
||||||
|
Contact: Thomas Perl <thomas.perl@jollamobile.com>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#include "platform/CCFileUtils.h"
|
||||||
|
#include "platform/CCPlatformMacros.h"
|
||||||
|
#include "platform/CCCommon.h"
|
||||||
|
#include "ccTypes.h"
|
||||||
|
#include "ccTypeInfo.h"
|
||||||
|
#include "ccMacros.h"
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
#include <QFile>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QStandardPaths>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
NS_CC_BEGIN
|
||||||
|
|
||||||
|
class CC_DLL FileUtilsQt5 : public FileUtils
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
FileUtilsQt5();
|
||||||
|
|
||||||
|
/* override funtions */
|
||||||
|
virtual bool init();
|
||||||
|
virtual std::string getWritablePath();
|
||||||
|
virtual bool isFileExist(const std::string& strFilePath);
|
||||||
|
};
|
||||||
|
|
||||||
|
FileUtils *
|
||||||
|
FileUtils::getInstance()
|
||||||
|
{
|
||||||
|
if (s_sharedFileUtils == NULL)
|
||||||
|
{
|
||||||
|
s_sharedFileUtils = new FileUtilsQt5();
|
||||||
|
s_sharedFileUtils->init();
|
||||||
|
}
|
||||||
|
return s_sharedFileUtils;
|
||||||
|
}
|
||||||
|
|
||||||
|
FileUtilsQt5::FileUtilsQt5()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
FileUtilsQt5::init()
|
||||||
|
{
|
||||||
|
// Determine directory of the application executable
|
||||||
|
QDir app_dir = QDir("/proc/self/exe").canonicalPath();
|
||||||
|
app_dir.cdUp();
|
||||||
|
|
||||||
|
// Resources should be placed alongside the binary (same directory)
|
||||||
|
QString path = app_dir.path() + "/Resources/";
|
||||||
|
_defaultResRootPath = path.toStdString();
|
||||||
|
|
||||||
|
return FileUtils::init();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string
|
||||||
|
FileUtilsQt5::getWritablePath()
|
||||||
|
{
|
||||||
|
QDir dir(QStandardPaths::writableLocation(QStandardPaths::DataLocation));
|
||||||
|
|
||||||
|
// Create directory if it does not exist yet
|
||||||
|
if (!dir.exists()) {
|
||||||
|
dir.mkpath(".");
|
||||||
|
}
|
||||||
|
|
||||||
|
return dir.path().toStdString();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FileUtilsQt5::isFileExist(const std::string& strFilePath)
|
||||||
|
{
|
||||||
|
QString filePath = QString::fromStdString(strFilePath);
|
||||||
|
|
||||||
|
// Try filename without any path first
|
||||||
|
if (QFile(filePath).exists()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If not found, look for file in _defaultResRootPath
|
||||||
|
QString defaultResRootPath = QString::fromStdString(_defaultResRootPath);
|
||||||
|
return QFile(QDir(defaultResRootPath).filePath(filePath)).exists();
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_CC_END
|
|
@ -0,0 +1,16 @@
|
||||||
|
#ifndef __CCGL_H__
|
||||||
|
#define __CCGL_H__
|
||||||
|
|
||||||
|
#include <GLES2/gl2.h>
|
||||||
|
#include <GLES2/gl2ext.h>
|
||||||
|
|
||||||
|
#define GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_OES
|
||||||
|
|
||||||
|
#define glClearDepth glClearDepthf
|
||||||
|
|
||||||
|
// android defines GL_BGRA_EXT but not GL_BRGA
|
||||||
|
#ifndef GL_BGRA
|
||||||
|
#define GL_BGRA 0x80E1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // __CCGL_H__
|
|
@ -0,0 +1,47 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Cocos2D-X Qt 5 Platform
|
||||||
|
*
|
||||||
|
* Copyright (C) 2013 Jolla Ltd.
|
||||||
|
* Contact: Thomas Perl <thomas.perl@jollamobile.com>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef __CCPLATFORMDEFINE_H__
|
||||||
|
#define __CCPLATFORMDEFINE_H__
|
||||||
|
|
||||||
|
// Adapted from platform/linux/CCPlatformDefine.h
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#if defined(_USRDLL)
|
||||||
|
# define CC_DLL __attribute__ ((visibility ("default")))
|
||||||
|
#else
|
||||||
|
# define CC_DLL __attribute__ ((visibility ("default")))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#define CC_ASSERT(cond) assert(cond)
|
||||||
|
#define CC_UNUSED_PARAM(unusedparam) (void)unusedparam
|
||||||
|
|
||||||
|
#endif /* __CCPLATFORMDEFINE_H__*/
|
|
@ -0,0 +1,58 @@
|
||||||
|
/****************************************************************************
|
||||||
|
Copyright (c) 2010 cocos2d-x.org
|
||||||
|
|
||||||
|
http://www.cocos2d-x.org
|
||||||
|
|
||||||
|
Cocos2D-X Qt 5 Platform
|
||||||
|
Copyright (C) 2013 Jolla Ltd.
|
||||||
|
Contact: Thomas Perl <thomas.perl@jollamobile.com>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __CC_STD_C_H__
|
||||||
|
#define __CC_STD_C_H__
|
||||||
|
|
||||||
|
#include "platform/CCPlatformMacros.h"
|
||||||
|
|
||||||
|
#include <float.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#ifndef MIN
|
||||||
|
#define MIN(x,y) (((x) > (y)) ? (y) : (x))
|
||||||
|
#endif // MIN
|
||||||
|
|
||||||
|
#ifndef MAX
|
||||||
|
#define MAX(x,y) (((x) < (y)) ? (y) : (x))
|
||||||
|
#endif // MAX
|
||||||
|
|
||||||
|
// some function linux do not have
|
||||||
|
#define tanf tan
|
||||||
|
#define sqrtf sqrt
|
||||||
|
#define cosf cos
|
||||||
|
#define sinf sin
|
||||||
|
|
||||||
|
#endif // __CC_STD_C_H__
|
|
@ -0,0 +1,54 @@
|
||||||
|
/* jconfig.h. Generated from jconfig.cfg by configure. */
|
||||||
|
/* jconfig.cfg --- source file edited by configure script */
|
||||||
|
/* see jconfig.txt for explanations */
|
||||||
|
|
||||||
|
#define HAVE_PROTOTYPES 1
|
||||||
|
#define HAVE_UNSIGNED_CHAR 1
|
||||||
|
#define HAVE_UNSIGNED_SHORT 1
|
||||||
|
/* #undef void */
|
||||||
|
/* #undef const */
|
||||||
|
/* #undef CHAR_IS_UNSIGNED */
|
||||||
|
#define HAVE_STDDEF_H 1
|
||||||
|
#define HAVE_STDLIB_H 1
|
||||||
|
#define HAVE_LOCALE_H 1
|
||||||
|
/* #undef NEED_BSD_STRINGS */
|
||||||
|
/* #undef NEED_SYS_TYPES_H */
|
||||||
|
/* #undef NEED_FAR_POINTERS */
|
||||||
|
/* #undef NEED_SHORT_EXTERNAL_NAMES */
|
||||||
|
/* Define this if you get warnings about undefined structures. */
|
||||||
|
/* #undef INCOMPLETE_TYPES_BROKEN */
|
||||||
|
|
||||||
|
/* Define "boolean" as unsigned char, not int, on Windows systems. */
|
||||||
|
//#ifdef _WIN32
|
||||||
|
#ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */
|
||||||
|
typedef unsigned char boolean;
|
||||||
|
#endif
|
||||||
|
#define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */
|
||||||
|
//#endif
|
||||||
|
|
||||||
|
#ifdef JPEG_INTERNALS
|
||||||
|
|
||||||
|
/* #undef RIGHT_SHIFT_IS_UNSIGNED */
|
||||||
|
#define INLINE __inline__
|
||||||
|
/* These are for configuring the JPEG memory manager. */
|
||||||
|
/* #undef DEFAULT_MAX_MEM */
|
||||||
|
/* #undef NO_MKTEMP */
|
||||||
|
|
||||||
|
#endif /* JPEG_INTERNALS */
|
||||||
|
|
||||||
|
#ifdef JPEG_CJPEG_DJPEG
|
||||||
|
|
||||||
|
#define BMP_SUPPORTED /* BMP image file format */
|
||||||
|
#define GIF_SUPPORTED /* GIF image file format */
|
||||||
|
#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */
|
||||||
|
/* #undef RLE_SUPPORTED */
|
||||||
|
#define TARGA_SUPPORTED /* Targa image file format */
|
||||||
|
|
||||||
|
/* #undef TWO_FILE_COMMANDLINE */
|
||||||
|
/* #undef NEED_SIGNAL_CATCHER */
|
||||||
|
/* #undef DONT_USE_B_MODE */
|
||||||
|
|
||||||
|
/* Define this if you want percent-done progress reports from cjpeg/djpeg. */
|
||||||
|
/* #undef PROGRESS_REPORT */
|
||||||
|
|
||||||
|
#endif /* JPEG_CJPEG_DJPEG */
|
|
@ -0,0 +1,390 @@
|
||||||
|
/*
|
||||||
|
* jmorecfg.h
|
||||||
|
*
|
||||||
|
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||||
|
* Modified 1997-2012 by Guido Vollbeding.
|
||||||
|
* This file is part of the Independent JPEG Group's software.
|
||||||
|
* For conditions of distribution and use, see the accompanying README file.
|
||||||
|
*
|
||||||
|
* This file contains additional configuration options that customize the
|
||||||
|
* JPEG software for special applications or support machine-dependent
|
||||||
|
* optimizations. Most users will not need to touch this file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Define BITS_IN_JSAMPLE as either
|
||||||
|
* 8 for 8-bit sample values (the usual setting)
|
||||||
|
* 12 for 12-bit sample values
|
||||||
|
* Only 8 and 12 are legal data precisions for lossy JPEG according to the
|
||||||
|
* JPEG standard, and the IJG code does not support anything else!
|
||||||
|
* We do not support run-time selection of data precision, sorry.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define BITS_IN_JSAMPLE 8 /* use 8 or 12 */
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Maximum number of components (color channels) allowed in JPEG image.
|
||||||
|
* To meet the letter of the JPEG spec, set this to 255. However, darn
|
||||||
|
* few applications need more than 4 channels (maybe 5 for CMYK + alpha
|
||||||
|
* mask). We recommend 10 as a reasonable compromise; use 4 if you are
|
||||||
|
* really short on memory. (Each allowed component costs a hundred or so
|
||||||
|
* bytes of storage, whether actually used in an image or not.)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define MAX_COMPONENTS 10 /* maximum number of image components */
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Basic data types.
|
||||||
|
* You may need to change these if you have a machine with unusual data
|
||||||
|
* type sizes; for example, "char" not 8 bits, "short" not 16 bits,
|
||||||
|
* or "long" not 32 bits. We don't care whether "int" is 16 or 32 bits,
|
||||||
|
* but it had better be at least 16.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Representation of a single sample (pixel element value).
|
||||||
|
* We frequently allocate large arrays of these, so it's important to keep
|
||||||
|
* them small. But if you have memory to burn and access to char or short
|
||||||
|
* arrays is very slow on your hardware, you might want to change these.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if BITS_IN_JSAMPLE == 8
|
||||||
|
/* JSAMPLE should be the smallest type that will hold the values 0..255.
|
||||||
|
* You can use a signed char by having GETJSAMPLE mask it with 0xFF.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_UNSIGNED_CHAR
|
||||||
|
|
||||||
|
typedef unsigned char JSAMPLE;
|
||||||
|
#define GETJSAMPLE(value) ((int) (value))
|
||||||
|
|
||||||
|
#else /* not HAVE_UNSIGNED_CHAR */
|
||||||
|
|
||||||
|
typedef char JSAMPLE;
|
||||||
|
#ifdef CHAR_IS_UNSIGNED
|
||||||
|
#define GETJSAMPLE(value) ((int) (value))
|
||||||
|
#else
|
||||||
|
#define GETJSAMPLE(value) ((int) (value) & 0xFF)
|
||||||
|
#endif /* CHAR_IS_UNSIGNED */
|
||||||
|
|
||||||
|
#endif /* HAVE_UNSIGNED_CHAR */
|
||||||
|
|
||||||
|
#define MAXJSAMPLE 255
|
||||||
|
#define CENTERJSAMPLE 128
|
||||||
|
|
||||||
|
#endif /* BITS_IN_JSAMPLE == 8 */
|
||||||
|
|
||||||
|
|
||||||
|
#if BITS_IN_JSAMPLE == 12
|
||||||
|
/* JSAMPLE should be the smallest type that will hold the values 0..4095.
|
||||||
|
* On nearly all machines "short" will do nicely.
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef short JSAMPLE;
|
||||||
|
#define GETJSAMPLE(value) ((int) (value))
|
||||||
|
|
||||||
|
#define MAXJSAMPLE 4095
|
||||||
|
#define CENTERJSAMPLE 2048
|
||||||
|
|
||||||
|
#endif /* BITS_IN_JSAMPLE == 12 */
|
||||||
|
|
||||||
|
|
||||||
|
/* Representation of a DCT frequency coefficient.
|
||||||
|
* This should be a signed value of at least 16 bits; "short" is usually OK.
|
||||||
|
* Again, we allocate large arrays of these, but you can change to int
|
||||||
|
* if you have memory to burn and "short" is really slow.
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef short JCOEF;
|
||||||
|
|
||||||
|
|
||||||
|
/* Compressed datastreams are represented as arrays of JOCTET.
|
||||||
|
* These must be EXACTLY 8 bits wide, at least once they are written to
|
||||||
|
* external storage. Note that when using the stdio data source/destination
|
||||||
|
* managers, this is also the data type passed to fread/fwrite.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_UNSIGNED_CHAR
|
||||||
|
|
||||||
|
typedef unsigned char JOCTET;
|
||||||
|
#define GETJOCTET(value) (value)
|
||||||
|
|
||||||
|
#else /* not HAVE_UNSIGNED_CHAR */
|
||||||
|
|
||||||
|
typedef char JOCTET;
|
||||||
|
#ifdef CHAR_IS_UNSIGNED
|
||||||
|
#define GETJOCTET(value) (value)
|
||||||
|
#else
|
||||||
|
#define GETJOCTET(value) ((value) & 0xFF)
|
||||||
|
#endif /* CHAR_IS_UNSIGNED */
|
||||||
|
|
||||||
|
#endif /* HAVE_UNSIGNED_CHAR */
|
||||||
|
|
||||||
|
|
||||||
|
/* These typedefs are used for various table entries and so forth.
|
||||||
|
* They must be at least as wide as specified; but making them too big
|
||||||
|
* won't cost a huge amount of memory, so we don't provide special
|
||||||
|
* extraction code like we did for JSAMPLE. (In other words, these
|
||||||
|
* typedefs live at a different point on the speed/space tradeoff curve.)
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* UINT8 must hold at least the values 0..255. */
|
||||||
|
|
||||||
|
#ifdef HAVE_UNSIGNED_CHAR
|
||||||
|
typedef unsigned char UINT8;
|
||||||
|
#else /* not HAVE_UNSIGNED_CHAR */
|
||||||
|
#ifdef CHAR_IS_UNSIGNED
|
||||||
|
typedef char UINT8;
|
||||||
|
#else /* not CHAR_IS_UNSIGNED */
|
||||||
|
typedef short UINT8;
|
||||||
|
#endif /* CHAR_IS_UNSIGNED */
|
||||||
|
#endif /* HAVE_UNSIGNED_CHAR */
|
||||||
|
|
||||||
|
/* UINT16 must hold at least the values 0..65535. */
|
||||||
|
|
||||||
|
#ifdef HAVE_UNSIGNED_SHORT
|
||||||
|
typedef unsigned short UINT16;
|
||||||
|
#else /* not HAVE_UNSIGNED_SHORT */
|
||||||
|
typedef unsigned int UINT16;
|
||||||
|
#endif /* HAVE_UNSIGNED_SHORT */
|
||||||
|
|
||||||
|
/* INT16 must hold at least the values -32768..32767. */
|
||||||
|
|
||||||
|
#ifndef XMD_H /* X11/xmd.h correctly defines INT16 */
|
||||||
|
typedef short INT16;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* INT32 must hold at least signed 32-bit values. */
|
||||||
|
|
||||||
|
#ifndef XMD_H /* X11/xmd.h correctly defines INT32 */
|
||||||
|
#ifndef _BASETSD_H_ /* Microsoft defines it in basetsd.h */
|
||||||
|
#ifndef _BASETSD_H /* MinGW is slightly different */
|
||||||
|
#ifndef QGLOBAL_H /* Qt defines it in qglobal.h */
|
||||||
|
typedef long INT32;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Datatype used for image dimensions. The JPEG standard only supports
|
||||||
|
* images up to 64K*64K due to 16-bit fields in SOF markers. Therefore
|
||||||
|
* "unsigned int" is sufficient on all machines. However, if you need to
|
||||||
|
* handle larger images and you don't mind deviating from the spec, you
|
||||||
|
* can change this datatype.
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef unsigned int JDIMENSION;
|
||||||
|
|
||||||
|
#define JPEG_MAX_DIMENSION 65500L /* a tad under 64K to prevent overflows */
|
||||||
|
|
||||||
|
|
||||||
|
/* These macros are used in all function definitions and extern declarations.
|
||||||
|
* You could modify them if you need to change function linkage conventions;
|
||||||
|
* in particular, you'll need to do that to make the library a Windows DLL.
|
||||||
|
* Another application is to make all functions global for use with debuggers
|
||||||
|
* or code profilers that require it.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* a function called through method pointers: */
|
||||||
|
#define METHODDEF(type) static type
|
||||||
|
/* a function used only in its module: */
|
||||||
|
#define LOCAL(type) static type
|
||||||
|
/* a function referenced thru EXTERNs: */
|
||||||
|
#define GLOBAL(type) type
|
||||||
|
/* a reference to a GLOBAL function: */
|
||||||
|
#define EXTERN(type) extern type
|
||||||
|
|
||||||
|
|
||||||
|
/* This macro is used to declare a "method", that is, a function pointer.
|
||||||
|
* We want to supply prototype parameters if the compiler can cope.
|
||||||
|
* Note that the arglist parameter must be parenthesized!
|
||||||
|
* Again, you can customize this if you need special linkage keywords.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_PROTOTYPES
|
||||||
|
#define JMETHOD(type,methodname,arglist) type (*methodname) arglist
|
||||||
|
#else
|
||||||
|
#define JMETHOD(type,methodname,arglist) type (*methodname) ()
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* The noreturn type identifier is used to declare functions
|
||||||
|
* which cannot return.
|
||||||
|
* Compilers can thus create more optimized code and perform
|
||||||
|
* better checks for warnings and errors.
|
||||||
|
* Static analyzer tools can make improved inferences about
|
||||||
|
* execution paths and are prevented from giving false alerts.
|
||||||
|
*
|
||||||
|
* Unfortunately, the proposed specifications of corresponding
|
||||||
|
* extensions in the Dec 2011 ISO C standard revision (C11),
|
||||||
|
* GCC, MSVC, etc. are not viable.
|
||||||
|
* Thus we introduce a user defined type to declare noreturn
|
||||||
|
* functions at least for clarity. A proper compiler would
|
||||||
|
* have a suitable noreturn type to match in place of void.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef HAVE_NORETURN_T
|
||||||
|
typedef void noreturn_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* Here is the pseudo-keyword for declaring pointers that must be "far"
|
||||||
|
* on 80x86 machines. Most of the specialized coding for 80x86 is handled
|
||||||
|
* by just saying "FAR *" where such a pointer is needed. In a few places
|
||||||
|
* explicit coding is needed; see uses of the NEED_FAR_POINTERS symbol.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FAR
|
||||||
|
#ifdef NEED_FAR_POINTERS
|
||||||
|
#define FAR far
|
||||||
|
#else
|
||||||
|
#define FAR
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* On a few systems, type boolean and/or its values FALSE, TRUE may appear
|
||||||
|
* in standard header files. Or you may have conflicts with application-
|
||||||
|
* specific header files that you want to include together with these files.
|
||||||
|
* Defining HAVE_BOOLEAN before including jpeglib.h should make it work.
|
||||||
|
*/
|
||||||
|
#define HAVE_BOOLEAN
|
||||||
|
#ifdef HAVE_BOOLEAN
|
||||||
|
#ifndef FALSE /* in case these macros already exist */
|
||||||
|
#define FALSE 0 /* values of boolean */
|
||||||
|
#endif
|
||||||
|
#ifndef TRUE
|
||||||
|
#define TRUE 1
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
typedef enum { FALSE = 0, TRUE = 1 } boolean;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The remaining options affect code selection within the JPEG library,
|
||||||
|
* but they don't need to be visible to most applications using the library.
|
||||||
|
* To minimize application namespace pollution, the symbols won't be
|
||||||
|
* defined unless JPEG_INTERNALS or JPEG_INTERNAL_OPTIONS has been defined.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef JPEG_INTERNALS
|
||||||
|
#define JPEG_INTERNAL_OPTIONS
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef JPEG_INTERNAL_OPTIONS
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* These defines indicate whether to include various optional functions.
|
||||||
|
* Undefining some of these symbols will produce a smaller but less capable
|
||||||
|
* library. Note that you can leave certain source files out of the
|
||||||
|
* compilation/linking process if you've #undef'd the corresponding symbols.
|
||||||
|
* (You may HAVE to do that if your compiler doesn't like null source files.)
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Capability options common to encoder and decoder: */
|
||||||
|
|
||||||
|
#define DCT_ISLOW_SUPPORTED /* slow but accurate integer algorithm */
|
||||||
|
#define DCT_IFAST_SUPPORTED /* faster, less accurate integer method */
|
||||||
|
#define DCT_FLOAT_SUPPORTED /* floating-point: accurate, fast on fast HW */
|
||||||
|
|
||||||
|
/* Encoder capability options: */
|
||||||
|
|
||||||
|
#define C_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */
|
||||||
|
#define C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
|
||||||
|
#define C_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/
|
||||||
|
#define DCT_SCALING_SUPPORTED /* Input rescaling via DCT? (Requires DCT_ISLOW)*/
|
||||||
|
#define ENTROPY_OPT_SUPPORTED /* Optimization of entropy coding parms? */
|
||||||
|
/* Note: if you selected 12-bit data precision, it is dangerous to turn off
|
||||||
|
* ENTROPY_OPT_SUPPORTED. The standard Huffman tables are only good for 8-bit
|
||||||
|
* precision, so jchuff.c normally uses entropy optimization to compute
|
||||||
|
* usable tables for higher precision. If you don't want to do optimization,
|
||||||
|
* you'll have to supply different default Huffman tables.
|
||||||
|
* The exact same statements apply for progressive JPEG: the default tables
|
||||||
|
* don't work for progressive mode. (This may get fixed, however.)
|
||||||
|
*/
|
||||||
|
#define INPUT_SMOOTHING_SUPPORTED /* Input image smoothing option? */
|
||||||
|
|
||||||
|
/* Decoder capability options: */
|
||||||
|
|
||||||
|
#define D_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */
|
||||||
|
#define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
|
||||||
|
#define D_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/
|
||||||
|
#define IDCT_SCALING_SUPPORTED /* Output rescaling via IDCT? */
|
||||||
|
#define SAVE_MARKERS_SUPPORTED /* jpeg_save_markers() needed? */
|
||||||
|
#define BLOCK_SMOOTHING_SUPPORTED /* Block smoothing? (Progressive only) */
|
||||||
|
#undef UPSAMPLE_SCALING_SUPPORTED /* Output rescaling at upsample stage? */
|
||||||
|
#define UPSAMPLE_MERGING_SUPPORTED /* Fast path for sloppy upsampling? */
|
||||||
|
#define QUANT_1PASS_SUPPORTED /* 1-pass color quantization? */
|
||||||
|
#define QUANT_2PASS_SUPPORTED /* 2-pass color quantization? */
|
||||||
|
|
||||||
|
/* more capability options later, no doubt */
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Ordering of RGB data in scanlines passed to or from the application.
|
||||||
|
* If your application wants to deal with data in the order B,G,R, just
|
||||||
|
* change these macros. You can also deal with formats such as R,G,B,X
|
||||||
|
* (one extra byte per pixel) by changing RGB_PIXELSIZE. Note that changing
|
||||||
|
* the offsets will also change the order in which colormap data is organized.
|
||||||
|
* RESTRICTIONS:
|
||||||
|
* 1. The sample applications cjpeg,djpeg do NOT support modified RGB formats.
|
||||||
|
* 2. The color quantizer modules will not behave desirably if RGB_PIXELSIZE
|
||||||
|
* is not 3 (they don't understand about dummy color components!). So you
|
||||||
|
* can't use color quantization if you change that value.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define RGB_RED 0 /* Offset of Red in an RGB scanline element */
|
||||||
|
#define RGB_GREEN 1 /* Offset of Green */
|
||||||
|
#define RGB_BLUE 2 /* Offset of Blue */
|
||||||
|
#define RGB_PIXELSIZE 3 /* JSAMPLEs per RGB scanline element */
|
||||||
|
|
||||||
|
|
||||||
|
/* Definitions for speed-related optimizations. */
|
||||||
|
|
||||||
|
|
||||||
|
/* If your compiler supports inline functions, define INLINE
|
||||||
|
* as the inline keyword; otherwise define it as empty.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef INLINE
|
||||||
|
#ifdef __GNUC__ /* for instance, GNU C knows about inline */
|
||||||
|
#define INLINE __inline__
|
||||||
|
#endif
|
||||||
|
#ifndef INLINE
|
||||||
|
#define INLINE /* default is to define it as empty */
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* On some machines (notably 68000 series) "int" is 32 bits, but multiplying
|
||||||
|
* two 16-bit shorts is faster than multiplying two ints. Define MULTIPLIER
|
||||||
|
* as short on such a machine. MULTIPLIER must be at least 16 bits wide.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef MULTIPLIER
|
||||||
|
#define MULTIPLIER int /* type for fastest integer multiply */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* FAST_FLOAT should be either float or double, whichever is done faster
|
||||||
|
* by your compiler. (Note that this type is only used in the floating point
|
||||||
|
* DCT routines, so it only matters if you've defined DCT_FLOAT_SUPPORTED.)
|
||||||
|
* Typically, float is faster in ANSI C compilers, while double is faster in
|
||||||
|
* pre-ANSI compilers (because they insist on converting to double anyway).
|
||||||
|
* The code below therefore chooses float if we have ANSI-style prototypes.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FAST_FLOAT
|
||||||
|
#ifdef HAVE_PROTOTYPES
|
||||||
|
#define FAST_FLOAT float
|
||||||
|
#else
|
||||||
|
#define FAST_FLOAT double
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* JPEG_INTERNAL_OPTIONS */
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1 @@
|
||||||
|
0b5053fcffd754e25abc95e24905e5476ee5c451
|
|
@ -0,0 +1,616 @@
|
||||||
|
|
||||||
|
/* pngconf.h - machine configurable file for libpng
|
||||||
|
*
|
||||||
|
* libpng version 1.6.2 - April 25, 2013
|
||||||
|
*
|
||||||
|
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||||
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
|
*
|
||||||
|
* This code is released under the libpng license.
|
||||||
|
* For conditions of distribution and use, see the disclaimer
|
||||||
|
* and license in png.h
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Any machine specific code is near the front of this file, so if you
|
||||||
|
* are configuring libpng for a machine, you may want to read the section
|
||||||
|
* starting here down to where it starts to typedef png_color, png_text,
|
||||||
|
* and png_info.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef PNGCONF_H
|
||||||
|
#define PNGCONF_H
|
||||||
|
|
||||||
|
/* To do: Do all of this in scripts/pnglibconf.dfa */
|
||||||
|
#ifdef PNG_SAFE_LIMITS_SUPPORTED
|
||||||
|
# ifdef PNG_USER_WIDTH_MAX
|
||||||
|
# undef PNG_USER_WIDTH_MAX
|
||||||
|
# define PNG_USER_WIDTH_MAX 1000000L
|
||||||
|
# endif
|
||||||
|
# ifdef PNG_USER_HEIGHT_MAX
|
||||||
|
# undef PNG_USER_HEIGHT_MAX
|
||||||
|
# define PNG_USER_HEIGHT_MAX 1000000L
|
||||||
|
# endif
|
||||||
|
# ifdef PNG_USER_CHUNK_MALLOC_MAX
|
||||||
|
# undef PNG_USER_CHUNK_MALLOC_MAX
|
||||||
|
# define PNG_USER_CHUNK_MALLOC_MAX 4000000L
|
||||||
|
# endif
|
||||||
|
# ifdef PNG_USER_CHUNK_CACHE_MAX
|
||||||
|
# undef PNG_USER_CHUNK_CACHE_MAX
|
||||||
|
# define PNG_USER_CHUNK_CACHE_MAX 128
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef PNG_BUILDING_SYMBOL_TABLE /* else includes may cause problems */
|
||||||
|
|
||||||
|
/* From libpng 1.6.0 libpng requires an ANSI X3.159-1989 ("ISOC90") compliant C
|
||||||
|
* compiler for correct compilation. The following header files are required by
|
||||||
|
* the standard. If your compiler doesn't provide these header files, or they
|
||||||
|
* do not match the standard, you will need to provide/improve them.
|
||||||
|
*/
|
||||||
|
#include <limits.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
/* Library header files. These header files are all defined by ISOC90; libpng
|
||||||
|
* expects conformant implementations, however, an ISOC90 conformant system need
|
||||||
|
* not provide these header files if the functionality cannot be implemented.
|
||||||
|
* In this case it will be necessary to disable the relevant parts of libpng in
|
||||||
|
* the build of pnglibconf.h.
|
||||||
|
*
|
||||||
|
* Prior to 1.6.0 string.h was included here; the API changes in 1.6.0 to not
|
||||||
|
* include this unnecessary header file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef PNG_STDIO_SUPPORTED
|
||||||
|
/* Required for the definition of FILE: */
|
||||||
|
# include <stdio.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef PNG_SETJMP_SUPPORTED
|
||||||
|
/* Required for the definition of jmp_buf and the declaration of longjmp: */
|
||||||
|
# include <setjmp.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef PNG_CONVERT_tIME_SUPPORTED
|
||||||
|
/* Required for struct tm: */
|
||||||
|
# include <time.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* PNG_BUILDING_SYMBOL_TABLE */
|
||||||
|
|
||||||
|
/* Prior to 1.6.0 it was possible to turn off 'const' in declarations using
|
||||||
|
* PNG_NO_CONST; this is no longer supported except for data declarations which
|
||||||
|
* apparently still cause problems in 2011 on some compilers.
|
||||||
|
*/
|
||||||
|
#define PNG_CONST const /* backward compatibility only */
|
||||||
|
|
||||||
|
/* This controls optimization of the reading of 16 and 32 bit values
|
||||||
|
* from PNG files. It can be set on a per-app-file basis - it
|
||||||
|
* just changes whether a macro is used when the function is called.
|
||||||
|
* The library builder sets the default; if read functions are not
|
||||||
|
* built into the library the macro implementation is forced on.
|
||||||
|
*/
|
||||||
|
#ifndef PNG_READ_INT_FUNCTIONS_SUPPORTED
|
||||||
|
# define PNG_USE_READ_MACROS
|
||||||
|
#endif
|
||||||
|
#if !defined(PNG_NO_USE_READ_MACROS) && !defined(PNG_USE_READ_MACROS)
|
||||||
|
# if PNG_DEFAULT_READ_MACROS
|
||||||
|
# define PNG_USE_READ_MACROS
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* COMPILER SPECIFIC OPTIONS.
|
||||||
|
*
|
||||||
|
* These options are provided so that a variety of difficult compilers
|
||||||
|
* can be used. Some are fixed at build time (e.g. PNG_API_RULE
|
||||||
|
* below) but still have compiler specific implementations, others
|
||||||
|
* may be changed on a per-file basis when compiling against libpng.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* The PNGARG macro was used in versions of libpng prior to 1.6.0 to protect
|
||||||
|
* against legacy (pre ISOC90) compilers that did not understand function
|
||||||
|
* prototypes. It is not required for modern C compilers.
|
||||||
|
*/
|
||||||
|
#ifndef PNGARG
|
||||||
|
# define PNGARG(arglist) arglist
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Function calling conventions.
|
||||||
|
* =============================
|
||||||
|
* Normally it is not necessary to specify to the compiler how to call
|
||||||
|
* a function - it just does it - however on x86 systems derived from
|
||||||
|
* Microsoft and Borland C compilers ('IBM PC', 'DOS', 'Windows' systems
|
||||||
|
* and some others) there are multiple ways to call a function and the
|
||||||
|
* default can be changed on the compiler command line. For this reason
|
||||||
|
* libpng specifies the calling convention of every exported function and
|
||||||
|
* every function called via a user supplied function pointer. This is
|
||||||
|
* done in this file by defining the following macros:
|
||||||
|
*
|
||||||
|
* PNGAPI Calling convention for exported functions.
|
||||||
|
* PNGCBAPI Calling convention for user provided (callback) functions.
|
||||||
|
* PNGCAPI Calling convention used by the ANSI-C library (required
|
||||||
|
* for longjmp callbacks and sometimes used internally to
|
||||||
|
* specify the calling convention for zlib).
|
||||||
|
*
|
||||||
|
* These macros should never be overridden. If it is necessary to
|
||||||
|
* change calling convention in a private build this can be done
|
||||||
|
* by setting PNG_API_RULE (which defaults to 0) to one of the values
|
||||||
|
* below to select the correct 'API' variants.
|
||||||
|
*
|
||||||
|
* PNG_API_RULE=0 Use PNGCAPI - the 'C' calling convention - throughout.
|
||||||
|
* This is correct in every known environment.
|
||||||
|
* PNG_API_RULE=1 Use the operating system convention for PNGAPI and
|
||||||
|
* the 'C' calling convention (from PNGCAPI) for
|
||||||
|
* callbacks (PNGCBAPI). This is no longer required
|
||||||
|
* in any known environment - if it has to be used
|
||||||
|
* please post an explanation of the problem to the
|
||||||
|
* libpng mailing list.
|
||||||
|
*
|
||||||
|
* These cases only differ if the operating system does not use the C
|
||||||
|
* calling convention, at present this just means the above cases
|
||||||
|
* (x86 DOS/Windows sytems) and, even then, this does not apply to
|
||||||
|
* Cygwin running on those systems.
|
||||||
|
*
|
||||||
|
* Note that the value must be defined in pnglibconf.h so that what
|
||||||
|
* the application uses to call the library matches the conventions
|
||||||
|
* set when building the library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Symbol export
|
||||||
|
* =============
|
||||||
|
* When building a shared library it is almost always necessary to tell
|
||||||
|
* the compiler which symbols to export. The png.h macro 'PNG_EXPORT'
|
||||||
|
* is used to mark the symbols. On some systems these symbols can be
|
||||||
|
* extracted at link time and need no special processing by the compiler,
|
||||||
|
* on other systems the symbols are flagged by the compiler and just
|
||||||
|
* the declaration requires a special tag applied (unfortunately) in a
|
||||||
|
* compiler dependent way. Some systems can do either.
|
||||||
|
*
|
||||||
|
* A small number of older systems also require a symbol from a DLL to
|
||||||
|
* be flagged to the program that calls it. This is a problem because
|
||||||
|
* we do not know in the header file included by application code that
|
||||||
|
* the symbol will come from a shared library, as opposed to a statically
|
||||||
|
* linked one. For this reason the application must tell us by setting
|
||||||
|
* the magic flag PNG_USE_DLL to turn on the special processing before
|
||||||
|
* it includes png.h.
|
||||||
|
*
|
||||||
|
* Four additional macros are used to make this happen:
|
||||||
|
*
|
||||||
|
* PNG_IMPEXP The magic (if any) to cause a symbol to be exported from
|
||||||
|
* the build or imported if PNG_USE_DLL is set - compiler
|
||||||
|
* and system specific.
|
||||||
|
*
|
||||||
|
* PNG_EXPORT_TYPE(type) A macro that pre or appends PNG_IMPEXP to
|
||||||
|
* 'type', compiler specific.
|
||||||
|
*
|
||||||
|
* PNG_DLL_EXPORT Set to the magic to use during a libpng build to
|
||||||
|
* make a symbol exported from the DLL. Not used in the
|
||||||
|
* public header files; see pngpriv.h for how it is used
|
||||||
|
* in the libpng build.
|
||||||
|
*
|
||||||
|
* PNG_DLL_IMPORT Set to the magic to force the libpng symbols to come
|
||||||
|
* from a DLL - used to define PNG_IMPEXP when
|
||||||
|
* PNG_USE_DLL is set.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* System specific discovery.
|
||||||
|
* ==========================
|
||||||
|
* This code is used at build time to find PNG_IMPEXP, the API settings
|
||||||
|
* and PNG_EXPORT_TYPE(), it may also set a macro to indicate the DLL
|
||||||
|
* import processing is possible. On Windows systems it also sets
|
||||||
|
* compiler-specific macros to the values required to change the calling
|
||||||
|
* conventions of the various functions.
|
||||||
|
*/
|
||||||
|
#if defined(_Windows) || defined(_WINDOWS) || defined(WIN32) ||\
|
||||||
|
defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
|
||||||
|
/* Windows system (DOS doesn't support DLLs). Includes builds under Cygwin or
|
||||||
|
* MinGW on any architecture currently supported by Windows. Also includes
|
||||||
|
* Watcom builds but these need special treatment because they are not
|
||||||
|
* compatible with GCC or Visual C because of different calling conventions.
|
||||||
|
*/
|
||||||
|
# if PNG_API_RULE == 2
|
||||||
|
/* If this line results in an error, either because __watcall is not
|
||||||
|
* understood or because of a redefine just below you cannot use *this*
|
||||||
|
* build of the library with the compiler you are using. *This* build was
|
||||||
|
* build using Watcom and applications must also be built using Watcom!
|
||||||
|
*/
|
||||||
|
# define PNGCAPI __watcall
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# if defined(__GNUC__) || (defined(_MSC_VER) && (_MSC_VER >= 800))
|
||||||
|
# define PNGCAPI __cdecl
|
||||||
|
# if PNG_API_RULE == 1
|
||||||
|
/* If this line results in an error __stdcall is not understood and
|
||||||
|
* PNG_API_RULE should not have been set to '1'.
|
||||||
|
*/
|
||||||
|
# define PNGAPI __stdcall
|
||||||
|
# endif
|
||||||
|
# else
|
||||||
|
/* An older compiler, or one not detected (erroneously) above,
|
||||||
|
* if necessary override on the command line to get the correct
|
||||||
|
* variants for the compiler.
|
||||||
|
*/
|
||||||
|
# ifndef PNGCAPI
|
||||||
|
# define PNGCAPI _cdecl
|
||||||
|
# endif
|
||||||
|
# if PNG_API_RULE == 1 && !defined(PNGAPI)
|
||||||
|
# define PNGAPI _stdcall
|
||||||
|
# endif
|
||||||
|
# endif /* compiler/api */
|
||||||
|
/* NOTE: PNGCBAPI always defaults to PNGCAPI. */
|
||||||
|
|
||||||
|
# if defined(PNGAPI) && !defined(PNG_USER_PRIVATEBUILD)
|
||||||
|
# error "PNG_USER_PRIVATEBUILD must be defined if PNGAPI is changed"
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# if (defined(_MSC_VER) && _MSC_VER < 800) ||\
|
||||||
|
(defined(__BORLANDC__) && __BORLANDC__ < 0x500)
|
||||||
|
/* older Borland and MSC
|
||||||
|
* compilers used '__export' and required this to be after
|
||||||
|
* the type.
|
||||||
|
*/
|
||||||
|
# ifndef PNG_EXPORT_TYPE
|
||||||
|
# define PNG_EXPORT_TYPE(type) type PNG_IMPEXP
|
||||||
|
# endif
|
||||||
|
# define PNG_DLL_EXPORT __export
|
||||||
|
# else /* newer compiler */
|
||||||
|
# define PNG_DLL_EXPORT __declspec(dllexport)
|
||||||
|
# ifndef PNG_DLL_IMPORT
|
||||||
|
# define PNG_DLL_IMPORT __declspec(dllimport)
|
||||||
|
# endif
|
||||||
|
# endif /* compiler */
|
||||||
|
|
||||||
|
#else /* !Windows */
|
||||||
|
# if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__)
|
||||||
|
# define PNGAPI _System
|
||||||
|
# else /* !Windows/x86 && !OS/2 */
|
||||||
|
/* Use the defaults, or define PNG*API on the command line (but
|
||||||
|
* this will have to be done for every compile!)
|
||||||
|
*/
|
||||||
|
# endif /* other system, !OS/2 */
|
||||||
|
#endif /* !Windows/x86 */
|
||||||
|
|
||||||
|
/* Now do all the defaulting . */
|
||||||
|
#ifndef PNGCAPI
|
||||||
|
# define PNGCAPI
|
||||||
|
#endif
|
||||||
|
#ifndef PNGCBAPI
|
||||||
|
# define PNGCBAPI PNGCAPI
|
||||||
|
#endif
|
||||||
|
#ifndef PNGAPI
|
||||||
|
# define PNGAPI PNGCAPI
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* PNG_IMPEXP may be set on the compilation system command line or (if not set)
|
||||||
|
* then in an internal header file when building the library, otherwise (when
|
||||||
|
* using the library) it is set here.
|
||||||
|
*/
|
||||||
|
#ifndef PNG_IMPEXP
|
||||||
|
# if defined(PNG_USE_DLL) && defined(PNG_DLL_IMPORT)
|
||||||
|
/* This forces use of a DLL, disallowing static linking */
|
||||||
|
# define PNG_IMPEXP PNG_DLL_IMPORT
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifndef PNG_IMPEXP
|
||||||
|
# define PNG_IMPEXP
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* In 1.5.2 the definition of PNG_FUNCTION has been changed to always treat
|
||||||
|
* 'attributes' as a storage class - the attributes go at the start of the
|
||||||
|
* function definition, and attributes are always appended regardless of the
|
||||||
|
* compiler. This considerably simplifies these macros but may cause problems
|
||||||
|
* if any compilers both need function attributes and fail to handle them as
|
||||||
|
* a storage class (this is unlikely.)
|
||||||
|
*/
|
||||||
|
#ifndef PNG_FUNCTION
|
||||||
|
# define PNG_FUNCTION(type, name, args, attributes) attributes type name args
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef PNG_EXPORT_TYPE
|
||||||
|
# define PNG_EXPORT_TYPE(type) PNG_IMPEXP type
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* The ordinal value is only relevant when preprocessing png.h for symbol
|
||||||
|
* table entries, so we discard it here. See the .dfn files in the
|
||||||
|
* scripts directory.
|
||||||
|
*/
|
||||||
|
#ifndef PNG_EXPORTA
|
||||||
|
|
||||||
|
# define PNG_EXPORTA(ordinal, type, name, args, attributes)\
|
||||||
|
PNG_FUNCTION(PNG_EXPORT_TYPE(type),(PNGAPI name),PNGARG(args), \
|
||||||
|
extern attributes)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* ANSI-C (C90) does not permit a macro to be invoked with an empty argument,
|
||||||
|
* so make something non-empty to satisfy the requirement:
|
||||||
|
*/
|
||||||
|
#define PNG_EMPTY /*empty list*/
|
||||||
|
|
||||||
|
#define PNG_EXPORT(ordinal, type, name, args)\
|
||||||
|
PNG_EXPORTA(ordinal, type, name, args, PNG_EMPTY)
|
||||||
|
|
||||||
|
/* Use PNG_REMOVED to comment out a removed interface. */
|
||||||
|
#ifndef PNG_REMOVED
|
||||||
|
# define PNG_REMOVED(ordinal, type, name, args, attributes)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef PNG_CALLBACK
|
||||||
|
# define PNG_CALLBACK(type, name, args) type (PNGCBAPI name) PNGARG(args)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Support for compiler specific function attributes. These are used
|
||||||
|
* so that where compiler support is available incorrect use of API
|
||||||
|
* functions in png.h will generate compiler warnings.
|
||||||
|
*
|
||||||
|
* Added at libpng-1.2.41.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef PNG_NO_PEDANTIC_WARNINGS
|
||||||
|
# ifndef PNG_PEDANTIC_WARNINGS_SUPPORTED
|
||||||
|
# define PNG_PEDANTIC_WARNINGS_SUPPORTED
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef PNG_PEDANTIC_WARNINGS_SUPPORTED
|
||||||
|
/* Support for compiler specific function attributes. These are used
|
||||||
|
* so that where compiler support is available, incorrect use of API
|
||||||
|
* functions in png.h will generate compiler warnings. Added at libpng
|
||||||
|
* version 1.2.41. Disabling these removes the warnings but may also produce
|
||||||
|
* less efficient code.
|
||||||
|
*/
|
||||||
|
# if defined(__GNUC__)
|
||||||
|
# ifndef PNG_USE_RESULT
|
||||||
|
# define PNG_USE_RESULT __attribute__((__warn_unused_result__))
|
||||||
|
# endif
|
||||||
|
# ifndef PNG_NORETURN
|
||||||
|
# define PNG_NORETURN __attribute__((__noreturn__))
|
||||||
|
# endif
|
||||||
|
# if __GNUC__ >= 3
|
||||||
|
# ifndef PNG_ALLOCATED
|
||||||
|
# define PNG_ALLOCATED __attribute__((__malloc__))
|
||||||
|
# endif
|
||||||
|
# ifndef PNG_DEPRECATED
|
||||||
|
# define PNG_DEPRECATED __attribute__((__deprecated__))
|
||||||
|
# endif
|
||||||
|
# ifndef PNG_PRIVATE
|
||||||
|
# if 0 /* Doesn't work so we use deprecated instead*/
|
||||||
|
# define PNG_PRIVATE \
|
||||||
|
__attribute__((warning("This function is not exported by libpng.")))
|
||||||
|
# else
|
||||||
|
# define PNG_PRIVATE \
|
||||||
|
__attribute__((__deprecated__))
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
# if ((__GNUC__ != 3) || !defined(__GNUC_MINOR__) || (__GNUC_MINOR__ >= 1))
|
||||||
|
# ifndef PNG_RESTRICT
|
||||||
|
# define PNG_RESTRICT __restrict
|
||||||
|
# endif
|
||||||
|
# endif /* __GNUC__ == 3.0 */
|
||||||
|
# endif /* __GNUC__ >= 3 */
|
||||||
|
|
||||||
|
# elif defined(_MSC_VER) && (_MSC_VER >= 1300)
|
||||||
|
# ifndef PNG_USE_RESULT
|
||||||
|
# define PNG_USE_RESULT /* not supported */
|
||||||
|
# endif
|
||||||
|
# ifndef PNG_NORETURN
|
||||||
|
# define PNG_NORETURN __declspec(noreturn)
|
||||||
|
# endif
|
||||||
|
# ifndef PNG_ALLOCATED
|
||||||
|
# if (_MSC_VER >= 1400)
|
||||||
|
# define PNG_ALLOCATED __declspec(restrict)
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
# ifndef PNG_DEPRECATED
|
||||||
|
# define PNG_DEPRECATED __declspec(deprecated)
|
||||||
|
# endif
|
||||||
|
# ifndef PNG_PRIVATE
|
||||||
|
# define PNG_PRIVATE __declspec(deprecated)
|
||||||
|
# endif
|
||||||
|
# ifndef PNG_RESTRICT
|
||||||
|
# if (_MSC_VER >= 1400)
|
||||||
|
# define PNG_RESTRICT __restrict
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# elif defined(__WATCOMC__)
|
||||||
|
# ifndef PNG_RESTRICT
|
||||||
|
# define PNG_RESTRICT __restrict
|
||||||
|
# endif
|
||||||
|
# endif /* _MSC_VER */
|
||||||
|
#endif /* PNG_PEDANTIC_WARNINGS */
|
||||||
|
|
||||||
|
#ifndef PNG_DEPRECATED
|
||||||
|
# define PNG_DEPRECATED /* Use of this function is deprecated */
|
||||||
|
#endif
|
||||||
|
#ifndef PNG_USE_RESULT
|
||||||
|
# define PNG_USE_RESULT /* The result of this function must be checked */
|
||||||
|
#endif
|
||||||
|
#ifndef PNG_NORETURN
|
||||||
|
# define PNG_NORETURN /* This function does not return */
|
||||||
|
#endif
|
||||||
|
#ifndef PNG_ALLOCATED
|
||||||
|
# define PNG_ALLOCATED /* The result of the function is new memory */
|
||||||
|
#endif
|
||||||
|
#ifndef PNG_PRIVATE
|
||||||
|
# define PNG_PRIVATE /* This is a private libpng function */
|
||||||
|
#endif
|
||||||
|
#ifndef PNG_RESTRICT
|
||||||
|
# define PNG_RESTRICT /* The C99 "restrict" feature */
|
||||||
|
#endif
|
||||||
|
#ifndef PNG_FP_EXPORT /* A floating point API. */
|
||||||
|
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||||
|
# define PNG_FP_EXPORT(ordinal, type, name, args)\
|
||||||
|
PNG_EXPORT(ordinal, type, name, args);
|
||||||
|
# else /* No floating point APIs */
|
||||||
|
# define PNG_FP_EXPORT(ordinal, type, name, args)
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#ifndef PNG_FIXED_EXPORT /* A fixed point API. */
|
||||||
|
# ifdef PNG_FIXED_POINT_SUPPORTED
|
||||||
|
# define PNG_FIXED_EXPORT(ordinal, type, name, args)\
|
||||||
|
PNG_EXPORT(ordinal, type, name, args);
|
||||||
|
# else /* No fixed point APIs */
|
||||||
|
# define PNG_FIXED_EXPORT(ordinal, type, name, args)
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef PNG_BUILDING_SYMBOL_TABLE
|
||||||
|
/* Some typedefs to get us started. These should be safe on most of the common
|
||||||
|
* platforms.
|
||||||
|
*
|
||||||
|
* png_uint_32 and png_int_32 may, currently, be larger than required to hold a
|
||||||
|
* 32-bit value however this is not normally advisable.
|
||||||
|
*
|
||||||
|
* png_uint_16 and png_int_16 should always be two bytes in size - this is
|
||||||
|
* verified at library build time.
|
||||||
|
*
|
||||||
|
* png_byte must always be one byte in size.
|
||||||
|
*
|
||||||
|
* The checks below use constants from limits.h, as defined by the ISOC90
|
||||||
|
* standard.
|
||||||
|
*/
|
||||||
|
#if CHAR_BIT == 8 && UCHAR_MAX == 255
|
||||||
|
typedef unsigned char png_byte;
|
||||||
|
#else
|
||||||
|
# error "libpng requires 8 bit bytes"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if INT_MIN == -32768 && INT_MAX == 32767
|
||||||
|
typedef int png_int_16;
|
||||||
|
#elif SHRT_MIN == -32768 && SHRT_MAX == 32767
|
||||||
|
typedef short png_int_16;
|
||||||
|
#else
|
||||||
|
# error "libpng requires a signed 16 bit type"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if UINT_MAX == 65535
|
||||||
|
typedef unsigned int png_uint_16;
|
||||||
|
#elif USHRT_MAX == 65535
|
||||||
|
typedef unsigned short png_uint_16;
|
||||||
|
#else
|
||||||
|
# error "libpng requires an unsigned 16 bit type"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if INT_MIN < -2147483646 && INT_MAX > 2147483646
|
||||||
|
typedef int png_int_32;
|
||||||
|
#elif LONG_MIN < -2147483646 && LONG_MAX > 2147483646
|
||||||
|
typedef long int png_int_32;
|
||||||
|
#else
|
||||||
|
# error "libpng requires a signed 32 bit (or more) type"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if UINT_MAX > 4294967294
|
||||||
|
typedef unsigned int png_uint_32;
|
||||||
|
#elif ULONG_MAX > 4294967294
|
||||||
|
typedef unsigned long int png_uint_32;
|
||||||
|
#else
|
||||||
|
# error "libpng requires an unsigned 32 bit (or more) type"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Prior to 1.6.0 it was possible to disable the use of size_t, 1.6.0, however,
|
||||||
|
* requires an ISOC90 compiler and relies on consistent behavior of sizeof.
|
||||||
|
*/
|
||||||
|
typedef size_t png_size_t;
|
||||||
|
typedef ptrdiff_t png_ptrdiff_t;
|
||||||
|
|
||||||
|
/* libpng needs to know the maximum value of 'size_t' and this controls the
|
||||||
|
* definition of png_alloc_size_t, below. This maximum value of size_t limits
|
||||||
|
* but does not control the maximum allocations the library makes - there is
|
||||||
|
* direct application control of this through png_set_user_limits().
|
||||||
|
*/
|
||||||
|
#ifndef PNG_SMALL_SIZE_T
|
||||||
|
/* Compiler specific tests for systems where size_t is known to be less than
|
||||||
|
* 32 bits (some of these systems may no longer work because of the lack of
|
||||||
|
* 'far' support; see above.)
|
||||||
|
*/
|
||||||
|
# if (defined(__TURBOC__) && !defined(__FLAT__)) ||\
|
||||||
|
(defined(_MSC_VER) && defined(MAXSEG_64K))
|
||||||
|
# define PNG_SMALL_SIZE_T
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* png_alloc_size_t is guaranteed to be no smaller than png_size_t, and no
|
||||||
|
* smaller than png_uint_32. Casts from png_size_t or png_uint_32 to
|
||||||
|
* png_alloc_size_t are not necessary; in fact, it is recommended not to use
|
||||||
|
* them at all so that the compiler can complain when something turns out to be
|
||||||
|
* problematic.
|
||||||
|
*
|
||||||
|
* Casts in the other direction (from png_alloc_size_t to png_size_t or
|
||||||
|
* png_uint_32) should be explicitly applied; however, we do not expect to
|
||||||
|
* encounter practical situations that require such conversions.
|
||||||
|
*
|
||||||
|
* PNG_SMALL_SIZE_T must be defined if the maximum value of size_t is less than
|
||||||
|
* 4294967295 - i.e. less than the maximum value of png_uint_32.
|
||||||
|
*/
|
||||||
|
#ifdef PNG_SMALL_SIZE_T
|
||||||
|
typedef png_uint_32 png_alloc_size_t;
|
||||||
|
#else
|
||||||
|
typedef png_size_t png_alloc_size_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Prior to 1.6.0 libpng offered limited support for Microsoft C compiler
|
||||||
|
* implementations of Intel CPU specific support of user-mode segmented address
|
||||||
|
* spaces, where 16-bit pointers address more than 65536 bytes of memory using
|
||||||
|
* separate 'segment' registers. The implementation requires two different
|
||||||
|
* types of pointer (only one of which includes the segment value.)
|
||||||
|
*
|
||||||
|
* If required this support is available in version 1.2 of libpng and may be
|
||||||
|
* available in versions through 1.5, although the correctness of the code has
|
||||||
|
* not been verified recently.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Typedef for floating-point numbers that are converted to fixed-point with a
|
||||||
|
* multiple of 100,000, e.g., gamma
|
||||||
|
*/
|
||||||
|
typedef png_int_32 png_fixed_point;
|
||||||
|
|
||||||
|
/* Add typedefs for pointers */
|
||||||
|
typedef void * png_voidp;
|
||||||
|
typedef const void * png_const_voidp;
|
||||||
|
typedef png_byte * png_bytep;
|
||||||
|
typedef const png_byte * png_const_bytep;
|
||||||
|
typedef png_uint_32 * png_uint_32p;
|
||||||
|
typedef const png_uint_32 * png_const_uint_32p;
|
||||||
|
typedef png_int_32 * png_int_32p;
|
||||||
|
typedef const png_int_32 * png_const_int_32p;
|
||||||
|
typedef png_uint_16 * png_uint_16p;
|
||||||
|
typedef const png_uint_16 * png_const_uint_16p;
|
||||||
|
typedef png_int_16 * png_int_16p;
|
||||||
|
typedef const png_int_16 * png_const_int_16p;
|
||||||
|
typedef char * png_charp;
|
||||||
|
typedef const char * png_const_charp;
|
||||||
|
typedef png_fixed_point * png_fixed_point_p;
|
||||||
|
typedef const png_fixed_point * png_const_fixed_point_p;
|
||||||
|
typedef png_size_t * png_size_tp;
|
||||||
|
typedef const png_size_t * png_const_size_tp;
|
||||||
|
|
||||||
|
#ifdef PNG_STDIO_SUPPORTED
|
||||||
|
typedef FILE * png_FILE_p;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||||
|
typedef double * png_doublep;
|
||||||
|
typedef const double * png_const_doublep;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Pointers to pointers; i.e. arrays */
|
||||||
|
typedef png_byte * * png_bytepp;
|
||||||
|
typedef png_uint_32 * * png_uint_32pp;
|
||||||
|
typedef png_int_32 * * png_int_32pp;
|
||||||
|
typedef png_uint_16 * * png_uint_16pp;
|
||||||
|
typedef png_int_16 * * png_int_16pp;
|
||||||
|
typedef const char * * png_const_charpp;
|
||||||
|
typedef char * * png_charpp;
|
||||||
|
typedef png_fixed_point * * png_fixed_point_pp;
|
||||||
|
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||||
|
typedef double * * png_doublepp;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Pointers to pointers to pointers; i.e., pointer to array */
|
||||||
|
typedef char * * * png_charppp;
|
||||||
|
|
||||||
|
#endif /* PNG_BUILDING_SYMBOL_TABLE */
|
||||||
|
|
||||||
|
#endif /* PNGCONF_H */
|
|
@ -0,0 +1,211 @@
|
||||||
|
/* libpng 1.6.2 STANDARD API DEFINITION */
|
||||||
|
|
||||||
|
/* pnglibconf.h - library build configuration */
|
||||||
|
|
||||||
|
/* Libpng version 1.6.2 - April 25, 2013 */
|
||||||
|
|
||||||
|
/* Copyright (c) 1998-2013 Glenn Randers-Pehrson */
|
||||||
|
|
||||||
|
/* This code is released under the libpng license. */
|
||||||
|
/* For conditions of distribution and use, see the disclaimer */
|
||||||
|
/* and license in png.h */
|
||||||
|
|
||||||
|
/* pnglibconf.h */
|
||||||
|
/* Machine generated file: DO NOT EDIT */
|
||||||
|
/* Derived from: scripts/pnglibconf.dfa */
|
||||||
|
#ifndef PNGLCONF_H
|
||||||
|
#define PNGLCONF_H
|
||||||
|
/* options */
|
||||||
|
#define PNG_16BIT_SUPPORTED
|
||||||
|
#define PNG_ALIGNED_MEMORY_SUPPORTED
|
||||||
|
/*#undef PNG_ARM_NEON_API_SUPPORTED*/
|
||||||
|
/*#undef PNG_ARM_NEON_CHECK_SUPPORTED*/
|
||||||
|
/*#undef PNG_ARM_NEON_SUPPORTED*/
|
||||||
|
#define PNG_BENIGN_ERRORS_SUPPORTED
|
||||||
|
#define PNG_BENIGN_READ_ERRORS_SUPPORTED
|
||||||
|
/*#undef PNG_BENIGN_WRITE_ERRORS_SUPPORTED*/
|
||||||
|
#define PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED
|
||||||
|
#define PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||||
|
#define PNG_COLORSPACE_SUPPORTED
|
||||||
|
#define PNG_CONSOLE_IO_SUPPORTED
|
||||||
|
#define PNG_CONVERT_tIME_SUPPORTED
|
||||||
|
#define PNG_EASY_ACCESS_SUPPORTED
|
||||||
|
/*#undef PNG_ERROR_NUMBERS_SUPPORTED*/
|
||||||
|
#define PNG_ERROR_TEXT_SUPPORTED
|
||||||
|
#define PNG_FIXED_POINT_SUPPORTED
|
||||||
|
#define PNG_FLOATING_ARITHMETIC_SUPPORTED
|
||||||
|
#define PNG_FLOATING_POINT_SUPPORTED
|
||||||
|
#define PNG_FORMAT_AFIRST_SUPPORTED
|
||||||
|
#define PNG_FORMAT_BGR_SUPPORTED
|
||||||
|
#define PNG_GAMMA_SUPPORTED
|
||||||
|
#define PNG_GET_PALETTE_MAX_SUPPORTED
|
||||||
|
#define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||||
|
#define PNG_INCH_CONVERSIONS_SUPPORTED
|
||||||
|
#define PNG_INFO_IMAGE_SUPPORTED
|
||||||
|
#define PNG_IO_STATE_SUPPORTED
|
||||||
|
#define PNG_MNG_FEATURES_SUPPORTED
|
||||||
|
#define PNG_POINTER_INDEXING_SUPPORTED
|
||||||
|
#define PNG_PROGRESSIVE_READ_SUPPORTED
|
||||||
|
#define PNG_READ_16BIT_SUPPORTED
|
||||||
|
#define PNG_READ_ALPHA_MODE_SUPPORTED
|
||||||
|
#define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED
|
||||||
|
#define PNG_READ_BACKGROUND_SUPPORTED
|
||||||
|
#define PNG_READ_BGR_SUPPORTED
|
||||||
|
#define PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||||
|
#define PNG_READ_COMPOSITE_NODIV_SUPPORTED
|
||||||
|
#define PNG_READ_COMPRESSED_TEXT_SUPPORTED
|
||||||
|
#define PNG_READ_EXPAND_16_SUPPORTED
|
||||||
|
#define PNG_READ_EXPAND_SUPPORTED
|
||||||
|
#define PNG_READ_FILLER_SUPPORTED
|
||||||
|
#define PNG_READ_GAMMA_SUPPORTED
|
||||||
|
#define PNG_READ_GET_PALETTE_MAX_SUPPORTED
|
||||||
|
#define PNG_READ_GRAY_TO_RGB_SUPPORTED
|
||||||
|
#define PNG_READ_INTERLACING_SUPPORTED
|
||||||
|
#define PNG_READ_INT_FUNCTIONS_SUPPORTED
|
||||||
|
#define PNG_READ_INVERT_ALPHA_SUPPORTED
|
||||||
|
#define PNG_READ_INVERT_SUPPORTED
|
||||||
|
#define PNG_READ_OPT_PLTE_SUPPORTED
|
||||||
|
#define PNG_READ_PACKSWAP_SUPPORTED
|
||||||
|
#define PNG_READ_PACK_SUPPORTED
|
||||||
|
#define PNG_READ_QUANTIZE_SUPPORTED
|
||||||
|
#define PNG_READ_RGB_TO_GRAY_SUPPORTED
|
||||||
|
#define PNG_READ_SCALE_16_TO_8_SUPPORTED
|
||||||
|
#define PNG_READ_SHIFT_SUPPORTED
|
||||||
|
#define PNG_READ_STRIP_16_TO_8_SUPPORTED
|
||||||
|
#define PNG_READ_STRIP_ALPHA_SUPPORTED
|
||||||
|
#define PNG_READ_SUPPORTED
|
||||||
|
#define PNG_READ_SWAP_ALPHA_SUPPORTED
|
||||||
|
#define PNG_READ_SWAP_SUPPORTED
|
||||||
|
#define PNG_READ_TEXT_SUPPORTED
|
||||||
|
#define PNG_READ_TRANSFORMS_SUPPORTED
|
||||||
|
#define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
|
||||||
|
#define PNG_READ_USER_CHUNKS_SUPPORTED
|
||||||
|
#define PNG_READ_USER_TRANSFORM_SUPPORTED
|
||||||
|
#define PNG_READ_bKGD_SUPPORTED
|
||||||
|
#define PNG_READ_cHRM_SUPPORTED
|
||||||
|
#define PNG_READ_gAMA_SUPPORTED
|
||||||
|
#define PNG_READ_hIST_SUPPORTED
|
||||||
|
#define PNG_READ_iCCP_SUPPORTED
|
||||||
|
#define PNG_READ_iTXt_SUPPORTED
|
||||||
|
#define PNG_READ_oFFs_SUPPORTED
|
||||||
|
#define PNG_READ_pCAL_SUPPORTED
|
||||||
|
#define PNG_READ_pHYs_SUPPORTED
|
||||||
|
#define PNG_READ_sBIT_SUPPORTED
|
||||||
|
#define PNG_READ_sCAL_SUPPORTED
|
||||||
|
#define PNG_READ_sPLT_SUPPORTED
|
||||||
|
#define PNG_READ_sRGB_SUPPORTED
|
||||||
|
#define PNG_READ_tEXt_SUPPORTED
|
||||||
|
#define PNG_READ_tIME_SUPPORTED
|
||||||
|
#define PNG_READ_tRNS_SUPPORTED
|
||||||
|
#define PNG_READ_zTXt_SUPPORTED
|
||||||
|
/*#undef PNG_SAFE_LIMITS_SUPPORTED*/
|
||||||
|
#define PNG_SAVE_INT_32_SUPPORTED
|
||||||
|
#define PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
|
||||||
|
#define PNG_SEQUENTIAL_READ_SUPPORTED
|
||||||
|
#define PNG_SETJMP_SUPPORTED
|
||||||
|
#define PNG_SET_CHUNK_CACHE_LIMIT_SUPPORTED
|
||||||
|
#define PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED
|
||||||
|
/*#undef PNG_SET_OPTION_SUPPORTED*/
|
||||||
|
#define PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
|
||||||
|
#define PNG_SET_USER_LIMITS_SUPPORTED
|
||||||
|
#define PNG_SIMPLIFIED_READ_AFIRST_SUPPORTED
|
||||||
|
#define PNG_SIMPLIFIED_READ_BGR_SUPPORTED
|
||||||
|
#define PNG_SIMPLIFIED_READ_SUPPORTED
|
||||||
|
#define PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED
|
||||||
|
#define PNG_SIMPLIFIED_WRITE_BGR_SUPPORTED
|
||||||
|
#define PNG_SIMPLIFIED_WRITE_SUPPORTED
|
||||||
|
#define PNG_STDIO_SUPPORTED
|
||||||
|
#define PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
|
||||||
|
#define PNG_TEXT_SUPPORTED
|
||||||
|
#define PNG_TIME_RFC1123_SUPPORTED
|
||||||
|
#define PNG_UNKNOWN_CHUNKS_SUPPORTED
|
||||||
|
#define PNG_USER_CHUNKS_SUPPORTED
|
||||||
|
#define PNG_USER_LIMITS_SUPPORTED
|
||||||
|
#define PNG_USER_MEM_SUPPORTED
|
||||||
|
#define PNG_USER_TRANSFORM_INFO_SUPPORTED
|
||||||
|
#define PNG_USER_TRANSFORM_PTR_SUPPORTED
|
||||||
|
#define PNG_WARNINGS_SUPPORTED
|
||||||
|
#define PNG_WRITE_16BIT_SUPPORTED
|
||||||
|
#define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
|
||||||
|
#define PNG_WRITE_BGR_SUPPORTED
|
||||||
|
#define PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||||
|
#define PNG_WRITE_COMPRESSED_TEXT_SUPPORTED
|
||||||
|
#define PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
|
||||||
|
#define PNG_WRITE_FILLER_SUPPORTED
|
||||||
|
#define PNG_WRITE_FILTER_SUPPORTED
|
||||||
|
#define PNG_WRITE_FLUSH_SUPPORTED
|
||||||
|
#define PNG_WRITE_GET_PALETTE_MAX_SUPPORTED
|
||||||
|
#define PNG_WRITE_INTERLACING_SUPPORTED
|
||||||
|
#define PNG_WRITE_INT_FUNCTIONS_SUPPORTED
|
||||||
|
#define PNG_WRITE_INVERT_ALPHA_SUPPORTED
|
||||||
|
#define PNG_WRITE_INVERT_SUPPORTED
|
||||||
|
#define PNG_WRITE_OPTIMIZE_CMF_SUPPORTED
|
||||||
|
#define PNG_WRITE_PACKSWAP_SUPPORTED
|
||||||
|
#define PNG_WRITE_PACK_SUPPORTED
|
||||||
|
#define PNG_WRITE_SHIFT_SUPPORTED
|
||||||
|
#define PNG_WRITE_SUPPORTED
|
||||||
|
#define PNG_WRITE_SWAP_ALPHA_SUPPORTED
|
||||||
|
#define PNG_WRITE_SWAP_SUPPORTED
|
||||||
|
#define PNG_WRITE_TEXT_SUPPORTED
|
||||||
|
#define PNG_WRITE_TRANSFORMS_SUPPORTED
|
||||||
|
#define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
|
||||||
|
#define PNG_WRITE_USER_TRANSFORM_SUPPORTED
|
||||||
|
#define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
|
||||||
|
#define PNG_WRITE_bKGD_SUPPORTED
|
||||||
|
#define PNG_WRITE_cHRM_SUPPORTED
|
||||||
|
#define PNG_WRITE_gAMA_SUPPORTED
|
||||||
|
#define PNG_WRITE_hIST_SUPPORTED
|
||||||
|
#define PNG_WRITE_iCCP_SUPPORTED
|
||||||
|
#define PNG_WRITE_iTXt_SUPPORTED
|
||||||
|
#define PNG_WRITE_oFFs_SUPPORTED
|
||||||
|
#define PNG_WRITE_pCAL_SUPPORTED
|
||||||
|
#define PNG_WRITE_pHYs_SUPPORTED
|
||||||
|
#define PNG_WRITE_sBIT_SUPPORTED
|
||||||
|
#define PNG_WRITE_sCAL_SUPPORTED
|
||||||
|
#define PNG_WRITE_sPLT_SUPPORTED
|
||||||
|
#define PNG_WRITE_sRGB_SUPPORTED
|
||||||
|
#define PNG_WRITE_tEXt_SUPPORTED
|
||||||
|
#define PNG_WRITE_tIME_SUPPORTED
|
||||||
|
#define PNG_WRITE_tRNS_SUPPORTED
|
||||||
|
#define PNG_WRITE_zTXt_SUPPORTED
|
||||||
|
#define PNG_bKGD_SUPPORTED
|
||||||
|
#define PNG_cHRM_SUPPORTED
|
||||||
|
#define PNG_gAMA_SUPPORTED
|
||||||
|
#define PNG_hIST_SUPPORTED
|
||||||
|
#define PNG_iCCP_SUPPORTED
|
||||||
|
#define PNG_iTXt_SUPPORTED
|
||||||
|
#define PNG_oFFs_SUPPORTED
|
||||||
|
#define PNG_pCAL_SUPPORTED
|
||||||
|
#define PNG_pHYs_SUPPORTED
|
||||||
|
#define PNG_sBIT_SUPPORTED
|
||||||
|
#define PNG_sCAL_SUPPORTED
|
||||||
|
#define PNG_sPLT_SUPPORTED
|
||||||
|
#define PNG_sRGB_SUPPORTED
|
||||||
|
#define PNG_tEXt_SUPPORTED
|
||||||
|
#define PNG_tIME_SUPPORTED
|
||||||
|
#define PNG_tRNS_SUPPORTED
|
||||||
|
#define PNG_zTXt_SUPPORTED
|
||||||
|
/* end of options */
|
||||||
|
/* settings */
|
||||||
|
#define PNG_API_RULE 0
|
||||||
|
#define PNG_CALLOC_SUPPORTED
|
||||||
|
#define PNG_COST_SHIFT 3
|
||||||
|
#define PNG_DEFAULT_READ_MACROS 1
|
||||||
|
#define PNG_GAMMA_THRESHOLD_FIXED 5000
|
||||||
|
#define PNG_IDAT_READ_SIZE PNG_ZBUF_SIZE
|
||||||
|
#define PNG_INFLATE_BUF_SIZE 1024
|
||||||
|
#define PNG_MAX_GAMMA_8 11
|
||||||
|
#define PNG_QUANTIZE_BLUE_BITS 5
|
||||||
|
#define PNG_QUANTIZE_GREEN_BITS 5
|
||||||
|
#define PNG_QUANTIZE_RED_BITS 5
|
||||||
|
#define PNG_TEXT_Z_DEFAULT_COMPRESSION (-1)
|
||||||
|
#define PNG_TEXT_Z_DEFAULT_STRATEGY 0
|
||||||
|
#define PNG_WEIGHT_SHIFT 8
|
||||||
|
#define PNG_ZBUF_SIZE 8192
|
||||||
|
#define PNG_Z_DEFAULT_COMPRESSION (-1)
|
||||||
|
#define PNG_Z_DEFAULT_NOFILTER_STRATEGY 0
|
||||||
|
#define PNG_Z_DEFAULT_STRATEGY 1
|
||||||
|
#define PNG_sCAL_PRECISION 5
|
||||||
|
#define PNG_sRGB_PROFILE_CHECKS 2
|
||||||
|
/* end of settings */
|
||||||
|
#endif /* PNGLCONF_H */
|
|
@ -0,0 +1,678 @@
|
||||||
|
/* $Id: tiff.h,v 1.68 2012-08-19 16:56:35 bfriesen Exp $ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1988-1997 Sam Leffler
|
||||||
|
* Copyright (c) 1991-1997 Silicon Graphics, Inc.
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, distribute, and sell this software and
|
||||||
|
* its documentation for any purpose is hereby granted without fee, provided
|
||||||
|
* that (i) the above copyright notices and this permission notice appear in
|
||||||
|
* all copies of the software and related documentation, and (ii) the names of
|
||||||
|
* Sam Leffler and Silicon Graphics may not be used in any advertising or
|
||||||
|
* publicity relating to the software without the specific, prior written
|
||||||
|
* permission of Sam Leffler and Silicon Graphics.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||||
|
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||||
|
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||||
|
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||||
|
* OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _TIFF_
|
||||||
|
#define _TIFF_
|
||||||
|
|
||||||
|
#include "tiffconf.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Tag Image File Format (TIFF)
|
||||||
|
*
|
||||||
|
* Based on Rev 6.0 from:
|
||||||
|
* Developer's Desk
|
||||||
|
* Aldus Corporation
|
||||||
|
* 411 First Ave. South
|
||||||
|
* Suite 200
|
||||||
|
* Seattle, WA 98104
|
||||||
|
* 206-622-5500
|
||||||
|
*
|
||||||
|
* (http://partners.adobe.com/asn/developer/PDFS/TN/TIFF6.pdf)
|
||||||
|
*
|
||||||
|
* For BigTIFF design notes see the following links
|
||||||
|
* http://www.remotesensing.org/libtiff/bigtiffdesign.html
|
||||||
|
* http://www.awaresystems.be/imaging/tiff/bigtiff.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define TIFF_VERSION_CLASSIC 42
|
||||||
|
#define TIFF_VERSION_BIG 43
|
||||||
|
|
||||||
|
#define TIFF_BIGENDIAN 0x4d4d
|
||||||
|
#define TIFF_LITTLEENDIAN 0x4949
|
||||||
|
#define MDI_LITTLEENDIAN 0x5045
|
||||||
|
#define MDI_BIGENDIAN 0x4550
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Intrinsic data types required by the file format:
|
||||||
|
*
|
||||||
|
* 8-bit quantities int8/uint8
|
||||||
|
* 16-bit quantities int16/uint16
|
||||||
|
* 32-bit quantities int32/uint32
|
||||||
|
* 64-bit quantities int64/uint64
|
||||||
|
* strings unsigned char*
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef TIFF_INT8_T int8;
|
||||||
|
typedef TIFF_UINT8_T uint8;
|
||||||
|
|
||||||
|
typedef TIFF_INT16_T int16;
|
||||||
|
typedef TIFF_UINT16_T uint16;
|
||||||
|
|
||||||
|
typedef TIFF_INT32_T int32;
|
||||||
|
typedef TIFF_UINT32_T uint32;
|
||||||
|
|
||||||
|
typedef TIFF_INT64_T int64;
|
||||||
|
typedef TIFF_UINT64_T uint64;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Some types as promoted in a variable argument list
|
||||||
|
* We use uint16_vap rather then directly using int, because this way
|
||||||
|
* we document the type we actually want to pass through, conceptually,
|
||||||
|
* rather then confusing the issue by merely stating the type it gets
|
||||||
|
* promoted to
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef int uint16_vap;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* TIFF header.
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
uint16 tiff_magic; /* magic number (defines byte order) */
|
||||||
|
uint16 tiff_version; /* TIFF version number */
|
||||||
|
} TIFFHeaderCommon;
|
||||||
|
typedef struct {
|
||||||
|
uint16 tiff_magic; /* magic number (defines byte order) */
|
||||||
|
uint16 tiff_version; /* TIFF version number */
|
||||||
|
uint32 tiff_diroff; /* byte offset to first directory */
|
||||||
|
} TIFFHeaderClassic;
|
||||||
|
typedef struct {
|
||||||
|
uint16 tiff_magic; /* magic number (defines byte order) */
|
||||||
|
uint16 tiff_version; /* TIFF version number */
|
||||||
|
uint16 tiff_offsetsize; /* size of offsets, should be 8 */
|
||||||
|
uint16 tiff_unused; /* unused word, should be 0 */
|
||||||
|
uint64 tiff_diroff; /* byte offset to first directory */
|
||||||
|
} TIFFHeaderBig;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NB: In the comments below,
|
||||||
|
* - items marked with a + are obsoleted by revision 5.0,
|
||||||
|
* - items marked with a ! are introduced in revision 6.0.
|
||||||
|
* - items marked with a % are introduced post revision 6.0.
|
||||||
|
* - items marked with a $ are obsoleted by revision 6.0.
|
||||||
|
* - items marked with a & are introduced by Adobe DNG specification.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Tag data type information.
|
||||||
|
*
|
||||||
|
* Note: RATIONALs are the ratio of two 32-bit integer values.
|
||||||
|
*/
|
||||||
|
typedef enum {
|
||||||
|
TIFF_NOTYPE = 0, /* placeholder */
|
||||||
|
TIFF_BYTE = 1, /* 8-bit unsigned integer */
|
||||||
|
TIFF_ASCII = 2, /* 8-bit bytes w/ last byte null */
|
||||||
|
TIFF_SHORT = 3, /* 16-bit unsigned integer */
|
||||||
|
TIFF_LONG = 4, /* 32-bit unsigned integer */
|
||||||
|
TIFF_RATIONAL = 5, /* 64-bit unsigned fraction */
|
||||||
|
TIFF_SBYTE = 6, /* !8-bit signed integer */
|
||||||
|
TIFF_UNDEFINED = 7, /* !8-bit untyped data */
|
||||||
|
TIFF_SSHORT = 8, /* !16-bit signed integer */
|
||||||
|
TIFF_SLONG = 9, /* !32-bit signed integer */
|
||||||
|
TIFF_SRATIONAL = 10, /* !64-bit signed fraction */
|
||||||
|
TIFF_FLOAT = 11, /* !32-bit IEEE floating point */
|
||||||
|
TIFF_DOUBLE = 12, /* !64-bit IEEE floating point */
|
||||||
|
TIFF_IFD = 13, /* %32-bit unsigned integer (offset) */
|
||||||
|
TIFF_LONG8 = 16, /* BigTIFF 64-bit unsigned integer */
|
||||||
|
TIFF_SLONG8 = 17, /* BigTIFF 64-bit signed integer */
|
||||||
|
TIFF_IFD8 = 18 /* BigTIFF 64-bit unsigned integer (offset) */
|
||||||
|
} TIFFDataType;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* TIFF Tag Definitions.
|
||||||
|
*/
|
||||||
|
#define TIFFTAG_SUBFILETYPE 254 /* subfile data descriptor */
|
||||||
|
#define FILETYPE_REDUCEDIMAGE 0x1 /* reduced resolution version */
|
||||||
|
#define FILETYPE_PAGE 0x2 /* one page of many */
|
||||||
|
#define FILETYPE_MASK 0x4 /* transparency mask */
|
||||||
|
#define TIFFTAG_OSUBFILETYPE 255 /* +kind of data in subfile */
|
||||||
|
#define OFILETYPE_IMAGE 1 /* full resolution image data */
|
||||||
|
#define OFILETYPE_REDUCEDIMAGE 2 /* reduced size image data */
|
||||||
|
#define OFILETYPE_PAGE 3 /* one page of many */
|
||||||
|
#define TIFFTAG_IMAGEWIDTH 256 /* image width in pixels */
|
||||||
|
#define TIFFTAG_IMAGELENGTH 257 /* image height in pixels */
|
||||||
|
#define TIFFTAG_BITSPERSAMPLE 258 /* bits per channel (sample) */
|
||||||
|
#define TIFFTAG_COMPRESSION 259 /* data compression technique */
|
||||||
|
#define COMPRESSION_NONE 1 /* dump mode */
|
||||||
|
#define COMPRESSION_CCITTRLE 2 /* CCITT modified Huffman RLE */
|
||||||
|
#define COMPRESSION_CCITTFAX3 3 /* CCITT Group 3 fax encoding */
|
||||||
|
#define COMPRESSION_CCITT_T4 3 /* CCITT T.4 (TIFF 6 name) */
|
||||||
|
#define COMPRESSION_CCITTFAX4 4 /* CCITT Group 4 fax encoding */
|
||||||
|
#define COMPRESSION_CCITT_T6 4 /* CCITT T.6 (TIFF 6 name) */
|
||||||
|
#define COMPRESSION_LZW 5 /* Lempel-Ziv & Welch */
|
||||||
|
#define COMPRESSION_OJPEG 6 /* !6.0 JPEG */
|
||||||
|
#define COMPRESSION_JPEG 7 /* %JPEG DCT compression */
|
||||||
|
#define COMPRESSION_T85 9 /* !TIFF/FX T.85 JBIG compression */
|
||||||
|
#define COMPRESSION_T43 10 /* !TIFF/FX T.43 colour by layered JBIG compression */
|
||||||
|
#define COMPRESSION_NEXT 32766 /* NeXT 2-bit RLE */
|
||||||
|
#define COMPRESSION_CCITTRLEW 32771 /* #1 w/ word alignment */
|
||||||
|
#define COMPRESSION_PACKBITS 32773 /* Macintosh RLE */
|
||||||
|
#define COMPRESSION_THUNDERSCAN 32809 /* ThunderScan RLE */
|
||||||
|
/* codes 32895-32898 are reserved for ANSI IT8 TIFF/IT <dkelly@apago.com) */
|
||||||
|
#define COMPRESSION_IT8CTPAD 32895 /* IT8 CT w/padding */
|
||||||
|
#define COMPRESSION_IT8LW 32896 /* IT8 Linework RLE */
|
||||||
|
#define COMPRESSION_IT8MP 32897 /* IT8 Monochrome picture */
|
||||||
|
#define COMPRESSION_IT8BL 32898 /* IT8 Binary line art */
|
||||||
|
/* compression codes 32908-32911 are reserved for Pixar */
|
||||||
|
#define COMPRESSION_PIXARFILM 32908 /* Pixar companded 10bit LZW */
|
||||||
|
#define COMPRESSION_PIXARLOG 32909 /* Pixar companded 11bit ZIP */
|
||||||
|
#define COMPRESSION_DEFLATE 32946 /* Deflate compression */
|
||||||
|
#define COMPRESSION_ADOBE_DEFLATE 8 /* Deflate compression,
|
||||||
|
as recognized by Adobe */
|
||||||
|
/* compression code 32947 is reserved for Oceana Matrix <dev@oceana.com> */
|
||||||
|
#define COMPRESSION_DCS 32947 /* Kodak DCS encoding */
|
||||||
|
#define COMPRESSION_JBIG 34661 /* ISO JBIG */
|
||||||
|
#define COMPRESSION_SGILOG 34676 /* SGI Log Luminance RLE */
|
||||||
|
#define COMPRESSION_SGILOG24 34677 /* SGI Log 24-bit packed */
|
||||||
|
#define COMPRESSION_JP2000 34712 /* Leadtools JPEG2000 */
|
||||||
|
#define COMPRESSION_LZMA 34925 /* LZMA2 */
|
||||||
|
#define TIFFTAG_PHOTOMETRIC 262 /* photometric interpretation */
|
||||||
|
#define PHOTOMETRIC_MINISWHITE 0 /* min value is white */
|
||||||
|
#define PHOTOMETRIC_MINISBLACK 1 /* min value is black */
|
||||||
|
#define PHOTOMETRIC_RGB 2 /* RGB color model */
|
||||||
|
#define PHOTOMETRIC_PALETTE 3 /* color map indexed */
|
||||||
|
#define PHOTOMETRIC_MASK 4 /* $holdout mask */
|
||||||
|
#define PHOTOMETRIC_SEPARATED 5 /* !color separations */
|
||||||
|
#define PHOTOMETRIC_YCBCR 6 /* !CCIR 601 */
|
||||||
|
#define PHOTOMETRIC_CIELAB 8 /* !1976 CIE L*a*b* */
|
||||||
|
#define PHOTOMETRIC_ICCLAB 9 /* ICC L*a*b* [Adobe TIFF Technote 4] */
|
||||||
|
#define PHOTOMETRIC_ITULAB 10 /* ITU L*a*b* */
|
||||||
|
#define PHOTOMETRIC_LOGL 32844 /* CIE Log2(L) */
|
||||||
|
#define PHOTOMETRIC_LOGLUV 32845 /* CIE Log2(L) (u',v') */
|
||||||
|
#define TIFFTAG_THRESHHOLDING 263 /* +thresholding used on data */
|
||||||
|
#define THRESHHOLD_BILEVEL 1 /* b&w art scan */
|
||||||
|
#define THRESHHOLD_HALFTONE 2 /* or dithered scan */
|
||||||
|
#define THRESHHOLD_ERRORDIFFUSE 3 /* usually floyd-steinberg */
|
||||||
|
#define TIFFTAG_CELLWIDTH 264 /* +dithering matrix width */
|
||||||
|
#define TIFFTAG_CELLLENGTH 265 /* +dithering matrix height */
|
||||||
|
#define TIFFTAG_FILLORDER 266 /* data order within a byte */
|
||||||
|
#define FILLORDER_MSB2LSB 1 /* most significant -> least */
|
||||||
|
#define FILLORDER_LSB2MSB 2 /* least significant -> most */
|
||||||
|
#define TIFFTAG_DOCUMENTNAME 269 /* name of doc. image is from */
|
||||||
|
#define TIFFTAG_IMAGEDESCRIPTION 270 /* info about image */
|
||||||
|
#define TIFFTAG_MAKE 271 /* scanner manufacturer name */
|
||||||
|
#define TIFFTAG_MODEL 272 /* scanner model name/number */
|
||||||
|
#define TIFFTAG_STRIPOFFSETS 273 /* offsets to data strips */
|
||||||
|
#define TIFFTAG_ORIENTATION 274 /* +image orientation */
|
||||||
|
#define ORIENTATION_TOPLEFT 1 /* row 0 top, col 0 lhs */
|
||||||
|
#define ORIENTATION_TOPRIGHT 2 /* row 0 top, col 0 rhs */
|
||||||
|
#define ORIENTATION_BOTRIGHT 3 /* row 0 bottom, col 0 rhs */
|
||||||
|
#define ORIENTATION_BOTLEFT 4 /* row 0 bottom, col 0 lhs */
|
||||||
|
#define ORIENTATION_LEFTTOP 5 /* row 0 lhs, col 0 top */
|
||||||
|
#define ORIENTATION_RIGHTTOP 6 /* row 0 rhs, col 0 top */
|
||||||
|
#define ORIENTATION_RIGHTBOT 7 /* row 0 rhs, col 0 bottom */
|
||||||
|
#define ORIENTATION_LEFTBOT 8 /* row 0 lhs, col 0 bottom */
|
||||||
|
#define TIFFTAG_SAMPLESPERPIXEL 277 /* samples per pixel */
|
||||||
|
#define TIFFTAG_ROWSPERSTRIP 278 /* rows per strip of data */
|
||||||
|
#define TIFFTAG_STRIPBYTECOUNTS 279 /* bytes counts for strips */
|
||||||
|
#define TIFFTAG_MINSAMPLEVALUE 280 /* +minimum sample value */
|
||||||
|
#define TIFFTAG_MAXSAMPLEVALUE 281 /* +maximum sample value */
|
||||||
|
#define TIFFTAG_XRESOLUTION 282 /* pixels/resolution in x */
|
||||||
|
#define TIFFTAG_YRESOLUTION 283 /* pixels/resolution in y */
|
||||||
|
#define TIFFTAG_PLANARCONFIG 284 /* storage organization */
|
||||||
|
#define PLANARCONFIG_CONTIG 1 /* single image plane */
|
||||||
|
#define PLANARCONFIG_SEPARATE 2 /* separate planes of data */
|
||||||
|
#define TIFFTAG_PAGENAME 285 /* page name image is from */
|
||||||
|
#define TIFFTAG_XPOSITION 286 /* x page offset of image lhs */
|
||||||
|
#define TIFFTAG_YPOSITION 287 /* y page offset of image lhs */
|
||||||
|
#define TIFFTAG_FREEOFFSETS 288 /* +byte offset to free block */
|
||||||
|
#define TIFFTAG_FREEBYTECOUNTS 289 /* +sizes of free blocks */
|
||||||
|
#define TIFFTAG_GRAYRESPONSEUNIT 290 /* $gray scale curve accuracy */
|
||||||
|
#define GRAYRESPONSEUNIT_10S 1 /* tenths of a unit */
|
||||||
|
#define GRAYRESPONSEUNIT_100S 2 /* hundredths of a unit */
|
||||||
|
#define GRAYRESPONSEUNIT_1000S 3 /* thousandths of a unit */
|
||||||
|
#define GRAYRESPONSEUNIT_10000S 4 /* ten-thousandths of a unit */
|
||||||
|
#define GRAYRESPONSEUNIT_100000S 5 /* hundred-thousandths */
|
||||||
|
#define TIFFTAG_GRAYRESPONSECURVE 291 /* $gray scale response curve */
|
||||||
|
#define TIFFTAG_GROUP3OPTIONS 292 /* 32 flag bits */
|
||||||
|
#define TIFFTAG_T4OPTIONS 292 /* TIFF 6.0 proper name alias */
|
||||||
|
#define GROUP3OPT_2DENCODING 0x1 /* 2-dimensional coding */
|
||||||
|
#define GROUP3OPT_UNCOMPRESSED 0x2 /* data not compressed */
|
||||||
|
#define GROUP3OPT_FILLBITS 0x4 /* fill to byte boundary */
|
||||||
|
#define TIFFTAG_GROUP4OPTIONS 293 /* 32 flag bits */
|
||||||
|
#define TIFFTAG_T6OPTIONS 293 /* TIFF 6.0 proper name */
|
||||||
|
#define GROUP4OPT_UNCOMPRESSED 0x2 /* data not compressed */
|
||||||
|
#define TIFFTAG_RESOLUTIONUNIT 296 /* units of resolutions */
|
||||||
|
#define RESUNIT_NONE 1 /* no meaningful units */
|
||||||
|
#define RESUNIT_INCH 2 /* english */
|
||||||
|
#define RESUNIT_CENTIMETER 3 /* metric */
|
||||||
|
#define TIFFTAG_PAGENUMBER 297 /* page numbers of multi-page */
|
||||||
|
#define TIFFTAG_COLORRESPONSEUNIT 300 /* $color curve accuracy */
|
||||||
|
#define COLORRESPONSEUNIT_10S 1 /* tenths of a unit */
|
||||||
|
#define COLORRESPONSEUNIT_100S 2 /* hundredths of a unit */
|
||||||
|
#define COLORRESPONSEUNIT_1000S 3 /* thousandths of a unit */
|
||||||
|
#define COLORRESPONSEUNIT_10000S 4 /* ten-thousandths of a unit */
|
||||||
|
#define COLORRESPONSEUNIT_100000S 5 /* hundred-thousandths */
|
||||||
|
#define TIFFTAG_TRANSFERFUNCTION 301 /* !colorimetry info */
|
||||||
|
#define TIFFTAG_SOFTWARE 305 /* name & release */
|
||||||
|
#define TIFFTAG_DATETIME 306 /* creation date and time */
|
||||||
|
#define TIFFTAG_ARTIST 315 /* creator of image */
|
||||||
|
#define TIFFTAG_HOSTCOMPUTER 316 /* machine where created */
|
||||||
|
#define TIFFTAG_PREDICTOR 317 /* prediction scheme w/ LZW */
|
||||||
|
#define PREDICTOR_NONE 1 /* no prediction scheme used */
|
||||||
|
#define PREDICTOR_HORIZONTAL 2 /* horizontal differencing */
|
||||||
|
#define PREDICTOR_FLOATINGPOINT 3 /* floating point predictor */
|
||||||
|
#define TIFFTAG_WHITEPOINT 318 /* image white point */
|
||||||
|
#define TIFFTAG_PRIMARYCHROMATICITIES 319 /* !primary chromaticities */
|
||||||
|
#define TIFFTAG_COLORMAP 320 /* RGB map for pallette image */
|
||||||
|
#define TIFFTAG_HALFTONEHINTS 321 /* !highlight+shadow info */
|
||||||
|
#define TIFFTAG_TILEWIDTH 322 /* !tile width in pixels */
|
||||||
|
#define TIFFTAG_TILELENGTH 323 /* !tile height in pixels */
|
||||||
|
#define TIFFTAG_TILEOFFSETS 324 /* !offsets to data tiles */
|
||||||
|
#define TIFFTAG_TILEBYTECOUNTS 325 /* !byte counts for tiles */
|
||||||
|
#define TIFFTAG_BADFAXLINES 326 /* lines w/ wrong pixel count */
|
||||||
|
#define TIFFTAG_CLEANFAXDATA 327 /* regenerated line info */
|
||||||
|
#define CLEANFAXDATA_CLEAN 0 /* no errors detected */
|
||||||
|
#define CLEANFAXDATA_REGENERATED 1 /* receiver regenerated lines */
|
||||||
|
#define CLEANFAXDATA_UNCLEAN 2 /* uncorrected errors exist */
|
||||||
|
#define TIFFTAG_CONSECUTIVEBADFAXLINES 328 /* max consecutive bad lines */
|
||||||
|
#define TIFFTAG_SUBIFD 330 /* subimage descriptors */
|
||||||
|
#define TIFFTAG_INKSET 332 /* !inks in separated image */
|
||||||
|
#define INKSET_CMYK 1 /* !cyan-magenta-yellow-black color */
|
||||||
|
#define INKSET_MULTIINK 2 /* !multi-ink or hi-fi color */
|
||||||
|
#define TIFFTAG_INKNAMES 333 /* !ascii names of inks */
|
||||||
|
#define TIFFTAG_NUMBEROFINKS 334 /* !number of inks */
|
||||||
|
#define TIFFTAG_DOTRANGE 336 /* !0% and 100% dot codes */
|
||||||
|
#define TIFFTAG_TARGETPRINTER 337 /* !separation target */
|
||||||
|
#define TIFFTAG_EXTRASAMPLES 338 /* !info about extra samples */
|
||||||
|
#define EXTRASAMPLE_UNSPECIFIED 0 /* !unspecified data */
|
||||||
|
#define EXTRASAMPLE_ASSOCALPHA 1 /* !associated alpha data */
|
||||||
|
#define EXTRASAMPLE_UNASSALPHA 2 /* !unassociated alpha data */
|
||||||
|
#define TIFFTAG_SAMPLEFORMAT 339 /* !data sample format */
|
||||||
|
#define SAMPLEFORMAT_UINT 1 /* !unsigned integer data */
|
||||||
|
#define SAMPLEFORMAT_INT 2 /* !signed integer data */
|
||||||
|
#define SAMPLEFORMAT_IEEEFP 3 /* !IEEE floating point data */
|
||||||
|
#define SAMPLEFORMAT_VOID 4 /* !untyped data */
|
||||||
|
#define SAMPLEFORMAT_COMPLEXINT 5 /* !complex signed int */
|
||||||
|
#define SAMPLEFORMAT_COMPLEXIEEEFP 6 /* !complex ieee floating */
|
||||||
|
#define TIFFTAG_SMINSAMPLEVALUE 340 /* !variable MinSampleValue */
|
||||||
|
#define TIFFTAG_SMAXSAMPLEVALUE 341 /* !variable MaxSampleValue */
|
||||||
|
#define TIFFTAG_CLIPPATH 343 /* %ClipPath
|
||||||
|
[Adobe TIFF technote 2] */
|
||||||
|
#define TIFFTAG_XCLIPPATHUNITS 344 /* %XClipPathUnits
|
||||||
|
[Adobe TIFF technote 2] */
|
||||||
|
#define TIFFTAG_YCLIPPATHUNITS 345 /* %YClipPathUnits
|
||||||
|
[Adobe TIFF technote 2] */
|
||||||
|
#define TIFFTAG_INDEXED 346 /* %Indexed
|
||||||
|
[Adobe TIFF Technote 3] */
|
||||||
|
#define TIFFTAG_JPEGTABLES 347 /* %JPEG table stream */
|
||||||
|
#define TIFFTAG_OPIPROXY 351 /* %OPI Proxy [Adobe TIFF technote] */
|
||||||
|
/* Tags 400-435 are from the TIFF/FX spec */
|
||||||
|
#define TIFFTAG_GLOBALPARAMETERSIFD 400 /* ! */
|
||||||
|
#define TIFFTAG_PROFILETYPE 401 /* ! */
|
||||||
|
#define PROFILETYPE_UNSPECIFIED 0 /* ! */
|
||||||
|
#define PROFILETYPE_G3_FAX 1 /* ! */
|
||||||
|
#define TIFFTAG_FAXPROFILE 402 /* ! */
|
||||||
|
#define FAXPROFILE_S 1 /* !TIFF/FX FAX profile S */
|
||||||
|
#define FAXPROFILE_F 2 /* !TIFF/FX FAX profile F */
|
||||||
|
#define FAXPROFILE_J 3 /* !TIFF/FX FAX profile J */
|
||||||
|
#define FAXPROFILE_C 4 /* !TIFF/FX FAX profile C */
|
||||||
|
#define FAXPROFILE_L 5 /* !TIFF/FX FAX profile L */
|
||||||
|
#define FAXPROFILE_M 6 /* !TIFF/FX FAX profile LM */
|
||||||
|
#define TIFFTAG_CODINGMETHODS 403 /* !TIFF/FX coding methods */
|
||||||
|
#define CODINGMETHODS_T4_1D (1 << 1) /* !T.4 1D */
|
||||||
|
#define CODINGMETHODS_T4_2D (1 << 2) /* !T.4 2D */
|
||||||
|
#define CODINGMETHODS_T6 (1 << 3) /* !T.6 */
|
||||||
|
#define CODINGMETHODS_T85 (1 << 4) /* !T.85 JBIG */
|
||||||
|
#define CODINGMETHODS_T42 (1 << 5) /* !T.42 JPEG */
|
||||||
|
#define CODINGMETHODS_T43 (1 << 6) /* !T.43 colour by layered JBIG */
|
||||||
|
#define TIFFTAG_VERSIONYEAR 404 /* !TIFF/FX version year */
|
||||||
|
#define TIFFTAG_MODENUMBER 405 /* !TIFF/FX mode number */
|
||||||
|
#define TIFFTAG_DECODE 433 /* !TIFF/FX decode */
|
||||||
|
#define TIFFTAG_IMAGEBASECOLOR 434 /* !TIFF/FX image base colour */
|
||||||
|
#define TIFFTAG_T82OPTIONS 435 /* !TIFF/FX T.82 options */
|
||||||
|
/*
|
||||||
|
* Tags 512-521 are obsoleted by Technical Note #2 which specifies a
|
||||||
|
* revised JPEG-in-TIFF scheme.
|
||||||
|
*/
|
||||||
|
#define TIFFTAG_JPEGPROC 512 /* !JPEG processing algorithm */
|
||||||
|
#define JPEGPROC_BASELINE 1 /* !baseline sequential */
|
||||||
|
#define JPEGPROC_LOSSLESS 14 /* !Huffman coded lossless */
|
||||||
|
#define TIFFTAG_JPEGIFOFFSET 513 /* !pointer to SOI marker */
|
||||||
|
#define TIFFTAG_JPEGIFBYTECOUNT 514 /* !JFIF stream length */
|
||||||
|
#define TIFFTAG_JPEGRESTARTINTERVAL 515 /* !restart interval length */
|
||||||
|
#define TIFFTAG_JPEGLOSSLESSPREDICTORS 517 /* !lossless proc predictor */
|
||||||
|
#define TIFFTAG_JPEGPOINTTRANSFORM 518 /* !lossless point transform */
|
||||||
|
#define TIFFTAG_JPEGQTABLES 519 /* !Q matrice offsets */
|
||||||
|
#define TIFFTAG_JPEGDCTABLES 520 /* !DCT table offsets */
|
||||||
|
#define TIFFTAG_JPEGACTABLES 521 /* !AC coefficient offsets */
|
||||||
|
#define TIFFTAG_YCBCRCOEFFICIENTS 529 /* !RGB -> YCbCr transform */
|
||||||
|
#define TIFFTAG_YCBCRSUBSAMPLING 530 /* !YCbCr subsampling factors */
|
||||||
|
#define TIFFTAG_YCBCRPOSITIONING 531 /* !subsample positioning */
|
||||||
|
#define YCBCRPOSITION_CENTERED 1 /* !as in PostScript Level 2 */
|
||||||
|
#define YCBCRPOSITION_COSITED 2 /* !as in CCIR 601-1 */
|
||||||
|
#define TIFFTAG_REFERENCEBLACKWHITE 532 /* !colorimetry info */
|
||||||
|
#define TIFFTAG_STRIPROWCOUNTS 559 /* !TIFF/FX strip row counts */
|
||||||
|
#define TIFFTAG_XMLPACKET 700 /* %XML packet
|
||||||
|
[Adobe XMP Specification,
|
||||||
|
January 2004 */
|
||||||
|
#define TIFFTAG_OPIIMAGEID 32781 /* %OPI ImageID
|
||||||
|
[Adobe TIFF technote] */
|
||||||
|
/* tags 32952-32956 are private tags registered to Island Graphics */
|
||||||
|
#define TIFFTAG_REFPTS 32953 /* image reference points */
|
||||||
|
#define TIFFTAG_REGIONTACKPOINT 32954 /* region-xform tack point */
|
||||||
|
#define TIFFTAG_REGIONWARPCORNERS 32955 /* warp quadrilateral */
|
||||||
|
#define TIFFTAG_REGIONAFFINE 32956 /* affine transformation mat */
|
||||||
|
/* tags 32995-32999 are private tags registered to SGI */
|
||||||
|
#define TIFFTAG_MATTEING 32995 /* $use ExtraSamples */
|
||||||
|
#define TIFFTAG_DATATYPE 32996 /* $use SampleFormat */
|
||||||
|
#define TIFFTAG_IMAGEDEPTH 32997 /* z depth of image */
|
||||||
|
#define TIFFTAG_TILEDEPTH 32998 /* z depth/data tile */
|
||||||
|
/* tags 33300-33309 are private tags registered to Pixar */
|
||||||
|
/*
|
||||||
|
* TIFFTAG_PIXAR_IMAGEFULLWIDTH and TIFFTAG_PIXAR_IMAGEFULLLENGTH
|
||||||
|
* are set when an image has been cropped out of a larger image.
|
||||||
|
* They reflect the size of the original uncropped image.
|
||||||
|
* The TIFFTAG_XPOSITION and TIFFTAG_YPOSITION can be used
|
||||||
|
* to determine the position of the smaller image in the larger one.
|
||||||
|
*/
|
||||||
|
#define TIFFTAG_PIXAR_IMAGEFULLWIDTH 33300 /* full image size in x */
|
||||||
|
#define TIFFTAG_PIXAR_IMAGEFULLLENGTH 33301 /* full image size in y */
|
||||||
|
/* Tags 33302-33306 are used to identify special image modes and data
|
||||||
|
* used by Pixar's texture formats.
|
||||||
|
*/
|
||||||
|
#define TIFFTAG_PIXAR_TEXTUREFORMAT 33302 /* texture map format */
|
||||||
|
#define TIFFTAG_PIXAR_WRAPMODES 33303 /* s & t wrap modes */
|
||||||
|
#define TIFFTAG_PIXAR_FOVCOT 33304 /* cotan(fov) for env. maps */
|
||||||
|
#define TIFFTAG_PIXAR_MATRIX_WORLDTOSCREEN 33305
|
||||||
|
#define TIFFTAG_PIXAR_MATRIX_WORLDTOCAMERA 33306
|
||||||
|
/* tag 33405 is a private tag registered to Eastman Kodak */
|
||||||
|
#define TIFFTAG_WRITERSERIALNUMBER 33405 /* device serial number */
|
||||||
|
/* tag 33432 is listed in the 6.0 spec w/ unknown ownership */
|
||||||
|
#define TIFFTAG_COPYRIGHT 33432 /* copyright string */
|
||||||
|
/* IPTC TAG from RichTIFF specifications */
|
||||||
|
#define TIFFTAG_RICHTIFFIPTC 33723
|
||||||
|
/* 34016-34029 are reserved for ANSI IT8 TIFF/IT <dkelly@apago.com) */
|
||||||
|
#define TIFFTAG_IT8SITE 34016 /* site name */
|
||||||
|
#define TIFFTAG_IT8COLORSEQUENCE 34017 /* color seq. [RGB,CMYK,etc] */
|
||||||
|
#define TIFFTAG_IT8HEADER 34018 /* DDES Header */
|
||||||
|
#define TIFFTAG_IT8RASTERPADDING 34019 /* raster scanline padding */
|
||||||
|
#define TIFFTAG_IT8BITSPERRUNLENGTH 34020 /* # of bits in short run */
|
||||||
|
#define TIFFTAG_IT8BITSPEREXTENDEDRUNLENGTH 34021/* # of bits in long run */
|
||||||
|
#define TIFFTAG_IT8COLORTABLE 34022 /* LW colortable */
|
||||||
|
#define TIFFTAG_IT8IMAGECOLORINDICATOR 34023 /* BP/BL image color switch */
|
||||||
|
#define TIFFTAG_IT8BKGCOLORINDICATOR 34024 /* BP/BL bg color switch */
|
||||||
|
#define TIFFTAG_IT8IMAGECOLORVALUE 34025 /* BP/BL image color value */
|
||||||
|
#define TIFFTAG_IT8BKGCOLORVALUE 34026 /* BP/BL bg color value */
|
||||||
|
#define TIFFTAG_IT8PIXELINTENSITYRANGE 34027 /* MP pixel intensity value */
|
||||||
|
#define TIFFTAG_IT8TRANSPARENCYINDICATOR 34028 /* HC transparency switch */
|
||||||
|
#define TIFFTAG_IT8COLORCHARACTERIZATION 34029 /* color character. table */
|
||||||
|
#define TIFFTAG_IT8HCUSAGE 34030 /* HC usage indicator */
|
||||||
|
#define TIFFTAG_IT8TRAPINDICATOR 34031 /* Trapping indicator
|
||||||
|
(untrapped=0, trapped=1) */
|
||||||
|
#define TIFFTAG_IT8CMYKEQUIVALENT 34032 /* CMYK color equivalents */
|
||||||
|
/* tags 34232-34236 are private tags registered to Texas Instruments */
|
||||||
|
#define TIFFTAG_FRAMECOUNT 34232 /* Sequence Frame Count */
|
||||||
|
/* tag 34377 is private tag registered to Adobe for PhotoShop */
|
||||||
|
#define TIFFTAG_PHOTOSHOP 34377
|
||||||
|
/* tags 34665, 34853 and 40965 are documented in EXIF specification */
|
||||||
|
#define TIFFTAG_EXIFIFD 34665 /* Pointer to EXIF private directory */
|
||||||
|
/* tag 34750 is a private tag registered to Adobe? */
|
||||||
|
#define TIFFTAG_ICCPROFILE 34675 /* ICC profile data */
|
||||||
|
#define TIFFTAG_IMAGELAYER 34732 /* !TIFF/FX image layer information */
|
||||||
|
/* tag 34750 is a private tag registered to Pixel Magic */
|
||||||
|
#define TIFFTAG_JBIGOPTIONS 34750 /* JBIG options */
|
||||||
|
#define TIFFTAG_GPSIFD 34853 /* Pointer to GPS private directory */
|
||||||
|
/* tags 34908-34914 are private tags registered to SGI */
|
||||||
|
#define TIFFTAG_FAXRECVPARAMS 34908 /* encoded Class 2 ses. parms */
|
||||||
|
#define TIFFTAG_FAXSUBADDRESS 34909 /* received SubAddr string */
|
||||||
|
#define TIFFTAG_FAXRECVTIME 34910 /* receive time (secs) */
|
||||||
|
#define TIFFTAG_FAXDCS 34911 /* encoded fax ses. params, Table 2/T.30 */
|
||||||
|
/* tags 37439-37443 are registered to SGI <gregl@sgi.com> */
|
||||||
|
#define TIFFTAG_STONITS 37439 /* Sample value to Nits */
|
||||||
|
/* tag 34929 is a private tag registered to FedEx */
|
||||||
|
#define TIFFTAG_FEDEX_EDR 34929 /* unknown use */
|
||||||
|
#define TIFFTAG_INTEROPERABILITYIFD 40965 /* Pointer to Interoperability private directory */
|
||||||
|
/* Adobe Digital Negative (DNG) format tags */
|
||||||
|
#define TIFFTAG_DNGVERSION 50706 /* &DNG version number */
|
||||||
|
#define TIFFTAG_DNGBACKWARDVERSION 50707 /* &DNG compatibility version */
|
||||||
|
#define TIFFTAG_UNIQUECAMERAMODEL 50708 /* &name for the camera model */
|
||||||
|
#define TIFFTAG_LOCALIZEDCAMERAMODEL 50709 /* &localized camera model
|
||||||
|
name */
|
||||||
|
#define TIFFTAG_CFAPLANECOLOR 50710 /* &CFAPattern->LinearRaw space
|
||||||
|
mapping */
|
||||||
|
#define TIFFTAG_CFALAYOUT 50711 /* &spatial layout of the CFA */
|
||||||
|
#define TIFFTAG_LINEARIZATIONTABLE 50712 /* &lookup table description */
|
||||||
|
#define TIFFTAG_BLACKLEVELREPEATDIM 50713 /* &repeat pattern size for
|
||||||
|
the BlackLevel tag */
|
||||||
|
#define TIFFTAG_BLACKLEVEL 50714 /* &zero light encoding level */
|
||||||
|
#define TIFFTAG_BLACKLEVELDELTAH 50715 /* &zero light encoding level
|
||||||
|
differences (columns) */
|
||||||
|
#define TIFFTAG_BLACKLEVELDELTAV 50716 /* &zero light encoding level
|
||||||
|
differences (rows) */
|
||||||
|
#define TIFFTAG_WHITELEVEL 50717 /* &fully saturated encoding
|
||||||
|
level */
|
||||||
|
#define TIFFTAG_DEFAULTSCALE 50718 /* &default scale factors */
|
||||||
|
#define TIFFTAG_DEFAULTCROPORIGIN 50719 /* &origin of the final image
|
||||||
|
area */
|
||||||
|
#define TIFFTAG_DEFAULTCROPSIZE 50720 /* &size of the final image
|
||||||
|
area */
|
||||||
|
#define TIFFTAG_COLORMATRIX1 50721 /* &XYZ->reference color space
|
||||||
|
transformation matrix 1 */
|
||||||
|
#define TIFFTAG_COLORMATRIX2 50722 /* &XYZ->reference color space
|
||||||
|
transformation matrix 2 */
|
||||||
|
#define TIFFTAG_CAMERACALIBRATION1 50723 /* &calibration matrix 1 */
|
||||||
|
#define TIFFTAG_CAMERACALIBRATION2 50724 /* &calibration matrix 2 */
|
||||||
|
#define TIFFTAG_REDUCTIONMATRIX1 50725 /* &dimensionality reduction
|
||||||
|
matrix 1 */
|
||||||
|
#define TIFFTAG_REDUCTIONMATRIX2 50726 /* &dimensionality reduction
|
||||||
|
matrix 2 */
|
||||||
|
#define TIFFTAG_ANALOGBALANCE 50727 /* &gain applied the stored raw
|
||||||
|
values*/
|
||||||
|
#define TIFFTAG_ASSHOTNEUTRAL 50728 /* &selected white balance in
|
||||||
|
linear reference space */
|
||||||
|
#define TIFFTAG_ASSHOTWHITEXY 50729 /* &selected white balance in
|
||||||
|
x-y chromaticity
|
||||||
|
coordinates */
|
||||||
|
#define TIFFTAG_BASELINEEXPOSURE 50730 /* &how much to move the zero
|
||||||
|
point */
|
||||||
|
#define TIFFTAG_BASELINENOISE 50731 /* &relative noise level */
|
||||||
|
#define TIFFTAG_BASELINESHARPNESS 50732 /* &relative amount of
|
||||||
|
sharpening */
|
||||||
|
#define TIFFTAG_BAYERGREENSPLIT 50733 /* &how closely the values of
|
||||||
|
the green pixels in the
|
||||||
|
blue/green rows track the
|
||||||
|
values of the green pixels
|
||||||
|
in the red/green rows */
|
||||||
|
#define TIFFTAG_LINEARRESPONSELIMIT 50734 /* &non-linear encoding range */
|
||||||
|
#define TIFFTAG_CAMERASERIALNUMBER 50735 /* &camera's serial number */
|
||||||
|
#define TIFFTAG_LENSINFO 50736 /* info about the lens */
|
||||||
|
#define TIFFTAG_CHROMABLURRADIUS 50737 /* &chroma blur radius */
|
||||||
|
#define TIFFTAG_ANTIALIASSTRENGTH 50738 /* &relative strength of the
|
||||||
|
camera's anti-alias filter */
|
||||||
|
#define TIFFTAG_SHADOWSCALE 50739 /* &used by Adobe Camera Raw */
|
||||||
|
#define TIFFTAG_DNGPRIVATEDATA 50740 /* &manufacturer's private data */
|
||||||
|
#define TIFFTAG_MAKERNOTESAFETY 50741 /* &whether the EXIF MakerNote
|
||||||
|
tag is safe to preserve
|
||||||
|
along with the rest of the
|
||||||
|
EXIF data */
|
||||||
|
#define TIFFTAG_CALIBRATIONILLUMINANT1 50778 /* &illuminant 1 */
|
||||||
|
#define TIFFTAG_CALIBRATIONILLUMINANT2 50779 /* &illuminant 2 */
|
||||||
|
#define TIFFTAG_BESTQUALITYSCALE 50780 /* &best quality multiplier */
|
||||||
|
#define TIFFTAG_RAWDATAUNIQUEID 50781 /* &unique identifier for
|
||||||
|
the raw image data */
|
||||||
|
#define TIFFTAG_ORIGINALRAWFILENAME 50827 /* &file name of the original
|
||||||
|
raw file */
|
||||||
|
#define TIFFTAG_ORIGINALRAWFILEDATA 50828 /* &contents of the original
|
||||||
|
raw file */
|
||||||
|
#define TIFFTAG_ACTIVEAREA 50829 /* &active (non-masked) pixels
|
||||||
|
of the sensor */
|
||||||
|
#define TIFFTAG_MASKEDAREAS 50830 /* &list of coordinates
|
||||||
|
of fully masked pixels */
|
||||||
|
#define TIFFTAG_ASSHOTICCPROFILE 50831 /* &these two tags used to */
|
||||||
|
#define TIFFTAG_ASSHOTPREPROFILEMATRIX 50832 /* map cameras's color space
|
||||||
|
into ICC profile space */
|
||||||
|
#define TIFFTAG_CURRENTICCPROFILE 50833 /* & */
|
||||||
|
#define TIFFTAG_CURRENTPREPROFILEMATRIX 50834 /* & */
|
||||||
|
/* tag 65535 is an undefined tag used by Eastman Kodak */
|
||||||
|
#define TIFFTAG_DCSHUESHIFTVALUES 65535 /* hue shift correction data */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The following are ``pseudo tags'' that can be used to control
|
||||||
|
* codec-specific functionality. These tags are not written to file.
|
||||||
|
* Note that these values start at 0xffff+1 so that they'll never
|
||||||
|
* collide with Aldus-assigned tags.
|
||||||
|
*
|
||||||
|
* If you want your private pseudo tags ``registered'' (i.e. added to
|
||||||
|
* this file), please post a bug report via the tracking system at
|
||||||
|
* http://www.remotesensing.org/libtiff/bugs.html with the appropriate
|
||||||
|
* C definitions to add.
|
||||||
|
*/
|
||||||
|
#define TIFFTAG_FAXMODE 65536 /* Group 3/4 format control */
|
||||||
|
#define FAXMODE_CLASSIC 0x0000 /* default, include RTC */
|
||||||
|
#define FAXMODE_NORTC 0x0001 /* no RTC at end of data */
|
||||||
|
#define FAXMODE_NOEOL 0x0002 /* no EOL code at end of row */
|
||||||
|
#define FAXMODE_BYTEALIGN 0x0004 /* byte align row */
|
||||||
|
#define FAXMODE_WORDALIGN 0x0008 /* word align row */
|
||||||
|
#define FAXMODE_CLASSF FAXMODE_NORTC /* TIFF Class F */
|
||||||
|
#define TIFFTAG_JPEGQUALITY 65537 /* Compression quality level */
|
||||||
|
/* Note: quality level is on the IJG 0-100 scale. Default value is 75 */
|
||||||
|
#define TIFFTAG_JPEGCOLORMODE 65538 /* Auto RGB<=>YCbCr convert? */
|
||||||
|
#define JPEGCOLORMODE_RAW 0x0000 /* no conversion (default) */
|
||||||
|
#define JPEGCOLORMODE_RGB 0x0001 /* do auto conversion */
|
||||||
|
#define TIFFTAG_JPEGTABLESMODE 65539 /* What to put in JPEGTables */
|
||||||
|
#define JPEGTABLESMODE_QUANT 0x0001 /* include quantization tbls */
|
||||||
|
#define JPEGTABLESMODE_HUFF 0x0002 /* include Huffman tbls */
|
||||||
|
/* Note: default is JPEGTABLESMODE_QUANT | JPEGTABLESMODE_HUFF */
|
||||||
|
#define TIFFTAG_FAXFILLFUNC 65540 /* G3/G4 fill function */
|
||||||
|
#define TIFFTAG_PIXARLOGDATAFMT 65549 /* PixarLogCodec I/O data sz */
|
||||||
|
#define PIXARLOGDATAFMT_8BIT 0 /* regular u_char samples */
|
||||||
|
#define PIXARLOGDATAFMT_8BITABGR 1 /* ABGR-order u_chars */
|
||||||
|
#define PIXARLOGDATAFMT_11BITLOG 2 /* 11-bit log-encoded (raw) */
|
||||||
|
#define PIXARLOGDATAFMT_12BITPICIO 3 /* as per PICIO (1.0==2048) */
|
||||||
|
#define PIXARLOGDATAFMT_16BIT 4 /* signed short samples */
|
||||||
|
#define PIXARLOGDATAFMT_FLOAT 5 /* IEEE float samples */
|
||||||
|
/* 65550-65556 are allocated to Oceana Matrix <dev@oceana.com> */
|
||||||
|
#define TIFFTAG_DCSIMAGERTYPE 65550 /* imager model & filter */
|
||||||
|
#define DCSIMAGERMODEL_M3 0 /* M3 chip (1280 x 1024) */
|
||||||
|
#define DCSIMAGERMODEL_M5 1 /* M5 chip (1536 x 1024) */
|
||||||
|
#define DCSIMAGERMODEL_M6 2 /* M6 chip (3072 x 2048) */
|
||||||
|
#define DCSIMAGERFILTER_IR 0 /* infrared filter */
|
||||||
|
#define DCSIMAGERFILTER_MONO 1 /* monochrome filter */
|
||||||
|
#define DCSIMAGERFILTER_CFA 2 /* color filter array */
|
||||||
|
#define DCSIMAGERFILTER_OTHER 3 /* other filter */
|
||||||
|
#define TIFFTAG_DCSINTERPMODE 65551 /* interpolation mode */
|
||||||
|
#define DCSINTERPMODE_NORMAL 0x0 /* whole image, default */
|
||||||
|
#define DCSINTERPMODE_PREVIEW 0x1 /* preview of image (384x256) */
|
||||||
|
#define TIFFTAG_DCSBALANCEARRAY 65552 /* color balance values */
|
||||||
|
#define TIFFTAG_DCSCORRECTMATRIX 65553 /* color correction values */
|
||||||
|
#define TIFFTAG_DCSGAMMA 65554 /* gamma value */
|
||||||
|
#define TIFFTAG_DCSTOESHOULDERPTS 65555 /* toe & shoulder points */
|
||||||
|
#define TIFFTAG_DCSCALIBRATIONFD 65556 /* calibration file desc */
|
||||||
|
/* Note: quality level is on the ZLIB 1-9 scale. Default value is -1 */
|
||||||
|
#define TIFFTAG_ZIPQUALITY 65557 /* compression quality level */
|
||||||
|
#define TIFFTAG_PIXARLOGQUALITY 65558 /* PixarLog uses same scale */
|
||||||
|
/* 65559 is allocated to Oceana Matrix <dev@oceana.com> */
|
||||||
|
#define TIFFTAG_DCSCLIPRECTANGLE 65559 /* area of image to acquire */
|
||||||
|
#define TIFFTAG_SGILOGDATAFMT 65560 /* SGILog user data format */
|
||||||
|
#define SGILOGDATAFMT_FLOAT 0 /* IEEE float samples */
|
||||||
|
#define SGILOGDATAFMT_16BIT 1 /* 16-bit samples */
|
||||||
|
#define SGILOGDATAFMT_RAW 2 /* uninterpreted data */
|
||||||
|
#define SGILOGDATAFMT_8BIT 3 /* 8-bit RGB monitor values */
|
||||||
|
#define TIFFTAG_SGILOGENCODE 65561 /* SGILog data encoding control*/
|
||||||
|
#define SGILOGENCODE_NODITHER 0 /* do not dither encoded values*/
|
||||||
|
#define SGILOGENCODE_RANDITHER 1 /* randomly dither encd values */
|
||||||
|
#define TIFFTAG_LZMAPRESET 65562 /* LZMA2 preset (compression level) */
|
||||||
|
#define TIFFTAG_PERSAMPLE 65563 /* interface for per sample tags */
|
||||||
|
#define PERSAMPLE_MERGED 0 /* present as a single value */
|
||||||
|
#define PERSAMPLE_MULTI 1 /* present as multiple values */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* EXIF tags
|
||||||
|
*/
|
||||||
|
#define EXIFTAG_EXPOSURETIME 33434 /* Exposure time */
|
||||||
|
#define EXIFTAG_FNUMBER 33437 /* F number */
|
||||||
|
#define EXIFTAG_EXPOSUREPROGRAM 34850 /* Exposure program */
|
||||||
|
#define EXIFTAG_SPECTRALSENSITIVITY 34852 /* Spectral sensitivity */
|
||||||
|
#define EXIFTAG_ISOSPEEDRATINGS 34855 /* ISO speed rating */
|
||||||
|
#define EXIFTAG_OECF 34856 /* Optoelectric conversion
|
||||||
|
factor */
|
||||||
|
#define EXIFTAG_EXIFVERSION 36864 /* Exif version */
|
||||||
|
#define EXIFTAG_DATETIMEORIGINAL 36867 /* Date and time of original
|
||||||
|
data generation */
|
||||||
|
#define EXIFTAG_DATETIMEDIGITIZED 36868 /* Date and time of digital
|
||||||
|
data generation */
|
||||||
|
#define EXIFTAG_COMPONENTSCONFIGURATION 37121 /* Meaning of each component */
|
||||||
|
#define EXIFTAG_COMPRESSEDBITSPERPIXEL 37122 /* Image compression mode */
|
||||||
|
#define EXIFTAG_SHUTTERSPEEDVALUE 37377 /* Shutter speed */
|
||||||
|
#define EXIFTAG_APERTUREVALUE 37378 /* Aperture */
|
||||||
|
#define EXIFTAG_BRIGHTNESSVALUE 37379 /* Brightness */
|
||||||
|
#define EXIFTAG_EXPOSUREBIASVALUE 37380 /* Exposure bias */
|
||||||
|
#define EXIFTAG_MAXAPERTUREVALUE 37381 /* Maximum lens aperture */
|
||||||
|
#define EXIFTAG_SUBJECTDISTANCE 37382 /* Subject distance */
|
||||||
|
#define EXIFTAG_METERINGMODE 37383 /* Metering mode */
|
||||||
|
#define EXIFTAG_LIGHTSOURCE 37384 /* Light source */
|
||||||
|
#define EXIFTAG_FLASH 37385 /* Flash */
|
||||||
|
#define EXIFTAG_FOCALLENGTH 37386 /* Lens focal length */
|
||||||
|
#define EXIFTAG_SUBJECTAREA 37396 /* Subject area */
|
||||||
|
#define EXIFTAG_MAKERNOTE 37500 /* Manufacturer notes */
|
||||||
|
#define EXIFTAG_USERCOMMENT 37510 /* User comments */
|
||||||
|
#define EXIFTAG_SUBSECTIME 37520 /* DateTime subseconds */
|
||||||
|
#define EXIFTAG_SUBSECTIMEORIGINAL 37521 /* DateTimeOriginal subseconds */
|
||||||
|
#define EXIFTAG_SUBSECTIMEDIGITIZED 37522 /* DateTimeDigitized subseconds */
|
||||||
|
#define EXIFTAG_FLASHPIXVERSION 40960 /* Supported Flashpix version */
|
||||||
|
#define EXIFTAG_COLORSPACE 40961 /* Color space information */
|
||||||
|
#define EXIFTAG_PIXELXDIMENSION 40962 /* Valid image width */
|
||||||
|
#define EXIFTAG_PIXELYDIMENSION 40963 /* Valid image height */
|
||||||
|
#define EXIFTAG_RELATEDSOUNDFILE 40964 /* Related audio file */
|
||||||
|
#define EXIFTAG_FLASHENERGY 41483 /* Flash energy */
|
||||||
|
#define EXIFTAG_SPATIALFREQUENCYRESPONSE 41484 /* Spatial frequency response */
|
||||||
|
#define EXIFTAG_FOCALPLANEXRESOLUTION 41486 /* Focal plane X resolution */
|
||||||
|
#define EXIFTAG_FOCALPLANEYRESOLUTION 41487 /* Focal plane Y resolution */
|
||||||
|
#define EXIFTAG_FOCALPLANERESOLUTIONUNIT 41488 /* Focal plane resolution unit */
|
||||||
|
#define EXIFTAG_SUBJECTLOCATION 41492 /* Subject location */
|
||||||
|
#define EXIFTAG_EXPOSUREINDEX 41493 /* Exposure index */
|
||||||
|
#define EXIFTAG_SENSINGMETHOD 41495 /* Sensing method */
|
||||||
|
#define EXIFTAG_FILESOURCE 41728 /* File source */
|
||||||
|
#define EXIFTAG_SCENETYPE 41729 /* Scene type */
|
||||||
|
#define EXIFTAG_CFAPATTERN 41730 /* CFA pattern */
|
||||||
|
#define EXIFTAG_CUSTOMRENDERED 41985 /* Custom image processing */
|
||||||
|
#define EXIFTAG_EXPOSUREMODE 41986 /* Exposure mode */
|
||||||
|
#define EXIFTAG_WHITEBALANCE 41987 /* White balance */
|
||||||
|
#define EXIFTAG_DIGITALZOOMRATIO 41988 /* Digital zoom ratio */
|
||||||
|
#define EXIFTAG_FOCALLENGTHIN35MMFILM 41989 /* Focal length in 35 mm film */
|
||||||
|
#define EXIFTAG_SCENECAPTURETYPE 41990 /* Scene capture type */
|
||||||
|
#define EXIFTAG_GAINCONTROL 41991 /* Gain control */
|
||||||
|
#define EXIFTAG_CONTRAST 41992 /* Contrast */
|
||||||
|
#define EXIFTAG_SATURATION 41993 /* Saturation */
|
||||||
|
#define EXIFTAG_SHARPNESS 41994 /* Sharpness */
|
||||||
|
#define EXIFTAG_DEVICESETTINGDESCRIPTION 41995 /* Device settings description */
|
||||||
|
#define EXIFTAG_SUBJECTDISTANCERANGE 41996 /* Subject distance range */
|
||||||
|
#define EXIFTAG_GAINCONTROL 41991 /* Gain control */
|
||||||
|
#define EXIFTAG_GAINCONTROL 41991 /* Gain control */
|
||||||
|
#define EXIFTAG_IMAGEUNIQUEID 42016 /* Unique image ID */
|
||||||
|
|
||||||
|
#endif /* _TIFF_ */
|
||||||
|
|
||||||
|
/* vim: set ts=8 sts=8 sw=8 noet: */
|
||||||
|
/*
|
||||||
|
* Local Variables:
|
||||||
|
* mode: c
|
||||||
|
* c-basic-offset: 8
|
||||||
|
* fill-column: 78
|
||||||
|
* End:
|
||||||
|
*/
|
|
@ -0,0 +1,128 @@
|
||||||
|
/* libtiff/tiffconf.h. Generated from tiffconf.h.in by configure. */
|
||||||
|
/*
|
||||||
|
Configuration defines for installed libtiff.
|
||||||
|
This file maintained for backward compatibility. Do not use definitions
|
||||||
|
from this file in your programs.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _TIFFCONF_
|
||||||
|
#define _TIFFCONF_
|
||||||
|
|
||||||
|
/* Signed 16-bit type */
|
||||||
|
#define TIFF_INT16_T signed short
|
||||||
|
|
||||||
|
/* Signed 32-bit type */
|
||||||
|
#define TIFF_INT32_T signed int
|
||||||
|
|
||||||
|
/* Signed 64-bit type */
|
||||||
|
#define TIFF_INT64_T signed long long
|
||||||
|
|
||||||
|
/* Signed 8-bit type */
|
||||||
|
#define TIFF_INT8_T signed char
|
||||||
|
|
||||||
|
/* Unsigned 16-bit type */
|
||||||
|
#define TIFF_UINT16_T unsigned short
|
||||||
|
|
||||||
|
/* Unsigned 32-bit type */
|
||||||
|
#define TIFF_UINT32_T unsigned int
|
||||||
|
|
||||||
|
/* Unsigned 64-bit type */
|
||||||
|
#define TIFF_UINT64_T unsigned long long
|
||||||
|
|
||||||
|
/* Unsigned 8-bit type */
|
||||||
|
#define TIFF_UINT8_T unsigned char
|
||||||
|
|
||||||
|
/* Signed size type */
|
||||||
|
#define TIFF_SSIZE_T signed long
|
||||||
|
|
||||||
|
/* Pointer difference type */
|
||||||
|
#define TIFF_PTRDIFF_T ptrdiff_t
|
||||||
|
|
||||||
|
/* Define to 1 if the system has the type `int16'. */
|
||||||
|
/* #undef HAVE_INT16 */
|
||||||
|
|
||||||
|
/* Define to 1 if the system has the type `int32'. */
|
||||||
|
/* #undef HAVE_INT32 */
|
||||||
|
|
||||||
|
/* Define to 1 if the system has the type `int8'. */
|
||||||
|
/* #undef HAVE_INT8 */
|
||||||
|
|
||||||
|
/* Compatibility stuff. */
|
||||||
|
|
||||||
|
/* Define as 0 or 1 according to the floating point format suported by the
|
||||||
|
machine */
|
||||||
|
#define HAVE_IEEEFP 1
|
||||||
|
|
||||||
|
/* Set the native cpu bit order (FILLORDER_LSB2MSB or FILLORDER_MSB2LSB) */
|
||||||
|
#define HOST_FILLORDER FILLORDER_LSB2MSB
|
||||||
|
|
||||||
|
/* Native cpu byte order: 1 if big-endian (Motorola) or 0 if little-endian
|
||||||
|
(Intel) */
|
||||||
|
#define HOST_BIGENDIAN 0
|
||||||
|
|
||||||
|
/* Support CCITT Group 3 & 4 algorithms */
|
||||||
|
#define CCITT_SUPPORT 1
|
||||||
|
|
||||||
|
/* Support JPEG compression (requires IJG JPEG library) */
|
||||||
|
/* #undef JPEG_SUPPORT */
|
||||||
|
|
||||||
|
/* Support JBIG compression (requires JBIG-KIT library) */
|
||||||
|
/* #undef JBIG_SUPPORT */
|
||||||
|
|
||||||
|
/* Support LogLuv high dynamic range encoding */
|
||||||
|
#define LOGLUV_SUPPORT 1
|
||||||
|
|
||||||
|
/* Support LZW algorithm */
|
||||||
|
#define LZW_SUPPORT 1
|
||||||
|
|
||||||
|
/* Support NeXT 2-bit RLE algorithm */
|
||||||
|
#define NEXT_SUPPORT 1
|
||||||
|
|
||||||
|
/* Support Old JPEG compresson (read contrib/ojpeg/README first! Compilation
|
||||||
|
fails with unpatched IJG JPEG library) */
|
||||||
|
/* #undef OJPEG_SUPPORT */
|
||||||
|
|
||||||
|
/* Support Macintosh PackBits algorithm */
|
||||||
|
#define PACKBITS_SUPPORT 1
|
||||||
|
|
||||||
|
/* Support Pixar log-format algorithm (requires Zlib) */
|
||||||
|
#define PIXARLOG_SUPPORT 1
|
||||||
|
|
||||||
|
/* Support ThunderScan 4-bit RLE algorithm */
|
||||||
|
#define THUNDER_SUPPORT 1
|
||||||
|
|
||||||
|
/* Support Deflate compression */
|
||||||
|
#define ZIP_SUPPORT 1
|
||||||
|
|
||||||
|
/* Support strip chopping (whether or not to convert single-strip uncompressed
|
||||||
|
images to mutiple strips of ~8Kb to reduce memory usage) */
|
||||||
|
#define STRIPCHOP_DEFAULT TIFF_STRIPCHOP
|
||||||
|
|
||||||
|
/* Enable SubIFD tag (330) support */
|
||||||
|
#define SUBIFD_SUPPORT 1
|
||||||
|
|
||||||
|
/* Treat extra sample as alpha (default enabled). The RGBA interface will
|
||||||
|
treat a fourth sample with no EXTRASAMPLE_ value as being ASSOCALPHA. Many
|
||||||
|
packages produce RGBA files but don't mark the alpha properly. */
|
||||||
|
#define DEFAULT_EXTRASAMPLE_AS_ALPHA 1
|
||||||
|
|
||||||
|
/* Pick up YCbCr subsampling info from the JPEG data stream to support files
|
||||||
|
lacking the tag (default enabled). */
|
||||||
|
#define CHECK_JPEG_YCBCR_SUBSAMPLING 1
|
||||||
|
|
||||||
|
/* Support MS MDI magic number files as TIFF */
|
||||||
|
#define MDI_SUPPORT 1
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Feature support definitions.
|
||||||
|
* XXX: These macros are obsoleted. Don't use them in your apps!
|
||||||
|
* Macros stays here for backward compatibility and should be always defined.
|
||||||
|
*/
|
||||||
|
#define COLORIMETRY_SUPPORT
|
||||||
|
#define YCBCR_SUPPORT
|
||||||
|
#define CMYK_SUPPORT
|
||||||
|
#define ICC_SUPPORT
|
||||||
|
#define PHOTOSHOP_SUPPORT
|
||||||
|
#define IPTC_SUPPORT
|
||||||
|
|
||||||
|
#endif /* _TIFFCONF_ */
|
|
@ -0,0 +1,557 @@
|
||||||
|
/* $Id: tiffio.h,v 1.91 2012-07-29 15:45:29 tgl Exp $ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1988-1997 Sam Leffler
|
||||||
|
* Copyright (c) 1991-1997 Silicon Graphics, Inc.
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, distribute, and sell this software and
|
||||||
|
* its documentation for any purpose is hereby granted without fee, provided
|
||||||
|
* that (i) the above copyright notices and this permission notice appear in
|
||||||
|
* all copies of the software and related documentation, and (ii) the names of
|
||||||
|
* Sam Leffler and Silicon Graphics may not be used in any advertising or
|
||||||
|
* publicity relating to the software without the specific, prior written
|
||||||
|
* permission of Sam Leffler and Silicon Graphics.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||||
|
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||||
|
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||||
|
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||||
|
* OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _TIFFIO_
|
||||||
|
#define _TIFFIO_
|
||||||
|
|
||||||
|
/*
|
||||||
|
* TIFF I/O Library Definitions.
|
||||||
|
*/
|
||||||
|
#include "tiff.h"
|
||||||
|
#include "tiffvers.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* TIFF is defined as an incomplete type to hide the
|
||||||
|
* library's internal data structures from clients.
|
||||||
|
*/
|
||||||
|
typedef struct tiff TIFF;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The following typedefs define the intrinsic size of
|
||||||
|
* data types used in the *exported* interfaces. These
|
||||||
|
* definitions depend on the proper definition of types
|
||||||
|
* in tiff.h. Note also that the varargs interface used
|
||||||
|
* to pass tag types and values uses the types defined in
|
||||||
|
* tiff.h directly.
|
||||||
|
*
|
||||||
|
* NB: ttag_t is unsigned int and not unsigned short because
|
||||||
|
* ANSI C requires that the type before the ellipsis be a
|
||||||
|
* promoted type (i.e. one of int, unsigned int, pointer,
|
||||||
|
* or double) and because we defined pseudo-tags that are
|
||||||
|
* outside the range of legal Aldus-assigned tags.
|
||||||
|
* NB: tsize_t is int32 and not uint32 because some functions
|
||||||
|
* return -1.
|
||||||
|
* NB: toff_t is not off_t for many reasons; TIFFs max out at
|
||||||
|
* 32-bit file offsets, and BigTIFF maxes out at 64-bit
|
||||||
|
* offsets being the most important, and to ensure use of
|
||||||
|
* a consistently unsigned type across architectures.
|
||||||
|
* Prior to libtiff 4.0, this was an unsigned 32 bit type.
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* this is the machine addressing size type, only it's signed, so make it
|
||||||
|
* int32 on 32bit machines, int64 on 64bit machines
|
||||||
|
*/
|
||||||
|
typedef TIFF_SSIZE_T tmsize_t;
|
||||||
|
typedef uint64 toff_t; /* file offset */
|
||||||
|
/* the following are deprecated and should be replaced by their defining
|
||||||
|
counterparts */
|
||||||
|
typedef uint32 ttag_t; /* directory tag */
|
||||||
|
typedef uint16 tdir_t; /* directory index */
|
||||||
|
typedef uint16 tsample_t; /* sample number */
|
||||||
|
typedef uint32 tstrile_t; /* strip or tile number */
|
||||||
|
typedef tstrile_t tstrip_t; /* strip number */
|
||||||
|
typedef tstrile_t ttile_t; /* tile number */
|
||||||
|
typedef tmsize_t tsize_t; /* i/o size in bytes */
|
||||||
|
typedef void* tdata_t; /* image data ref */
|
||||||
|
|
||||||
|
#if !defined(__WIN32__) && (defined(_WIN32) || defined(WIN32))
|
||||||
|
#define __WIN32__
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* On windows you should define USE_WIN32_FILEIO if you are using tif_win32.c
|
||||||
|
* or AVOID_WIN32_FILEIO if you are using something else (like tif_unix.c).
|
||||||
|
*
|
||||||
|
* By default tif_unix.c is assumed.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(_WINDOWS) || defined(__WIN32__) || defined(_Windows)
|
||||||
|
# if !defined(__CYGWIN) && !defined(AVOID_WIN32_FILEIO) && !defined(USE_WIN32_FILEIO)
|
||||||
|
# define AVOID_WIN32_FILEIO
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(USE_WIN32_FILEIO)
|
||||||
|
# define VC_EXTRALEAN
|
||||||
|
# include <windows.h>
|
||||||
|
# ifdef __WIN32__
|
||||||
|
DECLARE_HANDLE(thandle_t); /* Win32 file handle */
|
||||||
|
# else
|
||||||
|
typedef HFILE thandle_t; /* client data handle */
|
||||||
|
# endif /* __WIN32__ */
|
||||||
|
#else
|
||||||
|
typedef void* thandle_t; /* client data handle */
|
||||||
|
#endif /* USE_WIN32_FILEIO */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Flags to pass to TIFFPrintDirectory to control
|
||||||
|
* printing of data structures that are potentially
|
||||||
|
* very large. Bit-or these flags to enable printing
|
||||||
|
* multiple items.
|
||||||
|
*/
|
||||||
|
#define TIFFPRINT_NONE 0x0 /* no extra info */
|
||||||
|
#define TIFFPRINT_STRIPS 0x1 /* strips/tiles info */
|
||||||
|
#define TIFFPRINT_CURVES 0x2 /* color/gray response curves */
|
||||||
|
#define TIFFPRINT_COLORMAP 0x4 /* colormap */
|
||||||
|
#define TIFFPRINT_JPEGQTABLES 0x100 /* JPEG Q matrices */
|
||||||
|
#define TIFFPRINT_JPEGACTABLES 0x200 /* JPEG AC tables */
|
||||||
|
#define TIFFPRINT_JPEGDCTABLES 0x200 /* JPEG DC tables */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Colour conversion stuff
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* reference white */
|
||||||
|
#define D65_X0 (95.0470F)
|
||||||
|
#define D65_Y0 (100.0F)
|
||||||
|
#define D65_Z0 (108.8827F)
|
||||||
|
|
||||||
|
#define D50_X0 (96.4250F)
|
||||||
|
#define D50_Y0 (100.0F)
|
||||||
|
#define D50_Z0 (82.4680F)
|
||||||
|
|
||||||
|
/* Structure for holding information about a display device. */
|
||||||
|
|
||||||
|
typedef unsigned char TIFFRGBValue; /* 8-bit samples */
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
float d_mat[3][3]; /* XYZ -> luminance matrix */
|
||||||
|
float d_YCR; /* Light o/p for reference white */
|
||||||
|
float d_YCG;
|
||||||
|
float d_YCB;
|
||||||
|
uint32 d_Vrwr; /* Pixel values for ref. white */
|
||||||
|
uint32 d_Vrwg;
|
||||||
|
uint32 d_Vrwb;
|
||||||
|
float d_Y0R; /* Residual light for black pixel */
|
||||||
|
float d_Y0G;
|
||||||
|
float d_Y0B;
|
||||||
|
float d_gammaR; /* Gamma values for the three guns */
|
||||||
|
float d_gammaG;
|
||||||
|
float d_gammaB;
|
||||||
|
} TIFFDisplay;
|
||||||
|
|
||||||
|
typedef struct { /* YCbCr->RGB support */
|
||||||
|
TIFFRGBValue* clamptab; /* range clamping table */
|
||||||
|
int* Cr_r_tab;
|
||||||
|
int* Cb_b_tab;
|
||||||
|
int32* Cr_g_tab;
|
||||||
|
int32* Cb_g_tab;
|
||||||
|
int32* Y_tab;
|
||||||
|
} TIFFYCbCrToRGB;
|
||||||
|
|
||||||
|
typedef struct { /* CIE Lab 1976->RGB support */
|
||||||
|
int range; /* Size of conversion table */
|
||||||
|
#define CIELABTORGB_TABLE_RANGE 1500
|
||||||
|
float rstep, gstep, bstep;
|
||||||
|
float X0, Y0, Z0; /* Reference white point */
|
||||||
|
TIFFDisplay display;
|
||||||
|
float Yr2r[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yr to r */
|
||||||
|
float Yg2g[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yg to g */
|
||||||
|
float Yb2b[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yb to b */
|
||||||
|
} TIFFCIELabToRGB;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* RGBA-style image support.
|
||||||
|
*/
|
||||||
|
typedef struct _TIFFRGBAImage TIFFRGBAImage;
|
||||||
|
/*
|
||||||
|
* The image reading and conversion routines invoke
|
||||||
|
* ``put routines'' to copy/image/whatever tiles of
|
||||||
|
* raw image data. A default set of routines are
|
||||||
|
* provided to convert/copy raw image data to 8-bit
|
||||||
|
* packed ABGR format rasters. Applications can supply
|
||||||
|
* alternate routines that unpack the data into a
|
||||||
|
* different format or, for example, unpack the data
|
||||||
|
* and draw the unpacked raster on the display.
|
||||||
|
*/
|
||||||
|
typedef void (*tileContigRoutine)
|
||||||
|
(TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32,
|
||||||
|
unsigned char*);
|
||||||
|
typedef void (*tileSeparateRoutine)
|
||||||
|
(TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32,
|
||||||
|
unsigned char*, unsigned char*, unsigned char*, unsigned char*);
|
||||||
|
/*
|
||||||
|
* RGBA-reader state.
|
||||||
|
*/
|
||||||
|
struct _TIFFRGBAImage {
|
||||||
|
TIFF* tif; /* image handle */
|
||||||
|
int stoponerr; /* stop on read error */
|
||||||
|
int isContig; /* data is packed/separate */
|
||||||
|
int alpha; /* type of alpha data present */
|
||||||
|
uint32 width; /* image width */
|
||||||
|
uint32 height; /* image height */
|
||||||
|
uint16 bitspersample; /* image bits/sample */
|
||||||
|
uint16 samplesperpixel; /* image samples/pixel */
|
||||||
|
uint16 orientation; /* image orientation */
|
||||||
|
uint16 req_orientation; /* requested orientation */
|
||||||
|
uint16 photometric; /* image photometric interp */
|
||||||
|
uint16* redcmap; /* colormap pallete */
|
||||||
|
uint16* greencmap;
|
||||||
|
uint16* bluecmap;
|
||||||
|
/* get image data routine */
|
||||||
|
int (*get)(TIFFRGBAImage*, uint32*, uint32, uint32);
|
||||||
|
/* put decoded strip/tile */
|
||||||
|
union {
|
||||||
|
void (*any)(TIFFRGBAImage*);
|
||||||
|
tileContigRoutine contig;
|
||||||
|
tileSeparateRoutine separate;
|
||||||
|
} put;
|
||||||
|
TIFFRGBValue* Map; /* sample mapping array */
|
||||||
|
uint32** BWmap; /* black&white map */
|
||||||
|
uint32** PALmap; /* palette image map */
|
||||||
|
TIFFYCbCrToRGB* ycbcr; /* YCbCr conversion state */
|
||||||
|
TIFFCIELabToRGB* cielab; /* CIE L*a*b conversion state */
|
||||||
|
|
||||||
|
uint8* UaToAa; /* Unassociated alpha to associated alpha convertion LUT */
|
||||||
|
uint8* Bitdepth16To8; /* LUT for conversion from 16bit to 8bit values */
|
||||||
|
|
||||||
|
int row_offset;
|
||||||
|
int col_offset;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Macros for extracting components from the
|
||||||
|
* packed ABGR form returned by TIFFReadRGBAImage.
|
||||||
|
*/
|
||||||
|
#define TIFFGetR(abgr) ((abgr) & 0xff)
|
||||||
|
#define TIFFGetG(abgr) (((abgr) >> 8) & 0xff)
|
||||||
|
#define TIFFGetB(abgr) (((abgr) >> 16) & 0xff)
|
||||||
|
#define TIFFGetA(abgr) (((abgr) >> 24) & 0xff)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* A CODEC is a software package that implements decoding,
|
||||||
|
* encoding, or decoding+encoding of a compression algorithm.
|
||||||
|
* The library provides a collection of builtin codecs.
|
||||||
|
* More codecs may be registered through calls to the library
|
||||||
|
* and/or the builtin implementations may be overridden.
|
||||||
|
*/
|
||||||
|
typedef int (*TIFFInitMethod)(TIFF*, int);
|
||||||
|
typedef struct {
|
||||||
|
char* name;
|
||||||
|
uint16 scheme;
|
||||||
|
TIFFInitMethod init;
|
||||||
|
} TIFFCodec;
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
/* share internal LogLuv conversion routines? */
|
||||||
|
#ifndef LOGLUV_PUBLIC
|
||||||
|
#define LOGLUV_PUBLIC 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(__GNUC__) && !defined(__attribute__)
|
||||||
|
# define __attribute__(x) /*nothing*/
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(c_plusplus) || defined(__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
typedef void (*TIFFErrorHandler)(const char*, const char*, va_list);
|
||||||
|
typedef void (*TIFFErrorHandlerExt)(thandle_t, const char*, const char*, va_list);
|
||||||
|
typedef tmsize_t (*TIFFReadWriteProc)(thandle_t, void*, tmsize_t);
|
||||||
|
typedef toff_t (*TIFFSeekProc)(thandle_t, toff_t, int);
|
||||||
|
typedef int (*TIFFCloseProc)(thandle_t);
|
||||||
|
typedef toff_t (*TIFFSizeProc)(thandle_t);
|
||||||
|
typedef int (*TIFFMapFileProc)(thandle_t, void** base, toff_t* size);
|
||||||
|
typedef void (*TIFFUnmapFileProc)(thandle_t, void* base, toff_t size);
|
||||||
|
typedef void (*TIFFExtendProc)(TIFF*);
|
||||||
|
|
||||||
|
extern const char* TIFFGetVersion(void);
|
||||||
|
|
||||||
|
extern const TIFFCodec* TIFFFindCODEC(uint16);
|
||||||
|
extern TIFFCodec* TIFFRegisterCODEC(uint16, const char*, TIFFInitMethod);
|
||||||
|
extern void TIFFUnRegisterCODEC(TIFFCodec*);
|
||||||
|
extern int TIFFIsCODECConfigured(uint16);
|
||||||
|
extern TIFFCodec* TIFFGetConfiguredCODECs(void);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Auxiliary functions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern void* _TIFFmalloc(tmsize_t s);
|
||||||
|
extern void* _TIFFrealloc(void* p, tmsize_t s);
|
||||||
|
extern void _TIFFmemset(void* p, int v, tmsize_t c);
|
||||||
|
extern void _TIFFmemcpy(void* d, const void* s, tmsize_t c);
|
||||||
|
extern int _TIFFmemcmp(const void* p1, const void* p2, tmsize_t c);
|
||||||
|
extern void _TIFFfree(void* p);
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Stuff, related to tag handling and creating custom tags.
|
||||||
|
*/
|
||||||
|
extern int TIFFGetTagListCount( TIFF * );
|
||||||
|
extern uint32 TIFFGetTagListEntry( TIFF *, int tag_index );
|
||||||
|
|
||||||
|
#define TIFF_ANY TIFF_NOTYPE /* for field descriptor searching */
|
||||||
|
#define TIFF_VARIABLE -1 /* marker for variable length tags */
|
||||||
|
#define TIFF_SPP -2 /* marker for SamplesPerPixel tags */
|
||||||
|
#define TIFF_VARIABLE2 -3 /* marker for uint32 var-length tags */
|
||||||
|
|
||||||
|
#define FIELD_CUSTOM 65
|
||||||
|
|
||||||
|
typedef struct _TIFFField TIFFField;
|
||||||
|
typedef struct _TIFFFieldArray TIFFFieldArray;
|
||||||
|
|
||||||
|
extern const TIFFField* TIFFFindField(TIFF *, uint32, TIFFDataType);
|
||||||
|
extern const TIFFField* TIFFFieldWithTag(TIFF*, uint32);
|
||||||
|
extern const TIFFField* TIFFFieldWithName(TIFF*, const char *);
|
||||||
|
|
||||||
|
extern uint32 TIFFFieldTag(const TIFFField*);
|
||||||
|
extern const char* TIFFFieldName(const TIFFField*);
|
||||||
|
extern TIFFDataType TIFFFieldDataType(const TIFFField*);
|
||||||
|
extern int TIFFFieldPassCount(const TIFFField*);
|
||||||
|
extern int TIFFFieldReadCount(const TIFFField*);
|
||||||
|
extern int TIFFFieldWriteCount(const TIFFField*);
|
||||||
|
|
||||||
|
typedef int (*TIFFVSetMethod)(TIFF*, uint32, va_list);
|
||||||
|
typedef int (*TIFFVGetMethod)(TIFF*, uint32, va_list);
|
||||||
|
typedef void (*TIFFPrintMethod)(TIFF*, FILE*, long);
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
TIFFVSetMethod vsetfield; /* tag set routine */
|
||||||
|
TIFFVGetMethod vgetfield; /* tag get routine */
|
||||||
|
TIFFPrintMethod printdir; /* directory print routine */
|
||||||
|
} TIFFTagMethods;
|
||||||
|
|
||||||
|
extern TIFFTagMethods *TIFFAccessTagMethods(TIFF *);
|
||||||
|
extern void *TIFFGetClientInfo(TIFF *, const char *);
|
||||||
|
extern void TIFFSetClientInfo(TIFF *, void *, const char *);
|
||||||
|
|
||||||
|
extern void TIFFCleanup(TIFF* tif);
|
||||||
|
extern void TIFFClose(TIFF* tif);
|
||||||
|
extern int TIFFFlush(TIFF* tif);
|
||||||
|
extern int TIFFFlushData(TIFF* tif);
|
||||||
|
extern int TIFFGetField(TIFF* tif, uint32 tag, ...);
|
||||||
|
extern int TIFFVGetField(TIFF* tif, uint32 tag, va_list ap);
|
||||||
|
extern int TIFFGetFieldDefaulted(TIFF* tif, uint32 tag, ...);
|
||||||
|
extern int TIFFVGetFieldDefaulted(TIFF* tif, uint32 tag, va_list ap);
|
||||||
|
extern int TIFFReadDirectory(TIFF* tif);
|
||||||
|
extern int TIFFReadCustomDirectory(TIFF* tif, toff_t diroff, const TIFFFieldArray* infoarray);
|
||||||
|
extern int TIFFReadEXIFDirectory(TIFF* tif, toff_t diroff);
|
||||||
|
extern uint64 TIFFScanlineSize64(TIFF* tif);
|
||||||
|
extern tmsize_t TIFFScanlineSize(TIFF* tif);
|
||||||
|
extern uint64 TIFFRasterScanlineSize64(TIFF* tif);
|
||||||
|
extern tmsize_t TIFFRasterScanlineSize(TIFF* tif);
|
||||||
|
extern uint64 TIFFStripSize64(TIFF* tif);
|
||||||
|
extern tmsize_t TIFFStripSize(TIFF* tif);
|
||||||
|
extern uint64 TIFFRawStripSize64(TIFF* tif, uint32 strip);
|
||||||
|
extern tmsize_t TIFFRawStripSize(TIFF* tif, uint32 strip);
|
||||||
|
extern uint64 TIFFVStripSize64(TIFF* tif, uint32 nrows);
|
||||||
|
extern tmsize_t TIFFVStripSize(TIFF* tif, uint32 nrows);
|
||||||
|
extern uint64 TIFFTileRowSize64(TIFF* tif);
|
||||||
|
extern tmsize_t TIFFTileRowSize(TIFF* tif);
|
||||||
|
extern uint64 TIFFTileSize64(TIFF* tif);
|
||||||
|
extern tmsize_t TIFFTileSize(TIFF* tif);
|
||||||
|
extern uint64 TIFFVTileSize64(TIFF* tif, uint32 nrows);
|
||||||
|
extern tmsize_t TIFFVTileSize(TIFF* tif, uint32 nrows);
|
||||||
|
extern uint32 TIFFDefaultStripSize(TIFF* tif, uint32 request);
|
||||||
|
extern void TIFFDefaultTileSize(TIFF*, uint32*, uint32*);
|
||||||
|
extern int TIFFFileno(TIFF*);
|
||||||
|
extern int TIFFSetFileno(TIFF*, int);
|
||||||
|
extern thandle_t TIFFClientdata(TIFF*);
|
||||||
|
extern thandle_t TIFFSetClientdata(TIFF*, thandle_t);
|
||||||
|
extern int TIFFGetMode(TIFF*);
|
||||||
|
extern int TIFFSetMode(TIFF*, int);
|
||||||
|
extern int TIFFIsTiled(TIFF*);
|
||||||
|
extern int TIFFIsByteSwapped(TIFF*);
|
||||||
|
extern int TIFFIsUpSampled(TIFF*);
|
||||||
|
extern int TIFFIsMSB2LSB(TIFF*);
|
||||||
|
extern int TIFFIsBigEndian(TIFF*);
|
||||||
|
extern TIFFReadWriteProc TIFFGetReadProc(TIFF*);
|
||||||
|
extern TIFFReadWriteProc TIFFGetWriteProc(TIFF*);
|
||||||
|
extern TIFFSeekProc TIFFGetSeekProc(TIFF*);
|
||||||
|
extern TIFFCloseProc TIFFGetCloseProc(TIFF*);
|
||||||
|
extern TIFFSizeProc TIFFGetSizeProc(TIFF*);
|
||||||
|
extern TIFFMapFileProc TIFFGetMapFileProc(TIFF*);
|
||||||
|
extern TIFFUnmapFileProc TIFFGetUnmapFileProc(TIFF*);
|
||||||
|
extern uint32 TIFFCurrentRow(TIFF*);
|
||||||
|
extern uint16 TIFFCurrentDirectory(TIFF*);
|
||||||
|
extern uint16 TIFFNumberOfDirectories(TIFF*);
|
||||||
|
extern uint64 TIFFCurrentDirOffset(TIFF*);
|
||||||
|
extern uint32 TIFFCurrentStrip(TIFF*);
|
||||||
|
extern uint32 TIFFCurrentTile(TIFF* tif);
|
||||||
|
extern int TIFFReadBufferSetup(TIFF* tif, void* bp, tmsize_t size);
|
||||||
|
extern int TIFFWriteBufferSetup(TIFF* tif, void* bp, tmsize_t size);
|
||||||
|
extern int TIFFSetupStrips(TIFF *);
|
||||||
|
extern int TIFFWriteCheck(TIFF*, int, const char *);
|
||||||
|
extern void TIFFFreeDirectory(TIFF*);
|
||||||
|
extern int TIFFCreateDirectory(TIFF*);
|
||||||
|
extern int TIFFCreateCustomDirectory(TIFF*,const TIFFFieldArray*);
|
||||||
|
extern int TIFFCreateEXIFDirectory(TIFF*);
|
||||||
|
extern int TIFFLastDirectory(TIFF*);
|
||||||
|
extern int TIFFSetDirectory(TIFF*, uint16);
|
||||||
|
extern int TIFFSetSubDirectory(TIFF*, uint64);
|
||||||
|
extern int TIFFUnlinkDirectory(TIFF*, uint16);
|
||||||
|
extern int TIFFSetField(TIFF*, uint32, ...);
|
||||||
|
extern int TIFFVSetField(TIFF*, uint32, va_list);
|
||||||
|
extern int TIFFUnsetField(TIFF*, uint32);
|
||||||
|
extern int TIFFWriteDirectory(TIFF *);
|
||||||
|
extern int TIFFWriteCustomDirectory(TIFF *, uint64 *);
|
||||||
|
extern int TIFFCheckpointDirectory(TIFF *);
|
||||||
|
extern int TIFFRewriteDirectory(TIFF *);
|
||||||
|
|
||||||
|
#if defined(c_plusplus) || defined(__cplusplus)
|
||||||
|
extern void TIFFPrintDirectory(TIFF*, FILE*, long = 0);
|
||||||
|
extern int TIFFReadScanline(TIFF* tif, void* buf, uint32 row, uint16 sample = 0);
|
||||||
|
extern int TIFFWriteScanline(TIFF* tif, void* buf, uint32 row, uint16 sample = 0);
|
||||||
|
extern int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int = 0);
|
||||||
|
extern int TIFFReadRGBAImageOriented(TIFF*, uint32, uint32, uint32*,
|
||||||
|
int = ORIENTATION_BOTLEFT, int = 0);
|
||||||
|
#else
|
||||||
|
extern void TIFFPrintDirectory(TIFF*, FILE*, long);
|
||||||
|
extern int TIFFReadScanline(TIFF* tif, void* buf, uint32 row, uint16 sample);
|
||||||
|
extern int TIFFWriteScanline(TIFF* tif, void* buf, uint32 row, uint16 sample);
|
||||||
|
extern int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int);
|
||||||
|
extern int TIFFReadRGBAImageOriented(TIFF*, uint32, uint32, uint32*, int, int);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern int TIFFReadRGBAStrip(TIFF*, uint32, uint32 * );
|
||||||
|
extern int TIFFReadRGBATile(TIFF*, uint32, uint32, uint32 * );
|
||||||
|
extern int TIFFRGBAImageOK(TIFF*, char [1024]);
|
||||||
|
extern int TIFFRGBAImageBegin(TIFFRGBAImage*, TIFF*, int, char [1024]);
|
||||||
|
extern int TIFFRGBAImageGet(TIFFRGBAImage*, uint32*, uint32, uint32);
|
||||||
|
extern void TIFFRGBAImageEnd(TIFFRGBAImage*);
|
||||||
|
extern TIFF* TIFFOpen(const char*, const char*);
|
||||||
|
# ifdef __WIN32__
|
||||||
|
extern TIFF* TIFFOpenW(const wchar_t*, const char*);
|
||||||
|
# endif /* __WIN32__ */
|
||||||
|
extern TIFF* TIFFFdOpen(int, const char*, const char*);
|
||||||
|
extern TIFF* TIFFClientOpen(const char*, const char*,
|
||||||
|
thandle_t,
|
||||||
|
TIFFReadWriteProc, TIFFReadWriteProc,
|
||||||
|
TIFFSeekProc, TIFFCloseProc,
|
||||||
|
TIFFSizeProc,
|
||||||
|
TIFFMapFileProc, TIFFUnmapFileProc);
|
||||||
|
extern const char* TIFFFileName(TIFF*);
|
||||||
|
extern const char* TIFFSetFileName(TIFF*, const char *);
|
||||||
|
extern void TIFFError(const char*, const char*, ...) __attribute__((__format__ (__printf__,2,3)));
|
||||||
|
extern void TIFFErrorExt(thandle_t, const char*, const char*, ...) __attribute__((__format__ (__printf__,3,4)));
|
||||||
|
extern void TIFFWarning(const char*, const char*, ...) __attribute__((__format__ (__printf__,2,3)));
|
||||||
|
extern void TIFFWarningExt(thandle_t, const char*, const char*, ...) __attribute__((__format__ (__printf__,3,4)));
|
||||||
|
extern TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler);
|
||||||
|
extern TIFFErrorHandlerExt TIFFSetErrorHandlerExt(TIFFErrorHandlerExt);
|
||||||
|
extern TIFFErrorHandler TIFFSetWarningHandler(TIFFErrorHandler);
|
||||||
|
extern TIFFErrorHandlerExt TIFFSetWarningHandlerExt(TIFFErrorHandlerExt);
|
||||||
|
extern TIFFExtendProc TIFFSetTagExtender(TIFFExtendProc);
|
||||||
|
extern uint32 TIFFComputeTile(TIFF* tif, uint32 x, uint32 y, uint32 z, uint16 s);
|
||||||
|
extern int TIFFCheckTile(TIFF* tif, uint32 x, uint32 y, uint32 z, uint16 s);
|
||||||
|
extern uint32 TIFFNumberOfTiles(TIFF*);
|
||||||
|
extern tmsize_t TIFFReadTile(TIFF* tif, void* buf, uint32 x, uint32 y, uint32 z, uint16 s);
|
||||||
|
extern tmsize_t TIFFWriteTile(TIFF* tif, void* buf, uint32 x, uint32 y, uint32 z, uint16 s);
|
||||||
|
extern uint32 TIFFComputeStrip(TIFF*, uint32, uint16);
|
||||||
|
extern uint32 TIFFNumberOfStrips(TIFF*);
|
||||||
|
extern tmsize_t TIFFReadEncodedStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size);
|
||||||
|
extern tmsize_t TIFFReadRawStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size);
|
||||||
|
extern tmsize_t TIFFReadEncodedTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size);
|
||||||
|
extern tmsize_t TIFFReadRawTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size);
|
||||||
|
extern tmsize_t TIFFWriteEncodedStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc);
|
||||||
|
extern tmsize_t TIFFWriteRawStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc);
|
||||||
|
extern tmsize_t TIFFWriteEncodedTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc);
|
||||||
|
extern tmsize_t TIFFWriteRawTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc);
|
||||||
|
extern int TIFFDataWidth(TIFFDataType); /* table of tag datatype widths */
|
||||||
|
extern void TIFFSetWriteOffset(TIFF* tif, toff_t off);
|
||||||
|
extern void TIFFSwabShort(uint16*);
|
||||||
|
extern void TIFFSwabLong(uint32*);
|
||||||
|
extern void TIFFSwabLong8(uint64*);
|
||||||
|
extern void TIFFSwabFloat(float*);
|
||||||
|
extern void TIFFSwabDouble(double*);
|
||||||
|
extern void TIFFSwabArrayOfShort(uint16* wp, tmsize_t n);
|
||||||
|
extern void TIFFSwabArrayOfTriples(uint8* tp, tmsize_t n);
|
||||||
|
extern void TIFFSwabArrayOfLong(uint32* lp, tmsize_t n);
|
||||||
|
extern void TIFFSwabArrayOfLong8(uint64* lp, tmsize_t n);
|
||||||
|
extern void TIFFSwabArrayOfFloat(float* fp, tmsize_t n);
|
||||||
|
extern void TIFFSwabArrayOfDouble(double* dp, tmsize_t n);
|
||||||
|
extern void TIFFReverseBits(uint8* cp, tmsize_t n);
|
||||||
|
extern const unsigned char* TIFFGetBitRevTable(int);
|
||||||
|
|
||||||
|
#ifdef LOGLUV_PUBLIC
|
||||||
|
#define U_NEU 0.210526316
|
||||||
|
#define V_NEU 0.473684211
|
||||||
|
#define UVSCALE 410.
|
||||||
|
extern double LogL16toY(int);
|
||||||
|
extern double LogL10toY(int);
|
||||||
|
extern void XYZtoRGB24(float*, uint8*);
|
||||||
|
extern int uv_decode(double*, double*, int);
|
||||||
|
extern void LogLuv24toXYZ(uint32, float*);
|
||||||
|
extern void LogLuv32toXYZ(uint32, float*);
|
||||||
|
#if defined(c_plusplus) || defined(__cplusplus)
|
||||||
|
extern int LogL16fromY(double, int = SGILOGENCODE_NODITHER);
|
||||||
|
extern int LogL10fromY(double, int = SGILOGENCODE_NODITHER);
|
||||||
|
extern int uv_encode(double, double, int = SGILOGENCODE_NODITHER);
|
||||||
|
extern uint32 LogLuv24fromXYZ(float*, int = SGILOGENCODE_NODITHER);
|
||||||
|
extern uint32 LogLuv32fromXYZ(float*, int = SGILOGENCODE_NODITHER);
|
||||||
|
#else
|
||||||
|
extern int LogL16fromY(double, int);
|
||||||
|
extern int LogL10fromY(double, int);
|
||||||
|
extern int uv_encode(double, double, int);
|
||||||
|
extern uint32 LogLuv24fromXYZ(float*, int);
|
||||||
|
extern uint32 LogLuv32fromXYZ(float*, int);
|
||||||
|
#endif
|
||||||
|
#endif /* LOGLUV_PUBLIC */
|
||||||
|
|
||||||
|
extern int TIFFCIELabToRGBInit(TIFFCIELabToRGB*, const TIFFDisplay *, float*);
|
||||||
|
extern void TIFFCIELabToXYZ(TIFFCIELabToRGB *, uint32, int32, int32,
|
||||||
|
float *, float *, float *);
|
||||||
|
extern void TIFFXYZToRGB(TIFFCIELabToRGB *, float, float, float,
|
||||||
|
uint32 *, uint32 *, uint32 *);
|
||||||
|
|
||||||
|
extern int TIFFYCbCrToRGBInit(TIFFYCbCrToRGB*, float*, float*);
|
||||||
|
extern void TIFFYCbCrtoRGB(TIFFYCbCrToRGB *, uint32, int32, int32,
|
||||||
|
uint32 *, uint32 *, uint32 *);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* O B S O L E T E D I N T E R F A C E S
|
||||||
|
*
|
||||||
|
* Don't use this stuff in your applications, it may be removed in the future
|
||||||
|
* libtiff versions.
|
||||||
|
****************************************************************************/
|
||||||
|
typedef struct {
|
||||||
|
ttag_t field_tag; /* field's tag */
|
||||||
|
short field_readcount; /* read count/TIFF_VARIABLE/TIFF_SPP */
|
||||||
|
short field_writecount; /* write count/TIFF_VARIABLE */
|
||||||
|
TIFFDataType field_type; /* type of associated data */
|
||||||
|
unsigned short field_bit; /* bit in fieldsset bit vector */
|
||||||
|
unsigned char field_oktochange; /* if true, can change while writing */
|
||||||
|
unsigned char field_passcount; /* if true, pass dir count on set */
|
||||||
|
char *field_name; /* ASCII name */
|
||||||
|
} TIFFFieldInfo;
|
||||||
|
|
||||||
|
extern int TIFFMergeFieldInfo(TIFF*, const TIFFFieldInfo[], uint32);
|
||||||
|
|
||||||
|
#if defined(c_plusplus) || defined(__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _TIFFIO_ */
|
||||||
|
|
||||||
|
/* vim: set ts=8 sts=8 sw=8 noet: */
|
||||||
|
/*
|
||||||
|
* Local Variables:
|
||||||
|
* mode: c
|
||||||
|
* c-basic-offset: 8
|
||||||
|
* fill-column: 78
|
||||||
|
* End:
|
||||||
|
*/
|
|
@ -0,0 +1,9 @@
|
||||||
|
#define TIFFLIB_VERSION_STR "LIBTIFF, Version 4.0.3\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc."
|
||||||
|
/*
|
||||||
|
* This define can be used in code that requires
|
||||||
|
* compilation-related definitions specific to a
|
||||||
|
* version or versions of the library. Runtime
|
||||||
|
* version checking should be done based on the
|
||||||
|
* string returned by TIFFGetVersion.
|
||||||
|
*/
|
||||||
|
#define TIFFLIB_VERSION 20120922
|
|
@ -0,0 +1 @@
|
||||||
|
9e3629f0bc6e96d4af5aea9a20446e4f9b5ca6d0
|
|
@ -0,0 +1 @@
|
||||||
|
2a8128e7d552dc8b2d79c1cbd8c84c21ad578672
|
|
@ -0,0 +1 @@
|
||||||
|
60433133a48054eb884d9e6a0cee95fe4ba22b1c
|
|
@ -0,0 +1 @@
|
||||||
|
31b08ad941b4c313ae9996e4ba8bee4837f8bccb
|
|
@ -0,0 +1 @@
|
||||||
|
fb78024e2f81c33d196af83e7740de7c7f4ea021
|
|
@ -0,0 +1 @@
|
||||||
|
5fe8aca7e0bfa91c79b4b6b0a562f88a6653c452
|
|
@ -1 +1 @@
|
||||||
98a9f91fff796092bb7afab1f50fb11c3fe696d9
|
4c5c7d34a90f5fcac954f6d44803173224d8ead2
|
|
@ -244,7 +244,7 @@ public:
|
||||||
int lineWidth = textLines.at(line).lineWidth;
|
int lineWidth = textLines.at(line).lineWidth;
|
||||||
if (eAlignMask == Image::TextAlign::CENTER || eAlignMask == Image::TextAlign::TOP || eAlignMask == Image::TextAlign::BOTTOM) {
|
if (eAlignMask == Image::TextAlign::CENTER || eAlignMask == Image::TextAlign::TOP || eAlignMask == Image::TextAlign::BOTTOM) {
|
||||||
return (iMaxLineWidth - lineWidth) / 2;
|
return (iMaxLineWidth - lineWidth) / 2;
|
||||||
} else if (eAlignMask == Image::TextAlign::RIGHT || eAlignMask == Image::TextAlign::TO_RIGHT || eAlignMask == Image::TextAlign::BOTTOM_RIGHT) {
|
} else if (eAlignMask == Image::TextAlign::RIGHT || eAlignMask == Image::TextAlign::TOP_RIGHT || eAlignMask == Image::TextAlign::BOTTOM_RIGHT) {
|
||||||
return (iMaxLineWidth - lineWidth);
|
return (iMaxLineWidth - lineWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -428,7 +428,7 @@ bool Image::initWithString(
|
||||||
const char * pText,
|
const char * pText,
|
||||||
int nWidth/* = 0*/,
|
int nWidth/* = 0*/,
|
||||||
int nHeight/* = 0*/,
|
int nHeight/* = 0*/,
|
||||||
ETextAlign eAlignMask/* = kAlignCenter*/,
|
TextAlign eAlignMask/* = kAlignCenter*/,
|
||||||
const char * pFontName/* = nil*/,
|
const char * pFontName/* = nil*/,
|
||||||
int nSize/* = 0*/)
|
int nSize/* = 0*/)
|
||||||
{
|
{
|
||||||
|
@ -449,9 +449,8 @@ bool Image::initWithString(
|
||||||
|
|
||||||
_width = (short)dc.iMaxLineWidth;
|
_width = (short)dc.iMaxLineWidth;
|
||||||
_height = (short)dc.iMaxLineHeight;
|
_height = (short)dc.iMaxLineHeight;
|
||||||
_hasAlpha = true;
|
|
||||||
_preMulti = true;
|
_preMulti = true;
|
||||||
_bitsPerComponent = 8;
|
_renderFormat = Texture2D::PixelFormat::RGBA8888;
|
||||||
|
|
||||||
bRet = true;
|
bRet = true;
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,36 @@ static void _checkPath()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// D:/aaa/bbb/ccc/ddd/abc.txt --> D:\aaa\bbb\ccc\ddd\abc.txt
|
||||||
|
static inline std::string convertPathFormatToWindowStyle(const std::string& path)
|
||||||
|
{
|
||||||
|
std::string ret = path;
|
||||||
|
int len = ret.length();
|
||||||
|
for (int i = 0; i < len; ++i)
|
||||||
|
{
|
||||||
|
if (ret[i] == '/')
|
||||||
|
{
|
||||||
|
ret[i] = '\\';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
// D:\aaa\bbb\ccc\ddd\abc.txt --> D:/aaa/bbb/ccc/ddd/abc.txt
|
||||||
|
static inline std::string convertPathFormatToUnixStyle(const std::string& path)
|
||||||
|
{
|
||||||
|
std::string ret = path;
|
||||||
|
int len = ret.length();
|
||||||
|
for (int i = 0; i < len; ++i)
|
||||||
|
{
|
||||||
|
if (ret[i] == '\\')
|
||||||
|
{
|
||||||
|
ret[i] = '/';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
FileUtils* FileUtils::getInstance()
|
FileUtils* FileUtils::getInstance()
|
||||||
{
|
{
|
||||||
if (s_sharedFileUtils == NULL)
|
if (s_sharedFileUtils == NULL)
|
||||||
|
@ -81,7 +111,12 @@ bool FileUtilsWin32::isFileExist(const std::string& strFilePath)
|
||||||
{ // Not absolute path, add the default root path at the beginning.
|
{ // Not absolute path, add the default root path at the beginning.
|
||||||
strPath.insert(0, _defaultResRootPath);
|
strPath.insert(0, _defaultResRootPath);
|
||||||
}
|
}
|
||||||
return GetFileAttributesA(strPath.c_str()) != -1 ? true : false;
|
|
||||||
|
convertPathFormatToWindowStyle(strPath);
|
||||||
|
WCHAR wszBuf[MAX_PATH] = {0};
|
||||||
|
MultiByteToWideChar(CP_UTF8, 0, strPath.c_str(), -1, wszBuf, sizeof(wszBuf));
|
||||||
|
|
||||||
|
return GetFileAttributesW(wszBuf) != -1 ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FileUtilsWin32::isAbsolutePath(const std::string& strPath)
|
bool FileUtilsWin32::isAbsolutePath(const std::string& strPath)
|
||||||
|
@ -95,6 +130,68 @@ bool FileUtilsWin32::isAbsolutePath(const std::string& strPath)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned char* FileUtilsWin32::getFileData(const char* filename, const char* mode, unsigned long* size)
|
||||||
|
{
|
||||||
|
unsigned char * pBuffer = NULL;
|
||||||
|
CCASSERT(filename != NULL && size != NULL && mode != NULL, "Invalid parameters.");
|
||||||
|
*size = 0;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
// read the file from hardware
|
||||||
|
std::string fullPath = fullPathForFilename(filename);
|
||||||
|
|
||||||
|
WCHAR wszBuf[MAX_PATH] = {0};
|
||||||
|
MultiByteToWideChar(CP_UTF8, 0, fullPath.c_str(), -1, wszBuf, sizeof(wszBuf));
|
||||||
|
|
||||||
|
|
||||||
|
HANDLE fileHandle = ::CreateFileW(wszBuf, GENERIC_READ, 0, NULL, OPEN_EXISTING, NULL, NULL);
|
||||||
|
CC_BREAK_IF(fileHandle == INVALID_HANDLE_VALUE);
|
||||||
|
|
||||||
|
*size = ::GetFileSize(fileHandle, NULL);
|
||||||
|
|
||||||
|
pBuffer = new unsigned char[*size];
|
||||||
|
DWORD sizeRead = 0;
|
||||||
|
BOOL successed = FALSE;
|
||||||
|
successed = ::ReadFile(fileHandle, pBuffer, *size, &sizeRead, NULL);
|
||||||
|
::CloseHandle(fileHandle);
|
||||||
|
|
||||||
|
if (!successed)
|
||||||
|
{
|
||||||
|
CC_SAFE_DELETE_ARRAY(pBuffer);
|
||||||
|
}
|
||||||
|
} while (0);
|
||||||
|
|
||||||
|
if (! pBuffer)
|
||||||
|
{
|
||||||
|
std::string msg = "Get data from file(";
|
||||||
|
// Gets error code.
|
||||||
|
DWORD errorCode = ::GetLastError();
|
||||||
|
char errorCodeBuffer[20] = {0};
|
||||||
|
snprintf(errorCodeBuffer, sizeof(errorCodeBuffer), "%d", errorCode);
|
||||||
|
|
||||||
|
msg = msg + filename + ") failed, error code is " + errorCodeBuffer;
|
||||||
|
CCLOG("%s", msg.c_str());
|
||||||
|
}
|
||||||
|
return pBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string FileUtilsWin32::getPathForFilename(const std::string& filename, const std::string& resolutionDirectory, const std::string& searchPath)
|
||||||
|
{
|
||||||
|
std::string unixFileName = convertPathFormatToUnixStyle(filename);
|
||||||
|
std::string unixResolutionDirector = convertPathFormatToUnixStyle(resolutionDirectory);
|
||||||
|
std::string unixSearchPath = convertPathFormatToUnixStyle(searchPath);
|
||||||
|
|
||||||
|
return FileUtils::getPathForFilename(unixFileName, unixResolutionDirector, unixSearchPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string FileUtilsWin32::getFullPathForDirectoryAndFilename(const std::string& strDirectory, const std::string& strFilename)
|
||||||
|
{
|
||||||
|
std::string dosDirectory = convertPathFormatToWindowStyle(strDirectory);
|
||||||
|
std::string dosFilename = convertPathFormatToWindowStyle(strFilename);
|
||||||
|
|
||||||
|
return FileUtils::getFullPathForDirectoryAndFilename(dosDirectory, dosFilename);
|
||||||
|
}
|
||||||
|
|
||||||
string FileUtilsWin32::getWritablePath()
|
string FileUtilsWin32::getWritablePath()
|
||||||
{
|
{
|
||||||
// Get full path of executable, e.g. c:\Program Files (x86)\My Game Folder\MyGame.exe
|
// Get full path of executable, e.g. c:\Program Files (x86)\My Game Folder\MyGame.exe
|
||||||
|
|
|
@ -49,6 +49,39 @@ public:
|
||||||
virtual std::string getWritablePath();
|
virtual std::string getWritablePath();
|
||||||
virtual bool isFileExist(const std::string& strFilePath);
|
virtual bool isFileExist(const std::string& strFilePath);
|
||||||
virtual bool isAbsolutePath(const std::string& strPath);
|
virtual bool isAbsolutePath(const std::string& strPath);
|
||||||
|
protected:
|
||||||
|
/**
|
||||||
|
* Gets resource file data
|
||||||
|
*
|
||||||
|
* @param[in] filename The resource file name which contains the path.
|
||||||
|
* @param[in] pszMode The read mode of the file.
|
||||||
|
* @param[out] pSize If the file read operation succeeds, it will be the data size, otherwise 0.
|
||||||
|
* @return Upon success, a pointer to the data is returned, otherwise NULL.
|
||||||
|
* @warning Recall: you are responsible for calling delete[] on any Non-NULL pointer returned.
|
||||||
|
*/
|
||||||
|
virtual unsigned char* getFileData(const char* filename, const char* mode, unsigned long * size) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets full path for filename, resolution directory and search path.
|
||||||
|
*
|
||||||
|
* @param filename The file name.
|
||||||
|
* @param resolutionDirectory The resolution directory.
|
||||||
|
* @param searchPath The search path.
|
||||||
|
* @return The full path of the file. It will return an empty string if the full path of the file doesn't exist.
|
||||||
|
*/
|
||||||
|
virtual std::string getPathForFilename(const std::string& filename, const std::string& resolutionDirectory, const std::string& searchPath) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets full path for the directory and the filename.
|
||||||
|
*
|
||||||
|
* @note Only iOS and Mac need to override this method since they are using
|
||||||
|
* `[[NSBundle mainBundle] pathForResource: ofType: inDirectory:]` to make a full path.
|
||||||
|
* Other platforms will use the default implementation of this method.
|
||||||
|
* @param strDirectory The directory contains the file we are looking for.
|
||||||
|
* @param strFilename The name of the file.
|
||||||
|
* @return The full path of the file, if the file can't be found, it will return an empty string.
|
||||||
|
*/
|
||||||
|
virtual std::string getFullPathForDirectoryAndFilename(const std::string& strDirectory, const std::string& strFilename) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
// end of platform group
|
// end of platform group
|
||||||
|
|
|
@ -390,7 +390,8 @@ bool Image::initWithString(
|
||||||
SIZE size = {nWidth, nHeight};
|
SIZE size = {nWidth, nHeight};
|
||||||
CC_BREAK_IF(! dc.drawText(pText, size, eAlignMask));
|
CC_BREAK_IF(! dc.drawText(pText, size, eAlignMask));
|
||||||
|
|
||||||
_data = new unsigned char[size.cx * size.cy * 4];
|
_dataLen = size.cx * size.cy * 4;
|
||||||
|
_data = new unsigned char[_dataLen];
|
||||||
CC_BREAK_IF(! _data);
|
CC_BREAK_IF(! _data);
|
||||||
|
|
||||||
struct
|
struct
|
||||||
|
@ -404,9 +405,8 @@ bool Image::initWithString(
|
||||||
|
|
||||||
_width = (short)size.cx;
|
_width = (short)size.cx;
|
||||||
_height = (short)size.cy;
|
_height = (short)size.cy;
|
||||||
_hasAlpha = true;
|
|
||||||
_preMulti = false;
|
_preMulti = false;
|
||||||
_bitsPerComponent = 8;
|
_renderFormat = Texture2D::PixelFormat::RGBA8888;
|
||||||
// copy pixed data
|
// copy pixed data
|
||||||
bi.bmiHeader.biHeight = (bi.bmiHeader.biHeight > 0)
|
bi.bmiHeader.biHeight = (bi.bmiHeader.biHeight > 0)
|
||||||
? - bi.bmiHeader.biHeight : bi.bmiHeader.biHeight;
|
? - bi.bmiHeader.biHeight : bi.bmiHeader.biHeight;
|
||||||
|
|
|
@ -109,6 +109,11 @@ NS_CC_END
|
||||||
#undef RELATIVE
|
#undef RELATIVE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Conflicted with CCBReader::SizeType::RELATIVE and CCBReader::ScaleType::RELATIVE, so we need to undef it.
|
||||||
|
#ifdef ABSOLUTE
|
||||||
|
#undef ABSOLUTE
|
||||||
|
#endif
|
||||||
|
|
||||||
// Conflicted with HttpRequest::Type::DELETE, so we need to undef it.
|
// Conflicted with HttpRequest::Type::DELETE, so we need to undef it.
|
||||||
#ifdef DELETE
|
#ifdef DELETE
|
||||||
#undef DELETE
|
#undef DELETE
|
||||||
|
|
|
@ -46,6 +46,7 @@ SOURCES = ../actions/CCAction.cpp \
|
||||||
../effects/CCGrid.cpp \
|
../effects/CCGrid.cpp \
|
||||||
../keypad_dispatcher/CCKeypadDelegate.cpp \
|
../keypad_dispatcher/CCKeypadDelegate.cpp \
|
||||||
../keypad_dispatcher/CCKeypadDispatcher.cpp \
|
../keypad_dispatcher/CCKeypadDispatcher.cpp \
|
||||||
|
../keyboard_dispatcher/CCKeyboardDispatcher.cpp \
|
||||||
../label_nodes/CCLabelAtlas.cpp \
|
../label_nodes/CCLabelAtlas.cpp \
|
||||||
../label_nodes/CCLabelBMFont.cpp \
|
../label_nodes/CCLabelBMFont.cpp \
|
||||||
../label_nodes/CCLabelTTF.cpp \
|
../label_nodes/CCLabelTTF.cpp \
|
||||||
|
@ -66,7 +67,6 @@ SOURCES = ../actions/CCAction.cpp \
|
||||||
../particle_nodes/CCParticleBatchNode.cpp \
|
../particle_nodes/CCParticleBatchNode.cpp \
|
||||||
../platform/CCSAXParser.cpp \
|
../platform/CCSAXParser.cpp \
|
||||||
../platform/CCThread.cpp \
|
../platform/CCThread.cpp \
|
||||||
../platform/platform.cpp \
|
|
||||||
../platform/CCImageCommonWebp.cpp \
|
../platform/CCImageCommonWebp.cpp \
|
||||||
../platform/CCEGLViewProtocol.cpp \
|
../platform/CCEGLViewProtocol.cpp \
|
||||||
../platform/CCFileUtils.cpp \
|
../platform/CCFileUtils.cpp \
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
all:
|
all:
|
||||||
|
|
||||||
DEFINES += -DEMSCRIPTEN
|
DEFINES += -DEMSCRIPTEN -DCC_KEYBOARD_SUPPORT
|
||||||
|
|
||||||
THIS_MAKEFILE := $(CURDIR)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
|
THIS_MAKEFILE := $(CURDIR)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
|
||||||
ifndef COCOS_ROOT
|
ifndef COCOS_ROOT
|
||||||
|
@ -52,8 +52,8 @@ LBITS := $(shell getconf LONG_BIT)
|
||||||
INCLUDES += -I$(COCOS_SRC)/platform/third_party/linux
|
INCLUDES += -I$(COCOS_SRC)/platform/third_party/linux
|
||||||
|
|
||||||
ifeq ($(DEBUG), 1)
|
ifeq ($(DEBUG), 1)
|
||||||
CCFLAGS += -O0 -s ASSERTIONS=1 -s SAFE_HEAP=1 --jcache -s GL_UNSAFE_OPTS=0
|
CCFLAGS += -O0 -s ASSERTIONS=1 -s SAFE_HEAP=1 --jcache -s GL_UNSAFE_OPTS=0 -g
|
||||||
CXXFLAGS += -O0 -s ASSERTIONS=1 -s SAFE_HEAP=1 --jcache -s GL_UNSAFE_OPTS=0
|
CXXFLAGS += -O0 -s ASSERTIONS=1 -s SAFE_HEAP=1 --jcache -s GL_UNSAFE_OPTS=0 -g
|
||||||
DEFINES += -D_DEBUG -DCOCOS2D_DEBUG=1 -DCP_USE_DOUBLES=0
|
DEFINES += -D_DEBUG -DCOCOS2D_DEBUG=1 -DCP_USE_DOUBLES=0
|
||||||
OBJ_DIR := $(OBJ_DIR)/debug
|
OBJ_DIR := $(OBJ_DIR)/debug
|
||||||
LIB_DIR := $(LIB_DIR)/debug
|
LIB_DIR := $(LIB_DIR)/debug
|
||||||
|
|
|
@ -2,6 +2,7 @@ TARGET = libcocos2d.so
|
||||||
|
|
||||||
INCLUDES += \
|
INCLUDES += \
|
||||||
-I../platform/third_party/linux/libfreetype2 \
|
-I../platform/third_party/linux/libfreetype2 \
|
||||||
|
-I../platform/third_party/common/etc \
|
||||||
-I../../extensions \
|
-I../../extensions \
|
||||||
-I../../extensions/CCBReader \
|
-I../../extensions/CCBReader \
|
||||||
-I../../extensions/GUI/CCControlExtension \
|
-I../../extensions/GUI/CCControlExtension \
|
||||||
|
@ -63,7 +64,6 @@ SOURCES = ../actions/CCAction.cpp \
|
||||||
../particle_nodes/CCParticleBatchNode.cpp \
|
../particle_nodes/CCParticleBatchNode.cpp \
|
||||||
../platform/CCSAXParser.cpp \
|
../platform/CCSAXParser.cpp \
|
||||||
../platform/CCThread.cpp \
|
../platform/CCThread.cpp \
|
||||||
../platform/CCImageCommonWebp.cpp \
|
|
||||||
../platform/CCEGLViewProtocol.cpp \
|
../platform/CCEGLViewProtocol.cpp \
|
||||||
../platform/CCFileUtils.cpp \
|
../platform/CCFileUtils.cpp \
|
||||||
../platform/linux/CCStdC.cpp \
|
../platform/linux/CCStdC.cpp \
|
||||||
|
@ -73,6 +73,7 @@ SOURCES = ../actions/CCAction.cpp \
|
||||||
../platform/linux/CCEGLView.cpp \
|
../platform/linux/CCEGLView.cpp \
|
||||||
../platform/linux/CCImage.cpp \
|
../platform/linux/CCImage.cpp \
|
||||||
../platform/linux/CCDevice.cpp \
|
../platform/linux/CCDevice.cpp \
|
||||||
|
../platform/third_party/common/etc/etc1.cpp \
|
||||||
../script_support/CCScriptSupport.cpp \
|
../script_support/CCScriptSupport.cpp \
|
||||||
../sprite_nodes/CCAnimation.cpp \
|
../sprite_nodes/CCAnimation.cpp \
|
||||||
../sprite_nodes/CCAnimationCache.cpp \
|
../sprite_nodes/CCAnimationCache.cpp \
|
||||||
|
@ -101,9 +102,6 @@ SOURCES = ../actions/CCAction.cpp \
|
||||||
../textures/CCTexture2D.cpp \
|
../textures/CCTexture2D.cpp \
|
||||||
../textures/CCTextureAtlas.cpp \
|
../textures/CCTextureAtlas.cpp \
|
||||||
../textures/CCTextureCache.cpp \
|
../textures/CCTextureCache.cpp \
|
||||||
../textures/CCTextureETC.cpp \
|
|
||||||
../textures/CCTexturePVR.cpp \
|
|
||||||
../textures/etc/etc1.cpp\
|
|
||||||
../tilemap_parallax_nodes/CCParallaxNode.cpp \
|
../tilemap_parallax_nodes/CCParallaxNode.cpp \
|
||||||
../tilemap_parallax_nodes/CCTMXLayer.cpp \
|
../tilemap_parallax_nodes/CCTMXLayer.cpp \
|
||||||
../tilemap_parallax_nodes/CCTMXObjectGroup.cpp \
|
../tilemap_parallax_nodes/CCTMXObjectGroup.cpp \
|
||||||
|
|
|
@ -1,14 +1,36 @@
|
||||||
|
################################################################################
|
||||||
|
#
|
||||||
|
# LINUX MAKEFILE
|
||||||
|
#
|
||||||
|
# Available options are:
|
||||||
|
# - CLANG=1 : Compiles with clang instead of gcc. Clang must be in your PATH.
|
||||||
|
# - V=1 : Enables the verbose mode.
|
||||||
|
# - DEBUG=1 : Enables the debug mode, disable compiler optimizations.
|
||||||
|
# - OPENAL=1 : Uses OpenAL instead of FMOD as sound engine.
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
|
||||||
all:
|
all:
|
||||||
|
|
||||||
CC = gcc
|
|
||||||
CXX = g++
|
|
||||||
# Remove -Wall, because it enables -Wunused-function, and this warning exists in webp.h
|
# Remove -Wall, because it enables -Wunused-function, and this warning exists in webp.h
|
||||||
# when enable c++11. I don't know why.
|
# when enable c++11. I don't know why.
|
||||||
# GCC 4.6 is primary platform for cocos2d v.3, because it's default compiler for Android,
|
# GCC 4.6 is primary platform for cocos2d v.3, because it's default compiler for Android,
|
||||||
# Blackberry, some Linux distributions.It supports all important features of c++11, but have
|
# Blackberry, some Linux distributions.It supports all important features of c++11, but have
|
||||||
# no flag "-std=c++11" (which was turned on in version 4.7).
|
# no flag "-std=c++11" (which was turned on in version 4.7).
|
||||||
CCFLAGS += -MMD -Werror -Wno-deprecated-declarations -fPIC
|
CCFLAGS += -MMD -Wno-deprecated-declarations -fPIC
|
||||||
CXXFLAGS += -MMD -Werror -Wno-deprecated-declarations -fPIC -std=gnu++0x
|
CXXFLAGS += -MMD -Wno-deprecated-declarations -fPIC -std=gnu++0x
|
||||||
|
|
||||||
|
ifeq ($(CLANG), 1)
|
||||||
|
CC := clang
|
||||||
|
CXX := clang++
|
||||||
|
DEFINES += -D__STRICT_ANSI__ # Allows clang 3.3 to use __float128
|
||||||
|
else
|
||||||
|
CC = gcc
|
||||||
|
CXX = g++
|
||||||
|
CCFLAGS += -Werror
|
||||||
|
CXXFLAGS += -Werror
|
||||||
|
endif
|
||||||
|
|
||||||
ARFLAGS = cr
|
ARFLAGS = cr
|
||||||
|
|
||||||
DEFINES += -DLINUX -DCC_KEYBOARD_SUPPORT
|
DEFINES += -DLINUX -DCC_KEYBOARD_SUPPORT
|
||||||
|
@ -100,7 +122,7 @@ SHAREDLIBS += -lfmodex
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
SHAREDLIBS += -lglfw -lGLEW -lfontconfig -lpthread -lGL
|
SHAREDLIBS += -lSDL2 -lGLEW -lfontconfig -lpthread -lGL
|
||||||
SHAREDLIBS += -L$(FMOD_LIBDIR) -Wl,-rpath,$(abspath $(FMOD_LIBDIR))
|
SHAREDLIBS += -L$(FMOD_LIBDIR) -Wl,-rpath,$(abspath $(FMOD_LIBDIR))
|
||||||
SHAREDLIBS += -L$(LIB_DIR) -Wl,-rpath,$(abspath $(LIB_DIR))
|
SHAREDLIBS += -L$(LIB_DIR) -Wl,-rpath,$(abspath $(LIB_DIR))
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,166 @@
|
||||||
|
|
||||||
|
include(common.pri)
|
||||||
|
|
||||||
|
TEMPLATE = lib
|
||||||
|
|
||||||
|
# Uncomment the following line to build Cocos2D-X as static library
|
||||||
|
#CONFIG += static
|
||||||
|
|
||||||
|
LIBS += $${COCOS2DX_SYSTEM_LIBS}
|
||||||
|
|
||||||
|
#SOURCES += $$files(../Collision/*.cpp)
|
||||||
|
|
||||||
|
SOURCES += ../actions/CCAction.cpp \
|
||||||
|
../actions/CCActionCamera.cpp \
|
||||||
|
../actions/CCActionEase.cpp \
|
||||||
|
../actions/CCActionGrid.cpp \
|
||||||
|
../actions/CCActionGrid3D.cpp \
|
||||||
|
../actions/CCActionInstant.cpp \
|
||||||
|
../actions/CCActionInterval.cpp \
|
||||||
|
../actions/CCActionManager.cpp \
|
||||||
|
../actions/CCActionPageTurn3D.cpp \
|
||||||
|
../actions/CCActionProgressTimer.cpp \
|
||||||
|
../actions/CCActionTiledGrid.cpp \
|
||||||
|
../actions/CCActionCatmullRom.cpp \
|
||||||
|
../actions/CCActionTween.cpp \
|
||||||
|
../base_nodes/CCAtlasNode.cpp \
|
||||||
|
../base_nodes/CCNode.cpp \
|
||||||
|
../cocoa/CCAffineTransform.cpp \
|
||||||
|
../cocoa/CCAutoreleasePool.cpp \
|
||||||
|
../cocoa/CCGeometry.cpp \
|
||||||
|
../cocoa/CCNS.cpp \
|
||||||
|
../cocoa/CCObject.cpp \
|
||||||
|
../cocoa/CCSet.cpp \
|
||||||
|
../cocoa/CCArray.cpp \
|
||||||
|
../cocoa/CCDictionary.cpp \
|
||||||
|
../cocoa/CCString.cpp \
|
||||||
|
../cocoa/CCDataVisitor.cpp \
|
||||||
|
../cocoa/CCData.cpp \
|
||||||
|
../draw_nodes/CCDrawingPrimitives.cpp \
|
||||||
|
../draw_nodes/CCDrawNode.cpp \
|
||||||
|
../effects/CCGrabber.cpp \
|
||||||
|
../effects/CCGrid.cpp \
|
||||||
|
../keypad_dispatcher/CCKeypadDelegate.cpp \
|
||||||
|
../keypad_dispatcher/CCKeypadDispatcher.cpp \
|
||||||
|
../keyboard_dispatcher/CCKeyboardDispatcher.cpp \
|
||||||
|
../label_nodes/CCLabelAtlas.cpp \
|
||||||
|
../label_nodes/CCLabelBMFont.cpp \
|
||||||
|
../label_nodes/CCLabelTTF.cpp \
|
||||||
|
../layers_scenes_transitions_nodes/CCLayer.cpp \
|
||||||
|
../layers_scenes_transitions_nodes/CCScene.cpp \
|
||||||
|
../layers_scenes_transitions_nodes/CCTransition.cpp \
|
||||||
|
../layers_scenes_transitions_nodes/CCTransitionPageTurn.cpp \
|
||||||
|
../layers_scenes_transitions_nodes/CCTransitionProgress.cpp \
|
||||||
|
../menu_nodes/CCMenu.cpp \
|
||||||
|
../menu_nodes/CCMenuItem.cpp \
|
||||||
|
../misc_nodes/CCMotionStreak.cpp \
|
||||||
|
../misc_nodes/CCProgressTimer.cpp \
|
||||||
|
../misc_nodes/CCClippingNode.cpp \
|
||||||
|
../misc_nodes/CCRenderTexture.cpp \
|
||||||
|
../particle_nodes/CCParticleExamples.cpp \
|
||||||
|
../particle_nodes/CCParticleSystem.cpp \
|
||||||
|
../particle_nodes/CCParticleSystemQuad.cpp \
|
||||||
|
../particle_nodes/CCParticleBatchNode.cpp \
|
||||||
|
../platform/CCSAXParser.cpp \
|
||||||
|
../platform/CCThread.cpp \
|
||||||
|
../platform/CCImageCommonWebp.cpp \
|
||||||
|
../platform/CCEGLViewProtocol.cpp \
|
||||||
|
../platform/CCFileUtils.cpp \
|
||||||
|
../platform/qt5/CCCommon.cpp \
|
||||||
|
../platform/qt5/CCFileUtilsQt5.cpp \
|
||||||
|
../platform/qt5/CCEGLView.cpp \
|
||||||
|
../platform/qt5/CCDevice.cpp \
|
||||||
|
../platform/qt5/CCApplication.cpp \
|
||||||
|
../platform/qt5/CCAccelerometer.cpp \
|
||||||
|
../platform/qt5/AccelerometerListener.cpp \
|
||||||
|
../platform/linux/CCImage.cpp \
|
||||||
|
../script_support/CCScriptSupport.cpp \
|
||||||
|
../sprite_nodes/CCAnimation.cpp \
|
||||||
|
../sprite_nodes/CCAnimationCache.cpp \
|
||||||
|
../sprite_nodes/CCSprite.cpp \
|
||||||
|
../sprite_nodes/CCSpriteBatchNode.cpp \
|
||||||
|
../sprite_nodes/CCSpriteFrame.cpp \
|
||||||
|
../sprite_nodes/CCSpriteFrameCache.cpp \
|
||||||
|
../support/ccUTF8.cpp \
|
||||||
|
../support/CCProfiling.cpp \
|
||||||
|
../support/user_default/CCUserDefault.cpp \
|
||||||
|
../support/TransformUtils.cpp \
|
||||||
|
../support/base64.cpp \
|
||||||
|
../support/ccUtils.cpp \
|
||||||
|
../support/CCVertex.cpp \
|
||||||
|
../support/CCNotificationCenter.cpp \
|
||||||
|
../support/image_support/TGAlib.cpp \
|
||||||
|
../support/tinyxml2/tinyxml2.cpp \
|
||||||
|
../support/zip_support/ZipUtils.cpp \
|
||||||
|
../support/zip_support/ioapi.cpp \
|
||||||
|
../support/zip_support/unzip.cpp \
|
||||||
|
../support/data_support/ccCArray.cpp \
|
||||||
|
../support/component/CCComponent.cpp \
|
||||||
|
../support/component/CCComponentContainer.cpp \
|
||||||
|
../text_input_node/CCIMEDispatcher.cpp \
|
||||||
|
../text_input_node/CCTextFieldTTF.cpp \
|
||||||
|
../textures/CCTexture2D.cpp \
|
||||||
|
../textures/CCTextureAtlas.cpp \
|
||||||
|
../textures/CCTextureCache.cpp \
|
||||||
|
../textures/CCTextureETC.cpp \
|
||||||
|
../textures/CCTexturePVR.cpp \
|
||||||
|
../textures/etc/etc1.cpp \
|
||||||
|
../tilemap_parallax_nodes/CCParallaxNode.cpp \
|
||||||
|
../tilemap_parallax_nodes/CCTMXLayer.cpp \
|
||||||
|
../tilemap_parallax_nodes/CCTMXObjectGroup.cpp \
|
||||||
|
../tilemap_parallax_nodes/CCTMXTiledMap.cpp \
|
||||||
|
../tilemap_parallax_nodes/CCTMXXMLParser.cpp \
|
||||||
|
../tilemap_parallax_nodes/CCTileMapAtlas.cpp \
|
||||||
|
../touch_dispatcher/CCTouchDispatcher.cpp \
|
||||||
|
../touch_dispatcher/CCTouchHandler.cpp \
|
||||||
|
../touch_dispatcher/CCTouch.cpp \
|
||||||
|
../shaders/CCGLProgram.cpp \
|
||||||
|
../shaders/ccGLStateCache.cpp \
|
||||||
|
../shaders/CCShaderCache.cpp \
|
||||||
|
../shaders/ccShaders.cpp \
|
||||||
|
../kazmath/src/aabb.c \
|
||||||
|
../kazmath/src/plane.c \
|
||||||
|
../kazmath/src/vec2.c \
|
||||||
|
../kazmath/src/mat3.c \
|
||||||
|
../kazmath/src/quaternion.c \
|
||||||
|
../kazmath/src/vec3.c \
|
||||||
|
../kazmath/src/mat4.c \
|
||||||
|
../kazmath/src/ray2.c \
|
||||||
|
../kazmath/src/vec4.c \
|
||||||
|
../kazmath/src/neon_matrix_impl.c \
|
||||||
|
../kazmath/src/utility.c \
|
||||||
|
../kazmath/src/GL/mat4stack.c \
|
||||||
|
../kazmath/src/GL/matrix.c \
|
||||||
|
../CCCamera.cpp \
|
||||||
|
../CCConfiguration.cpp \
|
||||||
|
../CCDirector.cpp \
|
||||||
|
../CCScheduler.cpp \
|
||||||
|
../ccFPSImages.c \
|
||||||
|
../ccTypes.cpp \
|
||||||
|
../cocos2d.cpp
|
||||||
|
|
||||||
|
# Headers with QObject subclasses (will be processed by moc)
|
||||||
|
HEADERS += ../platform/qt5/AccelerometerListener.h
|
||||||
|
|
||||||
|
# WebP
|
||||||
|
INCLUDEPATH += ../../external/libwebp/webp
|
||||||
|
SOURCES += $$files(../../external/libwebp/dec/*.c)
|
||||||
|
SOURCES += $$files(../../external/libwebp/dsp/*.c)
|
||||||
|
SOURCES += $$files(../../external/libwebp/utils/*.c)
|
||||||
|
|
||||||
|
# FreeType (FIXME: use pkg-config)
|
||||||
|
INCLUDEPATH += /usr/include/freetype2
|
||||||
|
|
||||||
|
INCLUDEPATH += ../../extensions
|
||||||
|
INCLUDEPATH += ../../extensions/CCBReader
|
||||||
|
INCLUDEPATH += ../../extensions/GUI/CCControlExtension
|
||||||
|
INCLUDEPATH += ../../extensions/GUI/CCControlExtension
|
||||||
|
INCLUDEPATH += ../../external/chipmunk/include/chipmunk
|
||||||
|
INCLUDEPATH += ../../extensions/network
|
||||||
|
INCLUDEPATH += ../../extensions/Components
|
||||||
|
|
||||||
|
TARGET = $${LIB_OUTPUT_DIR}/cocos2d
|
||||||
|
|
||||||
|
INSTALLS += target
|
||||||
|
target.path = $${LIB_INSTALL_DIR}
|
||||||
|
|
|
@ -0,0 +1,60 @@
|
||||||
|
|
||||||
|
DEFINES += CC_TARGET_QT5
|
||||||
|
|
||||||
|
CONFIG += silent
|
||||||
|
|
||||||
|
# Disable some warnings to make compiler output easier to read during development
|
||||||
|
DISABLED_WARNINGS = -Wno-ignored-qualifiers -Wno-unused-parameter -Wno-psabi
|
||||||
|
QMAKE_CXXFLAGS += $${DISABLED_WARNINGS} -Wno-reorder
|
||||||
|
QMAKE_CFLAGS += $${DISABLED_WARNINGS}
|
||||||
|
|
||||||
|
# C++11 support (GCC 4.6; for newer versions, change to -std=c++11)
|
||||||
|
QMAKE_CXXFLAGS += -Doverride= -std=c++0x
|
||||||
|
|
||||||
|
OS_TYPE = linux
|
||||||
|
|
||||||
|
CONFIG(debug, debug|release) {
|
||||||
|
BUILD_TYPE = debug
|
||||||
|
} else {
|
||||||
|
BUILD_TYPE = release
|
||||||
|
}
|
||||||
|
|
||||||
|
OBJECTS_DIR = obj/$${BUILD_TYPE}
|
||||||
|
MOC_DIR = obj/$${BUILD_TYPE}
|
||||||
|
LIB_OUTPUT_DIR = $${PWD}/../../lib/$${OS_TYPE}/$${BUILD_TYPE}
|
||||||
|
|
||||||
|
# Installation location of binaries
|
||||||
|
LIB_INSTALL_DIR = /usr/lib
|
||||||
|
BIN_INSTALL_DIR = /usr/bin
|
||||||
|
DESKTOP_INSTALL_DIR = /usr/share/applications
|
||||||
|
|
||||||
|
INCLUDEPATH += $${PWD}/..
|
||||||
|
INCLUDEPATH += $${PWD}/../include
|
||||||
|
INCLUDEPATH += $${PWD}/../platform
|
||||||
|
INCLUDEPATH += $${PWD}/../platform/qt5
|
||||||
|
INCLUDEPATH += $${PWD}/../kazmath/include
|
||||||
|
|
||||||
|
COCOS2DX_SYSTEM_LIBS += -lz
|
||||||
|
COCOS2DX_SYSTEM_LIBS += -ljpeg -ltiff -lpng
|
||||||
|
COCOS2DX_SYSTEM_LIBS += -lfontconfig -lfreetype
|
||||||
|
|
||||||
|
# Sensors module needed for CCAccelerometer
|
||||||
|
QT += sensors
|
||||||
|
|
||||||
|
LINK_AGAINST_COCOS2DX = -L$${LIB_OUTPUT_DIR} -lcocos2d $${COCOS2DX_SYSTEM_LIBS}
|
||||||
|
|
||||||
|
# CocosDenshion (audio library)
|
||||||
|
QT += multimedia
|
||||||
|
INCLUDEPATH += $${PWD}/../../CocosDenshion/include
|
||||||
|
LINK_AGAINST_COCOSDENSHION = -lcocosdenshion
|
||||||
|
|
||||||
|
# Extensions library
|
||||||
|
INCLUDEPATH += $${PWD}/../../extensions
|
||||||
|
LINK_AGAINST_COCOSEXTENSION = -lextension -lbox2d -lchipmunk -lcurl
|
||||||
|
|
||||||
|
# Physics engines (pick one)
|
||||||
|
DEFINES += CC_ENABLE_CHIPMUNK_INTEGRATION
|
||||||
|
#DEFINES += CC_ENABLE_BOX2D_INTEGRATION
|
||||||
|
INCLUDEPATH += $${PWD}/../../external/chipmunk/include/chipmunk
|
||||||
|
INCLUDEPATH += $${PWD}/../../external
|
||||||
|
|
|
@ -7,8 +7,11 @@
|
||||||
<buildSpec>
|
<buildSpec>
|
||||||
<buildCommand>
|
<buildCommand>
|
||||||
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
|
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
|
||||||
<triggers>clean,full,incremental,</triggers>
|
|
||||||
<arguments>
|
<arguments>
|
||||||
|
<dictionary>
|
||||||
|
<key>?children?</key>
|
||||||
|
<value>?name?=outputEntries\|?children?=?name?=entry\\\\\\\|\\\|?name?=entry\\\\\\\|\\\|?name?=entry\\\\\\\|\\\|\||</value>
|
||||||
|
</dictionary>
|
||||||
<dictionary>
|
<dictionary>
|
||||||
<key>?name?</key>
|
<key>?name?</key>
|
||||||
<value></value>
|
<value></value>
|
||||||
|
@ -31,7 +34,7 @@
|
||||||
</dictionary>
|
</dictionary>
|
||||||
<dictionary>
|
<dictionary>
|
||||||
<key>org.eclipse.cdt.make.core.buildLocation</key>
|
<key>org.eclipse.cdt.make.core.buildLocation</key>
|
||||||
<value>${workspace_loc:/cocos2dx/Debug-Tizen-Device}</value>
|
<value>${workspace_loc:/cocos2dx/Debug-Tizen-Emulator}</value>
|
||||||
</dictionary>
|
</dictionary>
|
||||||
<dictionary>
|
<dictionary>
|
||||||
<key>org.eclipse.cdt.make.core.cleanBuildTarget</key>
|
<key>org.eclipse.cdt.make.core.cleanBuildTarget</key>
|
||||||
|
@ -43,7 +46,7 @@
|
||||||
</dictionary>
|
</dictionary>
|
||||||
<dictionary>
|
<dictionary>
|
||||||
<key>org.eclipse.cdt.make.core.enableAutoBuild</key>
|
<key>org.eclipse.cdt.make.core.enableAutoBuild</key>
|
||||||
<value>false</value>
|
<value>true</value>
|
||||||
</dictionary>
|
</dictionary>
|
||||||
<dictionary>
|
<dictionary>
|
||||||
<key>org.eclipse.cdt.make.core.enableCleanBuild</key>
|
<key>org.eclipse.cdt.make.core.enableCleanBuild</key>
|
||||||
|
@ -107,6 +110,11 @@
|
||||||
<type>1</type>
|
<type>1</type>
|
||||||
<locationURI>PARENT-1-PROJECT_LOC/CCConfiguration.h</locationURI>
|
<locationURI>PARENT-1-PROJECT_LOC/CCConfiguration.h</locationURI>
|
||||||
</link>
|
</link>
|
||||||
|
<link>
|
||||||
|
<name>src/CCDeprecated.cpp</name>
|
||||||
|
<type>1</type>
|
||||||
|
<locationURI>PARENT-1-PROJECT_LOC/CCDeprecated.cpp</locationURI>
|
||||||
|
</link>
|
||||||
<link>
|
<link>
|
||||||
<name>src/CCDirector.cpp</name>
|
<name>src/CCDirector.cpp</name>
|
||||||
<type>1</type>
|
<type>1</type>
|
||||||
|
@ -347,16 +355,6 @@
|
||||||
<type>1</type>
|
<type>1</type>
|
||||||
<locationURI>PARENT-1-PROJECT_LOC/platform/CCThread.h</locationURI>
|
<locationURI>PARENT-1-PROJECT_LOC/platform/CCThread.h</locationURI>
|
||||||
</link>
|
</link>
|
||||||
<link>
|
|
||||||
<name>src/platform/platform.cpp</name>
|
|
||||||
<type>1</type>
|
|
||||||
<locationURI>PARENT-1-PROJECT_LOC/platform/platform.cpp</locationURI>
|
|
||||||
</link>
|
|
||||||
<link>
|
|
||||||
<name>src/platform/platform.h</name>
|
|
||||||
<type>1</type>
|
|
||||||
<locationURI>PARENT-1-PROJECT_LOC/platform/platform.h</locationURI>
|
|
||||||
</link>
|
|
||||||
<link>
|
<link>
|
||||||
<name>src/platform/tizen</name>
|
<name>src/platform/tizen</name>
|
||||||
<type>2</type>
|
<type>2</type>
|
||||||
|
|
|
@ -69,7 +69,7 @@
|
||||||
</PreBuildEvent>
|
</PreBuildEvent>
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<AdditionalIncludeDirectories>$(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;$(ProjectDir)..;$(ProjectDir)..\platform\win32;$(ProjectDir)..\platform\third_party\win32\iconv;$(ProjectDir)..\platform\third_party\win32\zlib;$(ProjectDir)..\platform\third_party\win32\libpng;$(ProjectDir)..\platform\third_party\win32\libjpeg;$(ProjectDir)..\platform\third_party\win32\libtiff;$(ProjectDir)..\platform\third_party\win32\libwebp;$(ProjectDir)..\platform\third_party\win32\pthread;$(ProjectDir)..\platform\third_party\win32\OGLES;..\include;$(ProjectDir)..\kazmath\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;$(ProjectDir)..;$(ProjectDir)..\platform\win32;$(ProjectDir)..\platform\third_party\win32\iconv;$(ProjectDir)..\platform\third_party\win32\zlib;$(ProjectDir)..\platform\third_party\win32\libpng;$(ProjectDir)..\platform\third_party\win32\libjpeg;$(ProjectDir)..\platform\third_party\win32\libtiff;$(ProjectDir)..\platform\third_party\win32\libwebp;$(ProjectDir)..\platform\third_party\win32\pthread;$(ProjectDir)..\platform\third_party\win32\OGLES;..\include;$(ProjectDir)..\kazmath\include;$(ProjectDir)..\platform\third_party\common\etc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<MinimalRebuild>false</MinimalRebuild>
|
<MinimalRebuild>false</MinimalRebuild>
|
||||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||||
|
@ -82,8 +82,8 @@
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<PreLinkEvent>
|
<PreLinkEvent>
|
||||||
<Command>if not exist "$(OutDir)" mkdir "$(OutDir)"
|
<Command>if not exist "$(OutDir)" mkdir "$(OutDir)"
|
||||||
xcopy /Y /Q "$(ProjectDir)..\platform\third_party\win32\libraries\*.*" "$(OutDir)"
|
xcopy /Y /Q "$(ProjectDir)..\platform\third_party\win32\libraries\*.*" "$(OutDir)"
|
||||||
</Command>
|
</Command>
|
||||||
</PreLinkEvent>
|
</PreLinkEvent>
|
||||||
<Link>
|
<Link>
|
||||||
|
@ -118,8 +118,8 @@ xcopy /Y /Q "$(ProjectDir)..\platform\third_party\win32\libraries\*.*" "$(OutDir
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<PreLinkEvent>
|
<PreLinkEvent>
|
||||||
<Command>if not exist "$(OutDir)" mkdir "$(OutDir)"
|
<Command>if not exist "$(OutDir)" mkdir "$(OutDir)"
|
||||||
xcopy /Y /Q "$(ProjectDir)..\platform\third_party\win32\libraries\*.*" "$(OutDir)"
|
xcopy /Y /Q "$(ProjectDir)..\platform\third_party\win32\libraries\*.*" "$(OutDir)"
|
||||||
</Command>
|
</Command>
|
||||||
</PreLinkEvent>
|
</PreLinkEvent>
|
||||||
<Link>
|
<Link>
|
||||||
|
@ -194,9 +194,9 @@ xcopy /Y /Q "$(ProjectDir)..\platform\third_party\win32\libraries\*.*" "$(OutDir
|
||||||
<ClCompile Include="..\particle_nodes\CCParticleSystemQuad.cpp" />
|
<ClCompile Include="..\particle_nodes\CCParticleSystemQuad.cpp" />
|
||||||
<ClCompile Include="..\platform\CCEGLViewProtocol.cpp" />
|
<ClCompile Include="..\platform\CCEGLViewProtocol.cpp" />
|
||||||
<ClCompile Include="..\platform\CCFileUtils.cpp" />
|
<ClCompile Include="..\platform\CCFileUtils.cpp" />
|
||||||
<ClCompile Include="..\platform\CCImageCommonWebp.cpp" />
|
|
||||||
<ClCompile Include="..\platform\CCSAXParser.cpp" />
|
<ClCompile Include="..\platform\CCSAXParser.cpp" />
|
||||||
<ClCompile Include="..\platform\CCThread.cpp" />
|
<ClCompile Include="..\platform\CCThread.cpp" />
|
||||||
|
<ClCompile Include="..\platform\third_party\common\etc\etc1.cpp" />
|
||||||
<ClCompile Include="..\platform\win32\CCAccelerometer.cpp" />
|
<ClCompile Include="..\platform\win32\CCAccelerometer.cpp" />
|
||||||
<ClCompile Include="..\platform\win32\CCApplication.cpp" />
|
<ClCompile Include="..\platform\win32\CCApplication.cpp" />
|
||||||
<ClCompile Include="..\platform\win32\CCCommon.cpp" />
|
<ClCompile Include="..\platform\win32\CCCommon.cpp" />
|
||||||
|
@ -234,9 +234,6 @@ xcopy /Y /Q "$(ProjectDir)..\platform\third_party\win32\libraries\*.*" "$(OutDir
|
||||||
<ClCompile Include="..\textures\CCTexture2D.cpp" />
|
<ClCompile Include="..\textures\CCTexture2D.cpp" />
|
||||||
<ClCompile Include="..\textures\CCTextureAtlas.cpp" />
|
<ClCompile Include="..\textures\CCTextureAtlas.cpp" />
|
||||||
<ClCompile Include="..\textures\CCTextureCache.cpp" />
|
<ClCompile Include="..\textures\CCTextureCache.cpp" />
|
||||||
<ClCompile Include="..\textures\CCTextureETC.cpp" />
|
|
||||||
<ClCompile Include="..\textures\CCTexturePVR.cpp" />
|
|
||||||
<ClCompile Include="..\textures\etc\etc1.cpp" />
|
|
||||||
<ClCompile Include="..\tileMap_parallax_nodes\CCParallaxNode.cpp" />
|
<ClCompile Include="..\tileMap_parallax_nodes\CCParallaxNode.cpp" />
|
||||||
<ClCompile Include="..\tileMap_parallax_nodes\CCTileMapAtlas.cpp" />
|
<ClCompile Include="..\tileMap_parallax_nodes\CCTileMapAtlas.cpp" />
|
||||||
<ClCompile Include="..\tileMap_parallax_nodes\CCTMXLayer.cpp" />
|
<ClCompile Include="..\tileMap_parallax_nodes\CCTMXLayer.cpp" />
|
||||||
|
@ -343,6 +340,8 @@ xcopy /Y /Q "$(ProjectDir)..\platform\third_party\win32\libraries\*.*" "$(OutDir
|
||||||
<ClInclude Include="..\platform\CCPlatformMacros.h" />
|
<ClInclude Include="..\platform\CCPlatformMacros.h" />
|
||||||
<ClInclude Include="..\platform\CCSAXParser.h" />
|
<ClInclude Include="..\platform\CCSAXParser.h" />
|
||||||
<ClInclude Include="..\platform\CCThread.h" />
|
<ClInclude Include="..\platform\CCThread.h" />
|
||||||
|
<ClInclude Include="..\platform\platform.h" />
|
||||||
|
<ClInclude Include="..\platform\third_party\common\etc\etc1.h" />
|
||||||
<ClInclude Include="..\platform\win32\CCAccelerometer.h" />
|
<ClInclude Include="..\platform\win32\CCAccelerometer.h" />
|
||||||
<ClInclude Include="..\platform\win32\CCApplication.h" />
|
<ClInclude Include="..\platform\win32\CCApplication.h" />
|
||||||
<ClInclude Include="..\platform\win32\CCEGLView.h" />
|
<ClInclude Include="..\platform\win32\CCEGLView.h" />
|
||||||
|
@ -397,9 +396,6 @@ xcopy /Y /Q "$(ProjectDir)..\platform\third_party\win32\libraries\*.*" "$(OutDir
|
||||||
<ClInclude Include="..\textures\CCTexture2D.h" />
|
<ClInclude Include="..\textures\CCTexture2D.h" />
|
||||||
<ClInclude Include="..\textures\CCTextureAtlas.h" />
|
<ClInclude Include="..\textures\CCTextureAtlas.h" />
|
||||||
<ClInclude Include="..\textures\CCTextureCache.h" />
|
<ClInclude Include="..\textures\CCTextureCache.h" />
|
||||||
<ClInclude Include="..\textures\CCTextureETC.h" />
|
|
||||||
<ClInclude Include="..\textures\CCTexturePVR.h" />
|
|
||||||
<ClInclude Include="..\textures\etc\etc1.h" />
|
|
||||||
<ClInclude Include="..\tileMap_parallax_nodes\CCParallaxNode.h" />
|
<ClInclude Include="..\tileMap_parallax_nodes\CCParallaxNode.h" />
|
||||||
<ClInclude Include="..\tileMap_parallax_nodes\CCTileMapAtlas.h" />
|
<ClInclude Include="..\tileMap_parallax_nodes\CCTileMapAtlas.h" />
|
||||||
<ClInclude Include="..\tileMap_parallax_nodes\CCTMXLayer.h" />
|
<ClInclude Include="..\tileMap_parallax_nodes\CCTMXLayer.h" />
|
||||||
|
|
|
@ -103,12 +103,12 @@
|
||||||
<Filter Include="support\component">
|
<Filter Include="support\component">
|
||||||
<UniqueIdentifier>{caa78ce0-9b58-4314-b117-1acae278691e}</UniqueIdentifier>
|
<UniqueIdentifier>{caa78ce0-9b58-4314-b117-1acae278691e}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter Include="textures\etc">
|
|
||||||
<UniqueIdentifier>{5e6e45aa-50ef-451b-9bb1-f98b9b78259b}</UniqueIdentifier>
|
|
||||||
</Filter>
|
|
||||||
<Filter Include="keyboard_dispatcher">
|
<Filter Include="keyboard_dispatcher">
|
||||||
<UniqueIdentifier>{e7134ba0-4220-4dd1-b120-3533883394ac}</UniqueIdentifier>
|
<UniqueIdentifier>{e7134ba0-4220-4dd1-b120-3533883394ac}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
<Filter Include="platform\etc">
|
||||||
|
<UniqueIdentifier>{47fda93e-6eb4-4abc-b5bc-725bf667a395}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="..\base_nodes\CCAtlasNode.cpp">
|
<ClCompile Include="..\base_nodes\CCAtlasNode.cpp">
|
||||||
|
@ -330,9 +330,6 @@
|
||||||
<ClCompile Include="..\textures\CCTextureCache.cpp">
|
<ClCompile Include="..\textures\CCTextureCache.cpp">
|
||||||
<Filter>textures</Filter>
|
<Filter>textures</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\textures\CCTexturePVR.cpp">
|
|
||||||
<Filter>textures</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\tileMap_parallax_nodes\CCParallaxNode.cpp">
|
<ClCompile Include="..\tileMap_parallax_nodes\CCParallaxNode.cpp">
|
||||||
<Filter>tilemap_parallax_nodes</Filter>
|
<Filter>tilemap_parallax_nodes</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -446,9 +443,6 @@
|
||||||
<ClCompile Include="..\platform\CCFileUtils.cpp">
|
<ClCompile Include="..\platform\CCFileUtils.cpp">
|
||||||
<Filter>platform</Filter>
|
<Filter>platform</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\platform\CCImageCommonWebp.cpp">
|
|
||||||
<Filter>platform</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\platform\win32\CCDevice.cpp">
|
<ClCompile Include="..\platform\win32\CCDevice.cpp">
|
||||||
<Filter>platform\win32</Filter>
|
<Filter>platform\win32</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -465,22 +459,19 @@
|
||||||
<Filter>cocoa</Filter>
|
<Filter>cocoa</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\ccFPSImages.c" />
|
<ClCompile Include="..\ccFPSImages.c" />
|
||||||
<ClCompile Include="..\textures\CCTextureETC.cpp">
|
|
||||||
<Filter>textures</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\support\component\CCComponent.cpp">
|
<ClCompile Include="..\support\component\CCComponent.cpp">
|
||||||
<Filter>support\component</Filter>
|
<Filter>support\component</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\support\component\CCComponentContainer.cpp">
|
<ClCompile Include="..\support\component\CCComponentContainer.cpp">
|
||||||
<Filter>support\component</Filter>
|
<Filter>support\component</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\textures\etc\etc1.cpp">
|
|
||||||
<Filter>textures\etc</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\keyboard_dispatcher\CCKeyboardDispatcher.cpp">
|
<ClCompile Include="..\keyboard_dispatcher\CCKeyboardDispatcher.cpp">
|
||||||
<Filter>keyboard_dispatcher</Filter>
|
<Filter>keyboard_dispatcher</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\ccTypes.cpp" />
|
<ClCompile Include="..\ccTypes.cpp" />
|
||||||
|
<ClCompile Include="..\platform\third_party\common\etc\etc1.cpp">
|
||||||
|
<Filter>platform\etc</Filter>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="..\CCDeprecated.cpp" />
|
<ClCompile Include="..\CCDeprecated.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -754,9 +745,6 @@
|
||||||
<ClInclude Include="..\textures\CCTextureCache.h">
|
<ClInclude Include="..\textures\CCTextureCache.h">
|
||||||
<Filter>textures</Filter>
|
<Filter>textures</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\textures\CCTexturePVR.h">
|
|
||||||
<Filter>textures</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\tileMap_parallax_nodes\CCParallaxNode.h">
|
<ClInclude Include="..\tileMap_parallax_nodes\CCParallaxNode.h">
|
||||||
<Filter>tilemap_parallax_nodes</Filter>
|
<Filter>tilemap_parallax_nodes</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
@ -944,9 +932,6 @@
|
||||||
<ClInclude Include="..\cocoa\CCFloat.h">
|
<ClInclude Include="..\cocoa\CCFloat.h">
|
||||||
<Filter>cocoa</Filter>
|
<Filter>cocoa</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\textures\CCTextureETC.h">
|
|
||||||
<Filter>textures</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\ccFPSImages.h" />
|
<ClInclude Include="..\ccFPSImages.h" />
|
||||||
<ClInclude Include="..\support\component\CCComponentContainer.h">
|
<ClInclude Include="..\support\component\CCComponentContainer.h">
|
||||||
<Filter>support\component</Filter>
|
<Filter>support\component</Filter>
|
||||||
|
@ -954,14 +939,15 @@
|
||||||
<ClInclude Include="..\support\component\CCComponent.h">
|
<ClInclude Include="..\support\component\CCComponent.h">
|
||||||
<Filter>support\component</Filter>
|
<Filter>support\component</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\textures\etc\etc1.h">
|
|
||||||
<Filter>textures\etc</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\keyboard_dispatcher\CCKeyboardDispatcher.h">
|
<ClInclude Include="..\keyboard_dispatcher\CCKeyboardDispatcher.h">
|
||||||
<Filter>keyboard_dispatcher</Filter>
|
<Filter>keyboard_dispatcher</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\include\CCDeprecated.h">
|
<ClInclude Include="..\include\CCDeprecated.h">
|
||||||
<Filter>include</Filter>
|
<Filter>include</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\platform\third_party\common\etc\etc1.h">
|
||||||
|
<Filter>platform\etc</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\platform\platform.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -808,15 +808,15 @@ void Sprite::setSkewY(float sy)
|
||||||
SET_DIRTY_RECURSIVELY();
|
SET_DIRTY_RECURSIVELY();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sprite::setScaleX(float fScaleX)
|
void Sprite::setScaleX(float scaleX)
|
||||||
{
|
{
|
||||||
Node::setScaleX(fScaleX);
|
Node::setScaleX(scaleX);
|
||||||
SET_DIRTY_RECURSIVELY();
|
SET_DIRTY_RECURSIVELY();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sprite::setScaleY(float fScaleY)
|
void Sprite::setScaleY(float scaleY)
|
||||||
{
|
{
|
||||||
Node::setScaleY(fScaleY);
|
Node::setScaleY(scaleY);
|
||||||
SET_DIRTY_RECURSIVELY();
|
SET_DIRTY_RECURSIVELY();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1099,8 +1099,8 @@ void Sprite::setTexture(Texture2D *texture)
|
||||||
if (NULL == texture)
|
if (NULL == texture)
|
||||||
{
|
{
|
||||||
Image* image = new Image();
|
Image* image = new Image();
|
||||||
bool isOK = image->initWithImageData(cc_2x2_white_image, sizeof(cc_2x2_white_image), Image::Format::RAW_DATA, 2, 2, 8);
|
bool isOK = image->initWithRawData(cc_2x2_white_image, sizeof(cc_2x2_white_image), 2, 2, 8);
|
||||||
CCASSERT(isOK, "The 2x2 empty texture was created unsuccessfully.");
|
CCAssert(isOK, "The 2x2 empty texture was created unsuccessfully.");
|
||||||
|
|
||||||
texture = TextureCache::getInstance()->addUIImage(image, CC_2x2_WHITE_IMAGE_KEY);
|
texture = TextureCache::getInstance()->addUIImage(image, CC_2x2_WHITE_IMAGE_KEY);
|
||||||
CC_SAFE_RELEASE(image);
|
CC_SAFE_RELEASE(image);
|
||||||
|
|
|
@ -456,8 +456,8 @@ public:
|
||||||
|
|
||||||
/// @{
|
/// @{
|
||||||
/// @name Functions inherited from Node
|
/// @name Functions inherited from Node
|
||||||
virtual void setScaleX(float fScaleX) override;
|
virtual void setScaleX(float scaleX) override;
|
||||||
virtual void setScaleY(float fScaleY) override;
|
virtual void setScaleY(float scaleY) override;
|
||||||
virtual void setPosition(const Point& pos) override;
|
virtual void setPosition(const Point& pos) override;
|
||||||
virtual void setRotation(float fRotation) override;
|
virtual void setRotation(float fRotation) override;
|
||||||
virtual void setRotationX(float fRotationX) override;
|
virtual void setRotationX(float fRotationX) override;
|
||||||
|
|
|
@ -300,10 +300,157 @@ int ZipUtils::ccInflateGZipFile(const char *path, unsigned char **out)
|
||||||
return offset;
|
return offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ZipUtils::ccIsCCZFile(const char *path)
|
||||||
|
{
|
||||||
|
// load file into memory
|
||||||
|
unsigned char* compressed = NULL;
|
||||||
|
|
||||||
|
unsigned long fileLen = 0;
|
||||||
|
compressed = FileUtils::getInstance()->getFileData(path, "rb", &fileLen);
|
||||||
|
|
||||||
|
if(NULL == compressed || 0 == fileLen)
|
||||||
|
{
|
||||||
|
CCLOG("cocos2d: ZipUtils: loading file failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ccIsCCZBuffer(compressed, fileLen);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ZipUtils::ccIsCCZBuffer(const unsigned char *buffer, int len)
|
||||||
|
{
|
||||||
|
if (len < sizeof(struct CCZHeader))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct CCZHeader *header = (struct CCZHeader*) buffer;
|
||||||
|
return header->sig[0] == 'C' && header->sig[1] == 'C' && header->sig[2] == 'Z' && (header->sig[3] == '!' || header->sig[3] == 'p');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool ZipUtils::ccIsGZipFile(const char *path)
|
||||||
|
{
|
||||||
|
// load file into memory
|
||||||
|
unsigned char* compressed = NULL;
|
||||||
|
|
||||||
|
unsigned long fileLen = 0;
|
||||||
|
compressed = FileUtils::getInstance()->getFileData(path, "rb", &fileLen);
|
||||||
|
|
||||||
|
if(NULL == compressed || 0 == fileLen)
|
||||||
|
{
|
||||||
|
CCLOG("cocos2d: ZipUtils: loading file failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ccIsGZipBuffer(compressed, fileLen);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ZipUtils::ccIsGZipBuffer(const unsigned char *buffer, int len)
|
||||||
|
{
|
||||||
|
if (len < 2)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return buffer[0] == 0x1F && buffer[1] == 0x8B;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int ZipUtils::ccInflateCCZBuffer(const unsigned char *buffer, int bufferLen, unsigned char **out)
|
||||||
|
{
|
||||||
|
struct CCZHeader *header = (struct CCZHeader*) buffer;
|
||||||
|
|
||||||
|
// verify header
|
||||||
|
if( header->sig[0] == 'C' && header->sig[1] == 'C' && header->sig[2] == 'Z' && header->sig[3] == '!' )
|
||||||
|
{
|
||||||
|
// verify header version
|
||||||
|
unsigned int version = CC_SWAP_INT16_BIG_TO_HOST( header->version );
|
||||||
|
if( version > 2 )
|
||||||
|
{
|
||||||
|
CCLOG("cocos2d: Unsupported CCZ header format");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// verify compression format
|
||||||
|
if( CC_SWAP_INT16_BIG_TO_HOST(header->compression_type) != CCZ_COMPRESSION_ZLIB )
|
||||||
|
{
|
||||||
|
CCLOG("cocos2d: CCZ Unsupported compression method");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if( header->sig[0] == 'C' && header->sig[1] == 'C' && header->sig[2] == 'Z' && header->sig[3] == 'p' )
|
||||||
|
{
|
||||||
|
// encrypted ccz file
|
||||||
|
header = (struct CCZHeader*) buffer;
|
||||||
|
|
||||||
|
// verify header version
|
||||||
|
unsigned int version = CC_SWAP_INT16_BIG_TO_HOST( header->version );
|
||||||
|
if( version > 0 )
|
||||||
|
{
|
||||||
|
CCLOG("cocos2d: Unsupported CCZ header format");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// verify compression format
|
||||||
|
if( CC_SWAP_INT16_BIG_TO_HOST(header->compression_type) != CCZ_COMPRESSION_ZLIB )
|
||||||
|
{
|
||||||
|
CCLOG("cocos2d: CCZ Unsupported compression method");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// decrypt
|
||||||
|
unsigned int* ints = (unsigned int*)(buffer+12);
|
||||||
|
int enclen = (bufferLen-12)/4;
|
||||||
|
|
||||||
|
ccDecodeEncodedPvr(ints, enclen);
|
||||||
|
|
||||||
|
#if COCOS2D_DEBUG > 0
|
||||||
|
// verify checksum in debug mode
|
||||||
|
unsigned int calculated = ccChecksumPvr(ints, enclen);
|
||||||
|
unsigned int required = CC_SWAP_INT32_BIG_TO_HOST( header->reserved );
|
||||||
|
|
||||||
|
if(calculated != required)
|
||||||
|
{
|
||||||
|
CCLOG("cocos2d: Can't decrypt image file. Is the decryption key valid?");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CCLOG("cocos2d: Invalid CCZ file");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int len = CC_SWAP_INT32_BIG_TO_HOST( header->len );
|
||||||
|
|
||||||
|
*out = (unsigned char*)malloc( len );
|
||||||
|
if(! *out )
|
||||||
|
{
|
||||||
|
CCLOG("cocos2d: CCZ: Failed to allocate memory for texture");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned long destlen = len;
|
||||||
|
unsigned long source = (unsigned long) buffer + sizeof(*header);
|
||||||
|
int ret = uncompress(*out, &destlen, (Bytef*)source, bufferLen - sizeof(*header) );
|
||||||
|
|
||||||
|
if( ret != Z_OK )
|
||||||
|
{
|
||||||
|
CCLOG("cocos2d: CCZ: Failed to uncompress data");
|
||||||
|
free( *out );
|
||||||
|
*out = NULL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
int ZipUtils::ccInflateCCZFile(const char *path, unsigned char **out)
|
int ZipUtils::ccInflateCCZFile(const char *path, unsigned char **out)
|
||||||
{
|
{
|
||||||
CCASSERT(out, "");
|
CCAssert(out, "");
|
||||||
CCASSERT(&*out, "");
|
CCAssert(&*out, "");
|
||||||
|
|
||||||
// load file into memory
|
// load file into memory
|
||||||
unsigned char* compressed = NULL;
|
unsigned char* compressed = NULL;
|
||||||
|
@ -317,101 +464,7 @@ int ZipUtils::ccInflateCCZFile(const char *path, unsigned char **out)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct CCZHeader *header = (struct CCZHeader*) compressed;
|
return ccInflateCCZBuffer(compressed, fileLen, out);
|
||||||
|
|
||||||
// verify header
|
|
||||||
if( header->sig[0] == 'C' && header->sig[1] == 'C' && header->sig[2] == 'Z' && header->sig[3] == '!' )
|
|
||||||
{
|
|
||||||
// verify header version
|
|
||||||
unsigned int version = CC_SWAP_INT16_BIG_TO_HOST( header->version );
|
|
||||||
if( version > 2 )
|
|
||||||
{
|
|
||||||
CCLOG("cocos2d: Unsupported CCZ header format");
|
|
||||||
delete [] compressed;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// verify compression format
|
|
||||||
if( CC_SWAP_INT16_BIG_TO_HOST(header->compression_type) != CCZ_COMPRESSION_ZLIB )
|
|
||||||
{
|
|
||||||
CCLOG("cocos2d: CCZ Unsupported compression method");
|
|
||||||
delete [] compressed;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if( header->sig[0] == 'C' && header->sig[1] == 'C' && header->sig[2] == 'Z' && header->sig[3] == 'p' )
|
|
||||||
{
|
|
||||||
// encrypted ccz file
|
|
||||||
header = (struct CCZHeader*) compressed;
|
|
||||||
|
|
||||||
// verify header version
|
|
||||||
unsigned int version = CC_SWAP_INT16_BIG_TO_HOST( header->version );
|
|
||||||
if( version > 0 )
|
|
||||||
{
|
|
||||||
CCLOG("cocos2d: Unsupported CCZ header format");
|
|
||||||
delete [] compressed;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// verify compression format
|
|
||||||
if( CC_SWAP_INT16_BIG_TO_HOST(header->compression_type) != CCZ_COMPRESSION_ZLIB )
|
|
||||||
{
|
|
||||||
CCLOG("cocos2d: CCZ Unsupported compression method");
|
|
||||||
delete [] compressed;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// decrypt
|
|
||||||
unsigned int* ints = (unsigned int*)(compressed+12);
|
|
||||||
int enclen = (fileLen-12)/4;
|
|
||||||
|
|
||||||
ccDecodeEncodedPvr(ints, enclen);
|
|
||||||
|
|
||||||
#if COCOS2D_DEBUG > 0
|
|
||||||
// verify checksum in debug mode
|
|
||||||
unsigned int calculated = ccChecksumPvr(ints, enclen);
|
|
||||||
unsigned int required = CC_SWAP_INT32_BIG_TO_HOST( header->reserved );
|
|
||||||
|
|
||||||
if(calculated != required)
|
|
||||||
{
|
|
||||||
CCLOG("cocos2d: Can't decrypt image file. Is the decryption key valid?");
|
|
||||||
delete [] compressed;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
CCLOG("cocos2d: Invalid CCZ file");
|
|
||||||
delete [] compressed;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int len = CC_SWAP_INT32_BIG_TO_HOST( header->len );
|
|
||||||
|
|
||||||
*out = (unsigned char*)malloc( len );
|
|
||||||
if(! *out )
|
|
||||||
{
|
|
||||||
CCLOG("cocos2d: CCZ: Failed to allocate memory for texture");
|
|
||||||
delete [] compressed;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned long destlen = len;
|
|
||||||
unsigned long source = (unsigned long) compressed + sizeof(*header);
|
|
||||||
int ret = uncompress(*out, &destlen, (Bytef*)source, fileLen - sizeof(*header) );
|
|
||||||
|
|
||||||
delete [] compressed;
|
|
||||||
|
|
||||||
if( ret != Z_OK )
|
|
||||||
{
|
|
||||||
CCLOG("cocos2d: CCZ: Failed to uncompress data");
|
|
||||||
free( *out );
|
|
||||||
*out = NULL;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return len;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZipUtils::ccSetPvrEncryptionKeyPart(int index, unsigned int value)
|
void ZipUtils::ccSetPvrEncryptionKeyPart(int index, unsigned int value)
|
||||||
|
|
|
@ -85,6 +85,22 @@ namespace cocos2d
|
||||||
* @since v0.99.5
|
* @since v0.99.5
|
||||||
*/
|
*/
|
||||||
static int ccInflateGZipFile(const char *filename, unsigned char **out);
|
static int ccInflateGZipFile(const char *filename, unsigned char **out);
|
||||||
|
|
||||||
|
/** test a file is a GZip format file or not
|
||||||
|
*
|
||||||
|
* @returns true is a GZip format file. false is not
|
||||||
|
*
|
||||||
|
* @since v3.0
|
||||||
|
*/
|
||||||
|
static bool ccIsGZipFile(const char *filename);
|
||||||
|
|
||||||
|
/** test the buffer is GZip format or not
|
||||||
|
*
|
||||||
|
* @returns true is GZip format. false is not
|
||||||
|
*
|
||||||
|
* @since v3.0
|
||||||
|
*/
|
||||||
|
static bool ccIsGZipBuffer(const unsigned char *buffer, int len);
|
||||||
|
|
||||||
/** inflates a CCZ file into memory
|
/** inflates a CCZ file into memory
|
||||||
*
|
*
|
||||||
|
@ -94,6 +110,30 @@ namespace cocos2d
|
||||||
*/
|
*/
|
||||||
static int ccInflateCCZFile(const char *filename, unsigned char **out);
|
static int ccInflateCCZFile(const char *filename, unsigned char **out);
|
||||||
|
|
||||||
|
/** inflates a buffer with CCZ format into memory
|
||||||
|
*
|
||||||
|
* @returns the length of the deflated buffer
|
||||||
|
*
|
||||||
|
* @since v3.0
|
||||||
|
*/
|
||||||
|
static int ccInflateCCZBuffer(const unsigned char *buffer, int len, unsigned char **out);
|
||||||
|
|
||||||
|
/** test a file is a CCZ format file or not
|
||||||
|
*
|
||||||
|
* @returns true is a CCZ format file. false is not
|
||||||
|
*
|
||||||
|
* @since v3.0
|
||||||
|
*/
|
||||||
|
static bool ccIsCCZFile(const char *filename);
|
||||||
|
|
||||||
|
/** test the buffer is CCZ format or not
|
||||||
|
*
|
||||||
|
* @returns true is CCZ format. false is not
|
||||||
|
*
|
||||||
|
* @since v3.0
|
||||||
|
*/
|
||||||
|
static bool ccIsCCZBuffer(const unsigned char *buffer, int len);
|
||||||
|
|
||||||
/** Sets the pvr.ccz encryption key parts separately for added
|
/** Sets the pvr.ccz encryption key parts separately for added
|
||||||
* security.
|
* security.
|
||||||
*
|
*
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -27,6 +27,8 @@ THE SOFTWARE.
|
||||||
#define __CCTEXTURE2D_H__
|
#define __CCTEXTURE2D_H__
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
#include "cocoa/CCObject.h"
|
#include "cocoa/CCObject.h"
|
||||||
#include "cocoa/CCGeometry.h"
|
#include "cocoa/CCGeometry.h"
|
||||||
#include "ccTypes.h"
|
#include "ccTypes.h"
|
||||||
|
@ -37,6 +39,7 @@ THE SOFTWARE.
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
|
|
||||||
class Image;
|
class Image;
|
||||||
|
typedef struct _MipmapInfo MipmapInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @addtogroup textures
|
* @addtogroup textures
|
||||||
|
@ -76,7 +79,10 @@ public:
|
||||||
*/
|
*/
|
||||||
enum class PixelFormat
|
enum class PixelFormat
|
||||||
{
|
{
|
||||||
|
//! auto detect the type
|
||||||
|
AUTO,
|
||||||
|
//! 32-bit texture: BGRA8888
|
||||||
|
BGRA8888,
|
||||||
//! 32-bit texture: RGBA8888
|
//! 32-bit texture: RGBA8888
|
||||||
RGBA8888,
|
RGBA8888,
|
||||||
//! 24-bit texture: RGBA888
|
//! 24-bit texture: RGBA888
|
||||||
|
@ -94,12 +100,20 @@ public:
|
||||||
//! 16-bit textures: RGB5A1
|
//! 16-bit textures: RGB5A1
|
||||||
RGB5A1,
|
RGB5A1,
|
||||||
//! 4-bit PVRTC-compressed texture: PVRTC4
|
//! 4-bit PVRTC-compressed texture: PVRTC4
|
||||||
PRVTC4,
|
PVRTC4,
|
||||||
|
//! 4-bit PVRTC-compressed texture: PVRTC4 (has alpha channel)
|
||||||
|
PVRTC4A,
|
||||||
//! 2-bit PVRTC-compressed texture: PVRTC2
|
//! 2-bit PVRTC-compressed texture: PVRTC2
|
||||||
PRVTC2,
|
PVRTC2,
|
||||||
|
//! 2-bit PVRTC-compressed texture: PVRTC2 (has alpha channel)
|
||||||
|
PVRTC2A,
|
||||||
|
//! ETC-compressed texture: ETC
|
||||||
|
ETC,
|
||||||
|
|
||||||
//! Default texture format: RGBA8888
|
//! Default texture format: AUTO
|
||||||
DEFAULT = RGBA8888
|
DEFAULT = AUTO,
|
||||||
|
|
||||||
|
NONE = -1
|
||||||
};
|
};
|
||||||
|
|
||||||
/** sets the default pixel format for UIImagescontains alpha channel.
|
/** sets the default pixel format for UIImagescontains alpha channel.
|
||||||
|
@ -148,7 +162,10 @@ public:
|
||||||
void* keepData(void *data, unsigned int length);
|
void* keepData(void *data, unsigned int length);
|
||||||
|
|
||||||
/** Initializes with a texture2d with data */
|
/** Initializes with a texture2d with data */
|
||||||
bool initWithData(const void* data, Texture2D::PixelFormat pixelFormat, unsigned int pixelsWide, unsigned int pixelsHigh, const Size& contentSize);
|
bool initWithData(const void *data, int dataLen, Texture2D::PixelFormat pixelFormat, unsigned int pixelsWide, unsigned int pixelsHigh, const Size& contentSize);
|
||||||
|
|
||||||
|
/** Initializes with mipmaps */
|
||||||
|
bool initWithMipmaps(MipmapInfo* mipmaps, int mipmapsNum, Texture2D::PixelFormat pixelFormat, unsigned int pixelsWide, unsigned int pixelsHigh);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Drawing extensions to make it easy to draw basic quads using a Texture2D object.
|
Drawing extensions to make it easy to draw basic quads using a Texture2D object.
|
||||||
|
@ -161,22 +178,25 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Extensions to make it easy to create a Texture2D object from an image file.
|
Extensions to make it easy to create a Texture2D object from an image file.
|
||||||
Note that RGBA type textures will have their alpha premultiplied - use the blending mode (GL_ONE, GL_ONE_MINUS_SRC_ALPHA).
|
|
||||||
*/
|
*/
|
||||||
/** Initializes a texture from a UIImage object */
|
/**
|
||||||
|
Initializes a texture from a UIImage object.
|
||||||
|
We will use the format you specified with setDefaultAlphaPixelFormat to convert the image for texture.
|
||||||
|
NOTE: It will not convert the pvr image file.
|
||||||
|
*/
|
||||||
bool initWithImage(Image * uiImage);
|
bool initWithImage(Image * uiImage);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Initializes a texture from a UIImage object.
|
||||||
|
we will use the format you passed to the function to convert the image format to the texture format.
|
||||||
|
If you pass PixelFormat::Automatic, we will auto detect the image render type and use that type for texture to render.
|
||||||
|
**/
|
||||||
|
bool initWithImage(Image * uiImage, PixelFormat format);
|
||||||
|
|
||||||
/** Initializes a texture from a string with dimensions, alignment, font name and font size */
|
/** Initializes a texture from a string with dimensions, alignment, font name and font size */
|
||||||
bool initWithString(const char *text, const char *fontName, float fontSize, const Size& dimensions = Size(0, 0), TextHAlignment hAlignment = TextHAlignment::CENTER, TextVAlignment vAlignment = TextVAlignment::TOP);
|
bool initWithString(const char *text, const char *fontName, float fontSize, const Size& dimensions = Size(0, 0), TextHAlignment hAlignment = TextHAlignment::CENTER, TextVAlignment vAlignment = TextVAlignment::TOP);
|
||||||
/** Initializes a texture from a string using a text definition*/
|
/** Initializes a texture from a string using a text definition*/
|
||||||
bool initWithString(const char *text, const FontDefinition& textDefinition);
|
bool initWithString(const char *text, const FontDefinition& textDefinition);
|
||||||
|
|
||||||
/** Initializes a texture from a PVR file */
|
|
||||||
bool initWithPVRFile(const char* file);
|
|
||||||
|
|
||||||
/** Initializes a texture from a ETC file */
|
|
||||||
bool initWithETCFile(const char* file);
|
|
||||||
|
|
||||||
/** sets the min filter, mag filter, wrap s and wrap t texture parameters.
|
/** sets the min filter, mag filter, wrap s and wrap t texture parameters.
|
||||||
If the texture size is NPOT (non power of 2), then in can only use GL_CLAMP_TO_EDGE in GL_TEXTURE_WRAP_{S,T}.
|
If the texture size is NPOT (non power of 2), then in can only use GL_CLAMP_TO_EDGE in GL_TEXTURE_WRAP_{S,T}.
|
||||||
|
@ -267,10 +287,53 @@ public:
|
||||||
GLProgram* getShaderProgram() const;
|
GLProgram* getShaderProgram() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool initPremultipliedATextureWithImage(Image * image, unsigned int pixelsWide, unsigned int pixelsHigh);
|
|
||||||
|
/**convert functions*/
|
||||||
// By default PVR images are treated as if they don't have the alpha channel premultiplied
|
|
||||||
bool _PVRHaveAlphaPremultiplied;
|
/**
|
||||||
|
Convert the format to the format param you specified, if the format is PixelFormat::Automatic, it will detect it automatically and convert to the closest format for you.
|
||||||
|
It will return the converted format to you. if the outData != data, you must delete it manually.
|
||||||
|
*/
|
||||||
|
static PixelFormat convertDataToFormat(const unsigned char* data, int dataLen, PixelFormat originFormat, PixelFormat format, unsigned char** outData, int* outDataLen);
|
||||||
|
|
||||||
|
static PixelFormat convertI8ToFormat(const unsigned char* data, int dataLen, PixelFormat format, unsigned char** outData, int* outDataLen);
|
||||||
|
static PixelFormat convertAI88ToFormat(const unsigned char* data, int dataLen, PixelFormat format, unsigned char** outData, int* outDataLen);
|
||||||
|
static PixelFormat convertRGB888ToFormat(const unsigned char* data, int dataLen, PixelFormat format, unsigned char** outData, int* outDataLen);
|
||||||
|
static PixelFormat convertRGBA8888ToFormat(const unsigned char* data, int dataLen, PixelFormat format, unsigned char** outData, int* outDataLen);
|
||||||
|
|
||||||
|
//I8 to XXX
|
||||||
|
static void convertI8ToRGB888(const unsigned char* in, int len, unsigned char* out);
|
||||||
|
static void convertI8ToRGBA8888(const unsigned char* in, int len, unsigned char* out);
|
||||||
|
static void convertI8ToRGB565(const unsigned char* in, int len, unsigned char* out);
|
||||||
|
static void convertI8ToRGBA4444(const unsigned char* in, int len, unsigned char* out);
|
||||||
|
static void convertI8ToRGB5A1(const unsigned char* in, int len, unsigned char* out);
|
||||||
|
static void convertI8ToAI88(const unsigned char* in, int len, unsigned char* out);
|
||||||
|
|
||||||
|
//AI88 to XXX
|
||||||
|
static void convertAI88ToRGB888(const unsigned char* in, int len, unsigned char* out);
|
||||||
|
static void convertAI88ToRGBA8888(const unsigned char* in, int len, unsigned char* out);
|
||||||
|
static void convertAI88ToRGB565(const unsigned char* in, int len, unsigned char* out);
|
||||||
|
static void convertAI88ToRGBA4444(const unsigned char* in, int len, unsigned char* out);
|
||||||
|
static void convertAI88ToRGB5A1(const unsigned char* in, int len, unsigned char* out);
|
||||||
|
static void convertAI88ToA8(const unsigned char* in, int len, unsigned char* out);
|
||||||
|
static void convertAI88ToI8(const unsigned char* in, int len, unsigned char* out);
|
||||||
|
|
||||||
|
//RGB888 to XXX
|
||||||
|
static void convertRGB888ToRGBA8888(const unsigned char* in, int len, unsigned char* out);
|
||||||
|
static void convertRGB888ToRGB565(const unsigned char* in, int len, unsigned char* out);
|
||||||
|
static void convertRGB888ToI8(const unsigned char* in, int len, unsigned char* out);
|
||||||
|
static void convertRGB888ToAI88(const unsigned char* in, int len, unsigned char* out);
|
||||||
|
static void convertRGB888ToRGBA4444(const unsigned char* in, int len, unsigned char* out);
|
||||||
|
static void convertRGB888ToRGB5A1(const unsigned char* in, int len, unsigned char* out);
|
||||||
|
|
||||||
|
//RGBA8888 to XXX
|
||||||
|
static void convertRGBA8888ToRGB888(const unsigned char* in, int len, unsigned char* out);
|
||||||
|
static void convertRGBA8888ToRGB565(const unsigned char* in, int len, unsigned char* out);
|
||||||
|
static void convertRGBA8888ToI8(const unsigned char* in, int len, unsigned char* out);
|
||||||
|
static void convertRGBA8888ToA8(const unsigned char* in, int len, unsigned char* out);
|
||||||
|
static void convertRGBA8888ToAI88(const unsigned char* in, int len, unsigned char* out);
|
||||||
|
static void convertRGBA8888ToRGBA4444(const unsigned char* in, int len, unsigned char* out);
|
||||||
|
static void convertRGBA8888ToRGB5A1(const unsigned char* in, int len, unsigned char* out);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** pixel format of the texture */
|
/** pixel format of the texture */
|
||||||
|
@ -303,6 +366,49 @@ protected:
|
||||||
GLProgram* _shaderProgram;
|
GLProgram* _shaderProgram;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class TexturePixelFormatInfo {
|
||||||
|
public:
|
||||||
|
GLenum internalFormat;
|
||||||
|
GLenum format;
|
||||||
|
GLenum type;
|
||||||
|
int bpp;
|
||||||
|
bool compressed;
|
||||||
|
bool alpha;
|
||||||
|
|
||||||
|
TexturePixelFormatInfo(GLenum internalFormat, GLenum format, GLenum type, int bpp, bool compressed, bool alpha)
|
||||||
|
:internalFormat(internalFormat), format(format), type(type), bpp(bpp), compressed(compressed), alpha(alpha){}
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef const std::map<Texture2D::PixelFormat, const TexturePixelFormatInfo> ConstTexturePixelFormatInfoMap;
|
||||||
|
typedef const ConstTexturePixelFormatInfoMap::value_type ConstTexturePixelFormatInfoMapValue;
|
||||||
|
|
||||||
|
static ConstTexturePixelFormatInfoMapValue TexturePixelFormatInfoTablesValue[] =
|
||||||
|
{
|
||||||
|
ConstTexturePixelFormatInfoMapValue(Texture2D::PixelFormat::BGRA8888, TexturePixelFormatInfo(GL_RGBA, GL_BGRA, GL_UNSIGNED_BYTE, 32, false, true)),
|
||||||
|
ConstTexturePixelFormatInfoMapValue(Texture2D::PixelFormat::RGBA8888, TexturePixelFormatInfo(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, 32, false, true)),
|
||||||
|
ConstTexturePixelFormatInfoMapValue(Texture2D::PixelFormat::RGBA4444, TexturePixelFormatInfo(GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 16, false, true)),
|
||||||
|
ConstTexturePixelFormatInfoMapValue(Texture2D::PixelFormat::RGB5A1, TexturePixelFormatInfo(GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, 16, false, true)),
|
||||||
|
ConstTexturePixelFormatInfoMapValue(Texture2D::PixelFormat::RGB565, TexturePixelFormatInfo(GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, 16, false, false)),
|
||||||
|
ConstTexturePixelFormatInfoMapValue(Texture2D::PixelFormat::RGB888, TexturePixelFormatInfo(GL_RGB, GL_RGB, GL_UNSIGNED_BYTE, 24, false, false)),
|
||||||
|
ConstTexturePixelFormatInfoMapValue(Texture2D::PixelFormat::A8, TexturePixelFormatInfo(GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE, 8, false, false)),
|
||||||
|
ConstTexturePixelFormatInfoMapValue(Texture2D::PixelFormat::I8, TexturePixelFormatInfo(GL_LUMINANCE, GL_LUMINANCE, GL_UNSIGNED_BYTE, 8, false, false)),
|
||||||
|
ConstTexturePixelFormatInfoMapValue(Texture2D::PixelFormat::AI88, TexturePixelFormatInfo(GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, 16, false, true)),
|
||||||
|
|
||||||
|
#ifdef GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG
|
||||||
|
ConstTexturePixelFormatInfoMapValue(Texture2D::PixelFormat::PVRTC2, TexturePixelFormatInfo(GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG, 0xFFFFFFFF, 0xFFFFFFFF, 2, true, false)),
|
||||||
|
ConstTexturePixelFormatInfoMapValue(Texture2D::PixelFormat::PVRTC2A, TexturePixelFormatInfo(GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG, 0xFFFFFFFF, 0xFFFFFFFF, 2, true, true)),
|
||||||
|
ConstTexturePixelFormatInfoMapValue(Texture2D::PixelFormat::PVRTC4, TexturePixelFormatInfo(GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG, 0xFFFFFFFF, 0xFFFFFFFF, 4, true, false)),
|
||||||
|
ConstTexturePixelFormatInfoMapValue(Texture2D::PixelFormat::PVRTC4A, TexturePixelFormatInfo(GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, 0xFFFFFFFF, 0xFFFFFFFF, 4, true, true)),
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef GL_ETC1_RGB8_OES
|
||||||
|
ConstTexturePixelFormatInfoMapValue(Texture2D::PixelFormat::ETC, TexturePixelFormatInfo(GL_ETC1_RGB8_OES, 0xFFFFFFFF, 0xFFFFFFFF, 24, true, false)),
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
static ConstTexturePixelFormatInfoMap g_texturePixelFormatInfoTables(TexturePixelFormatInfoTablesValue,
|
||||||
|
TexturePixelFormatInfoTablesValue + sizeof(TexturePixelFormatInfoTablesValue) / sizeof(TexturePixelFormatInfoTablesValue[0]));
|
||||||
|
|
||||||
// end of textures group
|
// end of textures group
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue