Move function to convert doc::Image -> os::Surface to app/util

This commit is contained in:
David Capello 2020-06-09 19:56:25 -03:00
parent 9c37ea41ed
commit b41f1ace30
14 changed files with 67 additions and 54 deletions

View File

@ -32,7 +32,7 @@ because they don't depend on any other component.
## Level 2
* [doc](doc/) (base, fixmath, gfx, os): Document model library.
* [doc](doc/) (base, fixmath, gfx): Document model library.
* [ui](ui/) (base, gfx, os): Portable UI library (buttons, windows, text fields, etc.)
* [updater](updater/) (base, cfg, net): Component to check for updates.

View File

@ -597,6 +597,7 @@ add_library(app-lib
ui/layer_frame_comboboxes.cpp
util/autocrop.cpp
util/buffer_region.cpp
util/conversion_to_surface.cpp
util/create_cel_copy.cpp
util/expand_cel_canvas.cpp
util/filetoks.cpp

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2018 Igara Studio S.A.
// Copyright (C) 2018-2020 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -21,7 +21,7 @@
#include "app/ui/editor/editor_render.h"
#include "app/ui/keyboard_shortcuts.h"
#include "app/ui/status_bar.h"
#include "doc/conversion_to_surface.h"
#include "app/util/conversion_to_surface.h"
#include "doc/image.h"
#include "doc/palette.h"
#include "doc/primitives.h"
@ -231,7 +231,7 @@ protected:
break;
}
doc::convert_image_to_surface(m_doublebuf.get(), m_pal,
convert_image_to_surface(m_doublebuf.get(), m_pal,
m_doublesur, 0, 0, 0, 0, m_doublebuf->width(), m_doublebuf->height());
g->blit(m_doublesur, 0, 0, 0, 0, m_doublesur->width(), m_doublesur->height());
}

View File

@ -16,12 +16,12 @@
#include "app/doc.h"
#include "app/file/file.h"
#include "app/file_system.h"
#include "app/util/conversion_to_surface.h"
#include "base/bind.h"
#include "base/clamp.h"
#include "base/scoped_lock.h"
#include "base/thread.h"
#include "doc/algorithm/rotate.h"
#include "doc/conversion_to_surface.h"
#include "doc/image.h"
#include "doc/palette.h"
#include "doc/primitives.h"

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (C) 2019-2020 Igara Studio S.A.
// Copyright (C) 2018 David Capello
// Copyright (C) 2016 Carlo Caputo
//
@ -10,9 +10,9 @@
#include "config.h"
#endif
#include "app/util/conversion_to_surface.h"
#include "doc/blend_mode.h"
#include "doc/cel.h"
#include "doc/conversion_to_surface.h"
#include "doc/layer.h"
#include "doc/sprite.h"
#include "os/surface.h"

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2018-2019 Igara Studio S.A.
// Copyright (C) 2018-2020 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -26,10 +26,10 @@
#include "app/ui/main_window.h"
#include "app/ui/skin/skin_theme.h"
#include "app/ui_context.h"
#include "app/util/conversion_to_surface.h"
#include "base/bind.h"
#include "base/convert_to.h"
#include "doc/brush.h"
#include "doc/conversion_to_surface.h"
#include "doc/image.h"
#include "doc/palette.h"
#include "gfx/border.h"

View File

@ -51,7 +51,6 @@
#include "base/fs.h"
#include "base/scoped_value.h"
#include "doc/brush.h"
#include "doc/conversion_to_surface.h"
#include "doc/image.h"
#include "doc/palette.h"
#include "doc/remap.h"

View File

@ -15,8 +15,8 @@
#include "app/extensions.h"
#include "app/modules/palettes.h"
#include "app/ui/skin/skin_theme.h"
#include "app/util/conversion_to_surface.h"
#include "base/bind.h"
#include "doc/conversion_to_surface.h"
#include "doc/image.h"
#include "doc/image_ref.h"
#include "doc/primitives.h"
@ -113,8 +113,8 @@ private:
}
m_preview = os::instance()->createRgbaSurface(w, h);
doc::convert_image_to_surface(image2.get(), palette, m_preview,
0, 0, 0, 0, w, h);
convert_image_to_surface(image2.get(), palette, m_preview,
0, 0, 0, 0, w, h);
m_palId = palette->id();
m_palMods = palette->getModifications();

View File

@ -51,12 +51,12 @@
#include "app/ui/timeline/timeline.h"
#include "app/ui/toolbar.h"
#include "app/ui_context.h"
#include "app/util/conversion_to_surface.h"
#include "app/util/layer_utils.h"
#include "base/bind.h"
#include "base/chrono.h"
#include "base/clamp.h"
#include "base/convert_to.h"
#include "doc/conversion_to_surface.h"
#include "doc/doc.h"
#include "doc/mask_boundaries.h"
#include "doc/slice.h"

View File

@ -19,11 +19,11 @@
#include "app/ui/search_entry.h"
#include "app/ui/skin/skin_theme.h"
#include "app/ui_context.h"
#include "app/util/conversion_to_surface.h"
#include "app/util/freetype_utils.h"
#include "base/bind.h"
#include "base/fs.h"
#include "base/string.h"
#include "doc/conversion_to_surface.h"
#include "doc/image.h"
#include "doc/image_ref.h"
#include "os/surface.h"

View File

@ -1,14 +1,15 @@
// Aseprite Document Library
// Aseprite
// Copyright (c) 2020 Igara Studio S.A.
// Copyright (c) 2001-2018 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "doc/conversion_to_surface.h"
#include "app/util/conversion_to_surface.h"
#include "base/24bits.h"
#include "doc/algo.h"
@ -22,7 +23,9 @@
#include <algorithm>
#include <stdexcept>
namespace doc {
namespace app {
using namespace doc;
namespace {
@ -131,8 +134,14 @@ void convert_image_to_surface_selector(const Image* image, os::Surface* surface,
} // anonymous namespace
void convert_image_to_surface(const Image* image, const Palette* palette,
os::Surface* surface, int src_x, int src_y, int dst_x, int dst_y, int w, int h)
void convert_image_to_surface(
const doc::Image* image,
const doc::Palette* palette,
os::Surface* surface,
int src_x, int src_y,
int dst_x, int dst_y,
int w, int h)
{
gfx::Rect srcBounds(src_x, src_y, w, h);
srcBounds = srcBounds.createIntersection(image->bounds());
@ -198,4 +207,4 @@ void convert_image_to_surface(const Image* image, const Palette* palette,
}
}
} // namespace doc
} // namespace app

View File

@ -0,0 +1,33 @@
// Aseprite
// Copyright (c) 2020 Igara Studio S.A.
// Copyright (c) 2001-2014 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
#ifndef APP_UTIL_CONVERSION_TO_SURFACE_H_INCLUDED
#define APP_UTIL_CONVERSION_TO_SURFACE_H_INCLUDED
#pragma once
namespace doc {
class Image;
class Palette;
}
namespace os {
class Surface;
}
namespace app {
void convert_image_to_surface(
const doc::Image* image,
const doc::Palette* palette,
os::Surface* surface,
int src_x, int src_y,
int dst_x, int dst_y,
int w, int h);
} // namespace app
#endif

View File

@ -31,7 +31,6 @@ add_library(doc-lib
cels_range.cpp
color.cpp
compressed_image.cpp
conversion_to_surface.cpp
document.cpp
file/act_file.cpp
file/col_file.cpp
@ -70,10 +69,7 @@ add_library(doc-lib
tags.cpp
user_data_io.cpp)
# TODO Remove 'os' as dependency and move conversion_to_surface.cpp/h files
# to other library/layer (render-lib? new conversion-lib?)
target_link_libraries(doc-lib
laf-os
laf-gfx
fixmath-lib
laf-base)
laf-base
fixmath-lib)

View File

@ -1,25 +0,0 @@
// Aseprite Document Library
// Copyright (c) 2001-2014 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
#ifndef DOC_CONVERSION_TO_SURFACE_H_INCLUDED
#define DOC_CONVERSION_TO_SURFACE_H_INCLUDED
#pragma once
namespace os {
class Surface;
}
namespace doc {
class Image;
class Palette;
void convert_image_to_surface(const Image* image, const Palette* palette,
os::Surface* surface,
int src_x, int src_y, int dst_x, int dst_y, int w, int h);
} // namespace doc
#endif