Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import chromium skia #2816

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
985 changes: 985 additions & 0 deletions skia/BUILD.gn

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions skia/DIR_METADATA
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Metadata information for this directory.
#
# For more information on DIR_METADATA files, see:
# https://source.chromium.org/chromium/infra/infra/+/main:go/src/infra/tools/dirmd/README.md
#
# For the schema of this file, see Metadata message:
# https://source.chromium.org/chromium/infra/infra/+/main:go/src/infra/tools/dirmd/proto/dir_metadata.proto

monorail {
component: "Internals>Skia"
}
15 changes: 15 additions & 0 deletions skia/METADATA
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
third_party {
identifier {
type: "ChromiumVersion"
value: "114.0.5735.331" # from https://chromereleases.googleblog.com/2023/08/long-term-support-channel-update-for_23.html
}
identifier {
type: "Git"
value: "https://chromium.googlesource.com/chromium/src.git"
version: "fed499399d3f44d3a7957549d493bf30a5d8c867"
}
identifier {
type: "UpstreamSubdir"
value: "skia"
}
}
15 changes: 15 additions & 0 deletions skia/OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
set noparent
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]

# For Fuchsia-specific changes:
per-file ..._fuchsia*=file://build/fuchsia/OWNERS
259 changes: 259 additions & 0 deletions skia/config/SkUserConfig.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,259 @@

/*
* Copyright 2006 The Android Open Source Project
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/


#ifndef SKIA_CONFIG_SKUSERCONFIG_H_
#define SKIA_CONFIG_SKUSERCONFIG_H_

/* SkTypes.h, the root of the public header files, does the following trick:

#include "include/config/SkUserConfig.h"
#include "include/core/SkPostConfig.h"
#include "include/core/SkPreConfig.h"

SkPreConfig.h runs first, and it is responsible for initializing certain
skia defines.

SkPostConfig.h runs last, and its job is to just check that the final
defines are consistent (i.e. that we don't have mutually conflicting
defines).

SkUserConfig.h (this file) runs in the middle. It gets to change or augment
the list of flags initially set in preconfig, and then postconfig checks
that everything still makes sense.

Below are optional defines that add, subtract, or change default behavior
in Skia. Your port can locally edit this file to enable/disable flags as
you choose, or these can be delared on your command line (i.e. -Dfoo).

By default, this include file will always default to having all of the flags
commented out, so including it will have no effect.
*/

///////////////////////////////////////////////////////////////////////////////

/* Skia has lots of debug-only code. Often this is just null checks or other
parameter checking, but sometimes it can be quite intrusive (e.g. check that
each 32bit pixel is in premultiplied form). This code can be very useful
during development, but will slow things down in a shipping product.

By default, these mutually exclusive flags are defined in SkPreConfig.h,
based on the presence or absence of NDEBUG, but that decision can be changed
here.
*/
//#define SK_DEBUG
//#define SK_RELEASE

/* Skia has certain debug-only code that is extremely intensive even for debug
builds. This code is useful for diagnosing specific issues, but is not
generally applicable, therefore it must be explicitly enabled to avoid
the performance impact. By default these flags are undefined, but can be
enabled by uncommenting them below.
*/
//#define SK_DEBUG_GLYPH_CACHE
//#define SK_DEBUG_PATH

/* preconfig will have attempted to determine the endianness of the system,
but you can change these mutually exclusive flags here.
*/
//#define SK_CPU_BENDIAN
//#define SK_CPU_LENDIAN

/* Most compilers use the same bit endianness for bit flags in a byte as the
system byte endianness, and this is the default. If for some reason this
needs to be overridden, specify which of the mutually exclusive flags to
use. For example, some atom processors in certain configurations have big
endian byte order but little endian bit orders.
*/
//#define SK_UINT8_BITFIELD_BENDIAN
//#define SK_UINT8_BITFIELD_LENDIAN


/* To write debug messages to a console, skia will call SkDebugf(...) following
printf conventions (e.g. const char* format, ...). If you want to redirect
this to something other than printf, define yours here
*/
//#define SkDebugf(...) MyFunction(__VA_ARGS__)

/*
* To specify a different default font cache limit, define this. If this is
* undefined, skia will use a built-in value.
*/
//#define SK_DEFAULT_FONT_CACHE_LIMIT (1024 * 1024)

/*
* To specify the default size of the image cache, undefine this and set it to
* the desired value (in bytes). SkGraphics.h as a runtime API to set this
* value as well. If this is undefined, a built-in value will be used.
*/
//#define SK_DEFAULT_IMAGE_CACHE_LIMIT (1024 * 1024)

/* Define this to set the upper limit for text to support LCD. Values that
are very large increase the cost in the font cache and draw slower, without
improving readability. If this is undefined, Skia will use its default
value (e.g. 48)
*/
//#define SK_MAX_SIZE_FOR_LCDTEXT 48

/* Change the kN32_SkColorType ordering to BGRA to work in X windows.
*/
//#define SK_R32_SHIFT 16


/* Determines whether to build code that supports the Ganesh GPU backend. Some classes
that are not GPU-specific, such as SkShader subclasses, have optional code
that is used allows them to interact with this GPU backend. If you'd like to
include this code, include -DSK_GANESH in your cflags or uncomment below.
Defaults to not set (No Ganesh GPU backend).
This define affects the ABI of Skia, so make sure it matches the client which uses
the compiled version of Skia.
*/
// #define SK_GANESH

/* Skia makes use of histogram logging macros to trace the frequency of
* events. By default, Skia provides no-op versions of these macros.
* Skia consumers can provide their own definitions of these macros to
* integrate with their histogram collection backend.
*/
//#define SK_HISTOGRAM_BOOLEAN(name, sample)
//#define SK_HISTOGRAM_EXACT_LINEAR(name, sample, value_max)
//#define SK_HISTOGRAM_MEMORY_KB(name, sample)
#include "base/component_export.h"
#include "skia/ext/skia_histogram.h"

// ===== Begin Chrome-specific definitions =====

#ifdef DCHECK_ALWAYS_ON
#undef SK_RELEASE
#define SK_DEBUG
#endif

/* Define this to provide font subsetter for font subsetting when generating
PDF documents.
*/
#define SK_PDF_USE_HARFBUZZ_SUBSET

// Handle exporting using base/component_export.h
#define SK_API COMPONENT_EXPORT(SKIA)

// Chromium does not use these fonts. This define causes type1 fonts to be
// converted to type3 when producing PDFs, and reduces build size.
#define SK_PDF_DO_NOT_SUPPORT_TYPE_1_FONTS

#ifdef SK_DEBUG
#define SK_REF_CNT_MIXIN_INCLUDE "skia/config/sk_ref_cnt_ext_debug.h"
#else
#define SK_REF_CNT_MIXIN_INCLUDE "skia/config/sk_ref_cnt_ext_release.h"
#endif

// Log the file and line number for assertions.
#define SkDebugf(...) SkDebugf_FileLine(__FILE__, __LINE__, __VA_ARGS__)
SK_API void SkDebugf_FileLine(const char* file,
int line,
const char* format,
...);

#define SK_ABORT(format, ...) SkAbort_FileLine(__FILE__, __LINE__, \
format,##__VA_ARGS__)
[[noreturn]] SK_API void SkAbort_FileLine(const char* file,
int line,
const char* format,
...);

#if !defined(ANDROID) // On Android, we use the skia default settings.
#define SK_A32_SHIFT 24
#define SK_R32_SHIFT 16
#define SK_G32_SHIFT 8
#define SK_B32_SHIFT 0
#endif

#if defined(SK_BUILD_FOR_MAC)

#define SK_CPU_LENDIAN
#undef SK_CPU_BENDIAN

#elif defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_ANDROID)

// Prefer FreeType's emboldening algorithm to Skia's
// TODO: skia used to just use hairline, but has improved since then, so
// we should revisit this choice...
#define SK_USE_FREETYPE_EMBOLDEN

#if defined(SK_BUILD_FOR_UNIX) && defined(SK_CPU_BENDIAN)
// Above we set the order for ARGB channels in registers. I suspect that, on
// big endian machines, you can keep this the same and everything will work.
// The in-memory order will be different, of course, but as long as everything
// is reading memory as words rather than bytes, it will all work. However, if
// you find that colours are messed up I thought that I would leave a helpful
// locator for you. Also see the comments in
// base/gfx/bitmap_platform_device_linux.h
#error Read the comment at this location
#endif

#endif

#if defined(__has_attribute)
#if __has_attribute(trivial_abi)
#define SK_TRIVIAL_ABI [[clang::trivial_abi]]
#else
#define SK_TRIVIAL_ABI
#endif
#else
#define SK_TRIVIAL_ABI
#endif

// These flags are no longer defined in Skia, but we have them (temporarily)
// until we update our call-sites (typically these are for API changes).
//
// Remove these as we update our sites.

#define SK_LEGACY_LAYER_BOUNDS_EXPANSION // skbug.com/12083, skbug.com/12303

// Workaround for poor anisotropic mipmap quality,
// pending Skia ripmap support.
// (https://bugs.chromium.org/p/skia/issues/detail?id=4863)
#define SK_SUPPORT_LEGACY_ANISOTROPIC_MIPMAP_SCALE

// Temporarily insulate Chrome pixel tests from Skia LOD bias change on GPU.
#define SK_USE_LEGACY_MIPMAP_LOD_BIAS

// Max. verb count for paths rendered by the edge-AA tessellating path renderer.
#define GR_AA_TESSELLATOR_MAX_VERB_COUNT 100

#define SK_FORCE_AAA

#define SK_SUPPORT_LEGACY_DRAWLOOPER

#define SK_USE_LEGACY_MIPMAP_BUILDER

#define SK_SUPPORT_LEGACY_CONIC_CHOP

// To be replaced with SK_ENABLE_SKSL_IN_RASTER_PIPELINE (go/sksl-rp):
#define SK_ENABLE_SKVM

// Use the original std::vector based serializer
// Remove when new streaming support operations has been verified.
// #define SK_SUPPORT_LEGACY_STRIKE_SERIALIZATION

///////////////////////// Imported from BUILD.gn and skia_common.gypi

/* In some places Skia can use static initializers for global initialization,
* or fall back to lazy runtime initialization. Chrome always wants the latter.
*/
#define SK_ALLOW_STATIC_GLOBAL_INITIALIZERS 0

/* Restrict formats for Skia font matching to SFNT type fonts. */
#define SK_FONT_CONFIG_INTERFACE_ONLY_ALLOW_SFNT_FONTS

#define SK_IGNORE_BLURRED_RRECT_OPT
#define SK_USE_DISCARDABLE_SCALEDIMAGECACHE

#define SK_ATTR_DEPRECATED SK_NOTHING_ARG1
#define GR_GL_CUSTOM_SETUP_HEADER "GrGLConfig_chrome.h"

#endif // SKIA_CONFIG_SKUSERCONFIG_H_
65 changes: 65 additions & 0 deletions skia/config/sk_ref_cnt_ext_debug.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// Copyright 2013 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef SKIA_CONFIG_SK_REF_CNT_EXT_DEBUG_H_
#define SKIA_CONFIG_SK_REF_CNT_EXT_DEBUG_H_

#ifdef SKIA_CONFIG_SK_REF_CNT_EXT_RELEASE_H_
#error Only one SkRefCnt should be used.
#endif

#include <atomic>

class SkRefCnt;

namespace WTF {
void adopted(const SkRefCnt*);
void requireAdoption(const SkRefCnt*);
}

// Alternate implementation of SkRefCnt for Chromium debug builds
class SK_API SkRefCnt : public SkRefCntBase {
public:
SkRefCnt();
~SkRefCnt() override;
void ref() const { SkASSERT(flags_.load() != AdoptionRequired_Flag); SkRefCntBase::ref(); }
void deref() const { SkRefCntBase::unref(); }
private:
void adopted() const { flags_ |= Adopted_Flag; }
void requireAdoption() const { flags_ |= AdoptionRequired_Flag; }

enum {
Adopted_Flag = 0x1,
AdoptionRequired_Flag = 0x2,
};

mutable std::atomic<int> flags_;

friend void WTF::adopted(const SkRefCnt*);
friend void WTF::requireAdoption(const SkRefCnt*);
};

inline SkRefCnt::SkRefCnt() : flags_(0) { }

inline SkRefCnt::~SkRefCnt() { }

// Bootstrap for Blink's WTF::RefPtr

namespace WTF {
inline void adopted(const SkRefCnt* object) {
if (!object)
return;
object->adopted();
}
inline void requireAdoption(const SkRefCnt* object) {
if (!object)
return;
object->requireAdoption();
}
} // namespace WTF

using WTF::adopted;
using WTF::requireAdoption;

#endif // SKIA_CONFIG_SK_REF_CNT_EXT_DEBUG_H_
26 changes: 26 additions & 0 deletions skia/config/sk_ref_cnt_ext_release.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright 2013 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef SKIA_CONFIG_SK_REF_CNT_EXT_RELEASE_H_
#define SKIA_CONFIG_SK_REF_CNT_EXT_RELEASE_H_

#ifdef SKIA_CONFIG_SK_REF_CNT_EXT_DEBUG_H_
#error Only one SkRefCnt should be used.
#endif

// Alternate implementation of SkRefCnt for Chromium release builds
class SK_API SkRefCnt : public SkRefCntBase {
public:
void deref() const { SkRefCntBase::unref(); }
};

namespace WTF {
inline void Adopted(const SkRefCnt* object) {}
inline void RequireAdoption(const SkRefCnt* object) {}
} // namespace WTF

using WTF::Adopted;
using WTF::RequireAdoption;

#endif // SKIA_CONFIG_SK_REF_CNT_EXT_RELEASE_H_
1 change: 1 addition & 0 deletions skia/ext/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
skia_commit_hash.h
Loading
Loading