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

Side by Side Diff: core/fxge/win32/fx_win32_gdipext.cpp

Issue 2534953004: Return unique_ptrs from CFX_DIBitmap::Clone(). (Closed)
Patch Set: win again Created 4 years 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
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 <windows.h> 7 #include <windows.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 abs(dest_height) < src_height) { 551 abs(dest_height) < src_height) {
552 FX_RECT image_rect(dest_left, dest_top, dest_left + dest_width, 552 FX_RECT image_rect(dest_left, dest_top, dest_left + dest_width,
553 dest_top + dest_height); 553 dest_top + dest_height);
554 image_rect.Normalize(); 554 image_rect.Normalize();
555 FX_RECT image_clip = image_rect; 555 FX_RECT image_clip = image_rect;
556 image_clip.Intersect(*pClipRect); 556 image_clip.Intersect(*pClipRect);
557 if (image_clip.IsEmpty()) { 557 if (image_clip.IsEmpty()) {
558 return; 558 return;
559 } 559 }
560 image_clip.Offset(-image_rect.left, -image_rect.top); 560 image_clip.Offset(-image_rect.left, -image_rect.top);
561 CFX_DIBitmap* pStretched = nullptr; 561 CFX_DIBitmap* pStretched = nullptr;
dsinclair 2016/12/05 20:41:26 unique_ptr?
562 if (src_width * src_height > 10000) { 562 if (src_width * src_height > 10000) {
563 pStretched = 563 pStretched =
564 _StretchMonoToGray(dest_width, dest_height, pBitmap, &image_clip); 564 _StretchMonoToGray(dest_width, dest_height, pBitmap, &image_clip);
dsinclair 2016/12/05 20:41:26 Drop the _ from the method name
Tom Sepez 2016/12/05 21:38:13 Done.
565 } else { 565 } else {
566 pStretched = 566 pStretched =
567 pBitmap->StretchTo(dest_width, dest_height, false, &image_clip); 567 pBitmap->StretchTo(dest_width, dest_height, false, &image_clip)
568 .release();
568 } 569 }
569 GpBitmap* bitmap; 570 GpBitmap* bitmap;
570 CallFunc(GdipCreateBitmapFromScan0)(image_clip.Width(), image_clip.Height(), 571 CallFunc(GdipCreateBitmapFromScan0)(image_clip.Width(), image_clip.Height(),
571 (image_clip.Width() + 3) / 4 * 4, 572 (image_clip.Width() + 3) / 4 * 4,
572 PixelFormat8bppIndexed, 573 PixelFormat8bppIndexed,
573 pStretched->GetBuffer(), &bitmap); 574 pStretched->GetBuffer(), &bitmap);
574 int a, r, g, b; 575 int a, r, g, b;
575 ArgbDecode(argb, a, r, g, b); 576 ArgbDecode(argb, a, r, g, b);
576 UINT pal[258]; 577 UINT pal[258];
577 pal[0] = 0; 578 pal[0] = 0;
(...skipping 25 matching lines...) Expand all
603 const FX_RECT* pSrcRect, 604 const FX_RECT* pSrcRect,
604 int dest_left, 605 int dest_left,
605 int dest_top, 606 int dest_top,
606 int dest_width, 607 int dest_width,
607 int dest_height) { 608 int dest_height) {
608 int src_width = pSrcRect->Width(), src_height = pSrcRect->Height(); 609 int src_width = pSrcRect->Width(), src_height = pSrcRect->Height();
609 CGdiplusExt& GdiplusExt = 610 CGdiplusExt& GdiplusExt =
610 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; 611 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt;
611 if (pBitmap->GetBPP() == 1 && (pSrcRect->left % 8)) { 612 if (pBitmap->GetBPP() == 1 && (pSrcRect->left % 8)) {
612 FX_RECT new_rect(0, 0, src_width, src_height); 613 FX_RECT new_rect(0, 0, src_width, src_height);
613 CFX_DIBitmap* pCloned = pBitmap->Clone(pSrcRect); 614 CFX_DIBitmap* pCloned = pBitmap->Clone(pSrcRect).release();
dsinclair 2016/12/05 20:41:26 unique_ptr?
614 if (!pCloned) { 615 if (!pCloned) {
npm 2016/12/05 20:37:23 Nit: no {}
615 return; 616 return;
616 } 617 }
617 OutputImage(pGraphics, pCloned, &new_rect, dest_left, dest_top, dest_width, 618 OutputImage(pGraphics, pCloned, &new_rect, dest_left, dest_top, dest_width,
618 dest_height); 619 dest_height);
619 delete pCloned; 620 delete pCloned;
620 return; 621 return;
621 } 622 }
622 int src_pitch = pBitmap->GetPitch(); 623 int src_pitch = pBitmap->GetPitch();
623 uint8_t* scan0 = pBitmap->GetBuffer() + pSrcRect->top * src_pitch + 624 uint8_t* scan0 = pBitmap->GetBuffer() + pSrcRect->top * src_pitch +
624 pBitmap->GetBPP() * pSrcRect->left / 8; 625 pBitmap->GetBPP() * pSrcRect->left / 8;
(...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after
1514 FXSYS_memcpy(pData + dest_pitch * i, pInfo->pScan0 + pInfo->Stride * i, 1515 FXSYS_memcpy(pData + dest_pitch * i, pInfo->pScan0 + pInfo->Stride * i,
1515 dest_pitch); 1516 dest_pitch);
1516 } 1517 }
1517 } 1518 }
1518 CFX_DIBitmap* pDIBitmap = _FX_WindowsDIB_LoadFromBuf( 1519 CFX_DIBitmap* pDIBitmap = _FX_WindowsDIB_LoadFromBuf(
1519 pInfo->pbmi, pData, pInfo->pbmi->bmiHeader.biBitCount == 32); 1520 pInfo->pbmi, pData, pInfo->pbmi->bmiHeader.biBitCount == 32);
1520 FX_Free(pData); 1521 FX_Free(pData);
1521 FreeDIBitmap(pInfo); 1522 FreeDIBitmap(pInfo);
1522 return pDIBitmap; 1523 return pDIBitmap;
1523 } 1524 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698