summaryrefslogtreecommitdiff
path: root/core/fxge/agg
diff options
context:
space:
mode:
authorthestig <thestig@chromium.org>2016-06-13 15:02:05 -0700
committerCommit bot <commit-bot@chromium.org>2016-06-13 15:02:05 -0700
commit2f307669ded2621f87d0b019e508f6663523f1d7 (patch)
tree035cb0ad851aa008a4f3c27c365c40564ef69859 /core/fxge/agg
parent868150bd69f0f1f9472affc20deea0a9341bf22b (diff)
downloadpdfium-2f307669ded2621f87d0b019e508f6663523f1d7.tar.xz
Remove default arguments from IFX_RenderDeviceDriver.
Review-Url: https://codereview.chromium.org/2059883004
Diffstat (limited to 'core/fxge/agg')
-rw-r--r--core/fxge/agg/fx_agg_driver.cpp719
-rw-r--r--core/fxge/agg/fx_agg_driver.h44
2 files changed, 344 insertions, 419 deletions
diff --git a/core/fxge/agg/fx_agg_driver.cpp b/core/fxge/agg/fx_agg_driver.cpp
index 7d197f8c21..554c79f349 100644
--- a/core/fxge/agg/fx_agg_driver.cpp
+++ b/core/fxge/agg/fx_agg_driver.cpp
@@ -28,6 +28,238 @@ void HardClip(FX_FLOAT& x, FX_FLOAT& y) {
y = std::max(std::min(y, 50000.0f), -50000.0f);
}
+void RgbByteOrderSetPixel(CFX_DIBitmap* pBitmap, int x, int y, uint32_t argb) {
+ if (x < 0 || x >= pBitmap->GetWidth() || y < 0 || y >= pBitmap->GetHeight())
+ return;
+
+ uint8_t* pos = (uint8_t*)pBitmap->GetBuffer() + y * pBitmap->GetPitch() +
+ x * pBitmap->GetBPP() / 8;
+ if (pBitmap->GetFormat() == FXDIB_Argb) {
+ FXARGB_SETRGBORDERDIB(pos, argb);
+ return;
+ }
+
+ int alpha = FXARGB_A(argb);
+ pos[0] = (FXARGB_R(argb) * alpha + pos[0] * (255 - alpha)) / 255;
+ pos[1] = (FXARGB_G(argb) * alpha + pos[1] * (255 - alpha)) / 255;
+ pos[2] = (FXARGB_B(argb) * alpha + pos[2] * (255 - alpha)) / 255;
+}
+
+void RgbByteOrderCompositeRect(CFX_DIBitmap* pBitmap,
+ int left,
+ int top,
+ int width,
+ int height,
+ FX_ARGB argb) {
+ int src_alpha = FXARGB_A(argb);
+ if (src_alpha == 0)
+ return;
+
+ FX_RECT rect(left, top, left + width, top + height);
+ rect.Intersect(0, 0, pBitmap->GetWidth(), pBitmap->GetHeight());
+ width = rect.Width();
+ int src_r = FXARGB_R(argb);
+ int src_g = FXARGB_G(argb);
+ int src_b = FXARGB_B(argb);
+ int Bpp = pBitmap->GetBPP() / 8;
+ FX_BOOL bAlpha = pBitmap->HasAlpha();
+ int dib_argb = FXARGB_TOBGRORDERDIB(argb);
+ uint8_t* pBuffer = pBitmap->GetBuffer();
+ if (src_alpha == 255) {
+ for (int row = rect.top; row < rect.bottom; row++) {
+ uint8_t* dest_scan =
+ pBuffer + row * pBitmap->GetPitch() + rect.left * Bpp;
+ if (Bpp == 4) {
+ uint32_t* scan = (uint32_t*)dest_scan;
+ for (int col = 0; col < width; col++)
+ *scan++ = dib_argb;
+ } else {
+ for (int col = 0; col < width; col++) {
+ *dest_scan++ = src_r;
+ *dest_scan++ = src_g;
+ *dest_scan++ = src_b;
+ }
+ }
+ }
+ return;
+ }
+ for (int row = rect.top; row < rect.bottom; row++) {
+ uint8_t* dest_scan = pBuffer + row * pBitmap->GetPitch() + rect.left * Bpp;
+ if (bAlpha) {
+ for (int col = 0; col < width; col++) {
+ uint8_t back_alpha = dest_scan[3];
+ if (back_alpha == 0) {
+ FXARGB_SETRGBORDERDIB(dest_scan,
+ FXARGB_MAKE(src_alpha, src_r, src_g, src_b));
+ dest_scan += 4;
+ continue;
+ }
+ uint8_t dest_alpha =
+ back_alpha + src_alpha - back_alpha * src_alpha / 255;
+ dest_scan[3] = dest_alpha;
+ int alpha_ratio = src_alpha * 255 / dest_alpha;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_r, alpha_ratio);
+ dest_scan++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_g, alpha_ratio);
+ dest_scan++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_b, alpha_ratio);
+ dest_scan += 2;
+ }
+ } else {
+ for (int col = 0; col < width; col++) {
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_r, src_alpha);
+ dest_scan++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_g, src_alpha);
+ dest_scan++;
+ *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_b, src_alpha);
+ dest_scan++;
+ if (Bpp == 4)
+ dest_scan++;
+ }
+ }
+ }
+}
+
+void RgbByteOrderTransferBitmap(CFX_DIBitmap* pBitmap,
+ int dest_left,
+ int dest_top,
+ int width,
+ int height,
+ const CFX_DIBSource* pSrcBitmap,
+ int src_left,
+ int src_top) {
+ if (!pBitmap)
+ return;
+
+ pBitmap->GetOverlapRect(dest_left, dest_top, width, height,
+ pSrcBitmap->GetWidth(), pSrcBitmap->GetHeight(),
+ src_left, src_top, nullptr);
+ if (width == 0 || height == 0)
+ return;
+
+ int Bpp = pBitmap->GetBPP() / 8;
+ FXDIB_Format dest_format = pBitmap->GetFormat();
+ FXDIB_Format src_format = pSrcBitmap->GetFormat();
+ int pitch = pBitmap->GetPitch();
+ uint8_t* buffer = pBitmap->GetBuffer();
+ if (dest_format == src_format) {
+ for (int row = 0; row < height; row++) {
+ uint8_t* dest_scan = buffer + (dest_top + row) * pitch + dest_left * Bpp;
+ uint8_t* src_scan =
+ (uint8_t*)pSrcBitmap->GetScanline(src_top + row) + src_left * Bpp;
+ if (Bpp == 4) {
+ for (int col = 0; col < width; col++) {
+ FXARGB_SETDIB(dest_scan, FXARGB_MAKE(src_scan[3], src_scan[0],
+ src_scan[1], src_scan[2]));
+ dest_scan += 4;
+ src_scan += 4;
+ }
+ } else {
+ for (int col = 0; col < width; col++) {
+ *dest_scan++ = src_scan[2];
+ *dest_scan++ = src_scan[1];
+ *dest_scan++ = src_scan[0];
+ src_scan += 3;
+ }
+ }
+ }
+ return;
+ }
+
+ uint8_t* dest_buf = buffer + dest_top * pitch + dest_left * Bpp;
+ if (dest_format == FXDIB_Rgb) {
+ if (src_format == FXDIB_Rgb32) {
+ for (int row = 0; row < height; row++) {
+ uint8_t* dest_scan = dest_buf + row * pitch;
+ uint8_t* src_scan =
+ (uint8_t*)pSrcBitmap->GetScanline(src_top + row) + src_left * 4;
+ for (int col = 0; col < width; col++) {
+ *dest_scan++ = src_scan[2];
+ *dest_scan++ = src_scan[1];
+ *dest_scan++ = src_scan[0];
+ src_scan += 4;
+ }
+ }
+ } else {
+ ASSERT(FALSE);
+ }
+ return;
+ }
+
+ if (dest_format == FXDIB_Argb || dest_format == FXDIB_Rgb32) {
+ if (src_format == FXDIB_Rgb) {
+ for (int row = 0; row < height; row++) {
+ uint8_t* dest_scan = (uint8_t*)(dest_buf + row * pitch);
+ uint8_t* src_scan =
+ (uint8_t*)pSrcBitmap->GetScanline(src_top + row) + src_left * 3;
+ for (int col = 0; col < width; col++) {
+ FXARGB_SETDIB(dest_scan, FXARGB_MAKE(0xff, src_scan[0], src_scan[1],
+ src_scan[2]));
+ dest_scan += 4;
+ src_scan += 3;
+ }
+ }
+ } else if (src_format == FXDIB_Rgb32) {
+ ASSERT(dest_format == FXDIB_Argb);
+ for (int row = 0; row < height; row++) {
+ uint8_t* dest_scan = dest_buf + row * pitch;
+ uint8_t* src_scan =
+ (uint8_t*)(pSrcBitmap->GetScanline(src_top + row) + src_left * 4);
+ for (int col = 0; col < width; col++) {
+ FXARGB_SETDIB(dest_scan, FXARGB_MAKE(0xff, src_scan[0], src_scan[1],
+ src_scan[2]));
+ src_scan += 4;
+ dest_scan += 4;
+ }
+ }
+ }
+ return;
+ }
+
+ ASSERT(FALSE);
+}
+
+FX_ARGB DefaultCMYK2ARGB(FX_CMYK cmyk, uint8_t alpha) {
+ uint8_t r, g, b;
+ AdobeCMYK_to_sRGB1(FXSYS_GetCValue(cmyk), FXSYS_GetMValue(cmyk),
+ FXSYS_GetYValue(cmyk), FXSYS_GetKValue(cmyk), r, g, b);
+ return ArgbEncode(alpha, r, g, b);
+}
+
+FX_BOOL DibSetPixel(CFX_DIBitmap* pDevice,
+ int x,
+ int y,
+ uint32_t color,
+ int alpha_flag,
+ void* pIccTransform) {
+ FX_BOOL bObjCMYK = FXGETFLAG_COLORTYPE(alpha_flag);
+ int alpha = bObjCMYK ? FXGETFLAG_ALPHA_FILL(alpha_flag) : FXARGB_A(color);
+ if (pIccTransform) {
+ CCodec_IccModule* pIccModule =
+ CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
+ color = bObjCMYK ? FXCMYK_TODIB(color) : FXARGB_TODIB(color);
+ pIccModule->TranslateScanline(pIccTransform, (uint8_t*)&color,
+ (uint8_t*)&color, 1);
+ color = bObjCMYK ? FXCMYK_TODIB(color) : FXARGB_TODIB(color);
+ if (!pDevice->IsCmykImage()) {
+ color = (color & 0xffffff) | (alpha << 24);
+ }
+ } else {
+ if (pDevice->IsCmykImage()) {
+ if (!bObjCMYK)
+ return FALSE;
+ } else {
+ if (bObjCMYK)
+ color = DefaultCMYK2ARGB(color, alpha);
+ }
+ }
+ pDevice->SetPixel(x, y, color);
+ if (pDevice->m_pAlphaMask) {
+ pDevice->m_pAlphaMask->SetPixel(x, y, alpha << 24);
+ }
+ return TRUE;
+}
+
} // namespace
void CAgg_PathData::BuildPath(const CFX_PathData* pPathData,
@@ -231,12 +463,10 @@ FX_BOOL CFX_AggDeviceDriver::DrawDeviceText(int nChars,
CFX_FontCache* pCache,
const CFX_Matrix* pObject2Device,
FX_FLOAT font_size,
- uint32_t color,
- int alpha_flag,
- void* pIccTransform) {
+ uint32_t color) {
return FALSE;
-} // _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_
-#endif
+}
+#endif // _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_
int CFX_AggDeviceDriver::GetDeviceCaps(int caps_id) {
switch (caps_id) {
@@ -1230,15 +1460,13 @@ FX_BOOL CFX_AggDeviceDriver::DrawPath(const CFX_PathData* pPathData,
uint32_t fill_color,
uint32_t stroke_color,
int fill_mode,
- int alpha_flag,
- void* pIccTransform,
int blend_type) {
- if (blend_type != FXDIB_BLEND_NORMAL) {
+ if (blend_type != FXDIB_BLEND_NORMAL)
return FALSE;
- }
- if (!GetBuffer()) {
+
+ if (!GetBuffer())
return TRUE;
- }
+
m_FillFlags = fill_mode;
if ((fill_mode & 3) && fill_color) {
CAgg_PathData path_data;
@@ -1251,358 +1479,106 @@ FX_BOOL CFX_AggDeviceDriver::DrawPath(const CFX_PathData* pPathData,
? agg::fill_non_zero
: agg::fill_even_odd);
if (!RenderRasterizer(rasterizer, fill_color, fill_mode & FXFILL_FULLCOVER,
- FALSE, alpha_flag, pIccTransform)) {
+ FALSE, 0, nullptr)) {
return FALSE;
}
}
- int stroke_alpha = FXGETFLAG_COLORTYPE(alpha_flag)
- ? FXGETFLAG_ALPHA_STROKE(alpha_flag)
- : FXARGB_A(stroke_color);
- if (pGraphState && stroke_alpha) {
- if (fill_mode & FX_ZEROAREA_FILL) {
- CAgg_PathData path_data;
- path_data.BuildPath(pPathData, pObject2Device);
- agg::rasterizer_scanline_aa rasterizer;
- rasterizer.clip_box(0.0f, 0.0f,
- (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_WIDTH)),
- (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_HEIGHT)));
- RasterizeStroke(rasterizer, path_data.m_PathData, nullptr, pGraphState, 1,
- FALSE, fill_mode & FX_STROKE_TEXT_MODE);
- int fill_flag = FXGETFLAG_COLORTYPE(alpha_flag) << 8 |
- FXGETFLAG_ALPHA_STROKE(alpha_flag);
- if (!RenderRasterizer(rasterizer, stroke_color,
- fill_mode & FXFILL_FULLCOVER, m_bGroupKnockout,
- fill_flag, pIccTransform)) {
- return FALSE;
- }
- return TRUE;
- }
- CFX_Matrix matrix1, matrix2;
- if (pObject2Device) {
- matrix1.a = std::max(FXSYS_fabs(pObject2Device->a),
- FXSYS_fabs(pObject2Device->b));
- matrix1.d = matrix1.a;
- matrix2.Set(pObject2Device->a / matrix1.a, pObject2Device->b / matrix1.a,
- pObject2Device->c / matrix1.d, pObject2Device->d / matrix1.d,
- 0, 0);
- CFX_Matrix mtRervese;
- mtRervese.SetReverse(matrix2);
- matrix1 = *pObject2Device;
- matrix1.Concat(mtRervese);
- }
+ int stroke_alpha = FXARGB_A(stroke_color);
+ if (!pGraphState || !stroke_alpha)
+ return TRUE;
+
+ if (fill_mode & FX_ZEROAREA_FILL) {
CAgg_PathData path_data;
- path_data.BuildPath(pPathData, &matrix1);
+ path_data.BuildPath(pPathData, pObject2Device);
agg::rasterizer_scanline_aa rasterizer;
rasterizer.clip_box(0.0f, 0.0f, (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_WIDTH)),
(FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_HEIGHT)));
- RasterizeStroke(rasterizer, path_data.m_PathData, &matrix2, pGraphState,
- matrix1.a, FALSE, fill_mode & FX_STROKE_TEXT_MODE);
- int fill_flag = FXGETFLAG_COLORTYPE(alpha_flag) << 8 |
- FXGETFLAG_ALPHA_STROKE(alpha_flag);
+ RasterizeStroke(rasterizer, path_data.m_PathData, nullptr, pGraphState, 1,
+ FALSE, fill_mode & FX_STROKE_TEXT_MODE);
if (!RenderRasterizer(rasterizer, stroke_color,
- fill_mode & FXFILL_FULLCOVER, m_bGroupKnockout,
- fill_flag, pIccTransform)) {
+ fill_mode & FXFILL_FULLCOVER, m_bGroupKnockout, 0,
+ nullptr)) {
return FALSE;
}
+ return TRUE;
}
- return TRUE;
-}
-
-void RgbByteOrderSetPixel(CFX_DIBitmap* pBitmap, int x, int y, uint32_t argb) {
- if (x < 0 || x >= pBitmap->GetWidth() || y < 0 || y >= pBitmap->GetHeight()) {
- return;
+ CFX_Matrix matrix1;
+ CFX_Matrix matrix2;
+ if (pObject2Device) {
+ matrix1.a =
+ std::max(FXSYS_fabs(pObject2Device->a), FXSYS_fabs(pObject2Device->b));
+ matrix1.d = matrix1.a;
+ matrix2.Set(pObject2Device->a / matrix1.a, pObject2Device->b / matrix1.a,
+ pObject2Device->c / matrix1.d, pObject2Device->d / matrix1.d, 0,
+ 0);
+ CFX_Matrix mtRervese;
+ mtRervese.SetReverse(matrix2);
+ matrix1 = *pObject2Device;
+ matrix1.Concat(mtRervese);
}
- uint8_t* pos = (uint8_t*)pBitmap->GetBuffer() + y * pBitmap->GetPitch() +
- x * pBitmap->GetBPP() / 8;
- if (pBitmap->GetFormat() == FXDIB_Argb) {
- FXARGB_SETRGBORDERDIB(pos, argb);
- } else {
- int alpha = FXARGB_A(argb);
- pos[0] = (FXARGB_R(argb) * alpha + pos[0] * (255 - alpha)) / 255;
- pos[1] = (FXARGB_G(argb) * alpha + pos[1] * (255 - alpha)) / 255;
- pos[2] = (FXARGB_B(argb) * alpha + pos[2] * (255 - alpha)) / 255;
+ CAgg_PathData path_data;
+ path_data.BuildPath(pPathData, &matrix1);
+ agg::rasterizer_scanline_aa rasterizer;
+ rasterizer.clip_box(0.0f, 0.0f, (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_WIDTH)),
+ (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_HEIGHT)));
+ RasterizeStroke(rasterizer, path_data.m_PathData, &matrix2, pGraphState,
+ matrix1.a, FALSE, fill_mode & FX_STROKE_TEXT_MODE);
+ if (!RenderRasterizer(rasterizer, stroke_color, fill_mode & FXFILL_FULLCOVER,
+ m_bGroupKnockout, 0, nullptr)) {
+ return FALSE;
}
+ return TRUE;
}
-void RgbByteOrderCompositeRect(CFX_DIBitmap* pBitmap,
- int left,
- int top,
- int width,
- int height,
- FX_ARGB argb) {
- int src_alpha = FXARGB_A(argb);
- if (src_alpha == 0) {
- return;
- }
- FX_RECT rect(left, top, left + width, top + height);
- rect.Intersect(0, 0, pBitmap->GetWidth(), pBitmap->GetHeight());
- width = rect.Width();
- int src_r = FXARGB_R(argb), src_g = FXARGB_G(argb), src_b = FXARGB_B(argb);
- int Bpp = pBitmap->GetBPP() / 8;
- FX_BOOL bAlpha = pBitmap->HasAlpha();
- int dib_argb = FXARGB_TOBGRORDERDIB(argb);
- uint8_t* pBuffer = pBitmap->GetBuffer();
- if (src_alpha == 255) {
- for (int row = rect.top; row < rect.bottom; row++) {
- uint8_t* dest_scan =
- pBuffer + row * pBitmap->GetPitch() + rect.left * Bpp;
- if (Bpp == 4) {
- uint32_t* scan = (uint32_t*)dest_scan;
- for (int col = 0; col < width; col++) {
- *scan++ = dib_argb;
- }
- } else {
- for (int col = 0; col < width; col++) {
- *dest_scan++ = src_r;
- *dest_scan++ = src_g;
- *dest_scan++ = src_b;
- }
- }
- }
- return;
- }
- for (int row = rect.top; row < rect.bottom; row++) {
- uint8_t* dest_scan = pBuffer + row * pBitmap->GetPitch() + rect.left * Bpp;
- if (bAlpha) {
- for (int col = 0; col < width; col++) {
- uint8_t back_alpha = dest_scan[3];
- if (back_alpha == 0) {
- FXARGB_SETRGBORDERDIB(dest_scan,
- FXARGB_MAKE(src_alpha, src_r, src_g, src_b));
- dest_scan += 4;
- continue;
- }
- uint8_t dest_alpha =
- back_alpha + src_alpha - back_alpha * src_alpha / 255;
- dest_scan[3] = dest_alpha;
- int alpha_ratio = src_alpha * 255 / dest_alpha;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_r, alpha_ratio);
- dest_scan++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_g, alpha_ratio);
- dest_scan++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_b, alpha_ratio);
- dest_scan += 2;
- }
- } else {
- for (int col = 0; col < width; col++) {
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_r, src_alpha);
- dest_scan++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_g, src_alpha);
- dest_scan++;
- *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, src_b, src_alpha);
- dest_scan++;
- if (Bpp == 4) {
- dest_scan++;
- }
- }
- }
- }
-}
+FX_BOOL CFX_AggDeviceDriver::SetPixel(int x, int y, uint32_t color) {
+ if (!m_pBitmap->GetBuffer())
+ return TRUE;
-void RgbByteOrderTransferBitmap(CFX_DIBitmap* pBitmap,
- int dest_left,
- int dest_top,
- int width,
- int height,
- const CFX_DIBSource* pSrcBitmap,
- int src_left,
- int src_top) {
- if (!pBitmap) {
- return;
- }
- pBitmap->GetOverlapRect(dest_left, dest_top, width, height,
- pSrcBitmap->GetWidth(), pSrcBitmap->GetHeight(),
- src_left, src_top, nullptr);
- if (width == 0 || height == 0) {
- return;
- }
- int Bpp = pBitmap->GetBPP() / 8;
- FXDIB_Format dest_format = pBitmap->GetFormat();
- FXDIB_Format src_format = pSrcBitmap->GetFormat();
- int pitch = pBitmap->GetPitch();
- uint8_t* buffer = pBitmap->GetBuffer();
- if (dest_format == src_format) {
- for (int row = 0; row < height; row++) {
- uint8_t* dest_scan = buffer + (dest_top + row) * pitch + dest_left * Bpp;
- uint8_t* src_scan =
- (uint8_t*)pSrcBitmap->GetScanline(src_top + row) + src_left * Bpp;
- if (Bpp == 4) {
- for (int col = 0; col < width; col++) {
- FXARGB_SETDIB(dest_scan, FXARGB_MAKE(src_scan[3], src_scan[0],
- src_scan[1], src_scan[2]));
- dest_scan += 4;
- src_scan += 4;
- }
- } else {
- for (int col = 0; col < width; col++) {
- *dest_scan++ = src_scan[2];
- *dest_scan++ = src_scan[1];
- *dest_scan++ = src_scan[0];
- src_scan += 3;
- }
- }
- }
- return;
- }
- uint8_t* dest_buf = buffer + dest_top * pitch + dest_left * Bpp;
- if (dest_format == FXDIB_Rgb) {
- if (src_format == FXDIB_Rgb32) {
- for (int row = 0; row < height; row++) {
- uint8_t* dest_scan = dest_buf + row * pitch;
- uint8_t* src_scan =
- (uint8_t*)pSrcBitmap->GetScanline(src_top + row) + src_left * 4;
- for (int col = 0; col < width; col++) {
- *dest_scan++ = src_scan[2];
- *dest_scan++ = src_scan[1];
- *dest_scan++ = src_scan[0];
- src_scan += 4;
- }
- }
- } else {
- ASSERT(FALSE);
- }
- } else if (dest_format == FXDIB_Argb || dest_format == FXDIB_Rgb32) {
- if (src_format == FXDIB_Rgb) {
- for (int row = 0; row < height; row++) {
- uint8_t* dest_scan = (uint8_t*)(dest_buf + row * pitch);
- uint8_t* src_scan =
- (uint8_t*)pSrcBitmap->GetScanline(src_top + row) + src_left * 3;
- for (int col = 0; col < width; col++) {
- FXARGB_SETDIB(dest_scan, FXARGB_MAKE(0xff, src_scan[0], src_scan[1],
- src_scan[2]));
- dest_scan += 4;
- src_scan += 3;
- }
- }
- } else if (src_format == FXDIB_Rgb32) {
- ASSERT(dest_format == FXDIB_Argb);
- for (int row = 0; row < height; row++) {
- uint8_t* dest_scan = dest_buf + row * pitch;
- uint8_t* src_scan =
- (uint8_t*)(pSrcBitmap->GetScanline(src_top + row) + src_left * 4);
- for (int col = 0; col < width; col++) {
- FXARGB_SETDIB(dest_scan, FXARGB_MAKE(0xff, src_scan[0], src_scan[1],
- src_scan[2]));
- src_scan += 4;
- dest_scan += 4;
- }
- }
- }
- } else {
- ASSERT(FALSE);
+ if (!m_pClipRgn) {
+ if (!m_bRgbByteOrder)
+ return DibSetPixel(m_pBitmap, x, y, color, 0, nullptr);
+ RgbByteOrderSetPixel(m_pBitmap, x, y, color);
+ return TRUE;
}
-}
-
-FX_ARGB _DefaultCMYK2ARGB(FX_CMYK cmyk, uint8_t alpha) {
- uint8_t r, g, b;
- AdobeCMYK_to_sRGB1(FXSYS_GetCValue(cmyk), FXSYS_GetMValue(cmyk),
- FXSYS_GetYValue(cmyk), FXSYS_GetKValue(cmyk), r, g, b);
- return ArgbEncode(alpha, r, g, b);
-}
+ if (!m_pClipRgn->GetBox().Contains(x, y))
+ return TRUE;
-FX_BOOL _DibSetPixel(CFX_DIBitmap* pDevice,
- int x,
- int y,
- uint32_t color,
- int alpha_flag,
- void* pIccTransform) {
- FX_BOOL bObjCMYK = FXGETFLAG_COLORTYPE(alpha_flag);
- int alpha = bObjCMYK ? FXGETFLAG_ALPHA_FILL(alpha_flag) : FXARGB_A(color);
- if (pIccTransform) {
- CCodec_IccModule* pIccModule =
- CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
- color = bObjCMYK ? FXCMYK_TODIB(color) : FXARGB_TODIB(color);
- pIccModule->TranslateScanline(pIccTransform, (uint8_t*)&color,
- (uint8_t*)&color, 1);
- color = bObjCMYK ? FXCMYK_TODIB(color) : FXARGB_TODIB(color);
- if (!pDevice->IsCmykImage()) {
- color = (color & 0xffffff) | (alpha << 24);
- }
- } else {
- if (pDevice->IsCmykImage()) {
- if (!bObjCMYK) {
- return FALSE;
- }
- } else {
- if (bObjCMYK) {
- color = _DefaultCMYK2ARGB(color, alpha);
- }
- }
- }
- pDevice->SetPixel(x, y, color);
- if (pDevice->m_pAlphaMask) {
- pDevice->m_pAlphaMask->SetPixel(x, y, alpha << 24);
+ if (m_pClipRgn->GetType() == CFX_ClipRgn::RectI) {
+ if (!m_bRgbByteOrder)
+ return DibSetPixel(m_pBitmap, x, y, color, 0, nullptr);
+ RgbByteOrderSetPixel(m_pBitmap, x, y, color);
+ return TRUE;
}
- return TRUE;
-}
+ if (m_pClipRgn->GetType() != CFX_ClipRgn::MaskF)
+ return TRUE;
-FX_BOOL CFX_AggDeviceDriver::SetPixel(int x,
- int y,
- uint32_t color,
- int alpha_flag,
- void* pIccTransform) {
- if (!m_pBitmap->GetBuffer()) {
+ const CFX_DIBitmap* pMask = m_pClipRgn->GetMask().GetObject();
+ int new_alpha = FXARGB_A(color) * pMask->GetScanline(y)[x] / 255;
+ color = (color & 0xffffff) | (new_alpha << 24);
+ if (m_bRgbByteOrder) {
+ RgbByteOrderSetPixel(m_pBitmap, x, y, color);
return TRUE;
}
- if (!CFX_GEModule::Get()->GetCodecModule() ||
- !CFX_GEModule::Get()->GetCodecModule()->GetIccModule()) {
- pIccTransform = nullptr;
- }
- if (!m_pClipRgn) {
- if (m_bRgbByteOrder) {
- RgbByteOrderSetPixel(m_pBitmap, x, y, color);
- } else {
- return _DibSetPixel(m_pBitmap, x, y, color, alpha_flag, pIccTransform);
- }
- } else if (m_pClipRgn->GetBox().Contains(x, y)) {
- if (m_pClipRgn->GetType() == CFX_ClipRgn::RectI) {
- if (m_bRgbByteOrder) {
- RgbByteOrderSetPixel(m_pBitmap, x, y, color);
- } else {
- return _DibSetPixel(m_pBitmap, x, y, color, alpha_flag, pIccTransform);
- }
- } else if (m_pClipRgn->GetType() == CFX_ClipRgn::MaskF) {
- const CFX_DIBitmap* pMask = m_pClipRgn->GetMask().GetObject();
- FX_BOOL bCMYK = FXGETFLAG_COLORTYPE(alpha_flag);
- int new_alpha =
- bCMYK ? FXGETFLAG_ALPHA_FILL(alpha_flag) : FXARGB_A(color);
- new_alpha = new_alpha * pMask->GetScanline(y)[x] / 255;
- if (m_bRgbByteOrder) {
- RgbByteOrderSetPixel(m_pBitmap, x, y,
- (color & 0xffffff) | (new_alpha << 24));
- return TRUE;
- }
- if (bCMYK) {
- FXSETFLAG_ALPHA_FILL(alpha_flag, new_alpha);
- } else {
- color = (color & 0xffffff) | (new_alpha << 24);
- }
- return _DibSetPixel(m_pBitmap, x, y, color, alpha_flag, pIccTransform);
- }
- }
- return TRUE;
+ return DibSetPixel(m_pBitmap, x, y, color, 0, nullptr);
}
-FX_BOOL CFX_AggDeviceDriver::FillRect(const FX_RECT* pRect,
- uint32_t fill_color,
- int alpha_flag,
- void* pIccTransform,
- int blend_type) {
- if (blend_type != FXDIB_BLEND_NORMAL) {
+FX_BOOL CFX_AggDeviceDriver::FillRectWithBlend(const FX_RECT* pRect,
+ uint32_t fill_color,
+ int blend_type) {
+ if (blend_type != FXDIB_BLEND_NORMAL)
return FALSE;
- }
- if (!m_pBitmap->GetBuffer()) {
+
+ if (!m_pBitmap->GetBuffer())
return TRUE;
- }
+
FX_RECT clip_rect;
GetClipBox(&clip_rect);
FX_RECT draw_rect = clip_rect;
- if (pRect) {
+ if (pRect)
draw_rect.Intersect(*pRect);
- }
- if (draw_rect.IsEmpty()) {
+ if (draw_rect.IsEmpty())
return TRUE;
- }
+
if (!m_pClipRgn || m_pClipRgn->GetType() == CFX_ClipRgn::RectI) {
if (m_bRgbByteOrder) {
RgbByteOrderCompositeRect(m_pBitmap, draw_rect.left, draw_rect.top,
@@ -1610,8 +1586,7 @@ FX_BOOL CFX_AggDeviceDriver::FillRect(const FX_RECT* pRect,
fill_color);
} else {
m_pBitmap->CompositeRect(draw_rect.left, draw_rect.top, draw_rect.Width(),
- draw_rect.Height(), fill_color, alpha_flag,
- pIccTransform);
+ draw_rect.Height(), fill_color, 0, nullptr);
}
return TRUE;
}
@@ -1619,7 +1594,7 @@ FX_BOOL CFX_AggDeviceDriver::FillRect(const FX_RECT* pRect,
draw_rect.left, draw_rect.top, draw_rect.Width(), draw_rect.Height(),
m_pClipRgn->GetMask().GetObject(), fill_color,
draw_rect.left - clip_rect.left, draw_rect.top - clip_rect.top,
- FXDIB_BLEND_NORMAL, nullptr, m_bRgbByteOrder, alpha_flag, pIccTransform);
+ FXDIB_BLEND_NORMAL, nullptr, m_bRgbByteOrder, 0, nullptr);
return TRUE;
}
@@ -1636,48 +1611,35 @@ FX_BOOL CFX_AggDeviceDriver::GetClipBox(FX_RECT* pRect) {
FX_BOOL CFX_AggDeviceDriver::GetDIBits(CFX_DIBitmap* pBitmap,
int left,
- int top,
- void* pIccTransform,
- FX_BOOL bDEdge) {
- if (!m_pBitmap->GetBuffer()) {
+ int top) {
+ if (!m_pBitmap || !m_pBitmap->GetBuffer())
return TRUE;
- }
- if (bDEdge) {
- if (m_bRgbByteOrder) {
- RgbByteOrderTransferBitmap(pBitmap, 0, 0, pBitmap->GetWidth(),
- pBitmap->GetHeight(), m_pBitmap, left, top);
- } else {
- return pBitmap->TransferBitmap(0, 0, pBitmap->GetWidth(),
- pBitmap->GetHeight(), m_pBitmap, left, top,
- pIccTransform);
- }
- return TRUE;
- }
+
FX_RECT rect(left, top, left + pBitmap->GetWidth(),
top + pBitmap->GetHeight());
CFX_DIBitmap* pBack = nullptr;
if (m_pOriDevice) {
pBack = m_pOriDevice->Clone(&rect);
- if (!pBack) {
+ if (!pBack)
return TRUE;
- }
+
pBack->CompositeBitmap(0, 0, pBack->GetWidth(), pBack->GetHeight(),
m_pBitmap, 0, 0);
} else {
pBack = m_pBitmap->Clone(&rect);
+ if (!pBack)
+ return TRUE;
}
- if (!pBack) {
- return TRUE;
- }
+
FX_BOOL bRet = TRUE;
- left = left >= 0 ? 0 : left;
- top = top >= 0 ? 0 : top;
+ left = std::min(left, 0);
+ top = std::min(top, 0);
if (m_bRgbByteOrder) {
RgbByteOrderTransferBitmap(pBitmap, 0, 0, rect.Width(), rect.Height(),
pBack, left, top);
} else {
bRet = pBitmap->TransferBitmap(0, 0, rect.Width(), rect.Height(), pBack,
- left, top, pIccTransform);
+ left, top, nullptr);
}
delete pBack;
return bRet;
@@ -1688,20 +1650,19 @@ FX_BOOL CFX_AggDeviceDriver::SetDIBits(const CFX_DIBSource* pBitmap,
const FX_RECT* pSrcRect,
int left,
int top,
- int blend_type,
- int alpha_flag,
- void* pIccTransform) {
- if (!m_pBitmap->GetBuffer()) {
+ int blend_type) {
+ if (!m_pBitmap->GetBuffer())
return TRUE;
+
+ if (pBitmap->IsAlphaMask()) {
+ return m_pBitmap->CompositeMask(left, top, pSrcRect->Width(),
+ pSrcRect->Height(), pBitmap, argb,
+ pSrcRect->left, pSrcRect->top, blend_type,
+ m_pClipRgn, m_bRgbByteOrder, 0, nullptr);
}
- if (pBitmap->IsAlphaMask())
- return m_pBitmap->CompositeMask(
- left, top, pSrcRect->Width(), pSrcRect->Height(), pBitmap, argb,
- pSrcRect->left, pSrcRect->top, blend_type, m_pClipRgn, m_bRgbByteOrder,
- alpha_flag, pIccTransform);
return m_pBitmap->CompositeBitmap(
left, top, pSrcRect->Width(), pSrcRect->Height(), pBitmap, pSrcRect->left,
- pSrcRect->top, blend_type, m_pClipRgn, m_bRgbByteOrder, pIccTransform);
+ pSrcRect->top, blend_type, m_pClipRgn, m_bRgbByteOrder, nullptr);
}
FX_BOOL CFX_AggDeviceDriver::StretchDIBits(const CFX_DIBSource* pSource,
@@ -1712,17 +1673,14 @@ FX_BOOL CFX_AggDeviceDriver::StretchDIBits(const CFX_DIBSource* pSource,
int dest_height,
const FX_RECT* pClipRect,
uint32_t flags,
- int alpha_flag,
- void* pIccTransform,
int blend_type) {
- if (!m_pBitmap->GetBuffer()) {
+ if (!m_pBitmap->GetBuffer())
return TRUE;
- }
+
if (dest_width == pSource->GetWidth() &&
dest_height == pSource->GetHeight()) {
FX_RECT rect(0, 0, dest_width, dest_height);
- return SetDIBits(pSource, argb, &rect, dest_left, dest_top, blend_type,
- alpha_flag, pIccTransform);
+ return SetDIBits(pSource, argb, &rect, dest_left, dest_top, blend_type);
}
FX_RECT dest_rect(dest_left, dest_top, dest_left + dest_width,
dest_top + dest_height);
@@ -1731,8 +1689,7 @@ FX_BOOL CFX_AggDeviceDriver::StretchDIBits(const CFX_DIBSource* pSource,
dest_clip.Intersect(*pClipRect);
CFX_BitmapComposer composer;
composer.Compose(m_pBitmap, m_pClipRgn, 255, argb, dest_clip, FALSE, FALSE,
- FALSE, m_bRgbByteOrder, alpha_flag, pIccTransform,
- blend_type);
+ FALSE, m_bRgbByteOrder, 0, nullptr, blend_type);
dest_clip.Offset(-dest_rect.left, -dest_rect.top);
CFX_ImageStretcher stretcher(&composer, pSource, dest_width, dest_height,
dest_clip, flags);
@@ -1747,15 +1704,13 @@ FX_BOOL CFX_AggDeviceDriver::StartDIBits(const CFX_DIBSource* pSource,
const CFX_Matrix* pMatrix,
uint32_t render_flags,
void*& handle,
- int alpha_flag,
- void* pIccTransform,
int blend_type) {
- if (!m_pBitmap->GetBuffer()) {
+ if (!m_pBitmap->GetBuffer())
return TRUE;
- }
+
CFX_ImageRenderer* pRenderer = new CFX_ImageRenderer;
pRenderer->Start(m_pBitmap, m_pClipRgn, pSource, bitmap_alpha, argb, pMatrix,
- render_flags, m_bRgbByteOrder, alpha_flag, pIccTransform);
+ render_flags, m_bRgbByteOrder, 0, nullptr);
handle = pRenderer;
return TRUE;
}
diff --git a/core/fxge/agg/fx_agg_driver.h b/core/fxge/agg/fx_agg_driver.h
index 2c4e292faf..48d6fae87f 100644
--- a/core/fxge/agg/fx_agg_driver.h
+++ b/core/fxge/agg/fx_agg_driver.h
@@ -52,44 +52,20 @@ class CFX_AggDeviceDriver : public IFX_RenderDeviceDriver {
uint32_t fill_color,
uint32_t stroke_color,
int fill_mode,
- int alpha_flag,
- void* pIccTransform,
int blend_type) override;
- FX_BOOL SetPixel(int x,
- int y,
- uint32_t color,
- int alpha_flag,
- void* pIccTransform) override;
- FX_BOOL FillRect(const FX_RECT* pRect,
- uint32_t fill_color,
- int alpha_flag,
- void* pIccTransform,
- int blend_type) override;
- FX_BOOL DrawCosmeticLine(FX_FLOAT x1,
- FX_FLOAT y1,
- FX_FLOAT x2,
- FX_FLOAT y2,
- uint32_t color,
- int alpha_flag,
- void* pIccTransform,
- int blend_type) override {
- return FALSE;
- }
+ FX_BOOL SetPixel(int x, int y, uint32_t color) override;
+ FX_BOOL FillRectWithBlend(const FX_RECT* pRect,
+ uint32_t fill_color,
+ int blend_type) override;
FX_BOOL GetClipBox(FX_RECT* pRect) override;
- FX_BOOL GetDIBits(CFX_DIBitmap* pBitmap,
- int left,
- int top,
- void* pIccTransform = nullptr,
- FX_BOOL bDEdge = FALSE) override;
+ FX_BOOL GetDIBits(CFX_DIBitmap* pBitmap, int left, int top) override;
CFX_DIBitmap* GetBackDrop() override { return m_pOriDevice; }
FX_BOOL SetDIBits(const CFX_DIBSource* pBitmap,
uint32_t color,
const FX_RECT* pSrcRect,
int left,
int top,
- int blend_type,
- int alpha_flag,
- void* pIccTransform) override;
+ int blend_type) override;
FX_BOOL StretchDIBits(const CFX_DIBSource* pBitmap,
uint32_t color,
int dest_left,
@@ -98,8 +74,6 @@ class CFX_AggDeviceDriver : public IFX_RenderDeviceDriver {
int dest_height,
const FX_RECT* pClipRect,
uint32_t flags,
- int alpha_flag,
- void* pIccTransform,
int blend_type) override;
FX_BOOL StartDIBits(const CFX_DIBSource* pBitmap,
int bitmap_alpha,
@@ -107,8 +81,6 @@ class CFX_AggDeviceDriver : public IFX_RenderDeviceDriver {
const CFX_Matrix* pMatrix,
uint32_t flags,
void*& handle,
- int alpha_flag,
- void* pIccTransform,
int blend_type) override;
FX_BOOL ContinueDIBits(void* handle, IFX_Pause* pPause) override;
void CancelDIBits(void* handle) override;
@@ -118,9 +90,7 @@ class CFX_AggDeviceDriver : public IFX_RenderDeviceDriver {
CFX_FontCache* pCache,
const CFX_Matrix* pObject2Device,
FX_FLOAT font_size,
- uint32_t color,
- int alpha_flag,
- void* pIccTransform) override;
+ uint32_t color) override;
int GetDriverType() const override { return 1; }
FX_BOOL RenderRasterizer(agg::rasterizer_scanline_aa& rasterizer,