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 "xfa/fxgraphics/cagg_graphics.h"
8 
CAGG_Graphics()9 CAGG_Graphics::CAGG_Graphics() : m_owner(nullptr) {}
10 
Create(CFX_Graphics * owner,int32_t width,int32_t height,FXDIB_Format format)11 FWL_Error CAGG_Graphics::Create(CFX_Graphics* owner,
12                                 int32_t width,
13                                 int32_t height,
14                                 FXDIB_Format format) {
15   if (owner->m_renderDevice)
16     return FWL_Error::ParameterInvalid;
17   if (m_owner)
18     return FWL_Error::PropertyInvalid;
19 
20   CFX_FxgeDevice* device = new CFX_FxgeDevice;
21   device->Create(width, height, format, nullptr);
22   m_owner = owner;
23   m_owner->m_renderDevice = device;
24   m_owner->m_renderDevice->GetBitmap()->Clear(0xFFFFFFFF);
25   return FWL_Error::Succeeded;
26 }
27 
~CAGG_Graphics()28 CAGG_Graphics::~CAGG_Graphics() {
29   delete m_owner->m_renderDevice;
30 }
31