skia2/BUILD.gn

1526 lines
37 KiB
Plaintext
Raw Normal View History

# Copyright 2016 Google Inc.
#
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("gn/android_framework_defines.gni")
import("gn/shared_sources.gni")
if (is_fuchsia) {
import("//build/vulkan/config.gni")
}
if (!defined(is_skia_standalone)) {
is_skia_standalone = false
}
is_skia_dev_build = is_skia_standalone && !is_official_build
declare_args() {
skia_use_angle = false
skia_use_egl = false
skia_use_expat = true
skia_use_fontconfig = is_linux
skia_use_freetype = is_android || is_fuchsia || is_linux
skia_use_gdi = false
skia_use_icu = !is_fuchsia && !is_ios && !is_win # TODO: Windows
skia_use_libjpeg_turbo = true
skia_use_libpng = true
skia_use_libwebp = !is_fuchsia
skia_use_lua = false
skia_use_mesa = false
skia_use_piex = !is_win
skia_use_zlib = true
skia_android_serial = ""
skia_enable_android_framework_defines = false
skia_enable_discrete_gpu = true
skia_enable_effects = true
skia_enable_gpu = true
skia_enable_pdf = true
skia_enable_spirv_validation = is_skia_dev_build && is_debug
skia_enable_tools = is_skia_dev_build
skia_enable_vulkan_debug_layers = is_skia_dev_build && is_debug
skia_vulkan_sdk = getenv("VULKAN_SDK")
}
declare_args() {
skia_use_dng_sdk = !is_fuchsia && skia_use_libjpeg_turbo && skia_use_zlib
skia_use_sfntly = skia_use_icu
if (is_android) {
skia_use_vulkan = defined(ndk_api) && ndk_api >= 24
} else if (is_fuchsia) {
skia_use_vulkan = fuchsia_use_vulkan
} else {
skia_use_vulkan = skia_vulkan_sdk != ""
}
}
declare_args() {
if (skia_use_vulkan) {
if (is_fuchsia) {
skia_vulkan_headers = "$fuchsia_vulkan_sdk/include"
} else if (is_linux || is_win) {
skia_vulkan_headers = "$skia_vulkan_sdk/include"
} else {
# When buliding on Android we get the header via the NDK
skia_vulkan_headers = ""
}
} else {
skia_vulkan_headers = "third_party/vulkan"
}
}
# Our tools require static linking (they use non-exported symbols).
skia_enable_tools = skia_enable_tools && !is_component_build
fontmgr_android_enabled = skia_use_expat && skia_use_freetype
skia_public_includes = [
"include/android",
"include/c",
"include/codec",
"include/config",
"include/core",
"include/effects",
"include/encode",
"include/gpu",
"include/gpu/gl",
"include/pathops",
"include/ports",
"include/svg",
"include/utils",
"include/utils/mac",
]
# Skia public API, generally provided by :skia.
config("skia_public") {
include_dirs = skia_public_includes
if (skia_vulkan_headers != "") {
include_dirs += [ skia_vulkan_headers ]
}
defines = []
if (is_component_build) {
defines += [ "SKIA_DLL" ]
}
if (is_fuchsia || is_linux) {
defines += [ "SK_SAMPLES_FOR_X" ]
}
if (skia_enable_android_framework_defines) {
defines += android_framework_defines
}
if (!skia_enable_gpu) {
defines += [ "SK_SUPPORT_GPU=0" ]
}
}
# Skia internal APIs, used by Skia itself and a few test tools.
config("skia_private") {
visibility = [ ":*" ]
include_dirs = [
"include/private",
"src/c",
"src/codec",
"src/core",
"src/effects",
"src/fonts",
"src/image",
"src/images",
"src/lazy",
"src/opts",
"src/pathops",
"src/pdf",
"src/ports",
"src/sfnt",
"src/shaders",
"src/shaders/gradients",
"src/sksl",
"src/utils",
"src/utils/win",
"src/xml",
Add support for multiple frames in SkCodec Add an interface to decode frames beyond the first in SkCodec, and add an implementation for SkGifCodec. Add getFrameData to SkCodec. This method reads ahead in the stream to return a vector containing meta data about each frame in the image. This is not required in order to decode frames beyond the first, but it allows a client to learn extra information: - how long the frame should be displayed - whether a frame should be blended with a prior frame, allowing the client to provide the prior frame to speed up decoding Add a new fields to SkCodec::Options: - fFrameIndex - fHasPriorFrame The API is designed so that SkCodec never caches frames. If a client wants a frame beyond the first, they specify the frame in Options.fFrameIndex. If the client does not have the frame's required frame (the frame that this frame must be blended on top of) cached, they pass false for Options.fHasPriorFrame. Unless the frame is independent, the codec will then recursively decode all frames necessary to decode fFrameIndex. If the client has the required frame cached, they can put it in the dst they pass to the codec, and the codec will only draw fFrameIndex onto it. Replace SkGifCodec's scanline decoding support with progressive decoding, and update the tests accordingly. Implement new APIs in SkGifCodec. Instead of using gif_lib, use GIFImageReader, imported from Chromium (along with its copyright headers) with the following changes: - SkGifCodec is now the client - Replace blink types - Combine GIFColorMap::buildTable and ::getTable into a method that creates and returns an SkColorTable - Input comes from an SkStream, instead of a SegmentReader. Add SkStreamBuffer, which buffers the (potentially partial) stream in order to decode progressively. (FIXME: This requires copying data that previously was read directly from the SegmentReader. Does this hurt performance? If so, can we fix it?) - Remove UMA code - Instead of reporting screen width and height to the client, allow the client to query for it - Fail earlier if the first frame AND screen have size of zero - Compute required previous frame when adding a new one - Move GIFParseQuery from GIFImageDecoder to GIFImageReader - Allow parsing up to a specific frame (to skip parsing the rest of the stream if a client only wants the first frame) - Compute whether the first frame has alpha and supports index 8, to create the SkImageInfo. This happens before reporting that the size has been decoded. Add GIFImageDecoder::haveDecodedRow to SkGifCodec, imported from Chromium (along with its copyright header), with the following changes: - Add support for sampling - Use the swizzler - Keep track of the rows decoded - Do *not* keep track of whether we've seen alpha Remove SkCodec::kOutOfOrder_SkScanlineOrder, which was only used by GIF scanline decoding. Call onRewind even if there is no stream (SkGifCodec needs to clear its decoded state so it will decode from the beginning). Add a method to SkSwizzler to access the offset into the dst, taking subsetting into account. Add a GM that animates a GIF. Add tests for the new APIs. *** Behavior changes: * Previously, we reported that an image with a subset frame and no transparent index was opaque and used the background index (if present) to fill the background. This is necessary in order to support index 8, but it does not match viewers/browsers I have seen. Examples: - Chromium and Gimp render the background transparent - Firefox, Safari, Linux Image Viewer, Safari Preview clip to the frame (for a single frame image) This CL matches Chromium's behavior and renders the background transparent. This allows us to have consistent behavior across products and simplifies the code (relative to what we would have to do to continue the old behavior on Android). It also means that we will no longer support index 8 for some GIFs. * Stop checking for GIFSTAMP - all GIFs should be either 89a or 87a. This matches Chromium. I suspect that bugs would have been reported if valid GIFs started with "GIFVER" instead of "GIF89a" or "GIF87a" (but did not decode in Chromium). *** Future work not included in this CL: * Move some checks out of haveDecodedRow, since they are the same for the entire frame e.g. - intersecting the frameRect with the full image size - whether there is a color table * Change when we write transparent pixels - In some cases, Chromium deemed this unnecessary, but I suspect it is slower than the fallback case. There will continue to be cases where we should *not* write them, but for e.g. the first pass where we have already cleared to transparent (which we may also be able to skip) writing the transparent pixels will not make anything incorrect. * Report color type and alpha type per frame - Depending on alpha values, disposal methods, frame rects, etc, subsequent frames may have different properties than the first. * Skip copies of the encoded data - We copy the encoded data in case the stream is one that cannot be rewound, so we can parse and then decode (possibly not immediately). For some input streams, this is unnecessary. - I was concerned this cause a performance regression, but on average the new code is faster than the old for the images I tested [1]. - It may cause a performance regression for Chromium, though, where we can always move back in the stream, so this should be addressed. Design doc: https://docs.google.com/a/google.com/document/d/12Qhf9T92MWfdWujQwCIjhCO3sw6pTJB5pJBwDM1T7Kc/ [1] https://docs.google.com/a/google.com/spreadsheets/d/19V-t9BfbFw5eiwBTKA1qOBkZbchjlTC5EIz6HFy-6RI/ GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=2045293002 Review-Url: https://codereview.chromium.org/2045293002
2016-10-24 16:03:26 +00:00
"third_party/gif",
]
defines = [ "SK_GAMMA_APPLY_TO_A8" ]
if (is_android) {
defines += [
"SK_GAMMA_EXPONENT=1.4",
"SK_GAMMA_CONTRAST=0.0",
]
}
if (is_official_build || is_android) {
# TODO(bsalomon): it'd be nice to make Android normal.
defines += [ "SK_ALLOW_STATIC_GLOBAL_INITIALIZERS=0" ]
}
libs = []
lib_dirs = []
if (skia_use_vulkan) {
if (skia_vulkan_sdk != "" && !is_android && !is_fuchsia) {
if (is_win) {
lib_dirs += [
"$skia_vulkan_sdk/Bin",
"$skia_vulkan_sdk/Lib",
]
} else {
lib_dirs += [ "$skia_vulkan_sdk/lib/" ]
}
}
}
if (skia_enable_gpu) {
include_dirs += [ "src/gpu" ]
}
if (skia_use_angle) {
defines += [ "SK_ANGLE" ]
}
if (skia_enable_discrete_gpu) {
defines += [ "SK_ENABLE_DISCRETE_GPU" ]
}
}
# Any code that's linked into Skia-the-library should use this config via += skia_library_configs.
config("skia_library") {
visibility = [ ":*" ]
defines = [ "SKIA_IMPLEMENTATION=1" ]
}
skia_library_configs = [
":skia_public",
":skia_private",
":skia_library",
]
# Use for CPU-specific Skia code that needs particular compiler flags.
template("opts") {
if (invoker.enabled) {
source_set(target_name) {
forward_variables_from(invoker, "*")
configs += skia_library_configs
}
} else {
# If not enabled, a phony empty target that swallows all otherwise unused variables.
source_set(target_name) {
forward_variables_from(invoker,
"*",
[
"sources",
"cflags",
])
}
}
}
is_x86 = current_cpu == "x64" || current_cpu == "x86"
opts("none") {
enabled = !is_x86 && current_cpu != "arm" && current_cpu != "arm64"
sources = skia_opts.none_sources
cflags = []
}
opts("armv7") {
enabled = current_cpu == "arm"
sources = skia_opts.armv7_sources + skia_opts.neon_sources
cflags = []
}
opts("arm64") {
enabled = current_cpu == "arm64"
sources = skia_opts.arm64_sources
cflags = []
}
opts("crc32") {
enabled = current_cpu == "arm64"
sources = skia_opts.crc32_sources
cflags = [ "-march=armv8-a+crc" ]
}
opts("sse2") {
enabled = is_x86
sources = skia_opts.sse2_sources
if (is_win) {
defines = [ "SK_CPU_SSE_LEVEL=SK_CPU_SSE_LEVEL_SSE2" ]
} else {
cflags = [ "-msse2" ]
}
}
opts("ssse3") {
enabled = is_x86
sources = skia_opts.ssse3_sources
if (is_win) {
defines = [ "SK_CPU_SSE_LEVEL=SK_CPU_SSE_LEVEL_SSSE3" ]
} else {
cflags = [ "-mssse3" ]
}
}
opts("sse41") {
enabled = is_x86
sources = skia_opts.sse41_sources
if (is_win) {
defines = [ "SK_CPU_SSE_LEVEL=SK_CPU_SSE_LEVEL_SSE41" ]
} else {
cflags = [ "-msse4.1" ]
}
}
opts("sse42") {
enabled = is_x86
sources = skia_opts.sse42_sources
if (is_win) {
defines = [ "SK_CPU_SSE_LEVEL=SK_CPU_SSE_LEVEL_SSE42" ]
} else {
cflags = [ "-msse4.2" ]
}
}
opts("avx") {
enabled = is_x86
sources = skia_opts.avx_sources
if (is_win) {
cflags = [ "/arch:AVX" ]
} else {
cflags = [ "-mavx" ]
}
}
opts("hsw") {
enabled = is_x86
sources = skia_opts.hsw_sources
if (is_win) {
cflags = [ "/arch:AVX2" ]
} else {
cflags = [
"-mavx2",
"-mbmi",
"-mbmi2",
"-mf16c",
"-mfma",
]
}
}
# Any feature of Skia that requires third-party code should be optional and use this template.
template("optional") {
if (invoker.enabled) {
config(target_name + "_public") {
if (defined(invoker.public_defines)) {
defines = invoker.public_defines
}
}
source_set(target_name) {
forward_variables_from(invoker,
"*",
[
"public_defines",
"sources_when_disabled",
"configs_to_remove",
])
all_dependent_configs = [ ":" + target_name + "_public" ]
configs += skia_library_configs
if (defined(invoker.configs_to_remove)) {
configs -= invoker.configs_to_remove
}
}
} else {
source_set(target_name) {
forward_variables_from(invoker,
"*",
[
"public_defines",
"deps",
"libs",
"sources",
"sources_when_disabled",
"configs_to_remove",
])
if (defined(invoker.sources_when_disabled)) {
sources = invoker.sources_when_disabled
}
configs += skia_library_configs
}
}
}
optional("effects") {
enabled = skia_enable_effects
sources =
skia_effects_sources + [ "src/ports/SkGlobalInitialization_default.cpp" ]
sources_when_disabled = [ "src/ports/SkGlobalInitialization_none.cpp" ]
}
optional("fontmgr_android") {
enabled = fontmgr_android_enabled
deps = [
":typeface_freetype",
"//third_party/expat",
]
sources = [
"src/ports/SkFontMgr_android.cpp",
"src/ports/SkFontMgr_android_factory.cpp",
"src/ports/SkFontMgr_android_parser.cpp",
]
}
optional("fontmgr_custom") {
enabled = is_linux && skia_use_freetype && !skia_use_fontconfig
deps = [
":typeface_freetype",
]
sources = [
"src/ports/SkFontMgr_custom.cpp",
"src/ports/SkFontMgr_custom.h",
"src/ports/SkFontMgr_custom_directory.cpp",
"src/ports/SkFontMgr_custom_directory_factory.cpp",
"src/ports/SkFontMgr_custom_embedded.cpp",
"src/ports/SkFontMgr_custom_empty.cpp",
]
}
optional("fontmgr_fontconfig") {
enabled = skia_use_freetype && skia_use_fontconfig
deps = [
":typeface_freetype",
"//third_party:fontconfig",
]
sources = [
"src/ports/SkFontConfigInterface.cpp",
"src/ports/SkFontConfigInterface_direct.cpp",
"src/ports/SkFontConfigInterface_direct_factory.cpp",
"src/ports/SkFontMgr_FontConfigInterface.cpp",
"src/ports/SkFontMgr_fontconfig.cpp",
"src/ports/SkFontMgr_fontconfig_factory.cpp",
]
}
optional("fontmgr_fuchsia") {
enabled = is_fuchsia && skia_use_freetype
deps = [
":typeface_freetype",
]
sources = [
"src/ports/SkFontMgr_custom.cpp",
"src/ports/SkFontMgr_custom_empty.cpp",
"src/ports/SkFontMgr_custom_empty_factory.cpp",
]
}
optional("gpu") {
enabled = skia_enable_gpu
public_defines = []
sources = skia_gpu_sources + skia_sksl_sources +
[ "src/gpu/gl/GrGLDefaultInterface_native.cpp" ]
# These paths need to be absolute to match the ones produced by shared_sources.gni.
sources -= get_path_info([
"src/gpu/gl/GrGLCreateNativeInterface_none.cpp",
"src/gpu/gl/GrGLDefaultInterface_none.cpp",
],
"abspath")
libs = []
if (is_android) {
sources += [ "src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp" ]
} else if (skia_use_egl) {
sources += [ "src/gpu/gl/egl/GrGLCreateNativeInterface_egl.cpp" ]
libs += [ "EGL" ]
} else if (is_linux) {
sources += [ "src/gpu/gl/glx/GrGLCreateNativeInterface_glx.cpp" ]
libs += [
"GL",
"GLU",
]
} else if (is_mac) {
sources += [ "src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp" ]
} else if (is_ios) {
sources += [ "src/gpu/gl/iOS/GrGLCreateNativeInterface_iOS.cpp" ]
} else if (is_win) {
sources += [ "src/gpu/gl/win/GrGLCreateNativeInterface_win.cpp" ]
libs += [ "OpenGL32.lib" ]
} else {
sources += [ "src/gpu/gl/GrGLCreateNativeInterface_none.cpp" ]
}
if (skia_use_vulkan) {
public_defines += [ "SK_VULKAN" ]
sources += skia_vk_sources
if (skia_enable_vulkan_debug_layers) {
public_defines += [ "SK_ENABLE_VK_LAYERS" ]
}
}
if (skia_enable_spirv_validation) {
deps = [
"//third_party/spirv-tools",
]
public_defines += [ "SK_ENABLE_SPIRV_VALIDATION" ]
}
}
optional("jpeg") {
enabled = skia_use_libjpeg_turbo
public_defines = [ "SK_HAS_JPEG_LIBRARY" ]
deps = [
"//third_party/libjpeg-turbo:libjpeg",
]
sources = [
"src/codec/SkJpegCodec.cpp",
"src/codec/SkJpegDecoderMgr.cpp",
"src/codec/SkJpegUtility.cpp",
"src/images/SkJPEGWriteUtility.cpp",
"src/images/SkJpegEncoder.cpp",
]
}
optional("pdf") {
enabled = skia_use_zlib && skia_enable_pdf
public_defines = [ "SK_SUPPORT_PDF" ]
deps = [
"//third_party/zlib",
]
sources = skia_pdf_sources
sources_when_disabled = [ "src/pdf/SkDocument_PDF_None.cpp" ]
if (skia_use_sfntly) {
deps += [ "//third_party/sfntly" ]
public_defines += [ "SK_PDF_USE_SFNTLY" ]
}
}
optional("png") {
enabled = skia_use_libpng
public_defines = [ "SK_HAS_PNG_LIBRARY" ]
deps = [
"//third_party/libpng",
]
sources = [
"src/codec/SkIcoCodec.cpp",
"src/codec/SkPngCodec.cpp",
"src/images/SkPngEncoder.cpp",
]
}
optional("raw") {
enabled = skia_use_dng_sdk && skia_use_libjpeg_turbo && skia_use_piex
public_defines = [ "SK_CODEC_DECODES_RAW" ]
deps = [
"//third_party/dng_sdk",
"//third_party/libjpeg-turbo:libjpeg",
"//third_party/piex",
]
# SkRawCodec catches any exceptions thrown by dng_sdk, insulating the rest of
# Skia.
configs_to_remove = [ "//gn:no_exceptions" ]
sources = [
"src/codec/SkRawAdapterCodec.cpp",
"src/codec/SkRawCodec.cpp",
]
}
optional("typeface_freetype") {
enabled = skia_use_freetype
deps = [
"//third_party/freetype2",
]
sources = [
"src/ports/SkFontHost_FreeType.cpp",
"src/ports/SkFontHost_FreeType_common.cpp",
]
}
optional("webp") {
enabled = skia_use_libwebp
public_defines = [ "SK_HAS_WEBP_LIBRARY" ]
deps = [
"//third_party/libwebp",
]
sources = [
"src/codec/SkWebpAdapterCodec.cpp",
"src/codec/SkWebpCodec.cpp",
"src/images/SkWebpEncoder.cpp",
]
}
optional("xml") {
enabled = skia_use_expat
Revert "Revert "GN: define SK_XML to indicate :xml is enabled."" This reverts commit 7e8f80a08444f534376a25d45194c92f948c9594. Reason for revert: the SVG DM flakiness should be fixed by now. Original change's description: > Revert "GN: define SK_XML to indicate :xml is enabled." > > This reverts commit 7234448c11b0493a072723acd185dae986103df6. > > Reason for revert: this enabled tests which are making the bots flaky. > > Original change's description: > > GN: define SK_XML to indicate :xml is enabled. > > > > Without this, nothing ever defines SK_XML for dm/DM.cpp, dm/DMSrcSink.cpp, tests/SkDOMTest.cpp or tests/SkPEGTest.cpp. > > > > GYP does something similiar in gyp/xml.gyp. > > > > BUG=skia: > > > > GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4500 > > > > Change-Id: I93322722d6d86f5802495d7a2edad2f82ba36f69 > > Reviewed-on: https://skia-review.googlesource.com/4500 > > Reviewed-by: Hal Canary <halcanary@google.com> > > Commit-Queue: Eric Boren <borenet@google.com> > > Commit-Queue: Mike Klein <mtklein@chromium.org> > > > > TBR=mtklein@chromium.org,borenet@google.com,halcanary@google.com > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > > Change-Id: I46c198f4985f6e7f96c07b3100a3877ba46fdb18 > Reviewed-on: https://skia-review.googlesource.com/4526 > Commit-Queue: Mike Klein <mtklein@chromium.org> > Reviewed-by: Mike Klein <mtklein@chromium.org> > TBR=mtklein@chromium.org,borenet@google.com,halcanary@google.com,fmalita@chromium.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Change-Id: Ic3225f119dff3c6949a3b559ac60707d36bc3792 Reviewed-on: https://skia-review.googlesource.com/4544 Commit-Queue: Florin Malita <fmalita@chromium.org> Reviewed-by: Florin Malita <fmalita@chromium.org>
2016-11-08 16:07:52 +00:00
public_defines = [ "SK_XML" ]
deps = [
"//third_party/expat",
]
sources = [
"src/svg/SkSVGCanvas.cpp",
"src/svg/SkSVGDevice.cpp",
"src/xml/SkDOM.cpp",
"src/xml/SkXMLParser.cpp",
"src/xml/SkXMLWriter.cpp",
]
}
component("skia") {
public_configs = [ ":skia_public" ]
configs += skia_library_configs
deps = [
":arm64",
":armv7",
":avx",
":crc32",
":effects",
":fontmgr_android",
":fontmgr_custom",
":fontmgr_fontconfig",
":fontmgr_fuchsia",
":gpu",
":hsw",
":jpeg",
":none",
":pdf",
":png",
":raw",
":sse2",
":sse41",
":sse42",
":ssse3",
":webp",
":xml",
]
# This file (and all GN files in Skia) are designed to work with an
# empty sources assignment filter; we handle all that explicitly.
# We clear the filter here for clients who may have set up a global filter.
set_sources_assignment_filter([])
sources = []
sources += skia_core_sources
sources += skia_utils_sources
sources += skia_xps_sources
sources += [
"src/android/SkBitmapRegionCodec.cpp",
"src/android/SkBitmapRegionDecoder.cpp",
"src/codec/SkAndroidCodec.cpp",
"src/codec/SkBmpCodec.cpp",
"src/codec/SkBmpMaskCodec.cpp",
"src/codec/SkBmpRLECodec.cpp",
"src/codec/SkBmpStandardCodec.cpp",
"src/codec/SkCodec.cpp",
"src/codec/SkCodecImageGenerator.cpp",
Add support for multiple frames in SkCodec Add an interface to decode frames beyond the first in SkCodec, and add an implementation for SkGifCodec. Add getFrameData to SkCodec. This method reads ahead in the stream to return a vector containing meta data about each frame in the image. This is not required in order to decode frames beyond the first, but it allows a client to learn extra information: - how long the frame should be displayed - whether a frame should be blended with a prior frame, allowing the client to provide the prior frame to speed up decoding Add a new fields to SkCodec::Options: - fFrameIndex - fHasPriorFrame The API is designed so that SkCodec never caches frames. If a client wants a frame beyond the first, they specify the frame in Options.fFrameIndex. If the client does not have the frame's required frame (the frame that this frame must be blended on top of) cached, they pass false for Options.fHasPriorFrame. Unless the frame is independent, the codec will then recursively decode all frames necessary to decode fFrameIndex. If the client has the required frame cached, they can put it in the dst they pass to the codec, and the codec will only draw fFrameIndex onto it. Replace SkGifCodec's scanline decoding support with progressive decoding, and update the tests accordingly. Implement new APIs in SkGifCodec. Instead of using gif_lib, use GIFImageReader, imported from Chromium (along with its copyright headers) with the following changes: - SkGifCodec is now the client - Replace blink types - Combine GIFColorMap::buildTable and ::getTable into a method that creates and returns an SkColorTable - Input comes from an SkStream, instead of a SegmentReader. Add SkStreamBuffer, which buffers the (potentially partial) stream in order to decode progressively. (FIXME: This requires copying data that previously was read directly from the SegmentReader. Does this hurt performance? If so, can we fix it?) - Remove UMA code - Instead of reporting screen width and height to the client, allow the client to query for it - Fail earlier if the first frame AND screen have size of zero - Compute required previous frame when adding a new one - Move GIFParseQuery from GIFImageDecoder to GIFImageReader - Allow parsing up to a specific frame (to skip parsing the rest of the stream if a client only wants the first frame) - Compute whether the first frame has alpha and supports index 8, to create the SkImageInfo. This happens before reporting that the size has been decoded. Add GIFImageDecoder::haveDecodedRow to SkGifCodec, imported from Chromium (along with its copyright header), with the following changes: - Add support for sampling - Use the swizzler - Keep track of the rows decoded - Do *not* keep track of whether we've seen alpha Remove SkCodec::kOutOfOrder_SkScanlineOrder, which was only used by GIF scanline decoding. Call onRewind even if there is no stream (SkGifCodec needs to clear its decoded state so it will decode from the beginning). Add a method to SkSwizzler to access the offset into the dst, taking subsetting into account. Add a GM that animates a GIF. Add tests for the new APIs. *** Behavior changes: * Previously, we reported that an image with a subset frame and no transparent index was opaque and used the background index (if present) to fill the background. This is necessary in order to support index 8, but it does not match viewers/browsers I have seen. Examples: - Chromium and Gimp render the background transparent - Firefox, Safari, Linux Image Viewer, Safari Preview clip to the frame (for a single frame image) This CL matches Chromium's behavior and renders the background transparent. This allows us to have consistent behavior across products and simplifies the code (relative to what we would have to do to continue the old behavior on Android). It also means that we will no longer support index 8 for some GIFs. * Stop checking for GIFSTAMP - all GIFs should be either 89a or 87a. This matches Chromium. I suspect that bugs would have been reported if valid GIFs started with "GIFVER" instead of "GIF89a" or "GIF87a" (but did not decode in Chromium). *** Future work not included in this CL: * Move some checks out of haveDecodedRow, since they are the same for the entire frame e.g. - intersecting the frameRect with the full image size - whether there is a color table * Change when we write transparent pixels - In some cases, Chromium deemed this unnecessary, but I suspect it is slower than the fallback case. There will continue to be cases where we should *not* write them, but for e.g. the first pass where we have already cleared to transparent (which we may also be able to skip) writing the transparent pixels will not make anything incorrect. * Report color type and alpha type per frame - Depending on alpha values, disposal methods, frame rects, etc, subsequent frames may have different properties than the first. * Skip copies of the encoded data - We copy the encoded data in case the stream is one that cannot be rewound, so we can parse and then decode (possibly not immediately). For some input streams, this is unnecessary. - I was concerned this cause a performance regression, but on average the new code is faster than the old for the images I tested [1]. - It may cause a performance regression for Chromium, though, where we can always move back in the stream, so this should be addressed. Design doc: https://docs.google.com/a/google.com/document/d/12Qhf9T92MWfdWujQwCIjhCO3sw6pTJB5pJBwDM1T7Kc/ [1] https://docs.google.com/a/google.com/spreadsheets/d/19V-t9BfbFw5eiwBTKA1qOBkZbchjlTC5EIz6HFy-6RI/ GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=2045293002 Review-Url: https://codereview.chromium.org/2045293002
2016-10-24 16:03:26 +00:00
"src/codec/SkGifCodec.cpp",
"src/codec/SkMaskSwizzler.cpp",
"src/codec/SkMasks.cpp",
"src/codec/SkSampledCodec.cpp",
"src/codec/SkSampler.cpp",
Add support for multiple frames in SkCodec Add an interface to decode frames beyond the first in SkCodec, and add an implementation for SkGifCodec. Add getFrameData to SkCodec. This method reads ahead in the stream to return a vector containing meta data about each frame in the image. This is not required in order to decode frames beyond the first, but it allows a client to learn extra information: - how long the frame should be displayed - whether a frame should be blended with a prior frame, allowing the client to provide the prior frame to speed up decoding Add a new fields to SkCodec::Options: - fFrameIndex - fHasPriorFrame The API is designed so that SkCodec never caches frames. If a client wants a frame beyond the first, they specify the frame in Options.fFrameIndex. If the client does not have the frame's required frame (the frame that this frame must be blended on top of) cached, they pass false for Options.fHasPriorFrame. Unless the frame is independent, the codec will then recursively decode all frames necessary to decode fFrameIndex. If the client has the required frame cached, they can put it in the dst they pass to the codec, and the codec will only draw fFrameIndex onto it. Replace SkGifCodec's scanline decoding support with progressive decoding, and update the tests accordingly. Implement new APIs in SkGifCodec. Instead of using gif_lib, use GIFImageReader, imported from Chromium (along with its copyright headers) with the following changes: - SkGifCodec is now the client - Replace blink types - Combine GIFColorMap::buildTable and ::getTable into a method that creates and returns an SkColorTable - Input comes from an SkStream, instead of a SegmentReader. Add SkStreamBuffer, which buffers the (potentially partial) stream in order to decode progressively. (FIXME: This requires copying data that previously was read directly from the SegmentReader. Does this hurt performance? If so, can we fix it?) - Remove UMA code - Instead of reporting screen width and height to the client, allow the client to query for it - Fail earlier if the first frame AND screen have size of zero - Compute required previous frame when adding a new one - Move GIFParseQuery from GIFImageDecoder to GIFImageReader - Allow parsing up to a specific frame (to skip parsing the rest of the stream if a client only wants the first frame) - Compute whether the first frame has alpha and supports index 8, to create the SkImageInfo. This happens before reporting that the size has been decoded. Add GIFImageDecoder::haveDecodedRow to SkGifCodec, imported from Chromium (along with its copyright header), with the following changes: - Add support for sampling - Use the swizzler - Keep track of the rows decoded - Do *not* keep track of whether we've seen alpha Remove SkCodec::kOutOfOrder_SkScanlineOrder, which was only used by GIF scanline decoding. Call onRewind even if there is no stream (SkGifCodec needs to clear its decoded state so it will decode from the beginning). Add a method to SkSwizzler to access the offset into the dst, taking subsetting into account. Add a GM that animates a GIF. Add tests for the new APIs. *** Behavior changes: * Previously, we reported that an image with a subset frame and no transparent index was opaque and used the background index (if present) to fill the background. This is necessary in order to support index 8, but it does not match viewers/browsers I have seen. Examples: - Chromium and Gimp render the background transparent - Firefox, Safari, Linux Image Viewer, Safari Preview clip to the frame (for a single frame image) This CL matches Chromium's behavior and renders the background transparent. This allows us to have consistent behavior across products and simplifies the code (relative to what we would have to do to continue the old behavior on Android). It also means that we will no longer support index 8 for some GIFs. * Stop checking for GIFSTAMP - all GIFs should be either 89a or 87a. This matches Chromium. I suspect that bugs would have been reported if valid GIFs started with "GIFVER" instead of "GIF89a" or "GIF87a" (but did not decode in Chromium). *** Future work not included in this CL: * Move some checks out of haveDecodedRow, since they are the same for the entire frame e.g. - intersecting the frameRect with the full image size - whether there is a color table * Change when we write transparent pixels - In some cases, Chromium deemed this unnecessary, but I suspect it is slower than the fallback case. There will continue to be cases where we should *not* write them, but for e.g. the first pass where we have already cleared to transparent (which we may also be able to skip) writing the transparent pixels will not make anything incorrect. * Report color type and alpha type per frame - Depending on alpha values, disposal methods, frame rects, etc, subsequent frames may have different properties than the first. * Skip copies of the encoded data - We copy the encoded data in case the stream is one that cannot be rewound, so we can parse and then decode (possibly not immediately). For some input streams, this is unnecessary. - I was concerned this cause a performance regression, but on average the new code is faster than the old for the images I tested [1]. - It may cause a performance regression for Chromium, though, where we can always move back in the stream, so this should be addressed. Design doc: https://docs.google.com/a/google.com/document/d/12Qhf9T92MWfdWujQwCIjhCO3sw6pTJB5pJBwDM1T7Kc/ [1] https://docs.google.com/a/google.com/spreadsheets/d/19V-t9BfbFw5eiwBTKA1qOBkZbchjlTC5EIz6HFy-6RI/ GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=2045293002 Review-Url: https://codereview.chromium.org/2045293002
2016-10-24 16:03:26 +00:00
"src/codec/SkStreamBuffer.cpp",
"src/codec/SkSwizzler.cpp",
"src/codec/SkWbmpCodec.cpp",
"src/images/SkImageEncoder.cpp",
"src/ports/SkDiscardableMemory_none.cpp",
"src/ports/SkImageGenerator_skia.cpp",
"src/ports/SkMemory_malloc.cpp",
"src/ports/SkOSFile_stdio.cpp",
"src/sfnt/SkOTTable_name.cpp",
"src/sfnt/SkOTUtils.cpp",
"src/utils/mac/SkStream_mac.cpp",
"third_party/gif/SkGifImageReader.cpp",
]
libs = []
if (is_win) {
sources += [
"src/fonts/SkFontMgr_indirect.cpp",
"src/ports/SkDebug_win.cpp",
"src/ports/SkFontHost_win.cpp",
"src/ports/SkFontMgr_win_dw.cpp",
"src/ports/SkImageEncoder_WIC.cpp",
"src/ports/SkImageGeneratorWIC.cpp",
"src/ports/SkOSFile_win.cpp",
"src/ports/SkOSLibrary_win.cpp",
"src/ports/SkScalerContext_win_dw.cpp",
"src/ports/SkTLS_win.cpp",
"src/ports/SkTypeface_win_dw.cpp",
]
if (skia_use_gdi) {
sources += [ "src/ports/SkFontMgr_win_gdi_factory.cpp" ]
libs += [
"Gdi32.lib",
"Usp10.lib",
]
} else {
sources += [ "src/ports/SkFontMgr_win_dw_factory.cpp" ]
}
sources -=
[ get_path_info("src/utils/SkThreadUtils_pthread.cpp", "abspath") ]
libs += [
"FontSub.lib",
"Ole32.lib",
"OleAut32.lib",
"User32.lib",
]
} else {
sources += [
"src/ports/SkOSFile_posix.cpp",
"src/ports/SkOSLibrary_posix.cpp",
"src/ports/SkTLS_pthread.cpp",
]
}
if (is_android) {
deps += [ "//third_party/expat" ]
Strengthen is_official_build, update docs. This makes is_official_build turn off all development targets and features in Skia, including building third-party dependencies from source. This will intentionally break some external users, who will find themselves no longer able to find third-party headers or link against third-party libraries. These users have been building with our testing third-party dependencies unknowingly. They'll need to either explicitly turn back on building each dependency from source (skia_use_system_foo=false) or disable that dependency entirely (skia_use_foo=false). is_skia_standalone is now basically !is_official_build, so I've propagated that through, removing is_skia_standalone. In a few places we were using it as a stand-in for defined(ndk), so I've just written defined(ndk) there. Duh. gn_to_bp: is_offical_build's new strength also makes gn_to_bp.py simpler to write. In spirit, Android builds are official Skia builds that also build DM and nanobench. It seems that SkJumper (src/jumper/*) is (unintentionally) enabled on Android. Switching to an is_official_build would have disabled that. But as that accidental launch seems to have gone fine, I've kept it explicitly enabled. In the end, no changes to Android.bp or its SkUserConfig.h. The -Mini builder no longer needs to explicitly disable tools. CQ_INCLUDE_TRYBOTS=skia.primary:Build-Ubuntu-Clang-x86_64-Release-Mini Change-Id: Id06e53268a5caf55c6046ada354a0863c3031c73 Reviewed-on: https://skia-review.googlesource.com/9190 Reviewed-by: Leon Scroggins <scroggo@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org>
2017-03-03 14:21:30 +00:00
if (defined(ndk) && ndk != "") {
deps += [ "//third_party/cpu-features" ]
}
sources += [ "src/ports/SkDebug_android.cpp" ]
libs += [
"EGL",
"GLESv2",
"log",
]
}
if (is_linux) {
sources += [ "src/ports/SkDebug_stdio.cpp" ]
}
if (is_mac) {
sources += [
"src/ports/SkDebug_stdio.cpp",
"src/ports/SkFontHost_mac.cpp",
"src/ports/SkImageEncoder_CG.cpp",
"src/ports/SkImageGeneratorCG.cpp",
]
libs += [
# AppKit symbols NSFontWeightXXX may be dlsym'ed.
"AppKit.framework",
"ApplicationServices.framework",
"OpenGL.framework",
]
}
if (is_ios) {
sources += [
"src/ports/SkDebug_stdio.cpp",
"src/ports/SkFontHost_mac.cpp",
"src/ports/SkImageEncoder_CG.cpp",
"src/ports/SkImageGeneratorCG.cpp",
]
libs += [
"CoreFoundation.framework",
"CoreGraphics.framework",
"CoreText.framework",
"ImageIO.framework",
"MobileCoreServices.framework",
# UIKit symbols UIFontWeightXXX may be dlsym'ed.
"UIKit.framework",
]
}
if (is_fuchsia) {
sources += [ "src/ports/SkDebug_stdio.cpp" ]
}
}
# Targets guarded by skia_enable_tools may use //third_party freely.
if (skia_enable_tools) {
# Used by gn_to_bp.py to list our public include dirs.
source_set("public") {
configs += [ ":skia_public" ]
}
config("skia.h_config") {
include_dirs = [ "$target_gen_dir" ]
}
action("skia.h") {
public_configs = [ ":skia.h_config" ]
skia_h = "$target_gen_dir/skia.h"
script = "gn/find_headers.py"
args = [ rebase_path(skia_h, root_build_dir) ] +
rebase_path(skia_public_includes) +
[ rebase_path("third_party/vulkan") ]
depfile = "$skia_h.deps"
outputs = [
skia_h,
]
}
if (skia_enable_gpu && target_cpu == "x64") {
# Our bots only have 64-bit libOSMesa installed.
# TODO: worth fixing?
executable("fiddle") {
libs = []
if (is_linux) {
libs += [ "OSMesa" ]
}
sources = [
"tools/fiddle/draw.cpp",
"tools/fiddle/fiddle_main.cpp",
]
testonly = true
deps = [
":flags",
":skia",
":skia.h",
]
}
}
if (skia_enable_gpu) {
source_set("public_headers_warnings_check") {
sources = [
"tools/public_headers_warnings_check.cpp",
]
configs -= [ "//gn:warnings_except_public_headers" ]
deps = [
":skia",
":skia.h",
]
}
}
template("test_lib") {
config(target_name + "_config") {
include_dirs = invoker.public_include_dirs
if (defined(invoker.public_defines)) {
defines = invoker.public_defines
}
}
source_set(target_name) {
forward_variables_from(invoker, "*", [ "public_include_dirs" ])
public_configs = [
":" + target_name + "_config",
":skia_private",
]
if (!defined(deps)) {
deps = []
}
deps += [ ":skia" ]
testonly = true
}
}
template("test_app") {
if (defined(invoker.is_shared_library) && invoker.is_shared_library) {
shared_library("lib" + target_name) {
forward_variables_from(invoker, "*", [ "is_shared_library" ])
testonly = true
}
} else {
_executable = target_name
executable(_executable) {
forward_variables_from(invoker, "*", [ "is_shared_library" ])
testonly = true
}
}
if (is_android && skia_android_serial != "" && defined(_executable)) {
action("push_" + target_name) {
script = "gn/push_to_android.py"
deps = [
":" + _executable,
]
_stamp = "$target_gen_dir/$_executable.pushed_$skia_android_serial"
outputs = [
_stamp,
]
args = [
rebase_path("$root_build_dir/$_executable"),
skia_android_serial,
rebase_path(_stamp),
]
testonly = true
}
}
}
test_lib("gpu_tool_utils") {
public_include_dirs = []
if (skia_enable_gpu) {
public_defines = []
public_include_dirs += [ "tools/gpu" ]
deps = []
sources = [
"tools/gpu/GrContextFactory.cpp",
"tools/gpu/GrTest.cpp",
"tools/gpu/TestContext.cpp",
"tools/gpu/gl/GLTestContext.cpp",
"tools/gpu/gl/command_buffer/GLTestContext_command_buffer.cpp",
"tools/gpu/gl/debug/DebugGLTestContext.cpp",
"tools/gpu/gl/debug/GrBufferObj.cpp",
"tools/gpu/gl/debug/GrFrameBufferObj.cpp",
"tools/gpu/gl/debug/GrProgramObj.cpp",
"tools/gpu/gl/debug/GrShaderObj.cpp",
"tools/gpu/gl/debug/GrTextureObj.cpp",
"tools/gpu/gl/debug/GrTextureUnitObj.cpp",
"tools/gpu/gl/null/NullGLTestContext.cpp",
]
libs = []
if (is_android || skia_use_egl) {
sources += [ "tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp" ]
} else if (is_ios) {
sources += [ "tools/gpu/gl/iOS/CreatePlatformGLTestContext_iOS.mm" ]
libs += [ "OpenGLES.framework" ]
} else if (is_linux) {
sources += [ "tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp" ]
libs += [ "X11" ]
} else if (is_mac) {
sources += [ "tools/gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp" ]
} else if (is_win) {
sources += [ "tools/gpu/gl/win/CreatePlatformGLTestContext_win.cpp" ]
libs += [
"Gdi32.lib",
"OpenGL32.lib",
]
}
if (skia_use_angle) {
deps += [ "//third_party/angle2" ]
sources += [ "tools/gpu/gl/angle/GLTestContext_angle.cpp" ]
}
if (skia_use_mesa) {
public_defines += [ "SK_MESA" ]
sources += [ "tools/gpu/gl/mesa/GLTestContext_mesa.cpp" ]
libs += [ "OSMesa" ]
}
if (skia_use_vulkan) {
sources += [ "tools/gpu/vk/VkTestContext.cpp" ]
if (is_win) {
libs += [ "vulkan-1.lib" ]
} else {
libs += [ "vulkan" ]
}
}
}
}
test_lib("flags") {
public_include_dirs = [ "tools/flags" ]
sources = [
"tools/flags/SkCommandLineFlags.cpp",
]
}
test_lib("common_flags") {
public_include_dirs = [ "tools/flags" ]
sources = [
"tools/flags/SkCommonFlags.cpp",
"tools/flags/SkCommonFlagsConfig.cpp",
]
deps = [
":flags",
":gpu_tool_utils",
]
}
test_lib("tool_utils") {
public_include_dirs = [
"tools",
"tools/debugger",
"tools/timer",
]
sources = [
"tools/AndroidSkDebugToStdOut.cpp",
"tools/CrashHandler.cpp",
"tools/LsanSuppressions.cpp",
"tools/ProcStats.cpp",
"tools/Resources.cpp",
"tools/ThermalManager.cpp",
"tools/UrlDataManager.cpp",
"tools/debugger/SkDebugCanvas.cpp",
"tools/debugger/SkDrawCommand.cpp",
"tools/debugger/SkJsonWriteBuffer.cpp",
"tools/debugger/SkObjectParser.cpp",
"tools/picture_utils.cpp",
"tools/random_parse_path.cpp",
"tools/sk_tool_utils.cpp",
"tools/sk_tool_utils_font.cpp",
"tools/timer/Timer.cpp",
]
libs = []
if (is_ios) {
sources += [ "tools/ios_utils.m" ]
libs += [ "Foundation.framework" ]
}
deps = [
":common_flags",
":flags",
"//third_party/libpng",
]
public_deps = [
"//third_party/jsoncpp",
]
}
import("gn/gm.gni")
test_lib("gm") {
public_include_dirs = [ "gm" ]
sources = gm_sources
deps = [
Add support for multiple frames in SkCodec Add an interface to decode frames beyond the first in SkCodec, and add an implementation for SkGifCodec. Add getFrameData to SkCodec. This method reads ahead in the stream to return a vector containing meta data about each frame in the image. This is not required in order to decode frames beyond the first, but it allows a client to learn extra information: - how long the frame should be displayed - whether a frame should be blended with a prior frame, allowing the client to provide the prior frame to speed up decoding Add a new fields to SkCodec::Options: - fFrameIndex - fHasPriorFrame The API is designed so that SkCodec never caches frames. If a client wants a frame beyond the first, they specify the frame in Options.fFrameIndex. If the client does not have the frame's required frame (the frame that this frame must be blended on top of) cached, they pass false for Options.fHasPriorFrame. Unless the frame is independent, the codec will then recursively decode all frames necessary to decode fFrameIndex. If the client has the required frame cached, they can put it in the dst they pass to the codec, and the codec will only draw fFrameIndex onto it. Replace SkGifCodec's scanline decoding support with progressive decoding, and update the tests accordingly. Implement new APIs in SkGifCodec. Instead of using gif_lib, use GIFImageReader, imported from Chromium (along with its copyright headers) with the following changes: - SkGifCodec is now the client - Replace blink types - Combine GIFColorMap::buildTable and ::getTable into a method that creates and returns an SkColorTable - Input comes from an SkStream, instead of a SegmentReader. Add SkStreamBuffer, which buffers the (potentially partial) stream in order to decode progressively. (FIXME: This requires copying data that previously was read directly from the SegmentReader. Does this hurt performance? If so, can we fix it?) - Remove UMA code - Instead of reporting screen width and height to the client, allow the client to query for it - Fail earlier if the first frame AND screen have size of zero - Compute required previous frame when adding a new one - Move GIFParseQuery from GIFImageDecoder to GIFImageReader - Allow parsing up to a specific frame (to skip parsing the rest of the stream if a client only wants the first frame) - Compute whether the first frame has alpha and supports index 8, to create the SkImageInfo. This happens before reporting that the size has been decoded. Add GIFImageDecoder::haveDecodedRow to SkGifCodec, imported from Chromium (along with its copyright header), with the following changes: - Add support for sampling - Use the swizzler - Keep track of the rows decoded - Do *not* keep track of whether we've seen alpha Remove SkCodec::kOutOfOrder_SkScanlineOrder, which was only used by GIF scanline decoding. Call onRewind even if there is no stream (SkGifCodec needs to clear its decoded state so it will decode from the beginning). Add a method to SkSwizzler to access the offset into the dst, taking subsetting into account. Add a GM that animates a GIF. Add tests for the new APIs. *** Behavior changes: * Previously, we reported that an image with a subset frame and no transparent index was opaque and used the background index (if present) to fill the background. This is necessary in order to support index 8, but it does not match viewers/browsers I have seen. Examples: - Chromium and Gimp render the background transparent - Firefox, Safari, Linux Image Viewer, Safari Preview clip to the frame (for a single frame image) This CL matches Chromium's behavior and renders the background transparent. This allows us to have consistent behavior across products and simplifies the code (relative to what we would have to do to continue the old behavior on Android). It also means that we will no longer support index 8 for some GIFs. * Stop checking for GIFSTAMP - all GIFs should be either 89a or 87a. This matches Chromium. I suspect that bugs would have been reported if valid GIFs started with "GIFVER" instead of "GIF89a" or "GIF87a" (but did not decode in Chromium). *** Future work not included in this CL: * Move some checks out of haveDecodedRow, since they are the same for the entire frame e.g. - intersecting the frameRect with the full image size - whether there is a color table * Change when we write transparent pixels - In some cases, Chromium deemed this unnecessary, but I suspect it is slower than the fallback case. There will continue to be cases where we should *not* write them, but for e.g. the first pass where we have already cleared to transparent (which we may also be able to skip) writing the transparent pixels will not make anything incorrect. * Report color type and alpha type per frame - Depending on alpha values, disposal methods, frame rects, etc, subsequent frames may have different properties than the first. * Skip copies of the encoded data - We copy the encoded data in case the stream is one that cannot be rewound, so we can parse and then decode (possibly not immediately). For some input streams, this is unnecessary. - I was concerned this cause a performance regression, but on average the new code is faster than the old for the images I tested [1]. - It may cause a performance regression for Chromium, though, where we can always move back in the stream, so this should be addressed. Design doc: https://docs.google.com/a/google.com/document/d/12Qhf9T92MWfdWujQwCIjhCO3sw6pTJB5pJBwDM1T7Kc/ [1] https://docs.google.com/a/google.com/spreadsheets/d/19V-t9BfbFw5eiwBTKA1qOBkZbchjlTC5EIz6HFy-6RI/ GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=2045293002 Review-Url: https://codereview.chromium.org/2045293002
2016-10-24 16:03:26 +00:00
":flags",
":gpu_tool_utils",
":skia",
":tool_utils",
]
}
import("gn/tests.gni")
test_lib("tests") {
public_include_dirs = [ "tests" ]
sources = tests_sources + pathops_tests_sources
if (!fontmgr_android_enabled) {
sources -= [ "//tests/FontMgrAndroidParserTest.cpp" ]
}
deps = [
":experimental_svg_model",
":flags",
":skia",
":tool_utils",
"//third_party/libpng",
"//third_party/zlib",
]
public_deps = [
":gpu_tool_utils", # Test.h #includes headers from this target.
]
}
import("gn/bench.gni")
test_lib("bench") {
public_include_dirs = [ "bench" ]
sources = bench_sources
deps = [
":flags",
":gm",
":gpu_tool_utils",
":skia",
":tool_utils",
]
}
test_lib("experimental_svg_model") {
public_include_dirs = [ "experimental/svg/model" ]
sources = [
"experimental/svg/model/SkSVGAttribute.cpp",
"experimental/svg/model/SkSVGAttributeParser.cpp",
"experimental/svg/model/SkSVGCircle.cpp",
"experimental/svg/model/SkSVGClipPath.cpp",
"experimental/svg/model/SkSVGContainer.cpp",
"experimental/svg/model/SkSVGDOM.cpp",
"experimental/svg/model/SkSVGEllipse.cpp",
"experimental/svg/model/SkSVGLine.cpp",
"experimental/svg/model/SkSVGLinearGradient.cpp",
"experimental/svg/model/SkSVGNode.cpp",
"experimental/svg/model/SkSVGPath.cpp",
"experimental/svg/model/SkSVGPoly.cpp",
"experimental/svg/model/SkSVGRect.cpp",
"experimental/svg/model/SkSVGRenderContext.cpp",
"experimental/svg/model/SkSVGSVG.cpp",
"experimental/svg/model/SkSVGShape.cpp",
"experimental/svg/model/SkSVGStop.cpp",
"experimental/svg/model/SkSVGTransformableNode.cpp",
"experimental/svg/model/SkSVGValue.cpp",
]
deps = [
":skia",
]
}
test_lib("views") {
public_include_dirs = [ "include/views" ]
sources = [
"src/views/SkEvent.cpp",
"src/views/SkEventSink.cpp",
"src/views/SkOSMenu.cpp",
"src/views/SkTagList.cpp",
"src/views/SkTouchGesture.cpp",
"src/views/SkView.cpp",
"src/views/SkViewPriv.cpp",
]
libs = []
deps = []
if (!is_android) {
sources += [ "src/views/SkWindow.cpp" ]
}
if (is_linux) {
public_include_dirs += [ "src/views/unix" ]
sources += [
"src/views/unix/SkOSWindow_Unix.cpp",
"src/views/unix/keysym2ucs.c",
]
libs += [
"GL",
"X11",
]
} else if (is_mac) {
sources += [
"src/views/mac/SkEventNotifier.mm",
"src/views/mac/SkNSView.mm",
"src/views/mac/SkOSWindow_Mac.mm",
"src/views/mac/SkTextFieldCell.m",
]
libs += [
"QuartzCore.framework",
"Cocoa.framework",
"Foundation.framework",
]
} else if (is_win) {
sources += [ "src/views/win/SkOSWindow_win.cpp" ]
}
if (skia_use_angle) {
deps += [ "//third_party/angle2" ]
}
}
if (skia_use_lua) {
test_lib("lua") {
public_include_dirs = []
sources = [
"src/utils/SkLua.cpp",
"src/utils/SkLuaCanvas.cpp",
]
deps = [
"//third_party/lua",
]
}
test_app("lua_app") {
sources = [
"tools/lua/lua_app.cpp",
]
deps = [
":lua",
":skia",
"//third_party/lua",
]
}
test_app("lua_pictures") {
sources = [
"tools/lua/lua_pictures.cpp",
]
deps = [
":flags",
":lua",
":skia",
":tool_utils",
"//third_party/lua",
]
}
}
import("gn/samples.gni")
test_lib("samples") {
public_include_dirs = [ "samplecode" ]
include_dirs = [ "experimental" ]
sources = samples_sources + [
"experimental/SkSetPoly3To3.cpp",
"experimental/SkSetPoly3To3_A.cpp",
"experimental/SkSetPoly3To3_D.cpp",
]
deps = [
":experimental_svg_model",
":flags",
":gm",
":tool_utils",
":views",
":xml",
]
if (skia_use_lua) {
sources += [ "samplecode/SampleLua.cpp" ]
deps += [
":lua",
"//third_party/lua",
]
}
}
test_app("dm") {
sources = [
"dm/DM.cpp",
"dm/DMJsonWriter.cpp",
"dm/DMSrcSink.cpp",
]
include_dirs = [ "tests" ]
deps = [
":common_flags",
":experimental_svg_model",
":flags",
":gm",
":gpu_tool_utils",
":skia",
":tests",
":tool_utils",
"//third_party/jsoncpp",
"//third_party/libpng",
]
}
test_app("ok") {
sources = [
"tools/ok.cpp",
"tools/ok_dsts.cpp",
"tools/ok_srcs.cpp",
"tools/ok_test.cpp",
"tools/ok_vias.cpp",
]
deps = [
":gm",
":skia",
":tests",
":tool_utils",
]
}
if (!is_debug) { # I've benchmarked debug code once too many times...
test_app("monobench") {
sources = [
"tools/monobench.cpp",
]
deps = [
":bench",
":skia",
]
}
}
test_app("nanobench") {
sources = [
"bench/nanobench.cpp",
]
deps = [
":bench",
":common_flags",
":experimental_svg_model",
":flags",
":gm",
":gpu_tool_utils",
":skia",
":tool_utils",
"//third_party/jsoncpp",
]
}
test_app("skpinfo") {
sources = [
"tools/skpinfo.cpp",
]
deps = [
":flags",
":skia",
]
}
if (is_linux || is_win || is_mac) {
test_app("SampleApp") {
sources = [
"samplecode/SampleApp.cpp",
"samplecode/SamplePictFile.cpp",
]
if (is_mac) {
sources += [ "src/views/mac/skia_mac.mm" ]
} else if (is_win) {
sources += [ "src/views/win/skia_win.cpp" ]
} else if (is_linux) {
sources += [ "src/views/unix/skia_unix.cpp" ]
}
deps = [
":flags",
":gm",
":gpu_tool_utils",
":samples",
":skia",
":tool_utils",
":views",
]
if (skia_use_angle) {
deps += [ "//third_party/angle2" ]
}
}
}
if (skia_enable_gpu) {
test_app("skpbench") {
sources = [
"tools/skpbench/skpbench.cpp",
]
deps = [
":flags",
":gpu_tool_utils",
":skia",
":tool_utils",
]
}
}
# We can't yet build ICU on iOS or Windows.
if (!is_ios && !is_win) {
test_app("sktexttopdf-hb") {
sources = [
"tools/SkShaper_harfbuzz.cpp",
"tools/using_skia_and_harfbuzz.cpp",
]
deps = [
":skia",
"//third_party/harfbuzz",
]
}
}
test_app("sktexttopdf") {
sources = [
"tools/SkShaper_primitive.cpp",
"tools/using_skia_and_harfbuzz.cpp",
]
deps = [
":skia",
]
}
test_app("create_flutter_test_images") {
sources = [
"tools/create_flutter_test_images.cpp",
]
deps = [
":skia",
":tool_utils",
]
}
test_app("get_images_from_skps") {
sources = [
"tools/get_images_from_skps.cpp",
]
deps = [
":flags",
":skia",
"//third_party/jsoncpp",
]
}
test_app("colorspaceinfo") {
sources = [
"tools/colorspaceinfo.cpp",
]
deps = [
":flags",
":skia",
":tool_utils",
]
}
if (!is_ios) {
test_app("skiaserve") {
sources = [
"tools/skiaserve/Request.cpp",
"tools/skiaserve/Response.cpp",
"tools/skiaserve/skiaserve.cpp",
"tools/skiaserve/urlhandlers/BreakHandler.cpp",
"tools/skiaserve/urlhandlers/ClipAlphaHandler.cpp",
"tools/skiaserve/urlhandlers/CmdHandler.cpp",
"tools/skiaserve/urlhandlers/ColorModeHandler.cpp",
"tools/skiaserve/urlhandlers/DataHandler.cpp",
"tools/skiaserve/urlhandlers/DownloadHandler.cpp",
"tools/skiaserve/urlhandlers/EnableGPUHandler.cpp",
"tools/skiaserve/urlhandlers/ImgHandler.cpp",
"tools/skiaserve/urlhandlers/InfoHandler.cpp",
"tools/skiaserve/urlhandlers/OpBoundsHandler.cpp",
"tools/skiaserve/urlhandlers/OpsHandler.cpp",
"tools/skiaserve/urlhandlers/OverdrawHandler.cpp",
"tools/skiaserve/urlhandlers/PostHandler.cpp",
"tools/skiaserve/urlhandlers/QuitHandler.cpp",
"tools/skiaserve/urlhandlers/RootHandler.cpp",
]
deps = [
":flags",
":gpu_tool_utils",
":skia",
":tool_utils",
"//third_party/jsoncpp",
"//third_party/libmicrohttpd",
"//third_party/libpng",
]
}
}
test_app("fuzz") {
sources = [
"fuzz/FilterFuzz.cpp",
"fuzz/FuzzCanvas.cpp",
"fuzz/FuzzDrawFunctions.cpp",
"fuzz/FuzzGradients.cpp",
"fuzz/FuzzParsePath.cpp",
"fuzz/FuzzPathop.cpp",
"fuzz/FuzzScaleToSides.cpp",
"fuzz/fuzz.cpp",
]
deps = [
":flags",
":gpu_tool_utils",
":skia",
":tool_utils",
]
}
test_app("pathops_unittest") {
sources = pathops_tests_sources + [
rebase_path("tests/skia_test.cpp"),
rebase_path("tests/Test.cpp"),
]
deps = [
":flags",
":gpu_tool_utils",
":skia",
":tool_utils",
]
}
test_app("dump_record") {
sources = [
"tools/DumpRecord.cpp",
"tools/dump_record.cpp",
]
deps = [
":flags",
":skia",
]
}
test_app("skdiff") {
sources = [
"tools/skdiff/skdiff.cpp",
"tools/skdiff/skdiff_html.cpp",
"tools/skdiff/skdiff_main.cpp",
"tools/skdiff/skdiff_utils.cpp",
]
deps = [
":skia",
":tool_utils",
]
}
test_app("skp_parser") {
sources = [
"tools/skp_parser.cpp",
]
deps = [
":skia",
":tool_utils",
"//third_party/jsoncpp",
]
}
if (skia_enable_gpu && (is_android || is_linux || is_win || is_mac)) {
test_app("viewer") {
is_shared_library = is_android
sources = [
"tools/viewer/GMSlide.cpp",
"tools/viewer/ImageSlide.cpp",
"tools/viewer/SKPSlide.cpp",
"tools/viewer/SampleSlide.cpp",
"tools/viewer/Viewer.cpp",
"tools/viewer/sk_app/CommandSet.cpp",
"tools/viewer/sk_app/GLWindowContext.cpp",
"tools/viewer/sk_app/Window.cpp",
]
libs = []
if (is_android) {
sources += [
"tools/viewer/sk_app/android/GLWindowContext_android.cpp",
"tools/viewer/sk_app/android/RasterWindowContext_android.cpp",
"tools/viewer/sk_app/android/Window_android.cpp",
"tools/viewer/sk_app/android/main_android.cpp",
"tools/viewer/sk_app/android/surface_glue_android.cpp",
]
libs += [ "android" ]
} else if (is_linux) {
sources += [
"tools/viewer/sk_app/unix/GLWindowContext_unix.cpp",
"tools/viewer/sk_app/unix/RasterWindowContext_unix.cpp",
"tools/viewer/sk_app/unix/Window_unix.cpp",
"tools/viewer/sk_app/unix/main_unix.cpp",
]
} else if (is_win) {
sources += [
"tools/viewer/sk_app/win/GLWindowContext_win.cpp",
"tools/viewer/sk_app/win/RasterWindowContext_win.cpp",
"tools/viewer/sk_app/win/Window_win.cpp",
"tools/viewer/sk_app/win/main_win.cpp",
]
} else if (is_mac) {
sources += [
"tools/viewer/sk_app/mac/GLWindowContext_mac.cpp",
"tools/viewer/sk_app/mac/RasterWindowContext_mac.cpp",
"tools/viewer/sk_app/mac/Window_mac.cpp",
"tools/viewer/sk_app/mac/main_mac.cpp",
]
}
if (skia_use_vulkan) {
sources += [ "tools/viewer/sk_app/VulkanWindowContext.cpp" ]
if (is_android) {
sources +=
[ "tools/viewer/sk_app/android/VulkanWindowContext_android.cpp" ]
} else if (is_linux) {
sources += [ "tools/viewer/sk_app/unix/VulkanWindowContext_unix.cpp" ]
libs += [ "X11-xcb" ]
} else if (is_win) {
sources += [ "tools/viewer/sk_app/win/VulkanWindowContext_win.cpp" ]
}
}
include_dirs = []
deps = [
":flags",
":gm",
":gpu_tool_utils",
":samples",
":skia",
":tool_utils",
":views",
Integrate the ImGui library with viewer Code and docs are at: https://github.com/ocornut/imgui ImGui is an open source immediate mode GUI library that's lightweight and fairly simply to integrate. Widget functions return their state, and the library emits vertex and index data to render everything. It's got a huge set of built-in widgets and really robust layout control. For the initial integration, I had to fix up event handling in the viewer's app framework (to get mouse wheel and more keys, etc...). The new viewer 'Debug' window is toggled with the space bar. For this change, I've added one feature to that window: the slide picker. It's got a list of all slides, with filtering support, and the ability to click to switch slides. I also included the ImGui 'Demo' window (toggled with 'g'). This is nicely laid out, and includes examples of pretty much everything the library can do. It also serves as good documentation - find something that looks like what you want, and then go look at the corresponding code (all of it is in imgui_demo.cpp). I have other CLs with other features (like directly editing the primaries of the working color space), but I wanted to land this chunk first, then start adding more features. Other than adding new debugging features, there are few more outstanding work items: 1) Raster doesn't render the GUI correctly, due to non- invertible pos -> UV matrices. Florin is working on that. 2) Touch inputs aren't being routed yet, so the GUI isn't usable on Android yet. Might also be tough to work with, given the size. 3) ImGui has clipboard integration (that's why it wants the C, X, and V keys), but we need to wire it up to the OS' clipboard functions. 4) Draw commands can carry a void* payload to support drawing images (using whatever mechanism the engine has). I'd like to set that up (probably using SkImage*), which makes it really easy to add visualization of off-screen images in GMs, etc... BUG=skia: Change-Id: Iac2a63e37228d33141cb55b7e4d60bf11b7e9ae1 Reviewed-on: https://skia-review.googlesource.com/7702 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
2017-02-10 18:36:16 +00:00
"//third_party/imgui",
"//third_party/jsoncpp",
]
if (is_android) {
deps += [ "//third_party/native_app_glue" ]
} else if (is_mac) {
deps += [ "//third_party/libsdl" ]
}
}
}
Strengthen is_official_build, update docs. This makes is_official_build turn off all development targets and features in Skia, including building third-party dependencies from source. This will intentionally break some external users, who will find themselves no longer able to find third-party headers or link against third-party libraries. These users have been building with our testing third-party dependencies unknowingly. They'll need to either explicitly turn back on building each dependency from source (skia_use_system_foo=false) or disable that dependency entirely (skia_use_foo=false). is_skia_standalone is now basically !is_official_build, so I've propagated that through, removing is_skia_standalone. In a few places we were using it as a stand-in for defined(ndk), so I've just written defined(ndk) there. Duh. gn_to_bp: is_offical_build's new strength also makes gn_to_bp.py simpler to write. In spirit, Android builds are official Skia builds that also build DM and nanobench. It seems that SkJumper (src/jumper/*) is (unintentionally) enabled on Android. Switching to an is_official_build would have disabled that. But as that accidental launch seems to have gone fine, I've kept it explicitly enabled. In the end, no changes to Android.bp or its SkUserConfig.h. The -Mini builder no longer needs to explicitly disable tools. CQ_INCLUDE_TRYBOTS=skia.primary:Build-Ubuntu-Clang-x86_64-Release-Mini Change-Id: Id06e53268a5caf55c6046ada354a0863c3031c73 Reviewed-on: https://skia-review.googlesource.com/9190 Reviewed-by: Leon Scroggins <scroggo@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org>
2017-03-03 14:21:30 +00:00
if (is_android && defined(ndk) && ndk != "") {
copy("gdbserver") {
sources = [
"$ndk/$ndk_gdbserver",
]
outputs = [
"$root_out_dir/gdbserver",
]
}
}
if (skia_enable_gpu) {
test_app("skslc") {
defines = [ "SKSL_STANDALONE" ]
sources = [
"src/sksl/SkSLMain.cpp",
]
sources += skia_sksl_sources
include_dirs = [ "src/sksl" ]
}
}
}