summaryrefslogtreecommitdiff
path: root/core/fxge/dib/cfx_bitmapstorer.cpp
diff options
context:
space:
mode:
authorNicolas Pena <npm@chromium.org>2017-04-03 13:43:52 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-04-03 18:10:25 +0000
commit0c972ebccb8c5f250122955780bd632ff5c8630f (patch)
treea18c231aeb029572c9c965a0728c00bd273df2db /core/fxge/dib/cfx_bitmapstorer.cpp
parent72c6b181862ada8adf485ab8015120df32d9f600 (diff)
downloadpdfium-0c972ebccb8c5f250122955780bd632ff5c8630f.tar.xz
Split fx_dib part 5
Move more classes into their own files. Change-Id: Ic505be9e406eafb378235216ea19221ce172f32e Reviewed-on: https://pdfium-review.googlesource.com/3593 Commit-Queue: Nicolás Peña <npm@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fxge/dib/cfx_bitmapstorer.cpp')
-rw-r--r--core/fxge/dib/cfx_bitmapstorer.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/core/fxge/dib/cfx_bitmapstorer.cpp b/core/fxge/dib/cfx_bitmapstorer.cpp
new file mode 100644
index 0000000000..ac876b16b7
--- /dev/null
+++ b/core/fxge/dib/cfx_bitmapstorer.cpp
@@ -0,0 +1,56 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "core/fxge/dib/cfx_bitmapstorer.h"
+
+#include <utility>
+
+#include "core/fxge/dib/dib_int.h"
+#include "third_party/base/ptr_util.h"
+
+CFX_BitmapStorer::CFX_BitmapStorer() {}
+
+CFX_BitmapStorer::~CFX_BitmapStorer() {}
+
+CFX_RetainPtr<CFX_DIBitmap> CFX_BitmapStorer::Detach() {
+ return std::move(m_pBitmap);
+}
+
+void CFX_BitmapStorer::Replace(CFX_RetainPtr<CFX_DIBitmap>&& pBitmap) {
+ m_pBitmap = std::move(pBitmap);
+}
+
+void CFX_BitmapStorer::ComposeScanline(int line,
+ const uint8_t* scanline,
+ const uint8_t* scan_extra_alpha) {
+ uint8_t* dest_buf = const_cast<uint8_t*>(m_pBitmap->GetScanline(line));
+ uint8_t* dest_alpha_buf =
+ m_pBitmap->m_pAlphaMask
+ ? const_cast<uint8_t*>(m_pBitmap->m_pAlphaMask->GetScanline(line))
+ : nullptr;
+ if (dest_buf)
+ FXSYS_memcpy(dest_buf, scanline, m_pBitmap->GetPitch());
+
+ if (dest_alpha_buf) {
+ FXSYS_memcpy(dest_alpha_buf, scan_extra_alpha,
+ m_pBitmap->m_pAlphaMask->GetPitch());
+ }
+}
+
+bool CFX_BitmapStorer::SetInfo(int width,
+ int height,
+ FXDIB_Format src_format,
+ uint32_t* pSrcPalette) {
+ auto pBitmap = pdfium::MakeRetain<CFX_DIBitmap>();
+ if (!pBitmap->Create(width, height, src_format))
+ return false;
+
+ if (pSrcPalette)
+ pBitmap->SetPalette(pSrcPalette);
+
+ m_pBitmap = std::move(pBitmap);
+ return true;
+}