Skip to content

Commit f0963ff

Browse files
committed
Updating headers for current trunk (1.3 beta)
1 parent a221b7f commit f0963ff

29 files changed

+665
-814
lines changed

AppCore/App.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ class AExport App : public RefCounted {
107107
/// @note Certain Config options may be overridden during App creation,
108108
/// most commonly Config::face_winding and Config::device_scale_hint.
109109
///
110-
static Ref<App> Create(Settings settings = Settings(), Config config = Config());
110+
static RefPtr<App> Create(Settings settings = Settings(), Config config = Config());
111111

112112
///
113113
/// Get the App singleton.
@@ -146,7 +146,7 @@ class AExport App : public RefCounted {
146146
///
147147
/// Get the underlying Renderer instance.
148148
///
149-
virtual Ref<Renderer> renderer() = 0;
149+
virtual RefPtr<Renderer> renderer() = 0;
150150

151151
///
152152
/// Run the main loop.

AppCore/CAPI.h

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,18 @@
1616

1717
#include <Ultralight/CAPI.h>
1818

19-
#if defined(__WIN32__) || defined(_WIN32)
20-
# if defined(APPCORE_IMPLEMENTATION)
21-
# define ACExport __declspec(dllexport)
19+
#if defined(ULTRALIGHT_STATIC_BUILD)
20+
# define ACExport
21+
#else
22+
# if defined(__WIN32__) || defined(_WIN32)
23+
# if defined(APPCORE_IMPLEMENTATION)
24+
# define ACExport __declspec(dllexport)
25+
# else
26+
# define ACExport __declspec(dllimport)
27+
# endif
2228
# else
23-
# define ACExport __declspec(dllimport)
29+
# define ACExport __attribute__((visibility("default")))
2430
# endif
25-
#else
26-
# define ACExport __attribute__((visibility("default")))
2731
#endif
2832

2933
#ifdef __cplusplus

AppCore/Defines.h

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,28 +27,27 @@
2727
# error This project can only be compiled with a compiler that supports C++11
2828
#endif
2929

30-
31-
#if defined(__WIN32__) || defined(_WIN32)
32-
# if defined(ULTRALIGHT_STATIC_BUILD)
33-
# define AExport
34-
# else
30+
#if defined(ULTRALIGHT_STATIC_BUILD)
31+
# define AExport
32+
#else
33+
# if defined(__WIN32__) || defined(_WIN32)
3534
# if defined(APPCORE_IMPLEMENTATION)
3635
# define AExport __declspec(dllexport)
3736
# else
3837
# define AExport __declspec(dllimport)
3938
# endif
40-
# endif
41-
#define _thread_local __declspec(thread)
42-
#ifndef _NATIVE_WCHAR_T_DEFINED
43-
#define DISABLE_NATIVE_WCHAR_T
44-
#endif
45-
#else
46-
# if defined(ULTRALIGHT_STATIC_BUILD)
47-
# define AExport
4839
# else
4940
# define AExport __attribute__((visibility("default")))
5041
# endif
51-
#define _thread_local __thread
42+
#endif
43+
44+
#if defined(__WIN32__) || defined(_WIN32)
45+
# define _thread_local __declspec(thread)
46+
# ifndef _NATIVE_WCHAR_T_DEFINED
47+
# define DISABLE_NATIVE_WCHAR_T
48+
# endif
49+
#else
50+
# define _thread_local __thread
5251
#endif
5352

5453
#endif

AppCore/Overlay.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class AExport Overlay : public RefCounted {
4040
/// @param y The y-position (offset from the top of the Window), in
4141
/// pixels.
4242
///
43-
static Ref<Overlay> Create(Ref<Window> window, uint32_t width,
43+
static RefPtr<Overlay> Create(RefPtr<Window> window, uint32_t width,
4444
uint32_t height, int x, int y);
4545

4646
///
@@ -56,12 +56,12 @@ class AExport Overlay : public RefCounted {
5656
/// @param y The y-position (offset from the top of the Window), in
5757
/// pixels.
5858
///
59-
static Ref<Overlay> Create(Ref<Window> window, Ref<View> view, int x, int y);
59+
static RefPtr<Overlay> Create(RefPtr<Window> window, RefPtr<View> view, int x, int y);
6060

6161
///
6262
/// Get the underlying View.
6363
///
64-
virtual ultralight::Ref<ultralight::View> view() = 0;
64+
virtual ultralight::RefPtr<ultralight::View> view() = 0;
6565

6666
///
6767
/// Get the width (in pixels).

AppCore/Window.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class AExport Window : public RefCounted {
8181
/// @note Screen coordinates are device-scale-independent and have the following relationship
8282
/// to pixel coordinates: pixel_coordinate = round(screen_coordinate * scale)
8383
///
84-
static Ref<Window> Create(Monitor* monitor, uint32_t width, uint32_t height,
84+
static RefPtr<Window> Create(Monitor* monitor, uint32_t width, uint32_t height,
8585
bool fullscreen, unsigned int window_flags);
8686

8787
///

Ultralight/Bitmap.h

Lines changed: 85 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -23,34 +23,30 @@ namespace ultralight {
2323
///
2424
/// The various Bitmap formats.
2525
///
26-
enum UExport BitmapFormat {
27-
/**
28-
* Alpha channel only, 8-bits per pixel.
29-
*
30-
* Encoding: 8-bits per channel, unsigned normalized.
31-
*
32-
* Color-space: Linear (no gamma), alpha-coverage only.
33-
*/
34-
kBitmapFormat_A8_UNORM,
35-
36-
/**
37-
* Blue Green Red Alpha channels, 32-bits per pixel.
38-
*
39-
* Encoding: 8-bits per channel, unsigned normalized.
40-
*
41-
* Color-space: sRGB gamma with premultiplied linear alpha channel.
42-
*
43-
* NOTE: Alpha is premultiplied with BGR channels _before_ sRGB gamma is
44-
* applied so we can use sRGB conversion hardware and perform all
45-
* blending in linear space on GPU.
46-
*/
47-
kBitmapFormat_BGRA8_UNORM_SRGB,
26+
enum class UExport BitmapFormat : uint8_t {
27+
///
28+
/// Alpha channel only, 8-bits per pixel.
29+
///
30+
/// Encoding: 8-bits per channel, unsigned normalized.
31+
///
32+
/// Color-space: Linear (no gamma), alpha-coverage only.
33+
///
34+
A8_UNORM,
35+
36+
///
37+
/// Blue Green Red Alpha channels, 32-bits per pixel.
38+
///
39+
/// Encoding: 8-bits per channel, unsigned normalized.
40+
///
41+
/// Color-space: sRGB gamma with premultiplied linear alpha channel.
42+
///
43+
BGRA8_UNORM_SRGB,
4844
};
4945

5046
///
5147
/// Macro to get the bytes per pixel from a BitmapFormat
5248
///
53-
#define GetBytesPerPixel(x) (x == kBitmapFormat_A8_UNORM? 1 : 4)
49+
#define GetBytesPerPixel(x) (x == BitmapFormat::A8_UNORM ? 1 : 4)
5450

5551
///
5652
/// @brief Bitmap container with basic blitting and conversion routines.
@@ -60,11 +56,10 @@ class UExport Bitmap : public RefCounted {
6056
///
6157
/// Create an empty Bitmap. No pixels will be allocated.
6258
///
63-
static Ref<Bitmap> Create();
59+
static RefPtr<Bitmap> Create();
6460

6561
///
66-
/// Create a Bitmap with a certain configuration. Pixels will be allocated
67-
/// but not initialized.
62+
/// Create a Bitmap with a certain configuration. Pixels will be allocated but not initialized.
6863
///
6964
/// @param width The width in pixels.
7065
///
@@ -74,8 +69,7 @@ class UExport Bitmap : public RefCounted {
7469
///
7570
/// @return A ref-pointer to a new Bitmap instance.
7671
///
77-
static Ref<Bitmap> Create(uint32_t width, uint32_t height,
78-
BitmapFormat format);
72+
static RefPtr<Bitmap> Create(uint32_t width, uint32_t height, BitmapFormat format);
7973

8074
///
8175
/// Create a Bitmap with existing pixels and configuration.
@@ -86,37 +80,27 @@ class UExport Bitmap : public RefCounted {
8680
///
8781
/// @param format The pixel format to use.
8882
///
89-
/// @param row_bytes The number of bytes between each row (note that this
90-
/// value should be >= width * bytes_per_pixel).
83+
/// @param row_bytes The number of bytes between each row (note that this value should be >=
84+
/// width * bytes_per_pixel).
9185
///
9286
/// @param pixels Pointer to raw pixel buffer.
9387
///
9488
/// @param size Size of the raw pixel buffer.
9589
///
96-
/// @param should_copy Whether or not a copy should be made of the pixels.
97-
/// If this is false, the returned Bitmap will use the
98-
/// raw pixels passed in as its own, but you are still
99-
/// responsible for destroying your buffer afterwards.
100-
///
101-
/// @param fixup_gamma Whether or not we should reinterpret the source
102-
/// as an sRGB bitmap with premultiplied alpha applied
103-
/// after the gamma function (typical of PNGs). We
104-
/// expect all premultiplication to be applied before
105-
/// the gamma function so we can blend properly in
106-
/// linear space. Only valid for
107-
/// kBitmapFormat_BGRA8_UNORM_SRGB.
90+
/// @param should_copy Whether or not a copy should be made of the pixels. If this is false
91+
/// the returned Bitmap will use the raw pixels passed in as its own, but
92+
/// you are still responsible for destroying your buffer afterwards.
10893
///
10994
/// @return A ref-pointer to a new Bitmap instance.
11095
///
111-
static Ref<Bitmap> Create(uint32_t width, uint32_t height,
112-
BitmapFormat format, uint32_t row_bytes,
113-
const void* pixels, size_t size,
114-
bool should_copy = true, bool fixup_gamma = false);
96+
static RefPtr<Bitmap> Create(uint32_t width, uint32_t height, BitmapFormat format,
97+
uint32_t row_bytes, const void* pixels, size_t size,
98+
bool should_copy = true);
11599

116100
///
117101
/// Create a bitmap from a deep copy of another Bitmap.
118102
///
119-
static Ref<Bitmap> Create(const Bitmap& bitmap);
103+
static RefPtr<Bitmap> Create(const Bitmap& bitmap);
120104

121105
///
122106
/// Get the width in pixels.
@@ -146,8 +130,8 @@ class UExport Bitmap : public RefCounted {
146130
///
147131
/// Get the number of bytes between each row of pixels.
148132
///
149-
/// @note This value is usually calculated as width * bytes_per_pixel (bpp)
150-
/// but it may be larger due to alignment rules in the allocator.
133+
/// @note This value is usually calculated as width * bytes_per_pixel (bpp) but it may be larger
134+
/// due to alignment rules in the allocator.
151135
///
152136
virtual uint32_t row_bytes() const = 0;
153137

@@ -159,13 +143,13 @@ class UExport Bitmap : public RefCounted {
159143
virtual size_t size() const = 0;
160144

161145
///
162-
/// Whether or not this Bitmap owns the pixel buffer and will destroy it
163-
/// at the end of its lifetime.
146+
/// Whether or not this Bitmap owns the pixel buffer and will destroy it at the end of its
147+
/// lifetime.
164148
///
165149
virtual bool owns_pixels() const = 0;
166150

167151
///
168-
/// Lock the pixel buffer for reading/writing.
152+
/// Lock the pixel buffer for reading/writing.
169153
///
170154
/// @return A pointer to the pixel buffer.
171155
///
@@ -210,64 +194,83 @@ class UExport Bitmap : public RefCounted {
210194
///
211195
/// @param bitmap The bitmap to copy from.
212196
///
213-
virtual void Set(Ref<Bitmap> bitmap) = 0;
197+
virtual void Set(RefPtr<Bitmap> bitmap) = 0;
214198

215199
///
216200
/// Draw another bitmap to this bitmap.
217201
///
218-
/// @note Formats do not need to match. Bitmap formats will be converted
219-
/// to one another automatically. Note that when converting from
220-
/// BGRA8 to A8, only the Blue channel will be used.
202+
/// @note Formats do not need to match. Bitmap formats will be converted to one another
203+
/// automatically. Note that when converting from BGRA8 to A8, only the Blue channel will
204+
/// be used.
221205
///
222206
/// @param src_rect The source rectangle, relative to src bitmap.
223207
///
224208
/// @param dest_rect The destination rectangle, relative to this bitmap.
225-
///
209+
///
226210
/// @param src The source bitmap.
227-
///
228-
/// @param pad_repeat Whether or not we should pad the drawn bitmap by one
229-
/// pixel of repeated edge pixels from the source bitmap.
230211
///
231-
/// @return Whether or not the operation succeeded (this can fail if the
232-
/// src_rect and/or dest_rect are invalid, or if their total
233-
/// dimensions do not match).
212+
/// @param pad_repeat Whether or not we should pad the drawn bitmap by one pixel of repeated
213+
/// edge pixels from the source bitmap.
214+
///
215+
/// @return Whether or not the operation succeeded (this can fail if the src_rect and/or
216+
/// dest_rect are invalid, or if their total dimensions do not match).
234217
///
235-
virtual bool DrawBitmap(IntRect src_rect, IntRect dest_rect,
236-
Ref<Bitmap> src, bool pad_repeat) = 0;
218+
virtual bool DrawBitmap(IntRect src_rect, IntRect dest_rect, RefPtr<Bitmap> src, bool pad_repeat)
219+
= 0;
237220

238221
///
239-
/// Write this Bitmap out to a PNG image. (mainly used for Debug)
222+
/// Write this Bitmap out to a PNG image.
240223
///
241224
/// @param path The filepath to write to (opened with fopen())
242225
///
226+
/// @param convert_to_rgba The PNG format expects RGBA format but our bitmap is stored as BGRA,
227+
/// set this to true to perform the conversion automatically.
228+
///
229+
/// @param convert_to_straight_alpha The PNG format expects semi-transparent values to be
230+
/// stored as straight alpha instead of premultiplied alpha,
231+
/// set this to true to perform the conversion automatically.
232+
///
243233
/// @return Whether or not the operation succeeded.
244234
///
245-
virtual bool WritePNG(const char* path) = 0;
235+
virtual bool WritePNG(const char* path, bool convert_to_rgba = true,
236+
bool convert_to_straight_alpha = true) const = 0;
246237

247238
///
248-
/// Make a resized copy of this bitmap by writing to a pre-allocated
249-
/// destination bitmap.
239+
/// Make a resized copy of this bitmap by writing to a pre-allocated destination bitmap.
250240
///
251-
/// @param destination The bitmap to store the result in, the width and
252-
/// height of the destination will be used.
241+
/// @param destination The bitmap to store the result in, the width and height of the
242+
/// destination will be used.
253243
///
254-
/// @param high_quality Whether or not a high quality resampling will be
255-
/// used during the resize. (Otherwise, just uses fast
256-
/// nearest-neighbor sampling)
244+
/// @param high_quality Whether or not a high quality resampling will be used during the
245+
/// resize. (Otherwise, just uses fast nearest-neighbor sampling)
257246
///
258-
/// @return Whether or not the operation succeeded. This operation is only
259-
/// valid if both formats are kBitmapFormat_BGRA8_UNORM_SRGB and
260-
/// both the source and destination are non-empty.
247+
/// @return Whether or not the operation succeeded. This operation is only valid if both formats
248+
/// are BitmapFormat::BGRA8_UNORM_SRGB and the source and destination are non-empty.
261249
///
262-
virtual bool Resample(Ref<Bitmap> destination, bool high_quality) = 0;
250+
virtual bool Resample(RefPtr<Bitmap> destination, bool high_quality) = 0;
263251

264252
///
265-
/// This converts a BGRA bitmap to RGBA bitmap and vice-versa by swapping
266-
/// the red and blue channels.
253+
/// Convert a BGRA bitmap to RGBA bitmap and vice-versa by swapping the red and blue channels.
254+
///
255+
/// @note Only valid if the format is BitmapFormat::BGRA8_UNORM_SRGB
267256
///
268257
virtual void SwapRedBlueChannels() = 0;
269258

270-
protected:
259+
///
260+
/// Convert a BGRA bitmap from premultiplied alpha (the default) to straight alpha.
261+
///
262+
/// @note Only valid if the format is BitmapFormat::BGRA8_UNORM_SRGB
263+
///
264+
virtual void ConvertToStraightAlpha() = 0;
265+
266+
///
267+
/// Convert a BGRA bitmap from straight alpha to premultiplied alpha.
268+
///
269+
/// @note Only valid if the format is BitmapFormat::BGRA8_UNORM_SRGB
270+
///
271+
virtual void ConvertToPremultipliedAlpha() = 0;
272+
273+
protected:
271274
Bitmap();
272275
virtual ~Bitmap();
273276
Bitmap(const Bitmap&);
@@ -276,4 +279,4 @@ class UExport Bitmap : public RefCounted {
276279

277280
#pragma pack(pop)
278281

279-
} // namespace ultralight
282+
} // namespace ultralight

Ultralight/Buffer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class UExport Buffer : public RefCounted {
2525
///
2626
/// Create a Buffer, a copy of data is made.
2727
///
28-
static Ref<Buffer> Create(const void* data, size_t size);
28+
static RefPtr<Buffer> Create(const void* data, size_t size);
2929

3030
///
3131
/// Get a pointer to raw byte data.

0 commit comments

Comments
 (0)