@geastack/engine 0.1.15 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/canvas.cpp +270 -139
- package/css/engine.h +23 -3
- package/image_store.cpp +35 -2
- package/package.json +2 -2
- package/rasterized_font.cpp +42 -2
- package/touch_runtime.cpp +231 -178
- package/ui/canvas_element.cpp +432 -125
- package/ui/canvas_element.h +84 -16
- package/ui/core.cpp +1 -0
- package/ui/debugger_listeners.h +80 -0
- package/ui/debugger_overlay.h +79 -0
- package/ui/debugger_picker.h +105 -0
- package/ui/document.cpp +1 -1
- package/ui/image_node.cpp +33 -1
- package/ui/input.cpp +27 -6
- package/ui/input_render.cpp +6 -8
- package/ui/internal.h +20 -0
- package/ui/layout.cpp +130 -17
- package/ui/layout_snapshot.cpp +1 -0
- package/ui/node.h +4 -0
- package/ui/node_lifecycle.cpp +7 -0
- package/ui/node_model.h +38 -16
- package/ui/render.cpp +259 -26
- package/ui/style.cpp +571 -66
- package/ui/style.h +16 -1
- package/ui/text.cpp +113 -65
- package/ui/tree_events.cpp +55 -13
- package/ui/tree_internal.h +5 -0
- package/ui/tree_nodes.cpp +16 -1
- package/ui/tree_render.cpp +153 -13
- package/ui/tree_style.cpp +25 -3
- package/ui/view.cpp +8 -8
package/ui/render.cpp
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
#include "renderer_features.h"
|
|
3
|
-
#include "internal.h"
|
|
4
|
-
#include "state_init.h"
|
|
5
2
|
#include "canvas.h"
|
|
3
|
+
#include <image.h>
|
|
4
|
+
#include "canvas_element.h"
|
|
6
5
|
#include "display.h"
|
|
7
6
|
#include "graphics/font.h"
|
|
7
|
+
#include "internal.h"
|
|
8
8
|
#include "memory.h"
|
|
9
|
-
#include "
|
|
9
|
+
#include "renderer_features.h"
|
|
10
|
+
#include "state_init.h"
|
|
10
11
|
#include "style_values.h"
|
|
12
|
+
#include "tree_state.h"
|
|
11
13
|
#include <pixel.h>
|
|
12
14
|
|
|
13
15
|
#include <algorithm>
|
|
@@ -138,14 +140,13 @@ extern "C" __attribute__((weak)) void *gea_display_command_buffer(int *cap_comma
|
|
|
138
140
|
return nullptr;
|
|
139
141
|
}
|
|
140
142
|
|
|
141
|
-
//
|
|
142
|
-
//
|
|
143
|
-
//
|
|
144
|
-
// while a band rasterizes. Constant true everywhere else.
|
|
143
|
+
// Offscreen snapshots and banded raster callbacks temporarily bind the primary
|
|
144
|
+
// canvas to another buffer. The worker canvas still addresses the framebuffer,
|
|
145
|
+
// so neither command replay nor individual fills may split across cores.
|
|
145
146
|
#if GEA_EMBEDDED_DISPLAY_BANDED_UI
|
|
146
|
-
#define GEA_RENDER_SPLIT_ALLOWED (!gea::embedded::ui::gBandedRasterActive)
|
|
147
|
+
#define GEA_RENDER_SPLIT_ALLOWED (!gea::embedded::ui::gSnapshotRasterActive && !gea::embedded::ui::gBandedRasterActive)
|
|
147
148
|
#else
|
|
148
|
-
#define GEA_RENDER_SPLIT_ALLOWED
|
|
149
|
+
#define GEA_RENDER_SPLIT_ALLOWED (!gea::embedded::ui::gSnapshotRasterActive)
|
|
149
150
|
#endif
|
|
150
151
|
|
|
151
152
|
// 2nd-core fill offload. The target may provide a worker pinned to the other CPU;
|
|
@@ -330,6 +331,10 @@ int gLastScrollUiFrame = -1000;
|
|
|
330
331
|
return "BlitImage";
|
|
331
332
|
case DisplayCommandType::BlitImageScaled:
|
|
332
333
|
return "BlitImageScaled";
|
|
334
|
+
case DisplayCommandType::BlitImageProjected:
|
|
335
|
+
return "BlitImageProjected";
|
|
336
|
+
case DisplayCommandType::ReplayCanvasBatch:
|
|
337
|
+
return "ReplayCanvasBatch";
|
|
333
338
|
case DisplayCommandType::BeginFilterBlur:
|
|
334
339
|
return "BeginFilterBlur";
|
|
335
340
|
case DisplayCommandType::ApplyFilterBlur:
|
|
@@ -476,6 +481,12 @@ int gLastScrollUiFrame = -1000;
|
|
|
476
481
|
return cp;
|
|
477
482
|
}
|
|
478
483
|
|
|
484
|
+
int followingProjectedTextCodepoint(const char *text, int textTransform, bool wordStart)
|
|
485
|
+
{
|
|
486
|
+
if (!text || !*text || *text == '\n') return 0;
|
|
487
|
+
return transformedTextCodepoint(nextUtf8Codepoint(text), textTransform, wordStart);
|
|
488
|
+
}
|
|
489
|
+
|
|
479
490
|
struct FilterBlurCacheEntry
|
|
480
491
|
{
|
|
481
492
|
// Colour buffers are native pixels — the blur runs in this board's colour
|
|
@@ -528,6 +539,7 @@ int gLastScrollUiFrame = -1000;
|
|
|
528
539
|
int commandCapacity = 0;
|
|
529
540
|
bool commandsExternal = false;
|
|
530
541
|
int commandCount = 0;
|
|
542
|
+
bool imageReferences[gea::framework::graphics::kImageMax]{};
|
|
531
543
|
bool textClippedBackgrounds = false;
|
|
532
544
|
// Sticky: an append() was dropped because the command buffer is full.
|
|
533
545
|
// Reset by clear(); lets a caller detect a truncated record.
|
|
@@ -1923,7 +1935,7 @@ int gLastScrollUiFrame = -1000;
|
|
|
1923
1935
|
const std::int64_t dy = static_cast<std::int64_t>(qy[j]) - qy[i];
|
|
1924
1936
|
const std::int64_t spanX = std::max(std::llabs(static_cast<std::int64_t>(x0) - qx[i]), std::llabs(static_cast<std::int64_t>(x1) - qx[i])) + 1;
|
|
1925
1937
|
const std::int64_t spanY = std::max(std::llabs(static_cast<std::int64_t>(y0) - qy[i]), std::llabs(static_cast<std::int64_t>(y1) - qy[i])) + 1;
|
|
1926
|
-
worst = std::max(worst, std::llabs(dx) * spanY + std::llabs(dy) * spanX);
|
|
1938
|
+
worst = std::max<std::int64_t>(worst, std::llabs(dx) * spanY + std::llabs(dy) * spanX);
|
|
1927
1939
|
a[i] = static_cast<int>(-dy);
|
|
1928
1940
|
b[i] = static_cast<int>(dx);
|
|
1929
1941
|
}
|
|
@@ -2704,18 +2716,19 @@ int gLastScrollUiFrame = -1000;
|
|
|
2704
2716
|
const int cp = transformedTextCodepoint(nextUtf8Codepoint(p), command.projectedText.textTransform, wordStart);
|
|
2705
2717
|
if (!font.glyph(cp, &glyph))
|
|
2706
2718
|
{
|
|
2707
|
-
penX += font.
|
|
2719
|
+
penX += font.advance(
|
|
2720
|
+
cp, followingProjectedTextCodepoint(p, command.projectedText.textTransform, wordStart));
|
|
2708
2721
|
continue;
|
|
2709
2722
|
}
|
|
2710
2723
|
|
|
2711
2724
|
const int gx = penX + glyph.bearingX;
|
|
2712
2725
|
const int gy = command.projectedText.srcY + font.ascender() - glyph.bearingY;
|
|
2713
|
-
if (sourceX >= gx && sourceX < gx + glyph.width &&
|
|
2714
|
-
sourceY >= gy && sourceY < gy + glyph.height)
|
|
2726
|
+
if (sourceX >= gx && sourceX < gx + glyph.width && sourceY >= gy && sourceY < gy + glyph.height)
|
|
2715
2727
|
{
|
|
2716
2728
|
return font.coverage(glyph, sourceY - gy, sourceX - gx);
|
|
2717
2729
|
}
|
|
2718
|
-
penX +=
|
|
2730
|
+
penX += font.advance(
|
|
2731
|
+
cp, followingProjectedTextCodepoint(p, command.projectedText.textTransform, wordStart));
|
|
2719
2732
|
}
|
|
2720
2733
|
return 0;
|
|
2721
2734
|
}
|
|
@@ -2777,7 +2790,8 @@ int gLastScrollUiFrame = -1000;
|
|
|
2777
2790
|
const int cp = transformedTextCodepoint(nextUtf8Codepoint(p), command.projectedText.textTransform, wordStart);
|
|
2778
2791
|
if (!font.glyph(cp, &glyph))
|
|
2779
2792
|
{
|
|
2780
|
-
penX += font.
|
|
2793
|
+
penX += font.advance(
|
|
2794
|
+
cp, followingProjectedTextCodepoint(p, command.projectedText.textTransform, wordStart));
|
|
2781
2795
|
continue;
|
|
2782
2796
|
}
|
|
2783
2797
|
const int gx = penX + glyph.bearingX;
|
|
@@ -2808,7 +2822,8 @@ int gLastScrollUiFrame = -1000;
|
|
|
2808
2822
|
}
|
|
2809
2823
|
}
|
|
2810
2824
|
}
|
|
2811
|
-
penX +=
|
|
2825
|
+
penX += font.advance(
|
|
2826
|
+
cp, followingProjectedTextCodepoint(p, command.projectedText.textTransform, wordStart));
|
|
2812
2827
|
}
|
|
2813
2828
|
}
|
|
2814
2829
|
|
|
@@ -4930,6 +4945,85 @@ int gLastScrollUiFrame = -1000;
|
|
|
4930
4945
|
canvas->markDirty(x0, y0, x1, y1);
|
|
4931
4946
|
}
|
|
4932
4947
|
|
|
4948
|
+
void drawProjectedImage(const DisplayCommand &command)
|
|
4949
|
+
{
|
|
4950
|
+
auto *canvas = gea::platform::display::Display::canvas();
|
|
4951
|
+
const auto &image = command.projectedBlit;
|
|
4952
|
+
if (!canvas || !image.pixels || image.sourceWidth <= 0 || image.sourceHeight <= 0 ||
|
|
4953
|
+
image.width <= 0 || image.height <= 0)
|
|
4954
|
+
return;
|
|
4955
|
+
if (image.backfaceHidden)
|
|
4956
|
+
{
|
|
4957
|
+
long area = 0;
|
|
4958
|
+
for (int i = 0; i < 4; ++i)
|
|
4959
|
+
{
|
|
4960
|
+
const int next = (i + 1) % 4;
|
|
4961
|
+
area += long(image.xs[i]) * image.ys[next] - long(image.xs[next]) * image.ys[i];
|
|
4962
|
+
}
|
|
4963
|
+
if (area <= 0)
|
|
4964
|
+
return;
|
|
4965
|
+
}
|
|
4966
|
+
double coefficients[8]{};
|
|
4967
|
+
if (!screenToLocalRectHomography(image.xs, image.ys, 0, 0, image.sourceWidth, image.sourceHeight,
|
|
4968
|
+
coefficients))
|
|
4969
|
+
return;
|
|
4970
|
+
float h[8];
|
|
4971
|
+
for (int i = 0; i < 8; ++i)
|
|
4972
|
+
h[i] = static_cast<float>(coefficients[i]);
|
|
4973
|
+
const bool affine = std::abs(h[6]) < 0.000000001f && std::abs(h[7]) < 0.000000001f;
|
|
4974
|
+
const bool rounded = image.tl || image.tr || image.br || image.bl;
|
|
4975
|
+
const float localScaleX = float(image.width) / image.sourceWidth;
|
|
4976
|
+
const float localScaleY = float(image.height) / image.sourceHeight;
|
|
4977
|
+
int x0, y0, x1, y1;
|
|
4978
|
+
gea::platform::display::Display::clip(&x0, &y0, &x1, &y1);
|
|
4979
|
+
x0 = std::max({x0, 0, int(command.bx)});
|
|
4980
|
+
y0 = std::max({y0, 0, int(command.by)});
|
|
4981
|
+
x1 = std::min({x1, canvas->width() - 1, command.bx + command.bw - 1});
|
|
4982
|
+
y1 = std::min({y1, canvas->height() - 1, command.by + command.bh - 1});
|
|
4983
|
+
const int globalAlpha = canvas->globalAlpha();
|
|
4984
|
+
for (int y = y0; y <= y1; ++y)
|
|
4985
|
+
{
|
|
4986
|
+
const float py = y + 0.5f;
|
|
4987
|
+
for (int x = x0; x <= x1; ++x)
|
|
4988
|
+
{
|
|
4989
|
+
const float px = x + 0.5f;
|
|
4990
|
+
const float divisor = affine ? 1.0f : h[6] * px + h[7] * py + 1.0f;
|
|
4991
|
+
if (std::abs(divisor) < 0.000001f)
|
|
4992
|
+
continue;
|
|
4993
|
+
const float inverse = affine ? 1.0f : 1.0f / divisor;
|
|
4994
|
+
const float sx = (h[0] * px + h[1] * py + h[2]) * inverse;
|
|
4995
|
+
const float sy = (h[3] * px + h[4] * py + h[5]) * inverse;
|
|
4996
|
+
if (!(sx >= 0 && sx < image.sourceWidth && sy >= 0 && sy < image.sourceHeight))
|
|
4997
|
+
continue;
|
|
4998
|
+
if (rounded)
|
|
4999
|
+
{
|
|
5000
|
+
const float lx = sx * localScaleX;
|
|
5001
|
+
const float ly = sy * localScaleY;
|
|
5002
|
+
const bool right = lx >= image.width / 2.0f;
|
|
5003
|
+
const bool bottom = ly >= image.height / 2.0f;
|
|
5004
|
+
const int radius =
|
|
5005
|
+
bottom ? (right ? image.br : image.bl) : (right ? image.tr : image.tl);
|
|
5006
|
+
const float r = std::min(float(radius), std::min(image.width, image.height) / 2.0f);
|
|
5007
|
+
const float cx = right ? image.width - lx : lx;
|
|
5008
|
+
const float cy = bottom ? image.height - ly : ly;
|
|
5009
|
+
if (r > 0 && cx < r && cy < r && (cx - r) * (cx - r) + (cy - r) * (cy - r) > r * r)
|
|
5010
|
+
continue;
|
|
5011
|
+
}
|
|
5012
|
+
const int source = int(sy) * image.sourceWidth + int(sx);
|
|
5013
|
+
const int alpha = ((image.alpha ? image.alpha[source] : 255) * globalAlpha) / 255;
|
|
5014
|
+
if (!alpha)
|
|
5015
|
+
continue;
|
|
5016
|
+
const auto color = alpha == 255
|
|
5017
|
+
? image.pixels[source]
|
|
5018
|
+
: gea::framework::graphics::pixel::blendNative(
|
|
5019
|
+
image.pixels[source], canvas->readPixelNative(x, y), alpha);
|
|
5020
|
+
canvas->writePixelNativeExact(x, y, color);
|
|
5021
|
+
}
|
|
5022
|
+
}
|
|
5023
|
+
if (x0 <= x1 && y0 <= y1)
|
|
5024
|
+
canvas->markDirty(x0, y0, x1, y1);
|
|
5025
|
+
}
|
|
5026
|
+
|
|
4933
5027
|
void drawTransformedRoundedRect(const DisplayCommand &command)
|
|
4934
5028
|
{
|
|
4935
5029
|
auto *canvas = gea::platform::display::Display::canvas();
|
|
@@ -5353,6 +5447,18 @@ int gLastScrollUiFrame = -1000;
|
|
|
5353
5447
|
c->projectedText.x3 += dx;
|
|
5354
5448
|
c->projectedText.y3 += dy;
|
|
5355
5449
|
break;
|
|
5450
|
+
case DisplayCommandType::ReplayCanvasBatch:
|
|
5451
|
+
c->canvasBatch.x += dx;
|
|
5452
|
+
c->canvasBatch.y += dy;
|
|
5453
|
+
break;
|
|
5454
|
+
case DisplayCommandType::BlitImageProjected:
|
|
5455
|
+
c->projectedBlit.x += dx;
|
|
5456
|
+
c->projectedBlit.y += dy;
|
|
5457
|
+
for (int corner = 0; corner < 4; ++corner) {
|
|
5458
|
+
c->projectedBlit.xs[corner] += dx;
|
|
5459
|
+
c->projectedBlit.ys[corner] += dy;
|
|
5460
|
+
}
|
|
5461
|
+
break;
|
|
5356
5462
|
case DisplayCommandType::BlitImage:
|
|
5357
5463
|
c->blit.dx += dx;
|
|
5358
5464
|
c->blit.dy += dy;
|
|
@@ -6749,6 +6855,13 @@ int gLastScrollUiFrame = -1000;
|
|
|
6749
6855
|
gea::platform::display::Display::blitImage(c.blit.pixels, c.blit.alpha, c.blit.sourceWidth, c.blit.sourceHeight,
|
|
6750
6856
|
c.blit.dx, c.blit.dy);
|
|
6751
6857
|
break;
|
|
6858
|
+
case DisplayCommandType::ReplayCanvasBatch:
|
|
6859
|
+
CanvasRenderingContext2D::replayRetainedCanvas(c.canvasBatch.nodeId, c.canvasBatch.identity,
|
|
6860
|
+
c.canvasBatch.x, c.canvasBatch.y, c.canvasBatch.width, c.canvasBatch.height);
|
|
6861
|
+
break;
|
|
6862
|
+
case DisplayCommandType::BlitImageProjected:
|
|
6863
|
+
drawProjectedImage(c);
|
|
6864
|
+
break;
|
|
6752
6865
|
case DisplayCommandType::BlitImageScaled:
|
|
6753
6866
|
#if GEA_PIXEL_STORAGE_PACKED
|
|
6754
6867
|
if (gScrollStripReplayActive) {
|
|
@@ -6840,6 +6953,8 @@ int gLastScrollUiFrame = -1000;
|
|
|
6840
6953
|
GEA_REFRESH_PERF(__perf.treeReplayGradientUs += __replayDt);
|
|
6841
6954
|
break;
|
|
6842
6955
|
case DisplayCommandType::BlitImage:
|
|
6956
|
+
case DisplayCommandType::ReplayCanvasBatch:
|
|
6957
|
+
case DisplayCommandType::BlitImageProjected:
|
|
6843
6958
|
case DisplayCommandType::BlitImageScaled:
|
|
6844
6959
|
GEA_REFRESH_PERF(__perf.treeReplayImageUs += __replayDt);
|
|
6845
6960
|
break;
|
|
@@ -6998,6 +7113,13 @@ int gLastScrollUiFrame = -1000;
|
|
|
6998
7113
|
return;
|
|
6999
7114
|
}
|
|
7000
7115
|
Node *n = &Tree::instance().nodes()[id];
|
|
7116
|
+
// Plain leaf text fades through a retained alpha scope. Keeping the
|
|
7117
|
+
// scope at 255 and its glyph command at zero avoids a whole-list
|
|
7118
|
+
// rebuild whenever a label begins or ends a fade.
|
|
7119
|
+
const bool retainedTextAlpha = n->type == NodeType::Text && n->first_child < 0 &&
|
|
7120
|
+
!n->text.empty() && n->computedStyle().text_alpha == 255 &&
|
|
7121
|
+
n->layout.height >= std::max(16, static_cast<int>(n->computedStyle().font_size)) &&
|
|
7122
|
+
n->layout.height >= n->computedStyle().line_height;
|
|
7001
7123
|
if (n->computedStyle().display == 1 || isCollapsedFlexSubtree(*n) || ViewRenderer::backfaceSubtreeHidden(*n))
|
|
7002
7124
|
{
|
|
7003
7125
|
state.clearNodeRange(id);
|
|
@@ -7031,7 +7153,7 @@ int gLastScrollUiFrame = -1000;
|
|
|
7031
7153
|
}
|
|
7032
7154
|
}
|
|
7033
7155
|
}
|
|
7034
|
-
if (n->computedStyle().opacity == 0 && !contributesTextMask)
|
|
7156
|
+
if (n->computedStyle().opacity == 0 && !contributesTextMask && !retainedTextAlpha)
|
|
7035
7157
|
{
|
|
7036
7158
|
state.clearNodeRange(id);
|
|
7037
7159
|
return;
|
|
@@ -7067,7 +7189,7 @@ int gLastScrollUiFrame = -1000;
|
|
|
7067
7189
|
uint8_t cur_alpha = parent_alpha;
|
|
7068
7190
|
const Node *active_mask = mask_node;
|
|
7069
7191
|
|
|
7070
|
-
if (n->computedStyle().opacity < 255)
|
|
7192
|
+
if (n->computedStyle().opacity < 255 || retainedTextAlpha)
|
|
7071
7193
|
{
|
|
7072
7194
|
cur_alpha = (parent_alpha * n->computedStyle().opacity) / 255;
|
|
7073
7195
|
DisplayCommand *cmd = list.append();
|
|
@@ -7194,7 +7316,7 @@ int gLastScrollUiFrame = -1000;
|
|
|
7194
7316
|
if (filtered && !nativeTextInput)
|
|
7195
7317
|
recordFilterBlur(id, *n, DisplayCommandType::ApplyFilterBlur, cur_alpha);
|
|
7196
7318
|
|
|
7197
|
-
if (n->computedStyle().opacity < 255)
|
|
7319
|
+
if (n->computedStyle().opacity < 255 || retainedTextAlpha)
|
|
7198
7320
|
{
|
|
7199
7321
|
DisplayCommand *cmd = list.append();
|
|
7200
7322
|
if (cmd)
|
|
@@ -7935,7 +8057,44 @@ int gLastScrollUiFrame = -1000;
|
|
|
7935
8057
|
command.clip.y + command.clip.h >= height;
|
|
7936
8058
|
}
|
|
7937
8059
|
|
|
7938
|
-
static bool
|
|
8060
|
+
static bool simpleTextAlphaNode(int id, Node *nodes, int count)
|
|
8061
|
+
{
|
|
8062
|
+
if (id < 0 || id >= count || !state.hasNodeScratchFor(id)) return false;
|
|
8063
|
+
const Node &node = nodes[id];
|
|
8064
|
+
const int start = state.nodeDrawStart[id];
|
|
8065
|
+
const int end = state.nodeDrawEnd[id];
|
|
8066
|
+
return node.type == NodeType::Text && node.first_child < 0 &&
|
|
8067
|
+
node.computedStyle().text_alpha == 255 &&
|
|
8068
|
+
node.layout.height >= std::max(16, static_cast<int>(node.computedStyle().font_size)) &&
|
|
8069
|
+
node.layout.height >= node.computedStyle().line_height &&
|
|
8070
|
+
start >= 0 && end == start + 1 && end <= state.commandCount &&
|
|
8071
|
+
state.commands[start].type == DisplayCommandType::DrawText;
|
|
8072
|
+
}
|
|
8073
|
+
|
|
8074
|
+
// Only leaf text may carry partial opacity in simple replay. Its one
|
|
8075
|
+
// glyph command needs a local alpha, not ancestor/compositing traversal.
|
|
8076
|
+
struct SimpleTextAlphaScope
|
|
8077
|
+
{
|
|
8078
|
+
UniformRoundedRectBatch &batch;
|
|
8079
|
+
bool changed;
|
|
8080
|
+
SimpleTextAlphaScope(const Node &node, UniformRoundedRectBatch &rects)
|
|
8081
|
+
: batch(rects), changed(node.computedStyle().opacity != 255)
|
|
8082
|
+
{
|
|
8083
|
+
if (changed) {
|
|
8084
|
+
batch.flush();
|
|
8085
|
+
gea::platform::display::Display::setAlpha(node.computedStyle().opacity);
|
|
8086
|
+
}
|
|
8087
|
+
}
|
|
8088
|
+
~SimpleTextAlphaScope()
|
|
8089
|
+
{
|
|
8090
|
+
if (changed) {
|
|
8091
|
+
batch.flush();
|
|
8092
|
+
gea::platform::display::Display::setAlpha(255);
|
|
8093
|
+
}
|
|
8094
|
+
}
|
|
8095
|
+
};
|
|
8096
|
+
|
|
8097
|
+
static bool canUseSimpleDirtyReplay(int width, int height, const DisplayReplayRegion *regions = nullptr, int count = 0)
|
|
7939
8098
|
{
|
|
7940
8099
|
if (DisplayList::instance().hasTextClippedBackgrounds()) return false;
|
|
7941
8100
|
#if GEA_EMBEDDED_SIMPLE_REPLAY_DEBUG
|
|
@@ -7954,16 +8113,31 @@ int gLastScrollUiFrame = -1000;
|
|
|
7954
8113
|
if ((GEA_CSS_FILTERS ? rstyle(node.computedStyle()).filter_blur_radius : 0) > 0)
|
|
7955
8114
|
{ SRDBG("blur node", i); return false; }
|
|
7956
8115
|
if (node.computedStyle().opacity != 255 && node.computedStyle().opacity != 0)
|
|
7957
|
-
|
|
8116
|
+
if (!simpleTextAlphaNode(i, nodes, nodeCount))
|
|
8117
|
+
{ SRDBG("opacity node", i); return false; }
|
|
7958
8118
|
if (node.computedStyle().mask_right_fade_width > 0)
|
|
7959
8119
|
{ SRDBG("mask node", i); return false; }
|
|
7960
|
-
if (hasRetainedTransformState(node))
|
|
7961
|
-
|
|
8120
|
+
if (hasRetainedTransformState(node) || (regions && nodeHasTransformChain(i, nodes, nodeCount)))
|
|
8121
|
+
{
|
|
8122
|
+
if (!regions || count <= 0 || !state.hasNodeScratchFor(i))
|
|
8123
|
+
{ SRDBG("transform node", i); return false; }
|
|
8124
|
+
// Projected command bounds include the transform of every
|
|
8125
|
+
// ancestor. A static transformed subtree outside all transfer
|
|
8126
|
+
// windows cannot affect their replay; intersecting ink still
|
|
8127
|
+
// requires the general path, even if its layout box is outside.
|
|
8128
|
+
for (int ri = 0; ri < count; ++ri)
|
|
8129
|
+
if (commandRangeBBoxOverlaps(state.nodeDrawStart[i], state.nodeDrawEnd[i],
|
|
8130
|
+
regions[ri].x0, regions[ri].y0, regions[ri].x1, regions[ri].y1))
|
|
8131
|
+
{ SRDBG("transform region", i); return false; }
|
|
8132
|
+
}
|
|
7962
8133
|
}
|
|
7963
8134
|
for (int ci = 0; ci < state.commandCount; ci++)
|
|
7964
8135
|
{
|
|
7965
8136
|
const DisplayCommand &command = state.commands[ci];
|
|
7966
|
-
|
|
8137
|
+
const bool plainTextAlpha = command.type == DisplayCommandType::SetAlpha &&
|
|
8138
|
+
command.alpha.recordParentAlpha == 255 &&
|
|
8139
|
+
simpleTextAlphaNode(command.alpha.nodeId, nodes, nodeCount);
|
|
8140
|
+
if ((command.type == DisplayCommandType::SetAlpha && command.alpha.alpha != 255 && !plainTextAlpha) ||
|
|
7967
8141
|
command.type == DisplayCommandType::BeginFilterBlur ||
|
|
7968
8142
|
command.type == DisplayCommandType::ApplyFilterBlur)
|
|
7969
8143
|
{ SRDBG("alpha/blur cmd type", (int)command.type); return false; }
|
|
@@ -8010,6 +8184,8 @@ int gLastScrollUiFrame = -1000;
|
|
|
8010
8184
|
continue;
|
|
8011
8185
|
const int start = state.nodeDrawStart[node_id];
|
|
8012
8186
|
const int end = state.nodeDrawEnd[node_id];
|
|
8187
|
+
if (node.computedStyle().opacity == 0) continue;
|
|
8188
|
+
SimpleTextAlphaScope alpha(node, roundedRects);
|
|
8013
8189
|
replaySimpleCommandRangeInRegions(start, end, regions, count, roundedRects);
|
|
8014
8190
|
}
|
|
8015
8191
|
roundedRects.flush();
|
|
@@ -8063,6 +8239,8 @@ int gLastScrollUiFrame = -1000;
|
|
|
8063
8239
|
const int end = state.nodeDrawEnd[node_id];
|
|
8064
8240
|
if (start < 0 || end <= start || end > state.commandCount)
|
|
8065
8241
|
return;
|
|
8242
|
+
if (node.computedStyle().opacity == 0) return;
|
|
8243
|
+
SimpleTextAlphaScope alpha(node, roundedRects);
|
|
8066
8244
|
for (int ci = start; ci < end; ci++)
|
|
8067
8245
|
{
|
|
8068
8246
|
DisplayCommand *c = &state.commands[ci];
|
|
@@ -8119,6 +8297,8 @@ int gLastScrollUiFrame = -1000;
|
|
|
8119
8297
|
const int end = state.nodeDrawEnd[node_id];
|
|
8120
8298
|
if (start < 0 || end <= start || end > state.commandCount)
|
|
8121
8299
|
continue;
|
|
8300
|
+
if (node.computedStyle().opacity == 0) continue;
|
|
8301
|
+
SimpleTextAlphaScope alpha(node, roundedRects);
|
|
8122
8302
|
for (int ci = start; ci < end; ci++)
|
|
8123
8303
|
{
|
|
8124
8304
|
DisplayCommand *c = &state.commands[ci];
|
|
@@ -9105,7 +9285,7 @@ int gLastScrollUiFrame = -1000;
|
|
|
9105
9285
|
auto *canvas = gea::platform::display::Display::canvas();
|
|
9106
9286
|
const int width = canvas ? canvas->width() : 0;
|
|
9107
9287
|
const int height = canvas ? canvas->height() : 0;
|
|
9108
|
-
if (canUseSimpleDirtyReplay(width, height))
|
|
9288
|
+
if (canUseSimpleDirtyReplay(width, height, regions, count))
|
|
9109
9289
|
{
|
|
9110
9290
|
replaySimpleDirtyRegions(regions, count);
|
|
9111
9291
|
return;
|
|
@@ -9608,6 +9788,34 @@ int gLastScrollUiFrame = -1000;
|
|
|
9608
9788
|
return command;
|
|
9609
9789
|
}
|
|
9610
9790
|
|
|
9791
|
+
void DisplayList::retainImage(int id)
|
|
9792
|
+
{
|
|
9793
|
+
auto &images = gea::framework::graphics::ImageStore::instance();
|
|
9794
|
+
if (id >= 0 && id < gea::framework::graphics::kImageMax && !state.imageReferences[id])
|
|
9795
|
+
state.imageReferences[id] = images.retain(id);
|
|
9796
|
+
}
|
|
9797
|
+
|
|
9798
|
+
void DisplayList::pruneImageReferences()
|
|
9799
|
+
{
|
|
9800
|
+
bool referenced[gea::framework::graphics::kImageMax]{};
|
|
9801
|
+
auto &images = gea::framework::graphics::ImageStore::instance();
|
|
9802
|
+
for (int i = 0; i < state.commandCount; ++i) {
|
|
9803
|
+
const auto &command = state.commands[i];
|
|
9804
|
+
const gea::framework::graphics::pixel::native_t *pixels = nullptr;
|
|
9805
|
+
if (command.type == DisplayCommandType::BlitImage) pixels = command.blit.pixels;
|
|
9806
|
+
else if (command.type == DisplayCommandType::BlitImageScaled) pixels = command.scaledBlit.pixels;
|
|
9807
|
+
else if (command.type == DisplayCommandType::BlitImageProjected) pixels = command.projectedBlit.pixels;
|
|
9808
|
+
const int id = images.idForPixels(pixels);
|
|
9809
|
+
if (id >= 0) referenced[id] = true;
|
|
9810
|
+
}
|
|
9811
|
+
for (int id = 0; id < gea::framework::graphics::kImageMax; ++id) {
|
|
9812
|
+
if (state.imageReferences[id] && !referenced[id]) {
|
|
9813
|
+
state.imageReferences[id] = false;
|
|
9814
|
+
images.release(id);
|
|
9815
|
+
}
|
|
9816
|
+
}
|
|
9817
|
+
}
|
|
9818
|
+
|
|
9611
9819
|
void DisplayList::clear()
|
|
9612
9820
|
{
|
|
9613
9821
|
Tree &tree = Tree::instance();
|
|
@@ -9617,6 +9825,7 @@ int gLastScrollUiFrame = -1000;
|
|
|
9617
9825
|
state.filterBlurCacheHits = 0;
|
|
9618
9826
|
state.filterBlurCacheMisses = 0;
|
|
9619
9827
|
state.commandCount = 0;
|
|
9828
|
+
pruneImageReferences();
|
|
9620
9829
|
state.textClippedBackgrounds = false;
|
|
9621
9830
|
state.commandOverflow = false;
|
|
9622
9831
|
state.drawNodeOrderCount = 0;
|
|
@@ -9632,6 +9841,7 @@ int gLastScrollUiFrame = -1000;
|
|
|
9632
9841
|
void DisplayList::resetStorage()
|
|
9633
9842
|
{
|
|
9634
9843
|
state.resetStorage();
|
|
9844
|
+
pruneImageReferences();
|
|
9635
9845
|
invalidateStaticBackdrop();
|
|
9636
9846
|
}
|
|
9637
9847
|
|
|
@@ -10029,6 +10239,15 @@ int gLastScrollUiFrame = -1000;
|
|
|
10029
10239
|
c.quad.x3 = xs[3];
|
|
10030
10240
|
c.quad.y3 = ys[3];
|
|
10031
10241
|
}
|
|
10242
|
+
else if (c.type == DisplayCommandType::BlitImageProjected)
|
|
10243
|
+
{
|
|
10244
|
+
ViewRenderer::transformedRectCorners(n, false, c.projectedBlit.x, c.projectedBlit.y,
|
|
10245
|
+
c.projectedBlit.width, c.projectedBlit.height, xs, ys);
|
|
10246
|
+
for (int corner = 0; corner < 4; ++corner) {
|
|
10247
|
+
c.projectedBlit.xs[corner] = xs[corner];
|
|
10248
|
+
c.projectedBlit.ys[corner] = ys[corner];
|
|
10249
|
+
}
|
|
10250
|
+
}
|
|
10032
10251
|
else if (c.type == DisplayCommandType::DrawProjectedText)
|
|
10033
10252
|
{
|
|
10034
10253
|
ViewRenderer::transformedRectCorners(n, false, c.projectedText.srcX, c.projectedText.srcY,
|
|
@@ -10388,6 +10607,12 @@ int gLastScrollUiFrame = -1000;
|
|
|
10388
10607
|
c.bw = 0;
|
|
10389
10608
|
c.bh = 0;
|
|
10390
10609
|
}
|
|
10610
|
+
else if (c.type == DisplayCommandType::BlitImageProjected && c.projectedBlit.pixels == pixels)
|
|
10611
|
+
{
|
|
10612
|
+
c.projectedBlit.pixels = nullptr;
|
|
10613
|
+
c.projectedBlit.alpha = nullptr;
|
|
10614
|
+
c.bw = c.bh = 0;
|
|
10615
|
+
}
|
|
10391
10616
|
else if (c.type == DisplayCommandType::BlitImageScaled && c.scaledBlit.pixels == pixels)
|
|
10392
10617
|
{
|
|
10393
10618
|
c.scaledBlit.pixels = nullptr;
|
|
@@ -11471,6 +11696,8 @@ int gLastScrollUiFrame = -1000;
|
|
|
11471
11696
|
case DisplayCommandType::DrawProjectedText:
|
|
11472
11697
|
case DisplayCommandType::DrawText:
|
|
11473
11698
|
case DisplayCommandType::BlitImage:
|
|
11699
|
+
case DisplayCommandType::ReplayCanvasBatch:
|
|
11700
|
+
case DisplayCommandType::BlitImageProjected:
|
|
11474
11701
|
case DisplayCommandType::BlitImageScaled:
|
|
11475
11702
|
case DisplayCommandType::FillTransformedLinearGradient:
|
|
11476
11703
|
case DisplayCommandType::FillTransformedRoundedRect:
|
|
@@ -12748,6 +12975,7 @@ int gLastScrollUiFrame = -1000;
|
|
|
12748
12975
|
state.nodeDrawEnd[node] = -1;
|
|
12749
12976
|
}
|
|
12750
12977
|
state.shiftNodeDrawRangesAfter(end, delta, node);
|
|
12978
|
+
pruneImageReferences();
|
|
12751
12979
|
return true;
|
|
12752
12980
|
}
|
|
12753
12981
|
|
|
@@ -12836,6 +13064,11 @@ int gLastScrollUiFrame = -1000;
|
|
|
12836
13064
|
return DisplayCommandReplayer::canReplaySimpleDirtyRegions(width, height);
|
|
12837
13065
|
}
|
|
12838
13066
|
|
|
13067
|
+
bool DisplayList::canReplaySimpleDirtyRegions(int width, int height, const DisplayReplayRegion *regions, int count) const
|
|
13068
|
+
{
|
|
13069
|
+
return regions && count > 0 && DisplayCommandReplayer::canUseSimpleDirtyReplay(width, height, regions, count);
|
|
13070
|
+
}
|
|
13071
|
+
|
|
12839
13072
|
void DisplayList::replaySimpleClippedDirtyRegion(int x0, int y0, int x1, int y1, int origin)
|
|
12840
13073
|
{
|
|
12841
13074
|
const auto &tree = Tree::instance();
|