gecko-dev/gfx/layers/d3d9/CanvasLayerD3D9.h

120 строки
2.9 KiB
C
Исходник Обычный вид История

/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2012-05-21 15:12:37 +04:00
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef GFX_CANVASLAYERD3D9_H
#define GFX_CANVASLAYERD3D9_H
Merge from mozilla-central. --HG-- rename : js/src/xpconnect/idl/nsIXPConnect.idl => js/xpconnect/idl/nsIXPConnect.idl rename : js/src/xpconnect/loader/mozJSComponentLoader.cpp => js/xpconnect/loader/mozJSComponentLoader.cpp rename : js/src/xpconnect/loader/mozJSComponentLoader.h => js/xpconnect/loader/mozJSComponentLoader.h rename : js/src/xpconnect/loader/mozJSSubScriptLoader.cpp => js/xpconnect/loader/mozJSSubScriptLoader.cpp rename : js/src/xpconnect/public/nsAXPCNativeCallContext.h => js/xpconnect/public/nsAXPCNativeCallContext.h rename : js/src/xpconnect/public/xpc_map_end.h => js/xpconnect/public/xpc_map_end.h rename : js/src/xpconnect/shell/xpcshell.cpp => js/xpconnect/shell/xpcshell.cpp rename : js/src/xpconnect/src/Makefile.in => js/xpconnect/src/Makefile.in rename : js/src/xpconnect/src/xpccallcontext.cpp => js/xpconnect/src/XPCCallContext.cpp rename : js/src/xpconnect/src/xpccomponents.cpp => js/xpconnect/src/XPCComponents.cpp rename : js/src/xpconnect/src/xpcconvert.cpp => js/xpconnect/src/XPCConvert.cpp rename : js/src/xpconnect/src/xpcdebug.cpp => js/xpconnect/src/XPCDebug.cpp rename : js/src/xpconnect/src/xpcinlines.h => js/xpconnect/src/XPCInlines.h rename : js/src/xpconnect/src/xpcjsid.cpp => js/xpconnect/src/XPCJSID.cpp rename : js/src/xpconnect/src/xpcjsruntime.cpp => js/xpconnect/src/XPCJSRuntime.cpp rename : js/src/xpconnect/src/xpclog.cpp => js/xpconnect/src/XPCLog.cpp rename : js/src/xpconnect/src/xpclog.h => js/xpconnect/src/XPCLog.h rename : js/src/xpconnect/src/xpcmaps.cpp => js/xpconnect/src/XPCMaps.cpp rename : js/src/xpconnect/src/xpcmaps.h => js/xpconnect/src/XPCMaps.h rename : js/src/xpconnect/src/xpcquickstubs.cpp => js/xpconnect/src/XPCQuickStubs.cpp rename : js/src/xpconnect/src/xpcquickstubs.h => js/xpconnect/src/XPCQuickStubs.h rename : js/src/xpconnect/src/xpcruntimesvc.cpp => js/xpconnect/src/XPCRuntimeService.cpp rename : js/src/xpconnect/src/xpcthreadcontext.cpp => js/xpconnect/src/XPCThreadContext.cpp rename : js/src/xpconnect/src/xpcthrower.cpp => js/xpconnect/src/XPCThrower.cpp rename : js/src/xpconnect/src/xpcvariant.cpp => js/xpconnect/src/XPCVariant.cpp rename : js/src/xpconnect/src/xpcwrappedjs.cpp => js/xpconnect/src/XPCWrappedJS.cpp rename : js/src/xpconnect/src/xpcwrappedjsclass.cpp => js/xpconnect/src/XPCWrappedJSClass.cpp rename : js/src/xpconnect/src/xpcwrappednative.cpp => js/xpconnect/src/XPCWrappedNative.cpp rename : js/src/xpconnect/src/xpcwrappednativeinfo.cpp => js/xpconnect/src/XPCWrappedNativeInfo.cpp rename : js/src/xpconnect/src/xpcwrappednativejsops.cpp => js/xpconnect/src/XPCWrappedNativeJSOps.cpp rename : js/src/xpconnect/src/xpcwrappednativeproto.cpp => js/xpconnect/src/XPCWrappedNativeProto.cpp rename : js/src/xpconnect/src/xpcwrappednativescope.cpp => js/xpconnect/src/XPCWrappedNativeScope.cpp rename : js/src/xpconnect/src/XPCWrapper.cpp => js/xpconnect/src/XPCWrapper.cpp rename : js/src/xpconnect/src/XPCWrapper.h => js/xpconnect/src/XPCWrapper.h rename : js/src/xpconnect/src/dom_quickstubs.qsconf => js/xpconnect/src/dom_quickstubs.qsconf rename : js/src/xpconnect/src/nsXPConnect.cpp => js/xpconnect/src/nsXPConnect.cpp rename : js/src/xpconnect/src/qsgen.py => js/xpconnect/src/qsgen.py rename : js/src/xpconnect/src/xpcprivate.h => js/xpconnect/src/xpcprivate.h rename : js/src/xpconnect/src/xpcpublic.h => js/xpconnect/src/xpcpublic.h rename : js/src/xpconnect/tests/chrome/test_doublewrappedcompartments.xul => js/xpconnect/tests/chrome/test_doublewrappedcompartments.xul rename : js/src/xpconnect/tests/components/native/xpctest_attributes.cpp => js/xpconnect/tests/components/native/xpctest_attributes.cpp rename : js/src/xpconnect/tests/components/native/xpctest_params.cpp => js/xpconnect/tests/components/native/xpctest_params.cpp rename : js/src/xpconnect/tests/components/native/xpctest_private.h => js/xpconnect/tests/components/native/xpctest_private.h rename : js/src/xpconnect/tests/mochitest/file_doublewrappedcompartments.html => js/xpconnect/tests/mochitest/file_doublewrappedcompartments.html rename : js/src/xpconnect/tests/mochitest/test_bug502959.html => js/xpconnect/tests/mochitest/test_bug502959.html rename : js/src/xpconnect/tests/mochitest/test_bug505915.html => js/xpconnect/tests/mochitest/test_bug505915.html rename : js/src/xpconnect/wrappers/AccessCheck.cpp => js/xpconnect/wrappers/AccessCheck.cpp rename : js/src/xpconnect/wrappers/AccessCheck.h => js/xpconnect/wrappers/AccessCheck.h rename : js/src/xpconnect/wrappers/CrossOriginWrapper.cpp => js/xpconnect/wrappers/CrossOriginWrapper.cpp rename : js/src/xpconnect/wrappers/CrossOriginWrapper.h => js/xpconnect/wrappers/CrossOriginWrapper.h rename : js/src/xpconnect/wrappers/FilteringWrapper.cpp => js/xpconnect/wrappers/FilteringWrapper.cpp rename : js/src/xpconnect/wrappers/FilteringWrapper.h => js/xpconnect/wrappers/FilteringWrapper.h rename : js/src/xpconnect/wrappers/WrapperFactory.cpp => js/xpconnect/wrappers/WrapperFactory.cpp rename : js/src/xpconnect/wrappers/WrapperFactory.h => js/xpconnect/wrappers/WrapperFactory.h rename : js/src/xpconnect/wrappers/XrayWrapper.cpp => js/xpconnect/wrappers/XrayWrapper.cpp rename : js/src/xpconnect/wrappers/XrayWrapper.h => js/xpconnect/wrappers/XrayWrapper.h
2011-10-17 22:52:12 +04:00
#include "LayerManagerD3D9.h"
#include "GLContext.h"
#include "gfxASurface.h"
namespace mozilla {
namespace layers {
class ShadowBufferD3D9;
class THEBES_API CanvasLayerD3D9 :
public CanvasLayer,
public LayerD3D9
{
public:
CanvasLayerD3D9(LayerManagerD3D9 *aManager)
: CanvasLayer(aManager, NULL)
, LayerD3D9(aManager)
, mDataIsPremultiplied(false)
, mNeedsYFlip(false)
, mHasAlpha(true)
{
mImplData = static_cast<LayerD3D9*>(this);
aManager->deviceManager()->mLayersWithResources.AppendElement(this);
}
~CanvasLayerD3D9();
// CanvasLayer implementation
virtual void Initialize(const Data& aData);
// LayerD3D9 implementation
virtual Layer* GetLayer();
virtual void RenderLayer();
virtual void CleanResources();
virtual void LayerManagerDestroyed();
void CreateTexture();
protected:
typedef mozilla::gl::GLContext GLContext;
void UpdateSurface();
nsRefPtr<gfxASurface> mSurface;
nsRefPtr<GLContext> mGLContext;
nsRefPtr<IDirect3DTexture9> mTexture;
RefPtr<gfx::DrawTarget> mDrawTarget;
bool mDataIsPremultiplied;
bool mNeedsYFlip;
bool mHasAlpha;
nsAutoArrayPtr<uint8_t> mCachedTempBlob;
uint32_t mCachedTempBlob_Size;
uint8_t* GetTempBlob(const uint32_t aSize)
{
if (!mCachedTempBlob || aSize != mCachedTempBlob_Size) {
mCachedTempBlob = new uint8_t[aSize];
mCachedTempBlob_Size = aSize;
}
return mCachedTempBlob;
}
void DiscardTempBlob()
{
mCachedTempBlob = nullptr;
}
};
// NB: eventually we'll have separate shadow canvas2d and shadow
// canvas3d layers, but currently they look the same from the
// perspective of the compositor process
class ShadowCanvasLayerD3D9 : public ShadowCanvasLayer,
public LayerD3D9
{
public:
ShadowCanvasLayerD3D9(LayerManagerD3D9* aManager);
virtual ~ShadowCanvasLayerD3D9();
// CanvasLayer impl
virtual void Initialize(const Data& aData);
// This isn't meaningful for shadow canvas.
virtual void Updated(const nsIntRect&) {}
// ShadowCanvasLayer impl
virtual void Swap(const CanvasSurface& aNewFront,
bool needYFlip,
CanvasSurface* aNewBack);
virtual void DestroyFrontBuffer();
virtual void Disconnect();
virtual void Destroy();
// LayerD3D9 implementation
virtual Layer* GetLayer();
virtual void RenderLayer();
virtual void CleanResources();
virtual void LayerManagerDestroyed();
private:
virtual void Init(bool needYFlip);
bool mNeedsYFlip;
nsRefPtr<ShadowBufferD3D9> mBuffer;
};
} /* layers */
} /* mozilla */
#endif /* GFX_CANVASLAYERD3D9_H */