summaryrefslogtreecommitdiff
path: root/core/fxge
diff options
context:
space:
mode:
Diffstat (limited to 'core/fxge')
-rw-r--r--core/fxge/agg/fx_agg_driver.cpp2
-rw-r--r--core/fxge/apple/fx_quartz_device.cpp7
-rw-r--r--core/fxge/dib/cfx_dibitmap.cpp7
-rw-r--r--core/fxge/dib/cfx_imagestretcher.cpp47
-rw-r--r--core/fxge/dib/fx_dib_main.cpp15
-rw-r--r--core/fxge/fx_dib.h9
-rw-r--r--core/fxge/ge/cfx_renderdevice.cpp2
-rw-r--r--core/fxge/win32/fx_win32_device.cpp8
-rw-r--r--core/fxge/win32/fx_win32_gdipext.cpp7
-rw-r--r--core/fxge/win32/fx_win32_print.cpp2
10 files changed, 68 insertions, 38 deletions
diff --git a/core/fxge/agg/fx_agg_driver.cpp b/core/fxge/agg/fx_agg_driver.cpp
index b5ec4c5096..471fc9bb86 100644
--- a/core/fxge/agg/fx_agg_driver.cpp
+++ b/core/fxge/agg/fx_agg_driver.cpp
@@ -923,7 +923,7 @@ bool CFX_Renderer::Init(const CFX_RetainPtr<CFX_DIBitmap>& pDevice,
m_Color = FXARGB_TOBGRORDERDIB(color);
else
m_Color = FXARGB_TODIB(color);
- ArgbDecode(color, m_Alpha, m_Red, m_Green, m_Blue);
+ std::tie(m_Alpha, m_Red, m_Green, m_Blue) = ArgbDecode(color);
if (m_pDevice->GetBPP() == 1)
composite_span = &CFX_Renderer::CompositeSpan1bpp;
return true;
diff --git a/core/fxge/apple/fx_quartz_device.cpp b/core/fxge/apple/fx_quartz_device.cpp
index 15d05b0c2a..5151b02d8b 100644
--- a/core/fxge/apple/fx_quartz_device.cpp
+++ b/core/fxge/apple/fx_quartz_device.cpp
@@ -94,8 +94,11 @@ bool CQuartz2D::drawGraphicsString(void* graphics,
matrix->e, matrix->f));
CGContextSetTextMatrix(context, m);
}
- int32_t a, r, g, b;
- ArgbDecode(argb, a, r, g, b);
+ int32_t a;
+ int32_t r;
+ int32_t g;
+ int32_t b;
+ std::tie(a, r, g, b) = ArgbDecode(argb);
CGContextSetRGBFillColor(context, r / 255.f, g / 255.f, b / 255.f, a / 255.f);
CGContextSaveGState(context);
#if CGFLOAT_IS_DOUBLE
diff --git a/core/fxge/dib/cfx_dibitmap.cpp b/core/fxge/dib/cfx_dibitmap.cpp
index 760b26f23a..6f46e1d57e 100644
--- a/core/fxge/dib/cfx_dibitmap.cpp
+++ b/core/fxge/dib/cfx_dibitmap.cpp
@@ -147,8 +147,11 @@ void CFX_DIBitmap::Clear(uint32_t color) {
}
case FXDIB_Rgb:
case FXDIB_Rgba: {
- int a, r, g, b;
- ArgbDecode(color, a, r, g, b);
+ int a;
+ int r;
+ int g;
+ int b;
+ std::tie(a, r, g, b) = ArgbDecode(color);
if (r == g && g == b) {
memset(pBuffer, r, m_Pitch * m_Height);
} else {
diff --git a/core/fxge/dib/cfx_imagestretcher.cpp b/core/fxge/dib/cfx_imagestretcher.cpp
index f52a62d529..e0ba750c3c 100644
--- a/core/fxge/dib/cfx_imagestretcher.cpp
+++ b/core/fxge/dib/cfx_imagestretcher.cpp
@@ -7,6 +7,7 @@
#include "core/fxge/dib/cfx_imagestretcher.h"
#include <climits>
+#include <tuple>
#include "core/fxge/dib/cfx_dibitmap.h"
#include "core/fxge/dib/cfx_dibsource.h"
@@ -16,8 +17,9 @@
namespace {
+const int kMaxProgressiveStretchPixels = 1000000;
+
bool SourceSizeWithinLimit(int width, int height) {
- const int kMaxProgressiveStretchPixels = 1000000;
return !height || width < kMaxProgressiveStretchPixels / height;
}
@@ -32,11 +34,10 @@ FXDIB_Format GetStretchedFormat(const CFX_DIBSource& src) {
return format;
}
-void CmykDecode(uint32_t cmyk, int& c, int& m, int& y, int& k) {
- c = FXSYS_GetCValue(cmyk);
- m = FXSYS_GetMValue(cmyk);
- y = FXSYS_GetYValue(cmyk);
- k = FXSYS_GetKValue(cmyk);
+// Returns tuple c, m, y, k
+std::tuple<int, int, int, int> CmykDecode(const uint32_t cmyk) {
+ return std::make_tuple(FXSYS_GetCValue(cmyk), FXSYS_GetMValue(cmyk),
+ FXSYS_GetYValue(cmyk), FXSYS_GetKValue(cmyk));
}
} // namespace
@@ -68,10 +69,17 @@ bool CFX_ImageStretcher::Start() {
if (m_pSource->GetFormat() == FXDIB_1bppRgb && m_pSource->GetPalette()) {
FX_ARGB pal[256];
- int a0, r0, g0, b0, a1, r1, g1, b1;
- ArgbDecode(m_pSource->GetPaletteEntry(0), a0, r0, g0, b0);
- ArgbDecode(m_pSource->GetPaletteEntry(1), a1, r1, g1, b1);
- for (int i = 0; i < 256; i++) {
+ int a0;
+ int r0;
+ int g0;
+ int b0;
+ std::tie(a0, r0, g0, b0) = ArgbDecode(m_pSource->GetPaletteEntry(0));
+ int a1;
+ int r1;
+ int g1;
+ int b1;
+ std::tie(a1, r1, g1, b1) = ArgbDecode(m_pSource->GetPaletteEntry(1));
+ for (int i = 0; i < 256; ++i) {
int a = a0 + (a1 - a0) * i / 255;
int r = r0 + (r1 - r0) * i / 255;
int g = g0 + (g1 - g0) * i / 255;
@@ -85,10 +93,17 @@ bool CFX_ImageStretcher::Start() {
} else if (m_pSource->GetFormat() == FXDIB_1bppCmyk &&
m_pSource->GetPalette()) {
FX_CMYK pal[256];
- int c0, m0, y0, k0, c1, m1, y1, k1;
- CmykDecode(m_pSource->GetPaletteEntry(0), c0, m0, y0, k0);
- CmykDecode(m_pSource->GetPaletteEntry(1), c1, m1, y1, k1);
- for (int i = 0; i < 256; i++) {
+ int c0;
+ int m0;
+ int y0;
+ int k0;
+ std::tie(c0, m0, y0, k0) = CmykDecode(m_pSource->GetPaletteEntry(0));
+ int c1;
+ int m1;
+ int y1;
+ int k1;
+ std::tie(c1, m1, y1, k1) = CmykDecode(m_pSource->GetPaletteEntry(1));
+ for (int i = 0; i < 256; ++i) {
int c = c0 + (c1 - c0) * i / 255;
int m = m0 + (m1 - m0) * i / 255;
int y = y0 + (y1 - y0) * i / 255;
@@ -106,12 +121,14 @@ bool CFX_ImageStretcher::Start() {
if (m_Flags & FXDIB_DOWNSAMPLE)
return StartQuickStretch();
+
return StartStretch();
}
bool CFX_ImageStretcher::Continue(IFX_Pause* pPause) {
if (m_Flags & FXDIB_DOWNSAMPLE)
return ContinueQuickStretch(pPause);
+
return ContinueStretch(pPause);
}
@@ -163,7 +180,7 @@ bool CFX_ImageStretcher::ContinueQuickStretch(IFX_Pause* pPause) {
int result_width = m_ClipRect.Width();
int result_height = m_ClipRect.Height();
int src_height = m_pSource->GetHeight();
- for (; m_LineIndex < result_height; m_LineIndex++) {
+ for (; m_LineIndex < result_height; ++m_LineIndex) {
int dest_y;
int src_y;
if (m_bFlipY) {
diff --git a/core/fxge/dib/fx_dib_main.cpp b/core/fxge/dib/fx_dib_main.cpp
index 97b1aa7cca..3ede85c480 100644
--- a/core/fxge/dib/fx_dib_main.cpp
+++ b/core/fxge/dib/fx_dib_main.cpp
@@ -6,6 +6,7 @@
#include "core/fxge/fx_dib.h"
+#include <tuple>
#include <utility>
#include "third_party/base/ptr_util.h"
@@ -72,16 +73,14 @@ FX_RECT FXDIB_SwapClipBox(FX_RECT& clip,
return rect;
}
-void ArgbDecode(uint32_t argb, int& a, int& r, int& g, int& b) {
- a = FXARGB_A(argb);
- r = FXARGB_R(argb);
- g = FXARGB_G(argb);
- b = FXARGB_B(argb);
+std::tuple<int, int, int, int> ArgbDecode(FX_ARGB argb) {
+ return std::make_tuple(FXARGB_A(argb), FXARGB_R(argb), FXARGB_G(argb),
+ FXARGB_B(argb));
}
-void ArgbDecode(uint32_t argb, int& a, FX_COLORREF& rgb) {
- a = FXARGB_A(argb);
- rgb = FXSYS_RGB(FXARGB_R(argb), FXARGB_G(argb), FXARGB_B(argb));
+std::pair<int, FX_COLORREF> ArgbToColorRef(FX_ARGB argb) {
+ return {FXARGB_A(argb),
+ FXSYS_RGB(FXARGB_R(argb), FXARGB_G(argb), FXARGB_B(argb))};
}
uint32_t ArgbEncode(int a, FX_COLORREF rgb) {
diff --git a/core/fxge/fx_dib.h b/core/fxge/fx_dib.h
index 17c7c8fd0a..fa38573df8 100644
--- a/core/fxge/fx_dib.h
+++ b/core/fxge/fx_dib.h
@@ -7,6 +7,9 @@
#ifndef CORE_FXGE_FX_DIB_H_
#define CORE_FXGE_FX_DIB_H_
+#include <tuple>
+#include <utility>
+
#include "core/fxcrt/fx_coordinates.h"
enum FXDIB_Format {
@@ -80,8 +83,10 @@ inline FX_CMYK CmykEncode(int c, int m, int y, int k) {
return (c << 24) | (m << 16) | (y << 8) | k;
}
-void ArgbDecode(FX_ARGB argb, int& a, int& r, int& g, int& b);
-void ArgbDecode(FX_ARGB argb, int& a, FX_COLORREF& rgb);
+// Returns tuple a, r, g, b
+std::tuple<int, int, int, int> ArgbDecode(FX_ARGB argb);
+// Returns pair a, rgb
+std::pair<int, FX_COLORREF> ArgbToColorRef(FX_ARGB argb);
inline FX_ARGB ArgbEncode(int a, int r, int g, int b) {
return (a << 24) | (r << 16) | (g << 8) | b;
}
diff --git a/core/fxge/ge/cfx_renderdevice.cpp b/core/fxge/ge/cfx_renderdevice.cpp
index 46127ccb07..6a3f9c7f1c 100644
--- a/core/fxge/ge/cfx_renderdevice.cpp
+++ b/core/fxge/ge/cfx_renderdevice.cpp
@@ -1018,7 +1018,7 @@ bool CFX_RenderDevice::DrawNormalText(int nChars,
int g = 0;
int b = 0;
if (anti_alias == FXFT_RENDER_MODE_LCD)
- ArgbDecode(fill_color, a, r, g, b);
+ std::tie(a, r, g, b) = ArgbDecode(fill_color);
for (const FXTEXT_GLYPHPOS& glyph : glyphs) {
if (!glyph.m_pGlyph)
diff --git a/core/fxge/win32/fx_win32_device.cpp b/core/fxge/win32/fx_win32_device.cpp
index 986839ee88..de2f6c4b04 100644
--- a/core/fxge/win32/fx_win32_device.cpp
+++ b/core/fxge/win32/fx_win32_device.cpp
@@ -137,7 +137,7 @@ HPEN CreatePen(const CFX_GraphStateData* pGraphState,
}
int a;
FX_COLORREF rgb;
- ArgbDecode(argb, a, rgb);
+ std::tie(a, rgb) = ArgbToColorRef(argb);
LOGBRUSH lb;
lb.lbColor = rgb;
lb.lbStyle = BS_SOLID;
@@ -160,7 +160,7 @@ HPEN CreatePen(const CFX_GraphStateData* pGraphState,
HBRUSH CreateBrush(uint32_t argb) {
int a;
FX_COLORREF rgb;
- ArgbDecode(argb, a, rgb);
+ std::tie(a, rgb) = ArgbToColorRef(argb);
return CreateSolidBrush(rgb);
}
@@ -1090,7 +1090,7 @@ bool CGdiDeviceDriver::FillRectWithBlend(const FX_RECT* pRect,
int alpha;
FX_COLORREF rgb;
- ArgbDecode(fill_color, alpha, rgb);
+ std::tie(alpha, rgb) = ArgbToColorRef(fill_color);
if (alpha == 0)
return true;
@@ -1146,7 +1146,7 @@ bool CGdiDeviceDriver::DrawCosmeticLine(float x1,
int a;
FX_COLORREF rgb;
- ArgbDecode(color, a, rgb);
+ std::tie(a, rgb) = ArgbToColorRef(color);
if (a == 0)
return true;
diff --git a/core/fxge/win32/fx_win32_gdipext.cpp b/core/fxge/win32/fx_win32_gdipext.cpp
index 6a3527f393..87172ffff8 100644
--- a/core/fxge/win32/fx_win32_gdipext.cpp
+++ b/core/fxge/win32/fx_win32_gdipext.cpp
@@ -575,8 +575,11 @@ static void OutputImageMask(GpGraphics* pGraphics,
(image_clip.Width() + 3) / 4 * 4,
PixelFormat8bppIndexed,
pStretched->GetBuffer(), &bitmap);
- int a, r, g, b;
- ArgbDecode(argb, a, r, g, b);
+ int a;
+ int r;
+ int g;
+ int b;
+ std::tie(a, r, g, b) = ArgbDecode(argb);
UINT pal[258];
pal[0] = 0;
pal[1] = 256;
diff --git a/core/fxge/win32/fx_win32_print.cpp b/core/fxge/win32/fx_win32_print.cpp
index 58f00ed0fb..86636b5bfa 100644
--- a/core/fxge/win32/fx_win32_print.cpp
+++ b/core/fxge/win32/fx_win32_print.cpp
@@ -282,7 +282,7 @@ bool CGdiPrinterDriver::DrawDeviceText(int nChars,
// Color
int iUnusedAlpha;
FX_COLORREF rgb;
- ArgbDecode(color, iUnusedAlpha, rgb);
+ std::tie(iUnusedAlpha, rgb) = ArgbToColorRef(color);
SetTextColor(m_hDC, rgb);
SetBkMode(m_hDC, TRANSPARENT);