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

Side by Side Diff: core/fpdfapi/fpdf_page/cpdf_imageobject.cpp

Issue 2386423004: Move core/fpdfapi/fpdf_page to core/fpdfapi/page (Closed)
Patch Set: Rebase to master Created 4 years, 2 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/fpdfapi/fpdf_page/cpdf_imageobject.h ('k') | core/fpdfapi/fpdf_page/cpdf_meshstream.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7 #include "core/fpdfapi/fpdf_page/cpdf_imageobject.h"
8
9 #include <memory>
10
11 #include "core/fpdfapi/fpdf_page/cpdf_image.h"
12 #include "core/fpdfapi/fpdf_page/pageint.h"
13 #include "core/fpdfapi/fpdf_parser/cpdf_document.h"
14
15 CPDF_ImageObject::CPDF_ImageObject()
16 : m_pImage(nullptr), m_pImageOwned(false) {}
17
18 CPDF_ImageObject::~CPDF_ImageObject() {
19 Release();
20 }
21
22 CPDF_ImageObject* CPDF_ImageObject::Clone() const {
23 CPDF_ImageObject* obj = new CPDF_ImageObject;
24 obj->CopyData(this);
25
26 obj->m_pImage = m_pImage->Clone();
27 obj->m_Matrix = m_Matrix;
28 return obj;
29 }
30
31 CPDF_PageObject::Type CPDF_ImageObject::GetType() const {
32 return IMAGE;
33 }
34
35 void CPDF_ImageObject::Transform(const CFX_Matrix& matrix) {
36 m_Matrix.Concat(matrix);
37 CalcBoundingBox();
38 }
39
40 bool CPDF_ImageObject::IsImage() const {
41 return true;
42 }
43
44 CPDF_ImageObject* CPDF_ImageObject::AsImage() {
45 return this;
46 }
47
48 const CPDF_ImageObject* CPDF_ImageObject::AsImage() const {
49 return this;
50 }
51
52 void CPDF_ImageObject::CalcBoundingBox() {
53 m_Left = m_Bottom = 0;
54 m_Right = m_Top = 1.0f;
55 m_Matrix.TransformRect(m_Left, m_Right, m_Top, m_Bottom);
56 }
57
58 void CPDF_ImageObject::SetOwnedImage(std::unique_ptr<CPDF_Image> pImage) {
59 Release();
60 m_pImage = pImage.release();
61 m_pImageOwned = true;
62 }
63
64 void CPDF_ImageObject::SetUnownedImage(CPDF_Image* pImage) {
65 Release();
66 m_pImage = pImage;
67 m_pImageOwned = false;
68 }
69
70 void CPDF_ImageObject::Release() {
71 if (m_pImageOwned) {
72 delete m_pImage;
73 m_pImage = nullptr;
74 m_pImageOwned = false;
75 return;
76 }
77
78 if (!m_pImage)
79 return;
80
81 CPDF_DocPageData* pPageData = m_pImage->GetDocument()->GetPageData();
82 pPageData->ReleaseImage(m_pImage->GetStream());
83 m_pImage = nullptr;
84 }
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_page/cpdf_imageobject.h ('k') | core/fpdfapi/fpdf_page/cpdf_meshstream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698