FireBreath  1.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Pages
ActiveXAsyncDrawService.cpp
1 /**********************************************************\
2 Original Author: Gil Gonen
3 
4 Created: Jan 28, 2013
5 License: Dual license model; choose one of two:
6  New BSD License
7  http://www.opensource.org/licenses/bsd-license.php
8  - or -
9  GNU Lesser General Public License, version 2.1
10  http://www.gnu.org/licenses/lgpl-2.1.html
11 
12 Copyright 2013 Gil Gonen and the Firebreath development team
13 \**********************************************************/
14 
15 #include <boost/bind.hpp>
16 #include "BrowserHost.h"
17 #include "ActiveXAsyncDrawService.h"
18 #include "logging.h"
19 
20 using namespace FB::ActiveX;
21 
22 ActiveXAsyncDrawService::ActiveXAsyncDrawService(FB::BrowserHostPtr host, IViewObjectPresentSite* vops)
23  : D3d10AsyncDrawService(host)
24  , m_pViewObjectPresentSite(vops)
25 {
26  assert(vops);
27 }
28 
29 void ActiveXAsyncDrawService::present(bool initOnly)
30 {
31  ID3D10Device1* dev = device();
32  if (!dev)
33  return;
34 
35  if (m_pSurfacePresenter) {
36  BOOL isCurrent = 0;
37  m_pSurfacePresenter->IsCurrent(&isCurrent);
38  if (!isCurrent || m_dimsChanged) {
39  // don't bother presenting, because the new
40  // SurfacePresenter will replace it with blank
41  m_pSurfacePresenter = 0;
42  } else {
43  if (!initOnly) {
44  m_pSurfacePresenter->Present(0, NULL);
45  }
46  }
47  }
48 
49  if (!m_pSurfacePresenter) {
50  // (re)create surface presenter
51  m_dimsChanged = false;
52  UINT backBuffers = 1;
53  DXGI_FORMAT format = DXGI_FORMAT_B8G8R8A8_UNORM; // IE9 only supports this one
54  HRESULT hr = m_pViewObjectPresentSite->CreateSurfacePresenter(
55  dev, m_width, m_height, backBuffers, format, VIEW_OBJECT_ALPHA_MODE_PREMULTIPLIED, &m_pSurfacePresenter);
56  if (FAILED(hr) || !m_pSurfacePresenter) {
57  FBLOG_ERROR("ActiveXAsyncDrawService::present", "CreateSurfacePresenter failed");
58  return;
59  }
60  }
61 
62  // send the back buffer to the render thread
63  {
64  boost::lock_guard<boost::mutex> lock(m_mut);
65  REFIID riid = __uuidof(ID3D10Texture2D);
66  m_pSurfacePresenter->GetBuffer(0, riid, (void**) &m_pBackBuffer.p);
67  }
68  m_cond.notify_one();
69 }
70 
boost::shared_ptr< FB::BrowserHost > BrowserHostPtr
Defines an alias representing a BrowserHost shared_ptr (you should never use a BrowserHost* directly)...
Definition: APITypes.h:117