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

Side by Side Diff: core/fxge/dib/fx_dib_main.cpp

Issue 2010813003: Remove default arguments from CFX_FxgeDevice. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@fxgeclean2_textrenderer
Patch Set: rebase Created 4 years, 7 months 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/fxge/agg/fx_agg_driver.cpp ('k') | core/fxge/ge/fx_ge_device.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/include/fx_dib.h" 7 #include "core/fxge/include/fx_dib.h"
8 8
9 #include <limits.h> 9 #include <limits.h>
10 10
(...skipping 1353 matching lines...) Expand 10 before | Expand all | Expand 10 after
1364 int gray = FXRGB2GRAY(scanline[2], scanline[1], scanline[0]); 1364 int gray = FXRGB2GRAY(scanline[2], scanline[1], scanline[0]);
1365 *scanline++ = bb + (fb - bb) * gray / 255; 1365 *scanline++ = bb + (fb - bb) * gray / 255;
1366 *scanline++ = bg + (fg - bg) * gray / 255; 1366 *scanline++ = bg + (fg - bg) * gray / 255;
1367 *scanline = br + (fr - br) * gray / 255; 1367 *scanline = br + (fr - br) * gray / 255;
1368 scanline += gap; 1368 scanline += gap;
1369 } 1369 }
1370 } 1370 }
1371 } 1371 }
1372 return TRUE; 1372 return TRUE;
1373 } 1373 }
1374 FX_BOOL CFX_DIBitmap::DitherFS(const uint32_t* pPalette, 1374
1375 int pal_size,
1376 const FX_RECT* pRect) {
1377 if (!m_pBuffer) {
1378 return FALSE;
1379 }
1380 if (m_bpp != 8 && m_pPalette && m_AlphaFlag != 0) {
1381 return FALSE;
1382 }
1383 if (m_Width < 4 && m_Height < 4) {
1384 return FALSE;
1385 }
1386 FX_RECT rect(0, 0, m_Width, m_Height);
1387 if (pRect) {
1388 rect.Intersect(*pRect);
1389 }
1390 uint8_t translate[256];
1391 for (int i = 0; i < 256; i++) {
1392 int err2 = 65536;
1393 for (int j = 0; j < pal_size; j++) {
1394 uint8_t entry = (uint8_t)pPalette[j];
1395 int err = (int)entry - i;
1396 if (err * err < err2) {
1397 err2 = err * err;
1398 translate[i] = entry;
1399 }
1400 }
1401 }
1402 for (int row = rect.top; row < rect.bottom; row++) {
1403 uint8_t* scan = m_pBuffer + row * m_Pitch;
1404 uint8_t* next_scan = m_pBuffer + (row + 1) * m_Pitch;
1405 for (int col = rect.left; col < rect.right; col++) {
1406 int src_pixel = scan[col];
1407 int dest_pixel = translate[src_pixel];
1408 scan[col] = (uint8_t)dest_pixel;
1409 int error = -dest_pixel + src_pixel;
1410 if (col < rect.right - 1) {
1411 int src = scan[col + 1];
1412 src += error * 7 / 16;
1413 if (src > 255) {
1414 scan[col + 1] = 255;
1415 } else if (src < 0) {
1416 scan[col + 1] = 0;
1417 } else {
1418 scan[col + 1] = src;
1419 }
1420 }
1421 if (col < rect.right - 1 && row < rect.bottom - 1) {
1422 int src = next_scan[col + 1];
1423 src += error * 1 / 16;
1424 if (src > 255) {
1425 next_scan[col + 1] = 255;
1426 } else if (src < 0) {
1427 next_scan[col + 1] = 0;
1428 } else {
1429 next_scan[col + 1] = src;
1430 }
1431 }
1432 if (row < rect.bottom - 1) {
1433 int src = next_scan[col];
1434 src += error * 5 / 16;
1435 if (src > 255) {
1436 next_scan[col] = 255;
1437 } else if (src < 0) {
1438 next_scan[col] = 0;
1439 } else {
1440 next_scan[col] = src;
1441 }
1442 }
1443 if (col > rect.left && row < rect.bottom - 1) {
1444 int src = next_scan[col - 1];
1445 src += error * 3 / 16;
1446 if (src > 255) {
1447 next_scan[col - 1] = 255;
1448 } else if (src < 0) {
1449 next_scan[col - 1] = 0;
1450 } else {
1451 next_scan[col - 1] = src;
1452 }
1453 }
1454 }
1455 }
1456 return TRUE;
1457 }
1458 CFX_DIBitmap* CFX_DIBSource::FlipImage(FX_BOOL bXFlip, FX_BOOL bYFlip) const { 1375 CFX_DIBitmap* CFX_DIBSource::FlipImage(FX_BOOL bXFlip, FX_BOOL bYFlip) const {
1459 CFX_DIBitmap* pFlipped = new CFX_DIBitmap; 1376 CFX_DIBitmap* pFlipped = new CFX_DIBitmap;
1460 if (!pFlipped->Create(m_Width, m_Height, GetFormat())) { 1377 if (!pFlipped->Create(m_Width, m_Height, GetFormat())) {
1461 delete pFlipped; 1378 delete pFlipped;
1462 return NULL; 1379 return NULL;
1463 } 1380 }
1464 pFlipped->CopyPalette(m_pPalette); 1381 pFlipped->CopyPalette(m_pPalette);
1465 uint8_t* pDestBuffer = pFlipped->GetBuffer(); 1382 uint8_t* pDestBuffer = pFlipped->GetBuffer();
1466 int Bpp = m_bpp / 8; 1383 int Bpp = m_bpp / 8;
1467 for (int row = 0; row < m_Height; row++) { 1384 for (int row = 0; row < m_Height; row++) {
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
1751 uint32_t* pSrcPalette) { 1668 uint32_t* pSrcPalette) {
1752 m_pBitmap.reset(new CFX_DIBitmap); 1669 m_pBitmap.reset(new CFX_DIBitmap);
1753 if (!m_pBitmap->Create(width, height, src_format)) { 1670 if (!m_pBitmap->Create(width, height, src_format)) {
1754 m_pBitmap.reset(); 1671 m_pBitmap.reset();
1755 return FALSE; 1672 return FALSE;
1756 } 1673 }
1757 if (pSrcPalette) 1674 if (pSrcPalette)
1758 m_pBitmap->CopyPalette(pSrcPalette); 1675 m_pBitmap->CopyPalette(pSrcPalette);
1759 return TRUE; 1676 return TRUE;
1760 } 1677 }
OLDNEW
« no previous file with comments | « core/fxge/agg/fx_agg_driver.cpp ('k') | core/fxge/ge/fx_ge_device.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698