@geastack/engine 0.1.24 → 0.1.25

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geastack/engine",
3
- "version": "0.1.24",
3
+ "version": "0.1.25",
4
4
  "description": "GeaStack rendering engine, intrinsic JSX primitives, and native engine backends.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
package/ui/input.cpp CHANGED
@@ -159,7 +159,7 @@ public:
159
159
  activeTouchNode_ = activeNodeId;activeTouchOwner_=NodeHandle(activeNodeId);
160
160
  savedBackgroundColor_ = node.computedStyle().bg_color;
161
161
  savedHasBackground_ = node.computedStyle().has_bg;
162
- node.mutableStyle().bg_color = node.mutableStyle().has_active_bg ? node.mutableStyle().active_bg_color : lightenRgb565(node.mutableStyle().bg_color);
162
+ node.mutableStyle().bg_color = node.mutableStyle().has_active_bg ? node.mutableStyle().active_bg_color : lightenNativeColor(node.mutableStyle().bg_color);
163
163
  node.mutableStyle().has_bg = 1;
164
164
  activeBackgroundColor_ = node.computedStyle().bg_color;
165
165
  activeHasBackground_ = node.computedStyle().has_bg;
@@ -855,8 +855,9 @@ private:
855
855
  #endif
856
856
  }
857
857
 
858
- static std::uint16_t lightenRgb565(std::uint16_t color)
858
+ static style_color_t lightenNativeColor(style_color_t color)
859
859
  {
860
+ #if GEA_EMBEDDED_PIXEL_FORMAT == GEA_PIXEL_RGB565
860
861
  int r;
861
862
  int g;
862
863
  int b;
@@ -867,6 +868,13 @@ private:
867
868
  b += ((31 - b) * 6) / 32;
868
869
 
869
870
  return gea::framework::graphics::pixel::packRgb565Components(r, g, b);
871
+ #else
872
+ int r, g, b, a;
873
+ gea::framework::graphics::pixel::unpackNative8(color, &r, &g, &b, &a);
874
+ return gea::framework::graphics::pixel::packNative8(
875
+ r + ((255 - r) * 6) / 32, g + ((255 - g) * 6) / 32,
876
+ b + ((255 - b) * 6) / 32, a);
877
+ #endif
870
878
  }
871
879
 
872
880
  static int findActiveTouchNodeId(int nodeId)
@@ -1100,9 +1108,9 @@ private:
1100
1108
 
1101
1109
  NodeHandle activeTouchOwner_,activeScrollOwner_,momentumOwner_,hoveredOwner_;
1102
1110
  int activeTouchNode_ = -1;
1103
- std::uint16_t savedBackgroundColor_ = 0;
1111
+ style_color_t savedBackgroundColor_ = 0;
1104
1112
  std::int8_t savedHasBackground_ = 0;
1105
- std::uint16_t activeBackgroundColor_ = 0;
1113
+ style_color_t activeBackgroundColor_ = 0;
1106
1114
  std::int8_t activeHasBackground_ = 0;
1107
1115
  int activeScrollNode_ = -1;
1108
1116
  int snapAccumDy_ = 0;
package/ui/render.cpp CHANGED
@@ -3372,36 +3372,9 @@ int gLastScrollUiFrame = -1000;
3372
3372
  // identical to view.cpp's interpolatePremultipliedColor so the per-pixel
3373
3373
  // transformed gradient matches the colors the old strip path produced
3374
3374
  // (panel-endian aware via fromRgb888).
3375
- uint16_t tgPremulColor(uint16_t fromColor, uint8_t fromAlpha, uint16_t toColor, uint8_t toAlpha, int permille)
3376
- {
3377
- if (permille <= 0)
3378
- return fromColor;
3379
- if (permille >= 1000)
3380
- return toColor;
3381
- int fr = 0, fg = 0, fb = 0, tr = 0, tg = 0, tb = 0;
3382
- gea::framework::graphics::pixel::unpackRgb565(fromColor, &fr, &fg, &fb);
3383
- gea::framework::graphics::pixel::unpackRgb565(toColor, &tr, &tg, &tb);
3384
- fr = (fr * 255 + 15) / 31;
3385
- fg = (fg * 255 + 31) / 63;
3386
- fb = (fb * 255 + 15) / 31;
3387
- tr = (tr * 255 + 15) / 31;
3388
- tg = (tg * 255 + 31) / 63;
3389
- tb = (tb * 255 + 15) / 31;
3390
- const int fw = static_cast<int>(fromAlpha) * (1000 - permille);
3391
- const int tw = static_cast<int>(toAlpha) * permille;
3392
- const int wsum = fw + tw;
3393
- if (wsum <= 0)
3394
- return toColor;
3395
- const int r = (fr * fw + tr * tw + wsum / 2) / wsum;
3396
- const int g = (fg * fw + tg * tw + wsum / 2) / wsum;
3397
- const int b = (fb * fw + tb * tw + wsum / 2) / wsum;
3398
- return gea::framework::graphics::pixel::fromRgb888(r, g, b);
3399
- }
3375
+ // Interpolate in 8-bit channels before the target-specific packing step.
3376
+ using GradientKeyWord = std::conditional_t<GEA_PIXEL_FORMAT_IS_8888, std::uint32_t, std::uint16_t>;
3400
3377
 
3401
- // Same premultiplied interpolation as tgPremulColor but returns the un-quantized
3402
- // RGB888 (not packed to RGB565), so the face LUT can store the per-channel Bayer
3403
- // dither floor+remainder and dither per pixel — otherwise dark transformed
3404
- // gradients (the perspective floor) show hard RGB565 bands.
3405
3378
  void tgPremulRgb888(gea::framework::graphics::pixel::native_t fromColor, uint8_t fromAlpha, gea::framework::graphics::pixel::native_t toColor, uint8_t toAlpha, int permille, int *outR, int *outG, int *outB)
3406
3379
  {
3407
3380
  // Unpack the native gradient endpoints to 8-bit channels (5/6-bit expand on
@@ -3608,7 +3581,7 @@ int gLastScrollUiFrame = -1000;
3608
3581
  struct FaceLutSlot
3609
3582
  {
3610
3583
  bool valid = false;
3611
- std::uint16_t key[5] = {};
3584
+ GradientKeyWord key[5] = {};
3612
3585
  std::uint8_t keyA[4] = {};
3613
3586
  FaceDitherStop e[251];
3614
3587
  // Hot-path SoA mirrors of e[]: the per-pixel SIMD gather reads ONLY the
@@ -3682,7 +3655,7 @@ int gLastScrollUiFrame = -1000;
3682
3655
  };
3683
3656
  lockSlots();
3684
3657
  #endif
3685
- const std::uint16_t key[5] = {static_cast<std::uint16_t>(g.fromColor), static_cast<std::uint16_t>(g.midColor), static_cast<std::uint16_t>(g.toColor),
3658
+ const GradientKeyWord key[5] = {g.fromColor, g.midColor, g.toColor,
3686
3659
  static_cast<std::uint16_t>(midStop), static_cast<std::uint16_t>(toStop)};
3687
3660
  const std::uint8_t keyA[4] = {g.fromAlpha, g.midAlpha, g.toAlpha, g.hasMid};
3688
3661
  FaceLutSlot *slot = nullptr;
@@ -5632,17 +5605,17 @@ int gLastScrollUiFrame = -1000;
5632
5605
  gea::framework::graphics::pixel::native_t *color = nullptr;
5633
5606
  std::uint8_t *alpha = nullptr;
5634
5607
  int cap = 0, kw = 0, kh = 0;
5635
- std::uint16_t key[24] = {0};
5636
- std::uint16_t lastKey[24] = {0};
5608
+ GradientKeyWord key[24] = {0};
5609
+ GradientKeyWord lastKey[24] = {0};
5637
5610
  int keyLen = 0;
5638
5611
  int stable = 0;
5639
5612
  bool valid = false;
5640
5613
 
5641
5614
  template <typename SpanFn>
5642
- bool blit(const std::uint16_t *keyNow, int kl, int x0, int y0, int x1, int y1, int scrW, int scrH, SpanFn span)
5615
+ bool blit(const GradientKeyWord *keyNow, int kl, int x0, int y0, int x1, int y1, int scrW, int scrH, SpanFn span)
5643
5616
  {
5644
5617
  if (!valid || kw != scrW || kh != scrH || keyLen != kl ||
5645
- std::memcmp(keyNow, key, static_cast<std::size_t>(kl) * sizeof(std::uint16_t)) != 0)
5618
+ std::memcmp(keyNow, key, static_cast<std::size_t>(kl) * sizeof(GradientKeyWord)) != 0)
5646
5619
  return false;
5647
5620
  for (int y = y0; y <= y1; ++y)
5648
5621
  {
@@ -5658,15 +5631,15 @@ int gLastScrollUiFrame = -1000;
5658
5631
  }
5659
5632
 
5660
5633
  template <typename SpanFn, typename PixelFn>
5661
- void bake(const std::uint16_t *keyNow, int kl, int boxX, int boxY, int boxW, int boxH, int scrW, int scrH, SpanFn span, PixelFn pixel)
5634
+ void bake(const GradientKeyWord *keyNow, int kl, int boxX, int boxY, int boxW, int boxH, int scrW, int scrH, SpanFn span, PixelFn pixel)
5662
5635
  {
5663
- if (keyLen == kl && std::memcmp(keyNow, lastKey, static_cast<std::size_t>(kl) * sizeof(std::uint16_t)) == 0)
5636
+ if (keyLen == kl && std::memcmp(keyNow, lastKey, static_cast<std::size_t>(kl) * sizeof(GradientKeyWord)) == 0)
5664
5637
  {
5665
5638
  stable++;
5666
5639
  }
5667
5640
  else
5668
5641
  {
5669
- std::memcpy(lastKey, keyNow, static_cast<std::size_t>(kl) * sizeof(std::uint16_t));
5642
+ std::memcpy(lastKey, keyNow, static_cast<std::size_t>(kl) * sizeof(GradientKeyWord));
5670
5643
  keyLen = kl;
5671
5644
  stable = 1;
5672
5645
  valid = false;
@@ -5700,7 +5673,7 @@ int gLastScrollUiFrame = -1000;
5700
5673
  pixel(x, y, &color[off], &alpha[off]);
5701
5674
  }
5702
5675
  }
5703
- std::memcpy(key, keyNow, static_cast<std::size_t>(kl) * sizeof(std::uint16_t));
5676
+ std::memcpy(key, keyNow, static_cast<std::size_t>(kl) * sizeof(GradientKeyWord));
5704
5677
  kw = scrW;
5705
5678
  kh = scrH;
5706
5679
  valid = true;
@@ -5710,15 +5683,15 @@ int gLastScrollUiFrame = -1000;
5710
5683
  // but hands the filler whole rows so drawers can use their span fast
5711
5684
  // paths (e.g. the vertical-gradient constant-row fill).
5712
5685
  template <typename SpanFn, typename RowFn>
5713
- void bakeRows(const std::uint16_t *keyNow, int kl, int boxX, int boxY, int boxW, int boxH, int scrW, int scrH, SpanFn span, RowFn rowFn)
5686
+ void bakeRows(const GradientKeyWord *keyNow, int kl, int boxX, int boxY, int boxW, int boxH, int scrW, int scrH, SpanFn span, RowFn rowFn)
5714
5687
  {
5715
- if (keyLen == kl && std::memcmp(keyNow, lastKey, static_cast<std::size_t>(kl) * sizeof(std::uint16_t)) == 0)
5688
+ if (keyLen == kl && std::memcmp(keyNow, lastKey, static_cast<std::size_t>(kl) * sizeof(GradientKeyWord)) == 0)
5716
5689
  {
5717
5690
  stable++;
5718
5691
  }
5719
5692
  else
5720
5693
  {
5721
- std::memcpy(lastKey, keyNow, static_cast<std::size_t>(kl) * sizeof(std::uint16_t));
5694
+ std::memcpy(lastKey, keyNow, static_cast<std::size_t>(kl) * sizeof(GradientKeyWord));
5722
5695
  keyLen = kl;
5723
5696
  stable = 1;
5724
5697
  valid = false;
@@ -5749,7 +5722,7 @@ int gLastScrollUiFrame = -1000;
5749
5722
  const long long off = static_cast<long long>(y) * scrW + rowX0;
5750
5723
  rowFn(y, rowX0, rowX1, &color[off], &alpha[off]);
5751
5724
  }
5752
- std::memcpy(key, keyNow, static_cast<std::size_t>(kl) * sizeof(std::uint16_t));
5725
+ std::memcpy(key, keyNow, static_cast<std::size_t>(kl) * sizeof(GradientKeyWord));
5753
5726
  kw = scrW;
5754
5727
  kh = scrH;
5755
5728
  valid = true;
@@ -5830,35 +5803,10 @@ int gLastScrollUiFrame = -1000;
5830
5803
  gea::framework::graphics::pixel::unpackNative8(color, r, g, b, &a);
5831
5804
  }
5832
5805
 
5833
- static uint16_t packDitheredRgb888(int r, int g, int b, int x, int y)
5834
- {
5835
- static constexpr uint8_t bayer4[4][4] = {
5836
- {0, 8, 2, 10},
5837
- {12, 4, 14, 6},
5838
- {3, 11, 1, 9},
5839
- {15, 7, 13, 5},
5840
- };
5841
- const int threshold = bayer4[y & 3][x & 3] * 16 + 8;
5842
- auto quantize = [threshold](int value, int levels)
5843
- {
5844
- if (value <= 0)
5845
- return 0;
5846
- if (value >= 255)
5847
- return levels;
5848
- const int scaled = value * levels;
5849
- const int q = scaled / 255;
5850
- return q + ((scaled - q * 255) > threshold ? 1 : 0);
5851
- };
5852
- return gea::framework::graphics::pixel::packRgb565Components(
5853
- quantize(r, 31),
5854
- quantize(g, 63),
5855
- quantize(b, 31));
5856
- }
5857
-
5858
5806
  // One per-permille LUT entry. Holds the dither quantize floor `q` and the
5859
5807
  // remainder `rem` for each RGB565 channel, so the per-pixel dither is a
5860
5808
  // single compare (`rem > threshold`) with no divide. Bit-identical to the
5861
- // old packDitheredRgb888 quantize.
5809
+ // direct RGB565 quantization.
5862
5810
  struct DitherStop
5863
5811
  {
5864
5812
  uint8_t qR, remR, qG, remG, qB, remB, alpha;
@@ -6028,7 +5976,7 @@ int gLastScrollUiFrame = -1000;
6028
5976
  *x1 = std::min(*x1, rowRight);
6029
5977
  }
6030
5978
 
6031
- static void fillRun(int x, int y, int w, uint16_t color, uint8_t alpha, uint8_t baseAlpha)
5979
+ static void fillRun(int x, int y, int w, style_color_t color, uint8_t alpha, uint8_t baseAlpha)
6032
5980
  {
6033
5981
  const uint8_t effectiveAlpha = combineAlpha(baseAlpha, alpha);
6034
5982
  if (effectiveAlpha == 0 || w <= 0)
@@ -6077,14 +6025,14 @@ int gLastScrollUiFrame = -1000;
6077
6025
  static_cast<long long>(scrW) * scrH;
6078
6026
  const bool bgCacheable = bgBuf && bgCanvas && bgCanvas->pixels() && bgOpaque && bgLarge &&
6079
6027
  scrW > 0 && scrH > 0 && bgCap >= scrW * scrH;
6080
- const std::uint16_t bgKeyNow[14] = {
6081
- static_cast<std::uint16_t>(c.gradient.fromColor), static_cast<std::uint16_t>(c.gradient.midColor), static_cast<std::uint16_t>(c.gradient.toColor), c.gradient.midStop,
6028
+ const GradientKeyWord bgKeyNow[14] = {
6029
+ c.gradient.fromColor, c.gradient.midColor, c.gradient.toColor, c.gradient.midStop,
6082
6030
  c.gradient.toStop, static_cast<std::uint16_t>(c.gradient.angle), c.gradient.fromAlpha,
6083
6031
  c.gradient.midAlpha, c.gradient.toAlpha, c.gradient.hasMid,
6084
6032
  static_cast<std::uint16_t>(c.gradient.x), static_cast<std::uint16_t>(c.gradient.y),
6085
6033
  static_cast<std::uint16_t>(c.gradient.w), static_cast<std::uint16_t>(c.gradient.h)};
6086
- static std::uint16_t bgKey[14];
6087
- static std::uint16_t bgLastKey[14];
6034
+ static GradientKeyWord bgKey[14];
6035
+ static GradientKeyWord bgLastKey[14];
6088
6036
  static int bgStable = 0;
6089
6037
  static bool bgValid = false;
6090
6038
  static int bgKW = 0, bgKH = 0;
@@ -6116,8 +6064,8 @@ int gLastScrollUiFrame = -1000;
6116
6064
  (c.gradient.hasMid && c.gradient.midAlpha < 255);
6117
6065
  const bool transCacheable = bgCanvas && bgCanvas->pixels() && scrW > 0 && scrH > 0 && hasTransparency &&
6118
6066
  static_cast<long long>(c.gradient.w) * c.gradient.h * 16 >= static_cast<long long>(scrW) * scrH;
6119
- const std::uint16_t transKey[14] = {
6120
- static_cast<std::uint16_t>(c.gradient.fromColor), static_cast<std::uint16_t>(c.gradient.midColor), static_cast<std::uint16_t>(c.gradient.toColor), c.gradient.midStop, c.gradient.toStop,
6067
+ const GradientKeyWord transKey[14] = {
6068
+ c.gradient.fromColor, c.gradient.midColor, c.gradient.toColor, c.gradient.midStop, c.gradient.toStop,
6121
6069
  static_cast<std::uint16_t>(c.gradient.angle), c.gradient.fromAlpha, c.gradient.midAlpha, c.gradient.toAlpha,
6122
6070
  c.gradient.hasMid, static_cast<std::uint16_t>(c.gradient.x), static_cast<std::uint16_t>(c.gradient.y),
6123
6071
  static_cast<std::uint16_t>(c.gradient.w), static_cast<std::uint16_t>(c.gradient.h)};
@@ -6199,7 +6147,7 @@ int gLastScrollUiFrame = -1000;
6199
6147
  struct LutSlot
6200
6148
  {
6201
6149
  DitherStop lut[1001];
6202
- std::uint16_t key[5];
6150
+ GradientKeyWord key[5];
6203
6151
  std::uint8_t keyA[4];
6204
6152
  std::uint32_t lastUse;
6205
6153
  };
@@ -6245,7 +6193,7 @@ int gLastScrollUiFrame = -1000;
6245
6193
  }
6246
6194
  lutSlot->lastUse = ++lutUseCounter;
6247
6195
  DitherStop *lut = lutSlot->lut;
6248
- std::uint16_t *lutKey = lutSlot->key;
6196
+ GradientKeyWord *lutKey = lutSlot->key;
6249
6197
  std::uint8_t *lutKeyA = lutSlot->keyA;
6250
6198
  if (!lutMatch)
6251
6199
  {
@@ -6563,25 +6511,6 @@ int gLastScrollUiFrame = -1000;
6563
6511
  return (permille * 1000 + stop / 2) / stop;
6564
6512
  }
6565
6513
 
6566
- static uint16_t colorAt(const DisplayCommand &c, int permille, int x, int y)
6567
- {
6568
- const int local = localPermille(c, permille);
6569
- int r = 0, g = 0, b = 0;
6570
- LinearGradientDrawer::interpolatePremultipliedRgb888(c.radialGradient.fromColor,
6571
- c.radialGradient.fromAlpha,
6572
- c.radialGradient.toColor,
6573
- c.radialGradient.toAlpha,
6574
- local,
6575
- &r,
6576
- &g,
6577
- &b);
6578
- return LinearGradientDrawer::packDitheredRgb888(r,
6579
- g,
6580
- b,
6581
- x,
6582
- y);
6583
- }
6584
-
6585
6514
  static uint8_t alphaAt(const DisplayCommand &c, int permille)
6586
6515
  {
6587
6516
  return LinearGradientDrawer::interpolateAlpha(c.radialGradient.fromAlpha,
@@ -6632,14 +6561,14 @@ int gLastScrollUiFrame = -1000;
6632
6561
  const bool cacheable = rcanvas && rcanvas->pixels() && scrW > 0 && scrH > 0 &&
6633
6562
  static_cast<long long>(c.radialGradient.w) * c.radialGradient.h * 16 >=
6634
6563
  static_cast<long long>(scrW) * scrH;
6635
- const std::uint16_t keyNow[17] = {
6564
+ const GradientKeyWord keyNow[17] = {
6636
6565
  static_cast<std::uint16_t>(c.radialGradient.x), static_cast<std::uint16_t>(c.radialGradient.y),
6637
6566
  static_cast<std::uint16_t>(c.radialGradient.w), static_cast<std::uint16_t>(c.radialGradient.h),
6638
6567
  static_cast<std::uint16_t>(c.radialGradient.tl), static_cast<std::uint16_t>(c.radialGradient.tr),
6639
6568
  static_cast<std::uint16_t>(c.radialGradient.br), static_cast<std::uint16_t>(c.radialGradient.bl),
6640
6569
  static_cast<std::uint16_t>(c.radialGradient.cxPermille), static_cast<std::uint16_t>(c.radialGradient.cyPermille),
6641
6570
  static_cast<std::uint16_t>(c.radialGradient.rxPermille), static_cast<std::uint16_t>(c.radialGradient.ryPermille),
6642
- static_cast<std::uint16_t>(c.radialGradient.fromColor), static_cast<std::uint16_t>(c.radialGradient.toColor), c.radialGradient.stopPermille,
6571
+ c.radialGradient.fromColor, c.radialGradient.toColor, c.radialGradient.stopPermille,
6643
6572
  c.radialGradient.fromAlpha, c.radialGradient.toAlpha};
6644
6573
  static StaticGradientCache cache;
6645
6574
  auto span = [&](int y, int *a, int *b)
@@ -6659,7 +6588,7 @@ int gLastScrollUiFrame = -1000;
6659
6588
  #else
6660
6589
  static LinearGradientDrawer::DitherStop lut[1001];
6661
6590
  #endif
6662
- static uint16_t lutKeyFrom = 0xFFFF, lutKeyTo = 0;
6591
+ static style_color_t lutKeyFrom = 0xFFFF, lutKeyTo = 0;
6663
6592
  static uint8_t lutKeyFromA = 0xFF, lutKeyToA = 0;
6664
6593
  static uint16_t lutKeyStop = 0xFFFF;
6665
6594
  if (lutKeyFrom != c.radialGradient.fromColor || lutKeyTo != c.radialGradient.toColor ||
@@ -7771,7 +7700,7 @@ int gLastScrollUiFrame = -1000;
7771
7700
  continue;
7772
7701
  if (!regionInsideRetainedBackground(entry.command, x0, y0, x1, y1))
7773
7702
  continue;
7774
- const std::uint16_t color = entry.command.type == DisplayCommandType::FillRect
7703
+ const auto color = entry.command.type == DisplayCommandType::FillRect
7775
7704
  ? entry.command.fill.color
7776
7705
  : entry.command.fillRoundedRect.color;
7777
7706
  gea::platform::display::Display::fillRect(x0, y0, x1 - x0 + 1, y1 - y0 + 1, color);
@@ -11941,9 +11870,9 @@ int gLastScrollUiFrame = -1000;
11941
11870
  y1);
11942
11871
  }
11943
11872
 
11944
- bool commandDoesNotPaintColor(const DisplayCommand &command, uint16_t color)
11873
+ bool commandDoesNotPaintColor(const DisplayCommand &command, style_color_t color)
11945
11874
  {
11946
- uint16_t commandColor = 0;
11875
+ style_color_t commandColor = 0;
11947
11876
  switch (command.type)
11948
11877
  {
11949
11878
  case DisplayCommandType::PushClip:
@@ -11990,7 +11919,7 @@ int gLastScrollUiFrame = -1000;
11990
11919
  return commandColor != color;
11991
11920
  }
11992
11921
 
11993
- bool laterOverlappingCommandsAvoidColor(int node, const DisplayCommand &backgroundCommand, uint16_t color)
11922
+ bool laterOverlappingCommandsAvoidColor(int node, const DisplayCommand &backgroundCommand, style_color_t color)
11994
11923
  {
11995
11924
  Tree &tree = Tree::instance();
11996
11925
  Node *nodes = tree.nodes();
@@ -12068,8 +11997,8 @@ int gLastScrollUiFrame = -1000;
12068
11997
  }
12069
11998
 
12070
11999
  bool recolorRetainedFillRect(const DisplayCommand &command,
12071
- uint16_t oldColor,
12072
- uint16_t newColor,
12000
+ style_color_t oldColor,
12001
+ style_color_t newColor,
12073
12002
  int *outX0,
12074
12003
  int *outY0,
12075
12004
  int *outX1,
@@ -13302,10 +13231,10 @@ int gLastScrollUiFrame = -1000;
13302
13231
  const int edgePad = useAntialias ? axisRoundedRectAntialiasEdgePad(kernelWidth) : 0;
13303
13232
  const bool fastInterior = useAntialias &&
13304
13233
  static_cast<int>(r.w) * static_cast<int>(r.h) >= kRetainedRoundedRectFastInteriorArea;
13305
- if (useAntialias && !fastInterior)
13234
+ if (useAntialias && (!fastInterior || GEA_EMBEDDED_PIXEL_FORMAT != GEA_PIXEL_RGB565))
13306
13235
  {
13307
- // Small AA circles/pills are cheaper to repaint through the normal dirty-region
13308
- // path than to reverse-blend their retained edge pixels.
13236
+ // Reverse blending is specialized for RGB565. Use normal dirty-region
13237
+ // replay for other formats and for small antialiased shapes.
13309
13238
  return false;
13310
13239
  }
13311
13240
  const bool protectForegroundDuringFill = fastInterior;
@@ -13610,8 +13539,8 @@ int gLastScrollUiFrame = -1000;
13610
13539
  }
13611
13540
 
13612
13541
  bool recolorRetainedTransformedRoundedRect(const DisplayCommand &command,
13613
- uint16_t oldColor,
13614
- uint16_t newColor,
13542
+ style_color_t oldColor,
13543
+ style_color_t newColor,
13615
13544
  int *outX0,
13616
13545
  int *outY0,
13617
13546
  int *outX1,
package/ui/view.cpp CHANGED
@@ -77,13 +77,6 @@ void appendAlphaCommand(uint8_t alpha, int bx, int by, int bw, int bh)
77
77
  cmd->alpha.alpha = alpha;
78
78
  }
79
79
 
80
- uint16_t interpolateColor(uint16_t from, uint16_t to, int permille)
81
- {
82
- if (permille <= 0) return from;
83
- if (permille >= 1000) return to;
84
- return gea::framework::graphics::pixel::blend(to, from, (permille * 255 + 500) / 1000);
85
- }
86
-
87
80
  uint8_t interpolateAlpha(uint8_t from, uint8_t to, int permille)
88
81
  {
89
82
  if (permille <= 0) return from;
@@ -91,36 +84,6 @@ uint8_t interpolateAlpha(uint8_t from, uint8_t to, int permille)
91
84
  return static_cast<uint8_t>((static_cast<int>(from) * (1000 - permille) + static_cast<int>(to) * permille + 500) / 1000);
92
85
  }
93
86
 
94
- uint16_t interpolatePremultipliedColor(uint16_t fromColor, uint8_t fromAlpha,
95
- uint16_t toColor, uint8_t toAlpha,
96
- int permille)
97
- {
98
- if (permille <= 0) return fromColor;
99
- if (permille >= 1000) return toColor;
100
- int fr = 0, fg = 0, fb = 0, tr = 0, tg = 0, tb = 0;
101
- gea::framework::graphics::pixel::unpackRgb565(fromColor, &fr, &fg, &fb);
102
- gea::framework::graphics::pixel::unpackRgb565(toColor, &tr, &tg, &tb);
103
- fr = (fr * 255 + 15) / 31;
104
- fg = (fg * 255 + 31) / 63;
105
- fb = (fb * 255 + 15) / 31;
106
- tr = (tr * 255 + 15) / 31;
107
- tg = (tg * 255 + 31) / 63;
108
- tb = (tb * 255 + 15) / 31;
109
- const int fromWeight = static_cast<int>(fromAlpha) * (1000 - permille);
110
- const int toWeight = static_cast<int>(toAlpha) * permille;
111
- const int weight = fromWeight + toWeight;
112
- if (weight <= 0) return toColor;
113
- const int r = (fr * fromWeight + tr * toWeight + weight / 2) / weight;
114
- const int g = (fg * fromWeight + tg * toWeight + weight / 2) / weight;
115
- const int b = (fb * fromWeight + tb * toWeight + weight / 2) / weight;
116
- // Panel-endian-aware: framebuffer pixels are byte-swapped when
117
- // GEA_EMBEDDED_PIXEL_PANEL_ENDIAN=1 (the endpoints above return the already
118
- // byte-swapped stop colors). Emitting raw rgb565FromRgb888 here made the
119
- // interpolated middle of transformed gradient faces land un-swapped → scrambled
120
- // hues on device. fromRgb888 == rgb565FromRgb888 on host.
121
- return gea::framework::graphics::pixel::fromRgb888(r, g, b);
122
- }
123
-
124
87
  int clampPermille(int value)
125
88
  {
126
89
  if (value < 0) return 0;
@@ -143,31 +106,6 @@ int stopRangePermille(int permille, int start, int end)
143
106
  return ((permille - start) * 1000 + span / 2) / span;
144
107
  }
145
108
 
146
- uint16_t gradientColorAt(const Node &node, int permille)
147
- {
148
- permille = clampPermille(permille);
149
- const int toStop = gradientToStop(node);
150
- if (rstyle(node.computedStyle()).bg_gradient_has_mid && rstyle(node.computedStyle()).bg_gradient_mid_stop > 0 && rstyle(node.computedStyle()).bg_gradient_mid_stop < toStop) {
151
- const int stop = rstyle(node.computedStyle()).bg_gradient_mid_stop;
152
- if (permille <= stop)
153
- return interpolatePremultipliedColor(rstyle(node.computedStyle()).bg_gradient_from_color,
154
- rstyle(node.computedStyle()).bg_gradient_from_alpha,
155
- rstyle(node.computedStyle()).bg_gradient_mid_color,
156
- rstyle(node.computedStyle()).bg_gradient_mid_alpha,
157
- stopRangePermille(permille, 0, stop));
158
- return interpolatePremultipliedColor(rstyle(node.computedStyle()).bg_gradient_mid_color,
159
- rstyle(node.computedStyle()).bg_gradient_mid_alpha,
160
- rstyle(node.computedStyle()).bg_gradient_to_color,
161
- rstyle(node.computedStyle()).bg_gradient_to_alpha,
162
- stopRangePermille(permille, stop, toStop));
163
- }
164
- return interpolatePremultipliedColor(rstyle(node.computedStyle()).bg_gradient_from_color,
165
- rstyle(node.computedStyle()).bg_gradient_from_alpha,
166
- rstyle(node.computedStyle()).bg_gradient_to_color,
167
- rstyle(node.computedStyle()).bg_gradient_to_alpha,
168
- stopRangePermille(permille, 0, toStop));
169
- }
170
-
171
109
  uint8_t gradientAlphaAt(const Node &node, int permille)
172
110
  {
173
111
  permille = clampPermille(permille);
@@ -185,7 +123,7 @@ uint8_t gradientAlphaAt(const Node &node, int permille)
185
123
  return interpolateAlpha(rstyle(node.computedStyle()).bg_gradient_from_alpha, rstyle(node.computedStyle()).bg_gradient_to_alpha, stopRangePermille(permille, 0, toStop));
186
124
  }
187
125
 
188
- void appendFillRectWithAlpha(int x, int y, int w, int h, uint16_t color, uint8_t alpha, uint8_t parentAlpha, int bx, int by, int bw, int bh)
126
+ void appendFillRectWithAlpha(int x, int y, int w, int h, style_color_t color, uint8_t alpha, uint8_t parentAlpha, int bx, int by, int bw, int bh)
189
127
  {
190
128
  const uint8_t effectiveAlpha = combineAlpha(parentAlpha, alpha);
191
129
  if (effectiveAlpha != parentAlpha) appendAlphaCommand(effectiveAlpha, bx, by, bw, bh);
@@ -200,7 +138,7 @@ void appendFillRectWithAlpha(int x, int y, int w, int h, uint16_t color, uint8_t
200
138
  if (effectiveAlpha != parentAlpha) appendAlphaCommand(parentAlpha, bx, by, bw, bh);
201
139
  }
202
140
 
203
- void appendFillRectRaw(int x, int y, int w, int h, uint16_t color, int bx, int by, int bw, int bh)
141
+ void appendFillRectRaw(int x, int y, int w, int h, style_color_t color, int bx, int by, int bw, int bh)
204
142
  {
205
143
  DisplayCommand *cmd = DisplayList::instance().append();
206
144
  if (!cmd) return;
@@ -211,7 +149,7 @@ void appendFillRectRaw(int x, int y, int w, int h, uint16_t color, int bx, int b
211
149
  cmd->fill.color = color;
212
150
  }
213
151
 
214
- void appendFillQuadWithAlpha(const int16_t *xs, const int16_t *ys, uint16_t color, uint8_t alpha, uint8_t parentAlpha,
152
+ void appendFillQuadWithAlpha(const int16_t *xs, const int16_t *ys, style_color_t color, uint8_t alpha, uint8_t parentAlpha,
215
153
  int bx, int by, int bw, int bh,
216
154
  int lx = 0, int ly = 0, int lw = 0, int lh = 0, uint8_t reprojectMode = 0)
217
155
  {
@@ -237,7 +175,7 @@ void appendFillQuadWithAlpha(const int16_t *xs, const int16_t *ys, uint16_t colo
237
175
  if (effectiveAlpha != parentAlpha) appendAlphaCommand(parentAlpha, bx, by, bw, bh);
238
176
  }
239
177
 
240
- void appendFillQuadRaw(const int16_t *xs, const int16_t *ys, uint16_t color, int bx, int by, int bw, int bh,
178
+ void appendFillQuadRaw(const int16_t *xs, const int16_t *ys, style_color_t color, int bx, int by, int bw, int bh,
241
179
  int lx = 0, int ly = 0, int lw = 0, int lh = 0, uint8_t reprojectMode = 0)
242
180
  {
243
181
  DisplayCommand *cmd = DisplayList::instance().append();
@@ -258,7 +196,7 @@ void appendFillQuadRaw(const int16_t *xs, const int16_t *ys, uint16_t color, int
258
196
  cmd->quad.reprojectMode = reprojectMode;
259
197
  }
260
198
 
261
- void appendFillQuadStrokeSegmentRaw(const int16_t *xs, const int16_t *ys, uint16_t color,
199
+ void appendFillQuadStrokeSegmentRaw(const int16_t *xs, const int16_t *ys, style_color_t color,
262
200
  int bx, int by, int bw, int bh,
263
201
  float localX0, float localY0, float localX1, float localY1, float strokeWidth)
264
202
  {
@@ -285,7 +223,7 @@ void appendFillQuadStrokeSegmentRaw(const int16_t *xs, const int16_t *ys, uint16
285
223
  void boundsFromCorners(const int16_t *xs, const int16_t *ys, int *x0, int *y0, int *x1, int *y1);
286
224
 
287
225
  DisplayCommand *appendLinearGradientRectRaw(const Node &node, int x, int y, int w, int h,
288
- uint16_t fromColor, uint16_t midColor, uint16_t toColor,
226
+ style_color_t fromColor, style_color_t midColor, style_color_t toColor,
289
227
  uint16_t midStop, uint16_t toStop, int16_t angle, uint8_t fromAlpha,
290
228
  uint8_t midAlpha, uint8_t toAlpha, uint8_t hasMid)
291
229
  {
@@ -365,7 +303,7 @@ DisplayCommand *appendRadialGradientRectRaw(const Node &node, int x, int y, int
365
303
  return cmd;
366
304
  }
367
305
 
368
- void appendDrawLineRaw(int x0, int y0, int x1, int y1, uint16_t color)
306
+ void appendDrawLineRaw(int x0, int y0, int x1, int y1, style_color_t color)
369
307
  {
370
308
  DisplayCommand *cmd = DisplayList::instance().append();
371
309
  if (!cmd) return;
@@ -385,7 +323,7 @@ void appendDrawLineRaw(int x0, int y0, int x1, int y1, uint16_t color)
385
323
  cmd->line.color = color;
386
324
  }
387
325
 
388
- void appendStrokeSegmentBandRaw(float x0, float y0, float x1, float y1, float width, uint16_t color,
326
+ void appendStrokeSegmentBandRaw(float x0, float y0, float x1, float y1, float width, style_color_t color,
389
327
  float localX0 = 0.0f, float localY0 = 0.0f,
390
328
  float localX1 = 0.0f, float localY1 = 0.0f,
391
329
  bool reprojectable = false)
@@ -1554,8 +1492,8 @@ void appendReliefBordersWithAlpha(const Node &node, uint8_t parentAlpha)
1554
1492
  const int relief = rstyle(node.computedStyle()).border_relief[side];
1555
1493
  const int bands = relief == 1 || relief == 2 ? 2 : 1;
1556
1494
  const auto color = borderPaintColor(node.computedStyle(), side);
1557
- int r, g, b; pixel::unpackRgb565(color, &r, &g, &b);
1558
- r = pixel::expand5To8(r); g = pixel::expand6To8(g); b = pixel::expand5To8(b);
1495
+ int r, g, b, a;
1496
+ pixel::unpackNative8(color, &r, &g, &b, &a);
1559
1497
  // CSS permits UA-defined relief shades. Mixing with white keeps even a
1560
1498
  // black currentColor border visibly raised or recessed.
1561
1499
  const auto light = pixel::nativeColor((r * 3 + 510) / 5, (g * 3 + 510) / 5, (b * 3 + 510) / 5);
@@ -454,23 +454,18 @@ KbMetrics kbMetrics()
454
454
  // zone — what both the mount position and the app-resize math key off.
455
455
  int keyboardOccupiedHeight() { return kbMetrics().height + bottomInset(); }
456
456
 
457
- // `setStyle(Property::BackgroundColor, X)` expects X to be a RAW RGB565
458
- // value — the framework's renderer byte-swaps once on the way to the
459
- // display. Using `pixel::fromRgb888` here would double-swap and land
460
- // the bytes in the wrong order on the wire (the earlier "purple
461
- // keyboard on purple background" symptom). Use `rgb565FromRgb888`
462
- // which returns the plain RGB565 value the framework expects.
457
+ // Tree::setStyle applies the native style-to-framebuffer conversion.
463
458
  // The wide layout wears LVGL's default light theme: a #f5f5f5 screen
464
459
  // background, white keys, #e0e0e0 "checked" keys, #212121 text, and a
465
460
  // pressed state darkened by LV_OPA_35 of black.
466
- std::uint16_t rgb(int r, int g, int b) { return gea::framework::graphics::pixel::rgb565FromRgb888(r, g, b); }
467
- std::uint16_t kbBg() { return gState.wide ? rgb(0xf5, 0xf5, 0xf5) : rgb(0xd1, 0xd3, 0xda); }
468
- std::uint16_t keyLightBg() { return gState.wide ? rgb(0xff, 0xff, 0xff) : rgb(0xf2, 0xf2, 0xf7); }
469
- std::uint16_t keyUtilityBg() { return gState.wide ? rgb(0xe0, 0xe0, 0xe0) : rgb(0x6f, 0x73, 0x7d); }
470
- std::uint16_t keyPrimaryBg() { return gea::framework::graphics::pixel::rgb565FromRgb888(0x0a, 0x84, 0xff); }
471
- std::uint16_t keyShiftActiveBg() { return gea::framework::graphics::pixel::rgb565FromRgb888(0xff, 0xff, 0xff); }
472
- std::uint16_t labelDark() { return gState.wide ? rgb(0x21, 0x21, 0x21) : rgb(0x11, 0x11, 0x16); }
473
- std::uint16_t labelLight() { return gea::framework::graphics::pixel::rgb565FromRgb888(0xff, 0xff, 0xff); }
461
+ style_color_t rgb(int r, int g, int b) { return gea::framework::graphics::pixel::nativeStyleValue(r, g, b); }
462
+ style_color_t kbBg() { return gState.wide ? rgb(0xf5, 0xf5, 0xf5) : rgb(0xd1, 0xd3, 0xda); }
463
+ style_color_t keyLightBg() { return gState.wide ? rgb(0xff, 0xff, 0xff) : rgb(0xf2, 0xf2, 0xf7); }
464
+ style_color_t keyUtilityBg() { return gState.wide ? rgb(0xe0, 0xe0, 0xe0) : rgb(0x6f, 0x73, 0x7d); }
465
+ style_color_t keyPrimaryBg() { return gea::framework::graphics::pixel::nativeStyleValue(0x0a, 0x84, 0xff); }
466
+ style_color_t keyShiftActiveBg() { return gea::framework::graphics::pixel::nativeStyleValue(0xff, 0xff, 0xff); }
467
+ style_color_t labelDark() { return gState.wide ? rgb(0x21, 0x21, 0x21) : rgb(0x11, 0x11, 0x16); }
468
+ style_color_t labelLight() { return gea::framework::graphics::pixel::nativeStyleValue(0xff, 0xff, 0xff); }
474
469
 
475
470
  void applyKeyStyle(Tree &tree, int node, KeyKind kind, bool shiftActiveKey, const KbMetrics &m)
476
471
  {
@@ -482,17 +477,17 @@ void applyKeyStyle(Tree &tree, int node, KeyKind kind, bool shiftActiveKey, cons
482
477
  tree.setStyle(node, Property::BorderRadiusTopRight, m.borderRadius);
483
478
  tree.setStyle(node, Property::BorderRadiusBottomRight, m.borderRadius);
484
479
  tree.setStyle(node, Property::BorderRadiusBottomLeft, m.borderRadius);
485
- std::uint16_t bg;
486
- std::uint16_t activeBg;
480
+ style_color_t bg;
481
+ style_color_t activeBg;
487
482
  switch (kind) {
488
483
  case KeyKind::Primary:
489
484
  bg = keyPrimaryBg();
490
485
  // Slightly darker iOS blue for the press feedback. The framework's
491
486
  // InputController::pointerDown lightens bg-having nodes by default
492
- // (lightenRgb565), which would turn the already-bright blue near
487
+ // (lightenNativeColor), which would turn the already-bright blue near
493
488
  // white — explicitly setting active_bg makes the press obviously
494
489
  // "darker, not lighter".
495
- activeBg = gea::framework::graphics::pixel::rgb565FromRgb888(0x06, 0x6a, 0xd6);
490
+ activeBg = gea::framework::graphics::pixel::nativeStyleValue(0x06, 0x6a, 0xd6);
496
491
  break;
497
492
  case KeyKind::Utility:
498
493
  bg = shiftActiveKey ? keyShiftActiveBg() : keyUtilityBg();
@@ -508,7 +503,7 @@ void applyKeyStyle(Tree &tree, int node, KeyKind kind, bool shiftActiveKey, cons
508
503
  // Light keys go slightly darker to a visible iOS-press grey rather
509
504
  // than the framework's default "lighten" which would push #f2f2f7
510
505
  // past pure white and look like nothing happened.
511
- activeBg = gea::framework::graphics::pixel::rgb565FromRgb888(0xc7, 0xc7, 0xcc);
506
+ activeBg = gea::framework::graphics::pixel::nativeStyleValue(0xc7, 0xc7, 0xcc);
512
507
  break;
513
508
  }
514
509
  tree.setStyle(node, Property::BackgroundColor, static_cast<int>(bg));
@@ -543,7 +538,7 @@ void applyLabelStyle(Tree &tree, int node, LabelKind kind, KeyKind keyKind, bool
543
538
  // focused input's, so the keys read in the app's own face instead of
544
539
  // the 8x16 bitmap fallback.
545
540
  tree.setStyle(node, Property::FontId, keyboardFontId());
546
- std::uint16_t color;
541
+ style_color_t color;
547
542
  if (gState.wide || keyKind == KeyKind::Light || (keyKind == KeyKind::Utility && shiftActiveKey)) color = labelDark();
548
543
  else color = labelLight();
549
544
  tree.setStyle(node, Property::Color, static_cast<int>(color));