Skip to content

Commit

Permalink
Use new laf + skia m81 branch
Browse files Browse the repository at this point in the history
* Some minor refactors due laf changes.
* Updated the instructions to compile Aseprite linking to external
  skia instructions and pre-built packages.
  • Loading branch information
dacap committed Mar 2, 2020
1 parent eaa2dd1 commit 95b6551
Show file tree
Hide file tree
Showing 16 changed files with 113 additions and 204 deletions.
176 changes: 22 additions & 154 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
* [Issues with Retina displays](#issues-with-retina-displays)
* [Linux details](#linux-details)
* [Using shared third party libraries](#using-shared-third-party-libraries)
* [Building Skia dependency](#building-skia-dependency)
* [Skia on Windows](#skia-on-windows)
* [Skia on macOS](#skia-on-macos)
* [Skia on Linux](#skia-on-linux)

# Platforms

Expand Down Expand Up @@ -54,32 +50,24 @@ To compile Aseprite you will need:

* The latest version of [CMake](https://cmake.org) (3.14 or greater)
* [Ninja](https://ninja-build.org) build system
* You will need a compiled version of the Skia library.
Please check the details about [how to build Skia](#building-skia-dependency)
on your platform.
* And a compiled version of the `aseprite-m81` branch of
the [Skia library](https://github.com/aseprite/skia#readme).
There are [pre-built packages available](https://github.com/aseprite/skia/releases).
You can get some extra information in
the [*laf* dependencies](https://github.com/aseprite/laf#dependencies) page.

## Windows dependencies

First of all, you will need:

* Windows 10 (**we don't support cross-compiling and don't know if this would be possible**)
* [Visual Studio Community 2019](https://visualstudio.microsoft.com/downloads/)
* The [Desktop development with C++ item + Windows 10.0.17763.0 SDK](https://imgur.com/4Pq2Cbv)
from the Visual Studio installer

You will need to [compile Skia](#skia-on-windows) before and then
continue in the [Compiling](#compiling) section. Remember to check the
[Windows details](#windows-details) section to know how to call
`cmake` correctly.

## macOS dependencies

On macOS you will need macOS 10.14 SDK and Xcode 10.2.1 (older
On macOS you will need macOS 10.15 SDK and Xcode 11.2.1 (older
versions might work).

You must also compile [Skia](#skia-on-macos) before starting with the
[compilation](#compiling).

## Linux dependencies

You will need the following dependencies on Ubuntu/Debian:
Expand All @@ -88,10 +76,7 @@ You will need the following dependencies on Ubuntu/Debian:

On Fedora:

sudo yum install -y gcc-c++ cmake ninja-build libX11-devel libXcursor-devel mesa-libGL-devel fontconfig-devel

You must also compile [Skia](#skia-on-linux) before starting with the
[compilation](#compiling).
sudo dnf install -y gcc-c++ cmake ninja-build libX11-devel libXcursor-devel mesa-libGL-devel fontconfig-devel

# Compiling

Expand All @@ -109,7 +94,7 @@ You must also compile [Skia](#skia-on-linux) before starting with the
2. Enter in the new directory and execute `cmake`:

cd C:\aseprite\build
cmake -G Ninja ..
cmake -G Ninja -DLAF_BACKEND=skia ..

Here `cmake` needs different options depending on your
platform. You must check the details for
Expand All @@ -129,8 +114,7 @@ You must also compile [Skia](#skia-on-linux) before starting with the

## Windows details

After you've [compiled Skia](#skia-on-windows),
open a [developer command prompt](https://docs.microsoft.com/en-us/dotnet/framework/tools/developer-command-prompt-for-vs)
Open a [developer command prompt](https://docs.microsoft.com/en-us/dotnet/framework/tools/developer-command-prompt-for-vs)
or in the command line (`cmd.exe`) call:

call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\VsDevCmd.bat" -arch=x64
Expand All @@ -140,16 +124,15 @@ And then
cd aseprite
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DLAF_OS_BACKEND=skia -DSKIA_DIR=C:\deps\skia -DSKIA_OUT_DIR=C:\deps\skia\out\Release -G Ninja ..
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DLAF_BACKEND=skia -DSKIA_DIR=C:\deps\skia -DSKIA_LIBRARY_DIR=C:\deps\skia\out\Release-x64 -G Ninja ..
ninja aseprite

In this case, `C:\deps\skia` is the directory where Skia was compiled
as described in [Skia on Windows](#skia-on-windows) section.
or uncompressed.

## macOS details

After [compiling Skia](#skia-on-macos), you should run `cmake` with
the following parameters and then `ninja`:
Run `cmake` with the following parameters and then `ninja`:

cd aseprite
mkdir build
Expand All @@ -158,19 +141,18 @@ the following parameters and then `ninja`:
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_OSX_ARCHITECTURES=x86_64 \
-DCMAKE_OSX_DEPLOYMENT_TARGET=10.9 \
-DCMAKE_OSX_SYSROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk \
-DLAF_OS_BACKEND=skia \
-DCMAKE_OSX_SYSROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk \
-DLAF_BACKEND=skia \
-DSKIA_DIR=$HOME/deps/skia \
-DSKIA_OUT_DIR=$HOME/deps/skia/out/Release \
-DSKIA_LIBRARY_DIR=$HOME/deps/skia/out/Release-x64 \
-G Ninja \
..
ninja aseprite

In this case, `$HOME/deps/skia` is the directory where Skia was
compiled as described in [Skia on macOS](#skia-on-macos) section.
Make sure that `CMAKE_OSX_SYSROOT` is pointing to the correct SDK
directory (in this case
`/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk`),
compiled or downloaded. Make sure that `CMAKE_OSX_SYSROOT` is
pointing to the correct SDK directory (in this case
`/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk`),
but it could be different in your Mac.

### Issues with Retina displays
Expand All @@ -181,23 +163,22 @@ If you have a Retina display, check the following issue:

## Linux details

First you have to [compile Skia](#skia-on-linux), then you should run
`cmake` with the following parameters and then `ninja`:
Run `cmake` with the following parameters and then `ninja`:

cd aseprite
mkdir build
cd build
cmake \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DLAF_OS_BACKEND=skia \
-DLAF_BACKEND=skia \
-DSKIA_DIR=$HOME/deps/skia \
-DSKIA_OUT_DIR=$HOME/deps/skia/out/Release \
-DSKIA_LIBRARY_DIR=$HOME/deps/skia/out/Release-x64 \
-G Ninja \
..
ninja aseprite

In this case, `$HOME/deps/skia` is the directory where Skia was
compiled as described in [Skia on Linux](#skia-on-linux) section.
compiled or uncompressed.

# Using shared third party libraries

Expand All @@ -208,116 +189,3 @@ configuring each `USE_SHARED_` option.
After running `cmake -G`, you can edit `build/CMakeCache.txt` file,
and enable the `USE_SHARED_` flag (set its value to `ON`) of the
library that you want to be linked dynamically.

# Building Skia dependency

When you compile Aseprite with [Skia](https://skia.org) as back-end on
Windows or macOS, you need to compile a specific version of Skia. In
the following sections you will find straightforward steps to compile
Skia.

You can always check the
[official Skia instructions](https://skia.org/user/build) and select
the OS you are building for. Aseprite uses the `aseprite-m71` Skia
branch from `https://github.com/aseprite/skia`.

## Skia on Windows

Download
[Google depot tools](https://storage.googleapis.com/chrome-infra/depot_tools.zip)
and uncompress it in some place like `C:\deps\depot_tools`.

[It's recommended to compile Skia with Clang](https://github.com/google/skia/blob/master/site/user/build.md#a-note-on-software-backend-performance)
to get better performance. So you will need to [download Clang](http://releases.llvm.org/8.0.0/LLVM-8.0.0-win64.exe),
and install it on a folder like `C:\deps\llvm` (a folder without whitespaces).

Open a [developer command prompt](https://docs.microsoft.com/en-us/dotnet/framework/tools/developer-command-prompt-for-vs)
or command line (`cmd.exe`) and call:

call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\VsDevCmd.bat" -arch=x64

Then:

set PATH=C:\deps\depot_tools;%PATH%
cd C:\deps\depot_tools
gclient sync

(The `gclient` command might print an error like
`Error: client not configured; see 'gclient config'`.
Just ignore it.)

cd C:\deps
git clone -b aseprite-m71 https://github.com/aseprite/skia.git
cd skia
set GIT_EXECUTABLE=git.bat
python tools/git-sync-deps

(The `tools/git-sync-deps` will take some minutes because it downloads
a lot of packages, please wait and re-run the same command in case it
fails.)

Finally, if you've downloaded Clang, use this command:

set PATH=C:\deps\llvm\bin;%PATH%
gn gen out/Release --args="is_official_build=true skia_use_system_expat=false skia_use_system_libjpeg_turbo=false skia_use_system_libpng=false skia_use_system_libwebp=false skia_use_system_zlib=false target_cpu=""x64"" cc=""clang"" cxx=""clang++"" clang_win=""c:\deps\llvm"" win_vc=""C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC"""
ninja -C out/Release skia

If you haven't installed Clang, and want to compile Skia with MSVC
(anyway it's not recommended because the performance penalty is too
big), you can use the following commands instead:

gn gen out/Release --args="is_official_build=true skia_use_system_expat=false skia_use_system_libjpeg_turbo=false skia_use_system_libpng=false skia_use_system_libwebp=false skia_use_system_zlib=false target_cpu=""x64"" win_vc=""C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC"""
ninja -C out/Release skia

More information about these steps in the
[official Skia documentation](https://skia.org/user/build).

## Skia on macOS

These steps will create a `deps` folder in your home directory with a
couple of subdirectories needed to build Skia (you can change the
`$HOME/deps` with other directory). Some of these commands will take
several minutes to finish:

mkdir $HOME/deps
cd $HOME/deps
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
git clone -b aseprite-m71 https://github.com/aseprite/skia.git
export PATH="${PWD}/depot_tools:${PATH}"
cd skia
python tools/git-sync-deps
gn gen out/Release --args="is_official_build=true skia_use_system_expat=false skia_use_system_icu=false skia_use_libjpeg_turbo=false skia_use_system_libpng=false skia_use_system_libwebp=false skia_use_system_zlib=false extra_cflags_cc=[\"-frtti\"]"
ninja -C out/Release skia

After this you should have all Skia libraries compiled. When you
[compile Aseprite](#compiling), remember to add
`-DSKIA_DIR=$HOME/deps/skia` parameter to your `cmake` call as
described in the [macOS details](#macos-details) section.

More information about these steps in the
[official Skia documentation](https://skia.org/user/build).

## Skia on Linux

These steps will create a `deps` folder in your home directory with a
couple of subdirectories needed to build Skia (you can change the
`$HOME/deps` with other directory). Some of these commands will take
several minutes to finish:

mkdir $HOME/deps
cd $HOME/deps
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
git clone -b aseprite-m71 https://github.com/aseprite/skia.git
export PATH="${PWD}/depot_tools:${PATH}"
cd skia
python tools/git-sync-deps
gn gen out/Release --args="is_debug=false is_official_build=true skia_use_system_expat=false skia_use_system_icu=false skia_use_system_libjpeg_turbo=false skia_use_system_libpng=false skia_use_system_libwebp=false skia_use_system_zlib=false"
ninja -C out/Release skia

After this you should have all Skia libraries compiled. When you
[compile Aseprite](#compiling), remember to add
`-DSKIA_DIR=$HOME/deps/skia` parameter to your `cmake` call as
described in the [Linux details](#linux-details) section.

More information about these steps in the
[official Skia documentation](https://skia.org/user/build).
2 changes: 1 addition & 1 deletion laf
Submodule laf updated 51 files
+40 −20 CMakeLists.txt
+62 −5 README.md
+121 −0 cmake/FindSkia.cmake
+2 −1 cmake/LafFindTests.cmake
+19 −0 examples/CMakeLists.txt
+241 −0 examples/allevents.cpp
+169 −0 examples/complextextlayout.cpp
+112 −0 examples/helloworld.cpp
+108 −0 examples/listfonts.cpp
+2 −11 ft/CMakeLists.txt
+20 −14 gfx/CMakeLists.txt
+3 −2 gfx/packing_rects_tests.cpp
+12 −98 gfx/region.h
+1 −1 gfx/region_pixman.cpp
+115 −0 gfx/region_pixman.h
+86 −0 gfx/region_skia.cpp
+134 −0 gfx/region_skia.h
+3 −2 gfx/region_tests.cpp
+25 −87 os/CMakeLists.txt
+4 −1 os/README.md
+1 −1 os/app_main_tests.cpp
+1 −1 os/common/freetype_font.cpp
+2 −1 os/common/sprite_sheet_font.h
+9 −0 os/common/system.h
+28 −0 os/display.cpp
+9 −3 os/display.h
+0 −17 os/display_handle.h
+20 −15 os/draw_text.cpp
+37 −9 os/draw_text.h
+13 −6 os/font.h
+30 −0 os/font_manager.h
+90 −0 os/font_style.h
+35 −0 os/font_style_set.h
+2 −1 os/none/os.cpp
+40 −31 os/os.h
+24 −0 os/paint.h
+5 −0 os/scoped_handle.h
+32 −41 os/skia/skia_color_space.cpp
+3 −3 os/skia/skia_display.cpp
+2 −2 os/skia/skia_display.h
+45 −0 os/skia/skia_draw_text.cpp
+57 −0 os/skia/skia_draw_text_with_shaper.cpp
+116 −0 os/skia/skia_font_manager.h
+46 −0 os/skia/skia_helpers.h
+25 −1 os/skia/skia_surface.cpp
+15 −65 os/skia/skia_surface.h
+11 −1 os/skia/skia_system.h
+55 −7 os/surface.h
+3 −2 os/system.cpp
+13 −3 os/system.h
+27 −0 os/typeface.h
3 changes: 2 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Aseprite
# Copyright (C) 2019 Igara Studio S.A.
# Copyright (C) 2019-2020 Igara Studio S.A.
# Copyright (C) 2001-2018 David Capello

######################################################################
Expand Down Expand Up @@ -182,6 +182,7 @@ if(ENABLE_ASEPRITE_EXE)
if(WIN32 AND ENABLE_UI)
set_target_properties(aseprite PROPERTIES WIN32_EXECUTABLE true)
endif()
set_target_properties(aseprite PROPERTIES LINK_FLAGS "${LAF_BACKEND_LINK_FLAGS}")
target_link_libraries(aseprite app-lib)
add_dependencies(aseprite copy_data)

Expand Down
4 changes: 2 additions & 2 deletions src/app/app.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -636,7 +636,7 @@ void App::updateDisplayTitleBar()
}

title += defaultTitle;
os::instance()->defaultDisplay()->setTitleBar(title);
os::instance()->defaultDisplay()->setTitle(title);
}

InputChain& App::inputChain()
Expand Down
15 changes: 8 additions & 7 deletions src/app/modules/gfx.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -217,18 +217,19 @@ void draw_alpha_slider(os::Surface* s,
color.getGreen(),
color.getBlue(), 255): 0);

os::Paint paint;
for (int x=0; x<rc.w; ++x) {
const int a = (255 * x / xmax);
const doc::color_t c1 = doc::rgba_blender_normal(gridColor1, c, a);
const doc::color_t c2 = doc::rgba_blender_normal(gridColor2, c, a);
const int mid = rc.h/2;
const int odd = (x / rc.h) & 1;
s->drawVLine(
app::color_utils::color_for_ui(app::Color::fromImage(IMAGE_RGB, odd ? c2: c1)),
rc.x+x, rc.y, mid);
s->drawVLine(
app::color_utils::color_for_ui(app::Color::fromImage(IMAGE_RGB, odd ? c1: c2)),
rc.x+x, rc.y+mid, rc.h-mid);

paint.color(app::color_utils::color_for_ui(app::Color::fromImage(IMAGE_RGB, odd ? c2: c1)));
s->drawRect(gfx::Rect(rc.x+x, rc.y, 1, mid), paint);

paint.color(app::color_utils::color_for_ui(app::Color::fromImage(IMAGE_RGB, odd ? c1: c2)));
s->drawRect(gfx::Rect(rc.x+x, rc.y+mid, 1, rc.h-mid), paint);
}
}

Expand Down
7 changes: 5 additions & 2 deletions src/app/ui/color_selector.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2018 Igara Studio S.A.
// Copyright (C) 2018-2020 Igara Studio S.A.
// Copyright (C) 2016-2018 David Capello
//
// This program is distributed under the terms of
Expand Down Expand Up @@ -113,7 +113,10 @@ class ColorSelector::Painter {

auto oldCanvas = m_canvas;
m_canvas = os::instance()->createSurface(w, h, activeCS);
m_canvas->fillRect(bgColor, gfx::Rect(0, 0, w, h));
os::Paint paint;
paint.color(bgColor);
paint.style(os::Paint::Fill);
m_canvas->drawRect(gfx::Rect(0, 0, w, h), paint);
if (oldCanvas) {
m_canvas->drawSurface(oldCanvas, 0, 0);
oldCanvas->dispose();
Expand Down
10 changes: 6 additions & 4 deletions src/app/ui/color_spectrum.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Aseprite
// Copyright (C) 2020 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
Expand Down Expand Up @@ -111,11 +112,12 @@ void ColorSpectrum::onPaintSurfaceInBgThread(
if (m_paintFlags & BottomBarFlag) {
double lit = m_color.getHslLightness();
double hue = m_color.getHslHue();
os::Paint paint;
for (int x=0; x<bottom.w && !stop; ++x) {
gfx::Color color = color_utils::color_for_ui(
app::Color::fromHsl(hue, double(x) / double(bottom.w), lit));

s->drawVLine(color, bottom.x+x, bottom.y, bottom.h);
paint.color(
color_utils::color_for_ui(
app::Color::fromHsl(hue, double(x) / double(bottom.w), lit)));
s->drawRect(gfx::Rect(bottom.x+x, bottom.y, 1, bottom.h), paint);
}
if (stop)
return;
Expand Down
Loading

0 comments on commit 95b6551

Please sign in to comment.