12fc2651226baac27029e38c9d6ef883fa32084dbSteve Block/* 22fc2651226baac27029e38c9d6ef883fa32084dbSteve Block * Copyright (C) 2011 Apple Inc. All rights reserved. 32fc2651226baac27029e38c9d6ef883fa32084dbSteve Block * 42fc2651226baac27029e38c9d6ef883fa32084dbSteve Block * Redistribution and use in source and binary forms, with or without 52fc2651226baac27029e38c9d6ef883fa32084dbSteve Block * modification, are permitted provided that the following conditions 62fc2651226baac27029e38c9d6ef883fa32084dbSteve Block * are met: 72fc2651226baac27029e38c9d6ef883fa32084dbSteve Block * 1. Redistributions of source code must retain the above copyright 82fc2651226baac27029e38c9d6ef883fa32084dbSteve Block * notice, this list of conditions and the following disclaimer. 92fc2651226baac27029e38c9d6ef883fa32084dbSteve Block * 2. Redistributions in binary form must reproduce the above copyright 102fc2651226baac27029e38c9d6ef883fa32084dbSteve Block * notice, this list of conditions and the following disclaimer in the 112fc2651226baac27029e38c9d6ef883fa32084dbSteve Block * documentation and/or other materials provided with the distribution. 122fc2651226baac27029e38c9d6ef883fa32084dbSteve Block * 132fc2651226baac27029e38c9d6ef883fa32084dbSteve Block * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY 142fc2651226baac27029e38c9d6ef883fa32084dbSteve Block * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 152fc2651226baac27029e38c9d6ef883fa32084dbSteve Block * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 162fc2651226baac27029e38c9d6ef883fa32084dbSteve Block * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 172fc2651226baac27029e38c9d6ef883fa32084dbSteve Block * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 182fc2651226baac27029e38c9d6ef883fa32084dbSteve Block * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 192fc2651226baac27029e38c9d6ef883fa32084dbSteve Block * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 202fc2651226baac27029e38c9d6ef883fa32084dbSteve Block * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 212fc2651226baac27029e38c9d6ef883fa32084dbSteve Block * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 222fc2651226baac27029e38c9d6ef883fa32084dbSteve Block * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 232fc2651226baac27029e38c9d6ef883fa32084dbSteve Block * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 242fc2651226baac27029e38c9d6ef883fa32084dbSteve Block */ 252fc2651226baac27029e38c9d6ef883fa32084dbSteve Block 262fc2651226baac27029e38c9d6ef883fa32084dbSteve Block#ifndef LegacyCACFLayerTreeHost_h 272fc2651226baac27029e38c9d6ef883fa32084dbSteve Block#define LegacyCACFLayerTreeHost_h 282fc2651226baac27029e38c9d6ef883fa32084dbSteve Block 292fc2651226baac27029e38c9d6ef883fa32084dbSteve Block#if USE(ACCELERATED_COMPOSITING) 302fc2651226baac27029e38c9d6ef883fa32084dbSteve Block 312fc2651226baac27029e38c9d6ef883fa32084dbSteve Block#include "CACFLayerTreeHost.h" 322fc2651226baac27029e38c9d6ef883fa32084dbSteve Block 332fc2651226baac27029e38c9d6ef883fa32084dbSteve Blocknamespace WebCore { 342fc2651226baac27029e38c9d6ef883fa32084dbSteve Block 352fc2651226baac27029e38c9d6ef883fa32084dbSteve Block// FIXME: Currently there is a LegacyCACFLayerTreeHost for each WebView and each 362fc2651226baac27029e38c9d6ef883fa32084dbSteve Block// has its own WKCACFContext and Direct3DDevice9, which is inefficient. 372fc2651226baac27029e38c9d6ef883fa32084dbSteve Block// (https://bugs.webkit.org/show_bug.cgi?id=31855) 382fc2651226baac27029e38c9d6ef883fa32084dbSteve Blockclass LegacyCACFLayerTreeHost : public CACFLayerTreeHost { 392fc2651226baac27029e38c9d6ef883fa32084dbSteve Blockpublic: 402fc2651226baac27029e38c9d6ef883fa32084dbSteve Block static PassRefPtr<LegacyCACFLayerTreeHost> create(); 412fc2651226baac27029e38c9d6ef883fa32084dbSteve Block virtual ~LegacyCACFLayerTreeHost(); 422fc2651226baac27029e38c9d6ef883fa32084dbSteve Block 432fc2651226baac27029e38c9d6ef883fa32084dbSteve Blockprivate: 442fc2651226baac27029e38c9d6ef883fa32084dbSteve Block LegacyCACFLayerTreeHost(); 452fc2651226baac27029e38c9d6ef883fa32084dbSteve Block 462fc2651226baac27029e38c9d6ef883fa32084dbSteve Block void initD3DGeometry(); 472fc2651226baac27029e38c9d6ef883fa32084dbSteve Block 482fc2651226baac27029e38c9d6ef883fa32084dbSteve Block // Call this when the device window has changed size or when IDirect3DDevice9::Present returns 492fc2651226baac27029e38c9d6ef883fa32084dbSteve Block // D3DERR_DEVICELOST. Returns true if the device was recovered, false if rendering must be 502fc2651226baac27029e38c9d6ef883fa32084dbSteve Block // aborted and reattempted soon. 512fc2651226baac27029e38c9d6ef883fa32084dbSteve Block enum ResetReason { ChangedWindowSize, LostDevice }; 522fc2651226baac27029e38c9d6ef883fa32084dbSteve Block bool resetDevice(ResetReason); 532fc2651226baac27029e38c9d6ef883fa32084dbSteve Block 542fc2651226baac27029e38c9d6ef883fa32084dbSteve Block void renderSoon(); 552fc2651226baac27029e38c9d6ef883fa32084dbSteve Block void renderTimerFired(Timer<LegacyCACFLayerTreeHost>*); 562fc2651226baac27029e38c9d6ef883fa32084dbSteve Block 572fc2651226baac27029e38c9d6ef883fa32084dbSteve Block virtual void initializeContext(void* userData, PlatformCALayer*); 582fc2651226baac27029e38c9d6ef883fa32084dbSteve Block virtual void resize(); 592fc2651226baac27029e38c9d6ef883fa32084dbSteve Block virtual bool createRenderer(); 602fc2651226baac27029e38c9d6ef883fa32084dbSteve Block virtual void destroyRenderer(); 612fc2651226baac27029e38c9d6ef883fa32084dbSteve Block virtual CFTimeInterval lastCommitTime() const; 622fc2651226baac27029e38c9d6ef883fa32084dbSteve Block virtual void flushContext(); 632fc2651226baac27029e38c9d6ef883fa32084dbSteve Block virtual void contextDidChange(); 642fc2651226baac27029e38c9d6ef883fa32084dbSteve Block virtual void paint(); 652fc2651226baac27029e38c9d6ef883fa32084dbSteve Block virtual void render(const Vector<CGRect>& dirtyRects = Vector<CGRect>()); 662fc2651226baac27029e38c9d6ef883fa32084dbSteve Block 672fc2651226baac27029e38c9d6ef883fa32084dbSteve Block Timer<LegacyCACFLayerTreeHost> m_renderTimer; 682fc2651226baac27029e38c9d6ef883fa32084dbSteve Block COMPtr<IDirect3DDevice9> m_d3dDevice; 692fc2651226baac27029e38c9d6ef883fa32084dbSteve Block WKCACFContext* m_context; 702fc2651226baac27029e38c9d6ef883fa32084dbSteve Block bool m_mightBeAbleToCreateDeviceLater; 712fc2651226baac27029e38c9d6ef883fa32084dbSteve Block bool m_mustResetLostDeviceBeforeRendering; 722fc2651226baac27029e38c9d6ef883fa32084dbSteve Block 732fc2651226baac27029e38c9d6ef883fa32084dbSteve Block#ifndef NDEBUG 742fc2651226baac27029e38c9d6ef883fa32084dbSteve Block bool m_printTree; 752fc2651226baac27029e38c9d6ef883fa32084dbSteve Block#endif 762fc2651226baac27029e38c9d6ef883fa32084dbSteve Block}; 772fc2651226baac27029e38c9d6ef883fa32084dbSteve Block 782fc2651226baac27029e38c9d6ef883fa32084dbSteve Block} // namespace WebCore 792fc2651226baac27029e38c9d6ef883fa32084dbSteve Block 802fc2651226baac27029e38c9d6ef883fa32084dbSteve Block#endif // USE(ACCELERATED_COMPOSITING) 812fc2651226baac27029e38c9d6ef883fa32084dbSteve Block 822fc2651226baac27029e38c9d6ef883fa32084dbSteve Block#endif // LegacyCACFLayerTreeHost_h 83