Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1083)

Side by Side Diff: core/fxge/agg/fx_agg_driver.cpp

Issue 2459673002: Fix some FX_BOOL / int noise in core/fx* (Closed)
Patch Set: Fix some FX_BOOL / int noise in core/fx* Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/fxcodec/codec/fx_codec_fax.cpp ('k') | core/fxge/ge/cfx_renderdevice.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "core/fxge/agg/fx_agg_driver.h" 7 #include "core/fxge/agg/fx_agg_driver.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 FXSYS_GetYValue(cmyk), FXSYS_GetKValue(cmyk), r, g, b); 233 FXSYS_GetYValue(cmyk), FXSYS_GetKValue(cmyk), r, g, b);
234 return ArgbEncode(alpha, r, g, b); 234 return ArgbEncode(alpha, r, g, b);
235 } 235 }
236 236
237 FX_BOOL DibSetPixel(CFX_DIBitmap* pDevice, 237 FX_BOOL DibSetPixel(CFX_DIBitmap* pDevice,
238 int x, 238 int x,
239 int y, 239 int y,
240 uint32_t color, 240 uint32_t color,
241 int alpha_flag, 241 int alpha_flag,
242 void* pIccTransform) { 242 void* pIccTransform) {
243 FX_BOOL bObjCMYK = FXGETFLAG_COLORTYPE(alpha_flag); 243 FX_BOOL bObjCMYK = !!FXGETFLAG_COLORTYPE(alpha_flag);
244 int alpha = bObjCMYK ? FXGETFLAG_ALPHA_FILL(alpha_flag) : FXARGB_A(color); 244 int alpha = bObjCMYK ? FXGETFLAG_ALPHA_FILL(alpha_flag) : FXARGB_A(color);
245 if (pIccTransform) { 245 if (pIccTransform) {
246 CCodec_IccModule* pIccModule = 246 CCodec_IccModule* pIccModule =
247 CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); 247 CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
248 color = bObjCMYK ? FXCMYK_TODIB(color) : FXARGB_TODIB(color); 248 color = bObjCMYK ? FXCMYK_TODIB(color) : FXARGB_TODIB(color);
249 pIccModule->TranslateScanline(pIccTransform, (uint8_t*)&color, 249 pIccModule->TranslateScanline(pIccTransform, (uint8_t*)&color,
250 (uint8_t*)&color, 1); 250 (uint8_t*)&color, 1);
251 color = bObjCMYK ? FXCMYK_TODIB(color) : FXARGB_TODIB(color); 251 color = bObjCMYK ? FXCMYK_TODIB(color) : FXARGB_TODIB(color);
252 if (!pDevice->IsCmykImage()) { 252 if (!pDevice->IsCmykImage()) {
253 color = (color & 0xffffff) | (alpha << 24); 253 color = (color & 0xffffff) | (alpha << 24);
(...skipping 1054 matching lines...) Expand 10 before | Expand all | Expand 10 after
1308 } else { 1308 } else {
1309 m_ClipBox.left = m_ClipBox.top = 0; 1309 m_ClipBox.left = m_ClipBox.top = 0;
1310 m_ClipBox.right = m_pDevice->GetWidth(); 1310 m_ClipBox.right = m_pDevice->GetWidth();
1311 m_ClipBox.bottom = m_pDevice->GetHeight(); 1311 m_ClipBox.bottom = m_pDevice->GetHeight();
1312 } 1312 }
1313 m_pClipMask = nullptr; 1313 m_pClipMask = nullptr;
1314 if (m_pClipRgn && m_pClipRgn->GetType() == CFX_ClipRgn::MaskF) { 1314 if (m_pClipRgn && m_pClipRgn->GetType() == CFX_ClipRgn::MaskF) {
1315 m_pClipMask = m_pClipRgn->GetMask().GetObject(); 1315 m_pClipMask = m_pClipRgn->GetMask().GetObject();
1316 } 1316 }
1317 m_bFullCover = bFullCover; 1317 m_bFullCover = bFullCover;
1318 FX_BOOL bObjectCMYK = FXGETFLAG_COLORTYPE(alpha_flag); 1318 FX_BOOL bObjectCMYK = !!FXGETFLAG_COLORTYPE(alpha_flag);
1319 FX_BOOL bDeviceCMYK = pDevice->IsCmykImage(); 1319 FX_BOOL bDeviceCMYK = pDevice->IsCmykImage();
1320 m_Alpha = bObjectCMYK ? FXGETFLAG_ALPHA_FILL(alpha_flag) : FXARGB_A(color); 1320 m_Alpha = bObjectCMYK ? FXGETFLAG_ALPHA_FILL(alpha_flag) : FXARGB_A(color);
1321 CCodec_IccModule* pIccModule = nullptr; 1321 CCodec_IccModule* pIccModule = nullptr;
1322 if (!CFX_GEModule::Get()->GetCodecModule() || 1322 if (!CFX_GEModule::Get()->GetCodecModule() ||
1323 !CFX_GEModule::Get()->GetCodecModule()->GetIccModule()) { 1323 !CFX_GEModule::Get()->GetCodecModule()->GetIccModule()) {
1324 pIccTransform = nullptr; 1324 pIccTransform = nullptr;
1325 } else { 1325 } else {
1326 pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); 1326 pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
1327 } 1327 }
1328 if (m_pDevice->GetBPP() == 8) { 1328 if (m_pDevice->GetBPP() == 8) {
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1461 if ((fill_mode & 3) && fill_color) { 1461 if ((fill_mode & 3) && fill_color) {
1462 CAgg_PathData path_data; 1462 CAgg_PathData path_data;
1463 path_data.BuildPath(pPathData, pObject2Device); 1463 path_data.BuildPath(pPathData, pObject2Device);
1464 agg::rasterizer_scanline_aa rasterizer; 1464 agg::rasterizer_scanline_aa rasterizer;
1465 rasterizer.clip_box(0.0f, 0.0f, (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_WIDTH)), 1465 rasterizer.clip_box(0.0f, 0.0f, (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_WIDTH)),
1466 (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_HEIGHT))); 1466 (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_HEIGHT)));
1467 rasterizer.add_path(path_data.m_PathData); 1467 rasterizer.add_path(path_data.m_PathData);
1468 rasterizer.filling_rule((fill_mode & 3) == FXFILL_WINDING 1468 rasterizer.filling_rule((fill_mode & 3) == FXFILL_WINDING
1469 ? agg::fill_non_zero 1469 ? agg::fill_non_zero
1470 : agg::fill_even_odd); 1470 : agg::fill_even_odd);
1471 if (!RenderRasterizer(rasterizer, fill_color, fill_mode & FXFILL_FULLCOVER, 1471 if (!RenderRasterizer(rasterizer, fill_color,
1472 FALSE, 0, nullptr)) { 1472 !!(fill_mode & FXFILL_FULLCOVER), FALSE, 0,
1473 nullptr)) {
1473 return FALSE; 1474 return FALSE;
1474 } 1475 }
1475 } 1476 }
1476 int stroke_alpha = FXARGB_A(stroke_color); 1477 int stroke_alpha = FXARGB_A(stroke_color);
1477 if (!pGraphState || !stroke_alpha) 1478 if (!pGraphState || !stroke_alpha)
1478 return TRUE; 1479 return TRUE;
1479 1480
1480 if (fill_mode & FX_ZEROAREA_FILL) { 1481 if (fill_mode & FX_ZEROAREA_FILL) {
1481 CAgg_PathData path_data; 1482 CAgg_PathData path_data;
1482 path_data.BuildPath(pPathData, pObject2Device); 1483 path_data.BuildPath(pPathData, pObject2Device);
1483 agg::rasterizer_scanline_aa rasterizer; 1484 agg::rasterizer_scanline_aa rasterizer;
1484 rasterizer.clip_box(0.0f, 0.0f, (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_WIDTH)), 1485 rasterizer.clip_box(0.0f, 0.0f, (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_WIDTH)),
1485 (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_HEIGHT))); 1486 (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_HEIGHT)));
1486 RasterizeStroke(rasterizer, path_data.m_PathData, nullptr, pGraphState, 1, 1487 RasterizeStroke(rasterizer, path_data.m_PathData, nullptr, pGraphState, 1,
1487 FALSE, fill_mode & FX_STROKE_TEXT_MODE); 1488 FALSE, !!(fill_mode & FX_STROKE_TEXT_MODE));
1488 if (!RenderRasterizer(rasterizer, stroke_color, 1489 return RenderRasterizer(rasterizer, stroke_color,
1489 fill_mode & FXFILL_FULLCOVER, m_bGroupKnockout, 0, 1490 !!(fill_mode & FXFILL_FULLCOVER), m_bGroupKnockout,
1490 nullptr)) { 1491 0, nullptr);
1491 return FALSE;
1492 }
1493 return TRUE;
1494 } 1492 }
1495 CFX_Matrix matrix1; 1493 CFX_Matrix matrix1;
1496 CFX_Matrix matrix2; 1494 CFX_Matrix matrix2;
1497 if (pObject2Device) { 1495 if (pObject2Device) {
1498 matrix1.a = 1496 matrix1.a =
1499 std::max(FXSYS_fabs(pObject2Device->a), FXSYS_fabs(pObject2Device->b)); 1497 std::max(FXSYS_fabs(pObject2Device->a), FXSYS_fabs(pObject2Device->b));
1500 matrix1.d = matrix1.a; 1498 matrix1.d = matrix1.a;
1501 matrix2.Set(pObject2Device->a / matrix1.a, pObject2Device->b / matrix1.a, 1499 matrix2.Set(pObject2Device->a / matrix1.a, pObject2Device->b / matrix1.a,
1502 pObject2Device->c / matrix1.d, pObject2Device->d / matrix1.d, 0, 1500 pObject2Device->c / matrix1.d, pObject2Device->d / matrix1.d, 0,
1503 0); 1501 0);
1504 CFX_Matrix mtRervese; 1502 CFX_Matrix mtRervese;
1505 mtRervese.SetReverse(matrix2); 1503 mtRervese.SetReverse(matrix2);
1506 matrix1 = *pObject2Device; 1504 matrix1 = *pObject2Device;
1507 matrix1.Concat(mtRervese); 1505 matrix1.Concat(mtRervese);
1508 } 1506 }
1509 CAgg_PathData path_data; 1507 CAgg_PathData path_data;
1510 path_data.BuildPath(pPathData, &matrix1); 1508 path_data.BuildPath(pPathData, &matrix1);
1511 agg::rasterizer_scanline_aa rasterizer; 1509 agg::rasterizer_scanline_aa rasterizer;
1512 rasterizer.clip_box(0.0f, 0.0f, (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_WIDTH)), 1510 rasterizer.clip_box(0.0f, 0.0f, (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_WIDTH)),
1513 (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_HEIGHT))); 1511 (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_HEIGHT)));
1514 RasterizeStroke(rasterizer, path_data.m_PathData, &matrix2, pGraphState, 1512 RasterizeStroke(rasterizer, path_data.m_PathData, &matrix2, pGraphState,
1515 matrix1.a, FALSE, fill_mode & FX_STROKE_TEXT_MODE); 1513 matrix1.a, FALSE, !!(fill_mode & FX_STROKE_TEXT_MODE));
1516 if (!RenderRasterizer(rasterizer, stroke_color, fill_mode & FXFILL_FULLCOVER, 1514 return RenderRasterizer(rasterizer, stroke_color,
1517 m_bGroupKnockout, 0, nullptr)) { 1515 !!(fill_mode & FXFILL_FULLCOVER), m_bGroupKnockout, 0,
1518 return FALSE; 1516 nullptr);
1519 }
1520 return TRUE;
1521 } 1517 }
1522 1518
1523 FX_BOOL CFX_AggDeviceDriver::SetPixel(int x, int y, uint32_t color) { 1519 FX_BOOL CFX_AggDeviceDriver::SetPixel(int x, int y, uint32_t color) {
1524 if (!m_pBitmap->GetBuffer()) 1520 if (!m_pBitmap->GetBuffer())
1525 return TRUE; 1521 return TRUE;
1526 1522
1527 if (!m_pClipRgn) { 1523 if (!m_pClipRgn) {
1528 if (!m_bRgbByteOrder) 1524 if (!m_bRgbByteOrder)
1529 return DibSetPixel(m_pBitmap, x, y, color, 0, nullptr); 1525 return DibSetPixel(m_pBitmap, x, y, color, 0, nullptr);
1530 RgbByteOrderSetPixel(m_pBitmap, x, y, color); 1526 RgbByteOrderSetPixel(m_pBitmap, x, y, color);
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
1745 int height, 1741 int height,
1746 FXDIB_Format format, 1742 FXDIB_Format format,
1747 CFX_DIBitmap* pOriDevice) { 1743 CFX_DIBitmap* pOriDevice) {
1748 m_bOwnedBitmap = true; 1744 m_bOwnedBitmap = true;
1749 CFX_DIBitmap* pBitmap = new CFX_DIBitmap; 1745 CFX_DIBitmap* pBitmap = new CFX_DIBitmap;
1750 if (!pBitmap->Create(width, height, format)) { 1746 if (!pBitmap->Create(width, height, format)) {
1751 delete pBitmap; 1747 delete pBitmap;
1752 return false; 1748 return false;
1753 } 1749 }
1754 SetBitmap(pBitmap); 1750 SetBitmap(pBitmap);
1755 SetDeviceDriver(pdfium::MakeUnique<CFX_AggDeviceDriver>(pBitmap, FALSE, 1751 SetDeviceDriver(pdfium::MakeUnique<CFX_AggDeviceDriver>(pBitmap, false,
Tom Sepez 2016/10/27 17:59:29 Note: Because FALSE gets redefined by third_party
1756 pOriDevice, FALSE)); 1752 pOriDevice, false));
1757 return true; 1753 return true;
1758 } 1754 }
1759 1755
1760 CFX_FxgeDevice::~CFX_FxgeDevice() { 1756 CFX_FxgeDevice::~CFX_FxgeDevice() {
1761 if (m_bOwnedBitmap) { 1757 if (m_bOwnedBitmap) {
1762 delete GetBitmap(); 1758 delete GetBitmap();
1763 } 1759 }
1764 } 1760 }
1765 #endif 1761 #endif
OLDNEW
« no previous file with comments | « core/fxcodec/codec/fx_codec_fax.cpp ('k') | core/fxge/ge/cfx_renderdevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698