summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2018-01-06 16:36:49 -0300
committerJuan Linietsky <reduzio@gmail.com>2018-01-06 16:38:36 -0300
commit50b975548dcd65a9506e7fb449d40404320c0983 (patch)
treeabc9f7287fb6a0d539de897ca69c318c0cbdb8f7 /modules
parentb6989d0b511ef4003d33f5987a5dafc45cb3a1cf (diff)
Removed PBM bitmap loader, added abiliy to importi mages as bitmap. Fixes #14828
Diffstat (limited to 'modules')
-rw-r--r--modules/gdnative/gdnative.cpp2
-rw-r--r--modules/pbm/SCsub8
-rw-r--r--modules/pbm/bitmap_loader_pbm.cpp237
-rw-r--r--modules/pbm/bitmap_loader_pbm.h48
-rw-r--r--modules/pbm/config.py5
-rw-r--r--modules/pbm/register_types.cpp46
-rw-r--r--modules/pbm/register_types.h32
7 files changed, 0 insertions, 378 deletions
diff --git a/modules/gdnative/gdnative.cpp b/modules/gdnative/gdnative.cpp
index dec42dc17a..1379083b42 100644
--- a/modules/gdnative/gdnative.cpp
+++ b/modules/gdnative/gdnative.cpp
@@ -399,7 +399,6 @@ RES GDNativeLibraryResourceLoader::load(const String &p_path, const String &p_or
}
void GDNativeLibraryResourceLoader::get_recognized_extensions(List<String> *p_extensions) const {
- p_extensions->clear();
p_extensions->push_back("gdnlib");
}
@@ -438,7 +437,6 @@ bool GDNativeLibraryResourceSaver::recognize(const RES &p_resource) const {
void GDNativeLibraryResourceSaver::get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const {
if (Object::cast_to<GDNativeLibrary>(*p_resource) != NULL) {
- p_extensions->clear();
p_extensions->push_back("gdnlib");
}
}
diff --git a/modules/pbm/SCsub b/modules/pbm/SCsub
deleted file mode 100644
index fa328be025..0000000000
--- a/modules/pbm/SCsub
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/usr/bin/env python
-
-Import('env')
-Import('env_modules')
-
-env_pbm = env_modules.Clone()
-
-env_pbm.add_source_files(env.modules_sources, "*.cpp")
diff --git a/modules/pbm/bitmap_loader_pbm.cpp b/modules/pbm/bitmap_loader_pbm.cpp
deleted file mode 100644
index 805528ebfe..0000000000
--- a/modules/pbm/bitmap_loader_pbm.cpp
+++ /dev/null
@@ -1,237 +0,0 @@
-/*************************************************************************/
-/* bitmap_loader_pbm.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
-/* */
-/* 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 "bitmap_loader_pbm.h"
-#include "os/file_access.h"
-#include "scene/resources/bit_mask.h"
-
-static bool _get_token(FileAccessRef &f, uint8_t &saved, PoolVector<uint8_t> &r_token, bool p_binary = false, bool p_single_chunk = false) {
-
- int token_max = r_token.size();
- PoolVector<uint8_t>::Write w;
- if (token_max)
- w = r_token.write();
- int ofs = 0;
- bool lf = false;
-
- while (true) {
-
- uint8_t b;
- if (saved) {
- b = saved;
- saved = 0;
- } else {
- b = f->get_8();
- }
- if (f->eof_reached()) {
- if (ofs) {
- w = PoolVector<uint8_t>::Write();
- r_token.resize(ofs);
- return true;
- } else {
- return false;
- }
- }
-
- if (!ofs && !p_binary && b == '#') {
- //skip comment
- while (b != '\n') {
- if (f->eof_reached()) {
- return false;
- }
-
- b = f->get_8();
- }
-
- lf = true;
-
- } else if (b <= 32 && !(p_binary && (ofs || lf))) {
-
- if (b == '\n') {
- lf = true;
- }
-
- if (ofs && !p_single_chunk) {
- w = PoolVector<uint8_t>::Write();
- r_token.resize(ofs);
- saved = b;
-
- return true;
- }
- } else {
-
- bool resized = false;
- while (ofs >= token_max) {
- if (token_max)
- token_max <<= 1;
- else
- token_max = 1;
- resized = true;
- }
- if (resized) {
- // Note: Certain C++ static analyzers might point out that the following assigment is unnecessary.
- // This is wrong since PoolVector<class T>::Write has an operator= method where the lhs gets updated under certain conditions.
- // See core/dvector.h.
- w = PoolVector<uint8_t>::Write();
- r_token.resize(token_max);
- w = r_token.write();
- }
- w[ofs++] = b;
- }
- }
-
- return false;
-}
-
-static int _get_number_from_token(PoolVector<uint8_t> &r_token) {
-
- int len = r_token.size();
- PoolVector<uint8_t>::Read r = r_token.read();
- return String::to_int((const char *)r.ptr(), len);
-}
-
-RES ResourceFormatPBM::load(const String &p_path, const String &p_original_path, Error *r_error) {
-
-#define _RETURN(m_err) \
- { \
- if (r_error) \
- *r_error = m_err; \
- ERR_FAIL_V(RES()); \
- }
-
- FileAccessRef f = FileAccess::open(p_path, FileAccess::READ);
- uint8_t saved = 0;
- if (!f)
- _RETURN(ERR_CANT_OPEN);
-
- PoolVector<uint8_t> token;
-
- if (!_get_token(f, saved, token)) {
- _RETURN(ERR_PARSE_ERROR);
- }
-
- if (token.size() != 2) {
- _RETURN(ERR_FILE_CORRUPT);
- }
- if (token[0] != 'P') {
- _RETURN(ERR_FILE_CORRUPT);
- }
- if (token[1] != '1' && token[1] != '4') {
- _RETURN(ERR_FILE_CORRUPT);
- }
-
- bool bits = token[1] == '4';
-
- if (!_get_token(f, saved, token)) {
- _RETURN(ERR_PARSE_ERROR);
- }
-
- int width = _get_number_from_token(token);
- if (width <= 0) {
- _RETURN(ERR_FILE_CORRUPT);
- }
-
- if (!_get_token(f, saved, token)) {
- _RETURN(ERR_PARSE_ERROR);
- }
-
- int height = _get_number_from_token(token);
- if (height <= 0) {
- _RETURN(ERR_FILE_CORRUPT);
- }
-
- Ref<BitMap> bm;
- bm.instance();
- bm->create(Size2i(width, height));
-
- if (!bits) {
-
- int required_bytes = width * height;
- if (!_get_token(f, saved, token, false, true)) {
- _RETURN(ERR_PARSE_ERROR);
- }
-
- if (token.size() < required_bytes) {
- _RETURN(ERR_FILE_CORRUPT);
- }
-
- PoolVector<uint8_t>::Read r = token.read();
-
- for (int i = 0; i < height; i++) {
- for (int j = 0; j < width; j++) {
-
- char num = r[i * width + j];
- bm->set_bit(Point2i(j, i), num == '0');
- }
- }
-
- } else {
- //a single, entire token of bits!
- if (!_get_token(f, saved, token, true)) {
- _RETURN(ERR_PARSE_ERROR);
- }
- int required_bytes = Math::ceil((width * height) / 8.0);
- if (token.size() < required_bytes) {
- _RETURN(ERR_FILE_CORRUPT);
- }
-
- PoolVector<uint8_t>::Read r = token.read();
- int bitwidth = width;
- if (bitwidth % 8)
- bitwidth += 8 - (bitwidth % 8);
-
- for (int i = 0; i < height; i++) {
- for (int j = 0; j < width; j++) {
-
- int ofs = bitwidth * i + j;
-
- uint8_t byte = r[ofs / 8];
- bool bit = (byte >> (7 - (ofs % 8))) & 1;
-
- bm->set_bit(Point2i(j, i), !bit);
- }
- }
- }
-
- return bm;
-}
-
-void ResourceFormatPBM::get_recognized_extensions(List<String> *p_extensions) const {
- p_extensions->push_back("pbm");
-}
-bool ResourceFormatPBM::handles_type(const String &p_type) const {
- return p_type == "BitMap";
-}
-String ResourceFormatPBM::get_resource_type(const String &p_path) const {
-
- if (p_path.get_extension().to_lower() == "pbm")
- return "BitMap";
- return "";
-}
diff --git a/modules/pbm/bitmap_loader_pbm.h b/modules/pbm/bitmap_loader_pbm.h
deleted file mode 100644
index a93c482ece..0000000000
--- a/modules/pbm/bitmap_loader_pbm.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*************************************************************************/
-/* bitmap_loader_pbm.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
-/* */
-/* 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 BITMAP_LOADER_PBM_H
-#define BITMAP_LOADER_PBM_H
-
-#include "io/resource_loader.h"
-
-/**
- @author Juan Linietsky <reduzio@gmail.com>
-*/
-class ResourceFormatPBM : public ResourceFormatLoader {
-
-public:
- virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL);
- virtual void get_recognized_extensions(List<String> *p_extensions) const;
- virtual bool handles_type(const String &p_type) const;
- virtual String get_resource_type(const String &p_path) const;
-};
-
-#endif
diff --git a/modules/pbm/config.py b/modules/pbm/config.py
deleted file mode 100644
index 5f133eba90..0000000000
--- a/modules/pbm/config.py
+++ /dev/null
@@ -1,5 +0,0 @@
-def can_build(platform):
- return True
-
-def configure(env):
- pass
diff --git a/modules/pbm/register_types.cpp b/modules/pbm/register_types.cpp
deleted file mode 100644
index 37d8915fd6..0000000000
--- a/modules/pbm/register_types.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-/*************************************************************************/
-/* register_types.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
-/* */
-/* 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 "register_types.h"
-
-#include "bitmap_loader_pbm.h"
-
-static ResourceFormatPBM *pbm_loader = NULL;
-
-void register_pbm_types() {
-
- pbm_loader = memnew(ResourceFormatPBM);
- ResourceLoader::add_resource_format_loader(pbm_loader);
-}
-
-void unregister_pbm_types() {
-
- memdelete(pbm_loader);
-}
diff --git a/modules/pbm/register_types.h b/modules/pbm/register_types.h
deleted file mode 100644
index 408c7da275..0000000000
--- a/modules/pbm/register_types.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*************************************************************************/
-/* register_types.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
-/* */
-/* 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. */
-/*************************************************************************/
-
-void register_pbm_types();
-void unregister_pbm_types();