Commit 44a38db3 by Jessica Hawkwell

starting on NitroCairo

1 parent d8fe66d4
cmake_minimum_required (VERSION 3.10)
project(Nitrogen VERSION 1.0.0 DESCRIPTION "Nitrogen Desktop Experience")
option(USE_CAIRO "Use Cairo for rendering" ON)
execute_process(COMMAND ./ver.sh OUTPUT_VARIABLE GIT_COMMIT OUTPUT_STRIP_TRAILING_WHITESPACE)
set(CMAKE_PROJECT_VERSION_TWEAK ${GIT_COMMIT})
set(PROJECT_VERSION_TWEAK ${GIT_COMMIT})
......@@ -24,16 +26,37 @@ if (EXISTS /usr/local/include)
include_directories(/usr/local/include)
endif()
find_package(X11)
find_library(BoehmGC_C NAMES gc-threaded REQUIRED)
find_library(BoehmGC_CPP NAMES gccpp-threaded REQUIRED)
set(BoehmGC ${BoehmGC_C} ${BoehmGC_CPP})
find_package(X11)
if(USE_CAIRO)
find_library(Cairo_P cairo)
find_library(CairoMM_P cairomm)
else()
set(Cairo_P "")
set(CairoMM_P "")
endif()
set(Cairo "")
if(${Cairo_P} STREQUAL "NOTFOUND")
set(Cairo ${Cairo_P})
endif()
if(${CairoMM_P} STREQUAL "NOTFOUND")
set(Cairo ${Cairo} ${CairoMM_P})
endif()
#include_directories(AFTER SYSTEM ${CMAKE_BINARY_DIR}/deps/resvg/capi/include/)
#add_subdirectory(deps)
add_subdirectory(src/nde)
if(USE_CAIRO)
add_subdirectory(src/NitroCairo)
endif()
#add_subdirectory(src/NitroSVG)
add_subdirectory(src/ntk)
add_subdirectory(src/NitroWin)
cmake_minimum_required (VERSION 3.10)
project (NitroCairo DESCRIPTION "Cairo for Nitrogen")
configure_file(${PROJECT_NAME}.h.in ${PROJECT_NAME}.h)
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/build/share/doc/nitrogen/${PROJECT_NAME})
configure_file(${CMAKE_BINARY_DIR}/Doxyfile.in Doxyfile)
add_custom_target(doc_${PROJECT_NAME} COMMAND doxygen Doxyfile WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
add_dependencies(doc doc_${PROJECT_NAME})
add_library(${PROJECT_NAME} SHARED
nitrogen/cairo/CairoStatus.cpp
nitrogen/cairo/ContentTypes.cpp
nitrogen/cairo/FormatTypes.cpp
nitrogen/cairo/Surface.cpp
nitrogen/cairo/SurfaceTypes.cpp
)
target_link_libraries(${PROJECT_NAME} LINK_PUBLIC nde ${BoehmGC} ${X11_LIBRARIES} ${Cairo})
target_include_directories (NitroCairo PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
install(FILES ${PROJECT_NAME}.h DESTINATION include)
install(DIRECTORY nitrogen DESTINATION include FILES_MATCHING PATTERN "*.h")
install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION lib)
/*
* Copyright (c) 2020, jlhawkwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* File: NitroCairo.h
* Author: jlhawkwell
*/
#ifndef NITROCAIRO_H
#define NITROCAIRO_H
#ifndef GC_NAME_CONFLICT
#define GC_NAME_CONFLICT
#include <gc/gc.h>
#include <gc/gc_cpp.h>
#include <gc/gc_allocator.h>
#include <gc/gc_backptr.h>
#endif
#include <cairo/cairo.h>
#include <cairo/cairo-pdf.h>
#include <cairo/cairo-ps.h>
#include <cairo/cairo-svg.h>
#if defined(BEOS)
#include <cairo/cairo-beos.h>
#elif defined(OS2)
#include <cairo/cairo-os2.h>
#elif defined(TARGET_OS_MAC)
#include <cairo/cairo-quartz.h>
#elif defined(WIN32) || defined(_WIN32)
#include <cairo/cairo-win32.h>
#else
#include <cairo/cairo-xcb.h>
#include <cairo/cairo-xlib.h>
#include <cairo/cairo-xlib-xrender.h>
#endif
#define NITROCAIRO_NAME "NitroCairo"
#define NITROCAIRO_VERSION_MAJOR 1
#define NITROCAIRO_VERSION_MINOR 0
#define NITROCAIRO_VERSION_PATCH 0
#define NITROCAIRO_VERSION_TWEAK de85c12a
#define NITROCAIRO_VERSION "1.0.0.de85c12a"
#endif /* NITROCAIRO_H */
/*
* Copyright (c) 2020, jlhawkwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* File: NitroCairo.h
* Author: jlhawkwell
*/
#ifndef NITROCAIRO_H
#define NITROCAIRO_H
#ifndef GC_NAME_CONFLICT
#define GC_NAME_CONFLICT
#include <gc/gc.h>
#include <gc/gc_cpp.h>
#include <gc/gc_allocator.h>
#include <gc/gc_backptr.h>
#endif
#include <cairo/cairo.h>
#include <cairo/cairo-pdf.h>
#include <cairo/cairo-ps.h>
#include <cairo/cairo-svg.h>
#if defined(BEOS)
#include <cairo/cairo-beos.h>
#elif defined(OS2)
#include <cairo/cairo-os2.h>
#elif defined(TARGET_OS_MAC)
#include <cairo/cairo-quartz.h>
#elif defined(WIN32) || defined(_WIN32)
#include <cairo/cairo-win32.h>
#else
#include <cairo/cairo-xcb.h>
#include <cairo/cairo-xlib.h>
#include <cairo/cairo-xlib-xrender.h>
#endif
#define NITROCAIRO_NAME "@PROJECT_NAME@"
#define NITROCAIRO_VERSION_MAJOR @Nitrogen_VERSION_MAJOR@
#define NITROCAIRO_VERSION_MINOR @Nitrogen_VERSION_MINOR@
#define NITROCAIRO_VERSION_PATCH @Nitrogen_VERSION_PATCH@
#define NITROCAIRO_VERSION_TWEAK @Nitrogen_VERSION_TWEAK@
#define NITROCAIRO_VERSION "@Nitrogen_VERSION_MAJOR@.@Nitrogen_VERSION_MINOR@.@Nitrogen_VERSION_PATCH@.@Nitrogen_VERSION_TWEAK@"
#endif /* NITROCAIRO_H */
/*
* Copyright (c) 2020, jlhawkwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* File: CairoStatus.cpp
* Author: jlhawkwell
*/
#include <unordered_map>
#include <nitrogen/cairo/CairoStatus.h>
namespace nitrogen {
namespace cairo {
static std::unordered_map<CairoStatus,cairo_status_t> CairoStatusList = {
#include <nitrogen/cairo/util/ListHelper.h>
#include <nitrogen/cairo/enums/CairoStatusEnum.h>
};
cairo_status_t convert(Status s) {
for (auto it = CairoStatusList.begin(); it != CairoStatusList.end(); ++it) {
if (it->first == s) { return it->second; }
}
return cairo_status_t::CAIRO_STATUS_NULL_POINTER;
}
CairoStatus convert(cairo_status_t s) {
for (auto it = CairoStatusList.begin(); it != CairoStatusList.end(); ++it) {
if (it->second == s) { return it->first; }
}
return CairoStatus::NullPointer;
}
}
}
/*
* Copyright (c) 2020, jlhawkwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* File: CairoStatus.h
* Author: jlhawkwell
*/
#ifndef CairoStatus_h
#define CairoStatus_h
#include <NitroCairo.h>
namespace nitrogen {
namespace cairo {
enum CairoStatus {
#include <nitrogen/cairo/util/EnumHelper.h>
#include <nitrogen/cairo/enums/CairoStatusEnum.h>
};
cairo_status_t convert(Status s);
CairoStatus convert(cairo_status_t s);
}
}
#endif /* CairoStatus_h */
/*
* Copyright (c) 2020, jlhawkwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* File: ContentTypes.cpp
* Author: jlhawkwell
*/
#include <unordered_map>
#include <nitrogen/cairo/ContentTypes.h>
namespace nitrogen {
namespace cairo {
static std::unordered_map<ContentTypes,cairo_content_t> ContentTypesList = {
#include <nitrogen/cairo/util/ListHelper.h>
#include <nitrogen/cairo/enums/ContentTypesEnum.h>
};
cairo_content_t convert(ContentTypes ct) {
for (auto it = ContentTypesList.begin(); it != ContentTypesList.end(); ++it) {
if (it->first == ct) { return it->second; }
}
return cairo_content_t::CAIRO_CONTENT_COLOR;
}
ContentTypes convert(cairo_content_t ct) {
for (auto it = ContentTypesList.begin(); it != ContentTypesList.end(); ++it) {
if (it->second == ct) { return it->first; }
}
return ContentTypes::Color;
}
}
}
/*
* Copyright (c) 2020, jlhawkwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* File: ContentTypes.h
* Author: jlhawkwell
*/
#ifndef ContentTypes_h
#define ContentTypes_h
#include <NitroCairo.h>
namespace nitrogen {
namespace cairo {
enum ContentTypes {
#include <nitrogen/cairo/util/EnumHelper.h>
#include <nitrogen/cairo/enums/ContentTypesEnum.h>
};
cairo_content_t convert(ContentTypes ct);
ContentTypes convert(cairo_content_t ct);
}
}
#endif /* ContentTypes_h */
/*
* Copyright (c) 2020, jlhawkwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* File: Device.h
* Author: jlhawkwell
*/
#ifndef Device_h
#define Device_h
#include <nitrogen/cairo/CairoStatus.h>
#include <NitroCairo.h>
#include <nitrogen/cairo/ContentTypes.h>
#include <nitrogen/cairo/FormatTypes.h>
namespace nitrogen {
namespace cairo {
class Device : public gc {
friend class Surface;
public:
protected:
Device(cairo_device_t* device);
cairo_device_t* dev;
private:
};
}
}
#endif /* Device_h */
/*
* Copyright (c) 2020, jlhawkwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* File: FormatTypes.cpp
* Author: jlhawkwell
*/
#include <unordered_map>
#include <nitrogen/cairo/FormatTypes.h>
namespace nitrogen {
namespace cairo {
static std::unordered_map<FormatTypes,cairo_format_t> FormatTypesList = {
#include <nitrogen/cairo/util/ListHelper.h>
#include <nitrogen/cairo/enums/FormatTypesEnum.h>
};
cairo_format_t convert(FormatTypes ft) {
for (auto it = FormatTypesList.begin(); it != FormatTypesList.end(); ++it) {
if (it->first == ft) { return it->second; }
}
return cairo_format_t::CAIRO_FORMAT_INVALID;
}
FormatTypes convert(cairo_format_t ft) {
for (auto it = FormatTypesList.begin(); it != FormatTypesList.end(); ++it) {
if (it->second == ft) { return it->first; }
}
return FormatTypes::Invalid;
}
}
}
/*
* Copyright (c) 2020, jlhawkwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* File: FormatTypes.h
* Author: jlhawkwell
*/
#ifndef FormatTypes_h
#define FormatTypes_h
#include <NitroCairo.h>
namespace nitrogen {
namespace cairo {
enum FormatTypes {
#include <nitrogen/cairo/util/EnumHelper.h>
#include <nitrogen/cairo/enums/FormatTypesEnum.h>
};
cairo_format_t convert(FormatTypes ft);
FormatTypes convert(cairo_format_t ft);
}
}
#endif /* FormatTypes_h */
/*
* Copyright (c) 2020, jlhawkwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* File: Rectangle.h
* Author: jlhawkwell
*/
#ifndef Rectangle_h
#define Rectangle_h
//#include <NitroCairo.h>
namespace nitrogen {
namespace cairo {
template<class T>
struct Rectangle {
T x;
T y;
T width;
T height;
};
}
}
#endif /* Rectangle_h */
/*
* Copyright (c) 2020, jlhawkwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* File: Surface.cpp
* Author: jlhawkwell
*/
#include <nitrogen/cairo/Surface.h>
namespace nitrogen {
namespace cairo {
Surface::Surface(ContentTypes ctype, int width, int height) {
surface = nullptr;
}
Surface::~Surface() {
destroy();
}
Surface* Surface::createSimilar(ContentTypes ctype, int width, int height) {
cairo_surface_t* st =
cairo_surface_create_similar(surface, convert(ctype), width, height);
Surface* pt = new Surface(st);
return pt;
}
Surface* Surface::createSimilarImage(FormatTypes ftype, int width, int height) {
cairo_surface_t* st =
cairo_surface_create_similar_image(surface, convert(ftype), width, height);
Surface* pt = new Surface(st);
return pt;
}
Surface* Surface::createRect(double x, double y, double width, double height) {
cairo_surface_t* st =
cairo_surface_create_for_rectangle(surface, x, y, width, height);
Surface* pt = new Surface(st);
return pt;
}
Surface* Surface::reference() {
cairo_surface_t* st = cairo_surface_reference(surface);
Surface* pt = new Surface(st);
return pt;
}
void Surface::destroy() { cairo_surface_destroy(surface); }
Status Surface::status() {
return convert(cairo_surface_status(surface));
}
void Surface::finish() { cairo_surface_finish(surface); }
void Surface::flush() { cairo_surface_flush(surface); }
Device* Surface::getDevice() {
cairo_device_t* dt = cairo_surface_get_device(surface);
Device* pt = new Device(dt);
return pt;
}
void Surface::getFontOptions(cairo_font_options_t* options) {
cairo_surface_get_font_options(surface, options);
}
ContentTypes Surface::getContent() {
return convert(cairo_surface_get_content(surface));
}
void Surface::markDirty() { cairo_surface_mark_dirty(surface); }
void Surface::markDirtyRectangle(int x, int y, int width, int height) {
cairo_surface_mark_dirty_rectangle(surface, x, y, width, height);
}
void Surface::getDeviceOffset(double* x, double* y) {
cairo_surface_get_device_offset(surface, x, y);
}
void Surface::setDeviceOffset(double x, double y) {
cairo_surface_set_device_offset(surface, x, y);
}
void Surface::getDeviceScale(double* x, double* y) {
cairo_surface_get_device_scale(surface, x, y);
}
void Surface::setDeviceScale(double x, double y) {
cairo_surface_set_device_scale(surface, x, y);
}
void Surface::getFallbackResolution(double* x, double* y) {
cairo_surface_get_fallback_resolution(surface, x, y);
}
void Surface::setFallbackResolution(double x, double y) {
cairo_surface_set_fallback_resolution(surface, x, y);
}
SurfaceTypes Surface::getType() {
return convert(cairo_surface_get_type(surface));
}
unsigned int Surface::getReferenceCount() {
return cairo_surface_get_reference_count(surface);
}
void* Surface::getUserData(const cairo_user_data_key_t* key) {
return cairo_surface_get_user_data(surface, key);
}
Status Surface::setUserData(const cairo_user_data_key_t* key,
void* user_data, cairo_destroy_func_t destroy) {
return convert(cairo_surface_set_user_data(surface, key, user_data, destroy));
}
void Surface::copyPage() { cairo_surface_copy_page(surface); }
void Surface::showPage() { cairo_surface_show_page(surface); }
bool Surface::hasShowTextGlyphs() {
return cairo_surface_has_show_text_glyphs(surface);
}
CairoStatus Surface::setMimeData(std::string* mimeType,
const unsigned char* data, unsigned long length,
cairo_destroy_func_t destroy, void* closure) {
cairo_status_t st = cairo_surface_set_mime_data(surface, mimeType->c_str(),
data, length, destroy, closure);
return convert(st);
}
void Surface::getMimeData(std::string* mimeType,
const unsigned char** data, unsigned long * length) {
}
bool Surface::supportsMimeType(std::string* mimeType) {
return cairo_surface_supports_mime_type(surface, mimeType->c_str());
}
Surface* Surface::mapToImage(Rectangle<int>* region) {
const _cairo_rectangle_int* rect = new _cairo_rectangle_int{
region->x, region->y, region->width, region->height};
cairo_surface_t* st = cairo_surface_map_to_image(surface, rect);
Surface* pt = new Surface(st);
return pt;
}
void Surface::unmapImage(Surface* img) { cairo_surface_unmap_image(surface, img->surface); }
Surface::Surface(cairo_surface_t* sfc) { surface = sfc; }
}
}
/*
* Copyright (c) 2020, jlhawkwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* File: Surface.h
* Author: jlhawkwell
*/
#ifndef Surface_h
#define Surface_h
#include <iostream>
#include <NitroCairo.h>
#include <nitrogen/cairo/CairoStatus.h>
#include <nitrogen/cairo/ContentTypes.h>
#include <nitrogen/cairo/Device.h>
#include <nitrogen/cairo/FormatTypes.h>
#include <nitrogen/cairo/Rectangle.h>
#include <nitrogen/cairo/SurfaceTypes.h>
namespace nitrogen {
namespace cairo {
class Surface : public gc {
public:
Surface(ContentTypes ctype, int width, int height);
virtual ~Surface();
virtual Surface* createSimilar(ContentTypes ctype, int width, int height);
virtual Surface* createSimilarImage(FormatTypes ftype, int width, int height);
virtual Surface* createRect(double x, double y, double width, double height);
virtual Surface* reference();
virtual void destroy();
virtual Status status();
virtual void finish();
virtual void flush();
virtual Device* getDevice();
virtual void getFontOptions(cairo_font_options_t* options);
virtual ContentTypes getContent();
virtual void markDirty();
virtual void markDirtyRectangle(int x, int y, int width, int height);
virtual void getDeviceOffset(double* x, double* y);
virtual void setDeviceOffset(double x, double y);
virtual void getDeviceScale(double* x, double* y);
virtual void setDeviceScale(double x, double y);
virtual void getFallbackResolution(double* x, double* y);
virtual void setFallbackResolution(double x, double y);
virtual SurfaceTypes getType();
virtual unsigned int getReferenceCount();
virtual void* getUserData(const cairo_user_data_key_t* key);
virtual Status setUserData(const cairo_user_data_key_t* key,
void* user_data, cairo_destroy_func_t destroy);
virtual void copyPage();
virtual void showPage();
virtual bool hasShowTextGlyphs();
virtual CairoStatus setMimeData(std::string* mimeType, const unsigned char *data,
unsigned long length, cairo_destroy_func_t destroy, void *closure);
virtual void getMimeData(std::string* mimeType, const unsigned char **data,
unsigned long *length);
virtual bool supportsMimeType(std::string* mimeType);
virtual Surface* mapToImage(Rectangle<int>* region);
virtual void unmapImage(Surface* img);
protected:
cairo_surface_t* surface;
Surface(cairo_surface_t* sfc);
private:
};
}
}
#endif /* Surface_h */
/*
* Copyright (c) 2020, jlhawkwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* File: SurfaceTypes.cpp
* Author: jlhawkwell
*/
#include <unordered_map>
#include <nitrogen/cairo/SurfaceTypes.h>
namespace nitrogen {
namespace cairo {
static std::unordered_map<SurfaceTypes,cairo_surface_type_t> SurfaceTypesList = {
#include <nitrogen/cairo/util/ListHelper.h>
#include <nitrogen/cairo/enums/SurfaceTypesEnum.h>
};
cairo_surface_type_t convert(SurfaceTypes st) {
for (auto it = SurfaceTypesList.begin(); it != SurfaceTypesList.end(); ++it) {
if (it->first == st) { return it->second; }
}
return cairo_surface_type_t::CAIRO_SURFACE_TYPE_IMAGE;
}
SurfaceTypes convert(cairo_surface_type_t st) {
for (auto it = SurfaceTypesList.begin(); it != SurfaceTypesList.end(); ++it) {
if (it->second == st) { return it->first; }
}
return SurfaceTypes::Image;
}
}
}
/*
* Copyright (c) 2020, jlhawkwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* File: SurfaceTypes.h
* Author: jlhawkwell
*/
#ifndef SurfaceTypes_h
#define SurfaceTypes_h
#include <NitroCairo.h>
namespace nitrogen {
namespace cairo {
enum SurfaceTypes {
#include <nitrogen/cairo/util/EnumHelper.h>
#include <nitrogen/cairo/enums/SurfaceTypesEnum.h>
};
cairo_surface_type_t convert(SurfaceTypes st);
SurfaceTypes convert(cairo_surface_type_t st);
}
}
#endif /* SurfaceTypes_h */
NVPAIR(cSuccess, CAIRO_STATUS_SUCCESS)
NVPAIR(NoMemory, CAIRO_STATUS_NO_MEMORY)
NVPAIR(InvalidRestore, CAIRO_STATUS_INVALID_RESTORE)
NVPAIR(InvalidPopGroup, CAIRO_STATUS_INVALID_POP_GROUP)
NVPAIR(NoCurrentPoint, CAIRO_STATUS_NO_CURRENT_POINT)
NVPAIR(InvalidMatrix, CAIRO_STATUS_INVALID_MATRIX)
NVPAIR(InvalidStatus, CAIRO_STATUS_INVALID_STATUS)
NVPAIR(NullPointer, CAIRO_STATUS_NULL_POINTER)
NVPAIR(InvalidString, CAIRO_STATUS_INVALID_STRING)
NVPAIR(InvalidPathData, CAIRO_STATUS_INVALID_PATH_DATA)
NVPAIR(ReadError, CAIRO_STATUS_READ_ERROR)
NVPAIR(WriteError, CAIRO_STATUS_WRITE_ERROR)
NVPAIR(SurfaceFinished, CAIRO_STATUS_SURFACE_FINISHED)
NVPAIR(SurfaceTypeMismatch, CAIRO_STATUS_SURFACE_TYPE_MISMATCH)
NVPAIR(PatternTypeMismatch, CAIRO_STATUS_PATTERN_TYPE_MISMATCH)
NVPAIR(InvalidContent, CAIRO_STATUS_INVALID_CONTENT)
NVPAIR(InvalidFormat, CAIRO_STATUS_INVALID_FORMAT)
NVPAIR(InvalidVisual, CAIRO_STATUS_INVALID_VISUAL)
NVPAIR(FileNotFound, CAIRO_STATUS_FILE_NOT_FOUND)
NVPAIR(InvalidDash, CAIRO_STATUS_INVALID_DASH)
NVPAIR(InvalidComment, CAIRO_STATUS_INVALID_DSC_COMMENT)
NVPAIR(InvalidIndex, CAIRO_STATUS_INVALID_INDEX)
NVPAIR(ClipNotRepresentable, CAIRO_STATUS_CLIP_NOT_REPRESENTABLE)
NVPAIR(TempFileError, CAIRO_STATUS_TEMP_FILE_ERROR)
NVPAIR(InvalidStride, CAIRO_STATUS_INVALID_STRIDE)
NVPAIR(FontTypeMismatch, CAIRO_STATUS_FONT_TYPE_MISMATCH)
NVPAIR(UserFontImmutable, CAIRO_STATUS_USER_FONT_IMMUTABLE)
NVPAIR(UserFontError, CAIRO_STATUS_USER_FONT_ERROR)
NVPAIR(NegativeCount, CAIRO_STATUS_NEGATIVE_COUNT)
NVPAIR(InvalidClusters, CAIRO_STATUS_INVALID_CLUSTERS)
NVPAIR(InvalidSlant, CAIRO_STATUS_INVALID_SLANT)
NVPAIR(InvalidWeight, CAIRO_STATUS_INVALID_WEIGHT)
NVPAIR(InvalidSize, CAIRO_STATUS_INVALID_SIZE)
NVPAIR(FontNotImplemented, CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED)
NVPAIR(DeviceTypeMismatch, CAIRO_STATUS_DEVICE_TYPE_MISMATCH)
NVPAIR(DeviceError, CAIRO_STATUS_DEVICE_ERROR)
NVPAIR(InvalidMeshConstruction, CAIRO_STATUS_INVALID_MESH_CONSTRUCTION)
NVPAIR(DeviceFinished, CAIRO_STATUS_DEVICE_FINISHED)
NVPAIR(JBig2GlobalMissing, CAIRO_STATUS_JBIG2_GLOBAL_MISSING)
NVPAIR(PNGError, CAIRO_STATUS_PNG_ERROR)
NVPAIR(FreeTypeError, CAIRO_STATUS_FREETYPE_ERROR)
NVPAIR(Win32GDIError, CAIRO_STATUS_WIN32_GDI_ERROR)
NVPAIR(TagError, CAIRO_STATUS_TAG_ERROR)
NVPAIR(LastStatus, CAIRO_STATUS_LAST_STATUS)
NVPAIR(Alpha, CAIRO_CONTENT_ALPHA)
NVPAIR(Color, CAIRO_CONTENT_COLOR)
NVPAIR(AlphaColor, CAIRO_CONTENT_COLOR_ALPHA)
NVPAIR(Invalid, CAIRO_FORMAT_INVALID)
NVPAIR(ARGB32, CAIRO_FORMAT_ARGB32)
NVPAIR(RGB24, CAIRO_FORMAT_RGB24)
NVPAIR(Alpha8, CAIRO_FORMAT_A8)
NVPAIR(Alpha1, CAIRO_FORMAT_A1)
NVPAIR(RGB16, CAIRO_FORMAT_RGB16_565)
NVPAIR(RGB30, CAIRO_FORMAT_RGB30)
NVPAIR(Image, CAIRO_SURFACE_TYPE_IMAGE)
NVPAIR(PDF, CAIRO_SURFACE_TYPE_PDF)
NVPAIR(PostScript, CAIRO_SURFACE_TYPE_PS)
NVPAIR(Xlib, CAIRO_SURFACE_TYPE_XLIB)
NVPAIR(XCB, CAIRO_SURFACE_TYPE_XCB)
NVPAIR(Glitz, CAIRO_SURFACE_TYPE_GLITZ)
NVPAIR(Quartz, CAIRO_SURFACE_TYPE_QUARTZ)
NVPAIR(Win32, CAIRO_SURFACE_TYPE_WIN32)
NVPAIR(BeOS, CAIRO_SURFACE_TYPE_BEOS)
NVPAIR(DirectFB, CAIRO_SURFACE_TYPE_DIRECTFB)
NVPAIR(SVG, CAIRO_SURFACE_TYPE_SVG)
NVPAIR(OS2, CAIRO_SURFACE_TYPE_OS2)
NVPAIR(Win32Printing, CAIRO_SURFACE_TYPE_WIN32_PRINTING)
NVPAIR(QuartzImage, CAIRO_SURFACE_TYPE_QUARTZ_IMAGE)
NVPAIR(Script, CAIRO_SURFACE_TYPE_SCRIPT)
NVPAIR(Qt, CAIRO_SURFACE_TYPE_QT)
NVPAIR(Recording, CAIRO_SURFACE_TYPE_RECORDING)
NVPAIR(VG, CAIRO_SURFACE_TYPE_VG)
NVPAIR(OpenGL, CAIRO_SURFACE_TYPE_GL)
NVPAIR(DRM, CAIRO_SURFACE_TYPE_DRM)
NVPAIR(tee, CAIRO_SURFACE_TYPE_TEE)
NVPAIR(XML, CAIRO_SURFACE_TYPE_XML)
NVPAIR(Skia, CAIRO_SURFACE_TYPE_SKIA)
NVPAIR(Subsurface, CAIRO_SURFACE_TYPE_SUBSURFACE)
NVPAIR(COGL, CAIRO_SURFACE_TYPE_COGL)
/*
* Copyright (c) 2020, jlhawkwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* File: Convert.h
* Author: jlhawkwell
*/
#ifndef Convert_h
#define Convert_h
#include <NitroCairo.h>
#include <unordered_map>
namespace nitrogen {
namespace cairo {
namespace util {
template<class I, class O>
O convert<I,O>(I in, O def, std::unordered_map<I,O>* list) {
for (auto it = list->begin(); it != list->end(); ++it) {
if (it->first == in) { return it->second; }
}
return def;
}
template<class I, class O>
O convert<I,O>(I in, O def, std::unordered_map<O,I>* list) {
for (auto it = list->begin(); it != list->end(); ++it) {
if (it->second == in) { return it->first; }
}
return def;
}
}
}
}
#endif /* Convert_h */
/*
* Copyright (c) 2020, jlhawkwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* File: EnumHelper.h
* Author: jlhawkwell
*/
#ifdef NVPAIR
#undef NVPAIR
#endif
#define NVPAIR(n, v) n = v,
/*
* Copyright (c) 2020, jlhawkwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* File: Convert.h
* Author: jlhawkwell
*/
#ifdef NVPAIR
#undef NVPAIR
#endif
#define NVPAIR(n, v) {n, v},
cmake_minimum_required (VERSION 3.10)
project (NitroSVG DESCRIPTION "Nitrogen SVG Renderer")
configure_file(${PROJECT_NAME}.h.in ${PROJECT_NAME}.h)
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/build/share/doc/nitrogen/${PROJECT_NAME})
configure_file(${CMAKE_BINARY_DIR}/Doxyfile.in Doxyfile)
add_custom_target(doc_${PROJECT_NAME} COMMAND doxygen Doxyfile WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
add_dependencies(doc doc_${PROJECT_NAME})
add_library(${PROJECT_NAME} SHARED )
target_link_libraries(${PROJECT_NAME} LINK_PUBLIC nde ${BoehmGC} ${X11_LIBRARIES} ${Cairo})
target_include_directories (NitroSVG PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
install(FILES ${PROJECT_NAME}.h DESTINATION include)
install(DIRECTORY nitrogen DESTINATION include FILES_MATCHING PATTERN "*.h")
install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION lib)
/*
* Copyright (c) 2018, jlhawkwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* File: nde.h
* Author: jlhawkwell
*
* Created on March 16, 2018, 12:49 PM
*/
#ifndef NDE_H
#define NDE_H
#ifndef GC_NAME_CONFLICT
#define GC_NAME_CONFLICT
#include <gc/gc.h>
#include <gc/gc_cpp.h>
#include <gc/gc_allocator.h>
#include <gc/gc_backptr.h>
#endif
#define NDE_NAME "NitroSVG"
#define NDE_VERSION_MAJOR 1
#define NDE_VERSION_MINOR 0
#define NDE_VERSION_PATCH 0
#define NDE_VERSION_TWEAK de85c12a
#define NDE_VERSION "1.0.0.de85c12a"
#include <typeinfo>
#include <iosfwd>
#include <string>
namespace nitrogen {
template <typename T>
char * getTypeName(const T obj) {
return (char *)typeid(obj).name();
}
}
#endif /* NDE_H */
/*
* Copyright (c) 2020, jlhawkwell
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* File: NitroSVG.h
* Author: jlhawkwell
*
* Created on March 16, 2020 02:49 AM
*/
#ifndef NITROSVG_H
#define NITROSVG_H
#ifndef GC_NAME_CONFLICT
#define GC_NAME_CONFLICT
#include <gc/gc.h>
#include <gc/gc_cpp.h>
#include <gc/gc_allocator.h>
#include <gc/gc_backptr.h>
#endif
#define NITROSVG_NAME "@PROJECT_NAME@"
#define NITROSVG_VERSION_MAJOR @Nitrogen_VERSION_MAJOR@
#define NITROSVG_VERSION_MINOR @Nitrogen_VERSION_MINOR@
#define NITROSVG_VERSION_PATCH @Nitrogen_VERSION_PATCH@
#define NITROSVG_VERSION_TWEAK @Nitrogen_VERSION_TWEAK@
#define NITROSVG_VERSION "@Nitrogen_VERSION_MAJOR@.@Nitrogen_VERSION_MINOR@.@Nitrogen_VERSION_PATCH@.@Nitrogen_VERSION_TWEAK@"
#include <typeinfo>
#include <iosfwd>
#include <string>
#endif /* NITROSVG_H */
......@@ -7,9 +7,7 @@ configure_file(${CMAKE_BINARY_DIR}/Doxyfile.in Doxyfile)
add_custom_target(doc_${PROJECT_NAME} COMMAND doxygen Doxyfile WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
add_dependencies(doc doc_${PROJECT_NAME})
link_libraries(${X11_LIBRARIES})
add_executable(${PROJECT_NAME} NUtils.cpp NWMAction.cpp NWManager.cpp main.cpp)
target_link_libraries(${PROJECT_NAME} LINK_PUBLIC ${BoehmGC} nde)
target_link_libraries(${PROJECT_NAME} LINK_PUBLIC ${BoehmGC} ${X11_LIBRARIES} nde)
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin)
......@@ -7,11 +7,6 @@ configure_file(${CMAKE_BINARY_DIR}/Doxyfile.in Doxyfile)
add_custom_target(doc_${PROJECT_NAME} COMMAND doxygen Doxyfile WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
add_dependencies(doc doc_${PROJECT_NAME})
find_package(X11)
find_library(BoehmGC gc-threaded)
find_library(Cairo cairo)
find_library(CairoMM cairomm)
add_library(${PROJECT_NAME} SHARED ntkMain.cpp
nitrogen/Object.cpp
nitrogen/nwt/ActionEvent.cpp
......
......@@ -41,10 +41,10 @@ namespace nitrogen {
}
std::string* Object::toString() {
std::string* out
std::string* out;
out->append(getTypeName(*this));
out->append("(");
out->append(std::to_string((uintptr_t)*this));
out->append(std::to_string((uintptr_t)this));
out->append(")");
return out;
}
......
......@@ -34,6 +34,7 @@
#include "NativeGraphics.h"
#include <X11/Xlib.h>
#include <typeinfo>
namespace nitrogen {
namespace nwt {
......@@ -48,13 +49,13 @@ namespace nitrogen {
width = 32;
height = 32;
std::string* fnt = std::string("serif");
std::string* fnt = new std::string("serif");
font = new Font(fnt, 12, 12);
color = new Color(0,0,0);
xdisp = XOpenDisplay(nullptr);
xdraw = XCreateSimpleWindow(xdisp, DefaultRootWindow(xdisp), tx, ty, width, height, 0, 0, 0);
xgc = XCreateGC(xdisp, 0, 0, nullptr);
xdraw = nullptr; //XCreateSimpleWindow(xdisp, DefaultRootWindow(xdisp), tx, ty, width, height, 0, 0, 0);
xgc = nullptr; //XCreateGC(xdisp, 0, 0, nullptr);
}
NativeGraphics::NativeGraphics(NativeGraphics& ng) {
......@@ -105,7 +106,7 @@ namespace nitrogen {
}
void NativeGraphics::drawString(std::string* str, int x, int y) {
XDrawString(xdisp, xdraw, xgc, x, y, str->c_str(), str->length());
//XDrawString(xdisp, xdraw, xgc, x, y, str->c_str(), str->length());
}
void NativeGraphics::drawString(std::string& str, int x, int y) {
......@@ -163,12 +164,21 @@ namespace nitrogen {
// overrides
NativeGraphics& NativeGraphics::operator()() {
NativeGraphics* ng = new NativeGraphics();
return ng;
return *ng;
}
Graphics& NativeGraphics::operator=(Graphics& right) {
const char * tid_l = typeid(this).name();
const char * tid_r = typeid(right).name();
if (std::strcmp(tid_l, tid_r)) {
return (Graphics&)operator=((NativeGraphics&)right);
}
return right;
}
NativeGraphics& NativeGraphics::operator=(NativeGraphics& right) {
if (*this != right) {
*mask = *right.mask;
mask = right.mask;
cx = right.cx;
cy = right.cy;
tx = right.tx;
......@@ -176,18 +186,27 @@ namespace nitrogen {
width = right.width;
height = right.height;
*font = *right.font;
*color = *right.color;
font = right.font;
color = right.color;
*xdisp = *right.xdisp;
*xdraw = *right.xdraw;
*xgc = *right.xgc;
xdisp = right.xdisp;
xdraw = right.xdraw;
xgc = right.xgc;
}
return *this;
}
//bool operator!=(Graphics& right)
bool NativeGraphics::operator==(Graphics& right) {
const char * tid_l = typeid(this).name();
const char * tid_r = typeid(right).name();
if (std::strcmp(tid_l, tid_r)) {
return operator==((NativeGraphics&)right);
}
return false;
}
bool NativeGraphics::operator==(NativeGraphics& right) {
if ( *mask != *right.mask ) { return false; }
if ( mask != right.mask ) { return false; }
if ( cx != right.cx ) { return false; }
if ( cy != right.cy ) { return false; }
if ( tx != right.tx ) { return false; }
......@@ -198,9 +217,9 @@ namespace nitrogen {
if ( *font != *right.font ) { return false; }
if ( *color != *right.color ) { return false; }
if ( *xdisp != *right.xdisp ) { return false; }
if ( *xdraw != *right.xdraw ) { return false; }
if ( *xgc != *right.xgc ) { return false; }
if ( xdisp != right.xdisp ) { return false; }
if ( xdraw != right.xdraw ) { return false; }
if ( xgc != right.xgc ) { return false; }
return true;
}
......
......@@ -72,9 +72,10 @@ namespace nitrogen {
//std::string* toString();
NativeGraphics& operator()() override;
NativeGraphics& operator=(NativeGraphics& right) override;
//bool operator!=(NativeGraphics& right);
bool operator==(NativeGraphics& right) override;
Graphics& operator=(Graphics& right) override;
NativeGraphics& operator=(NativeGraphics& right);
bool operator==(Graphics& right) override;
bool operator==(NativeGraphics& right);
protected:
unsigned long mask;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!