2010-09-30 15:53:49 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
2012-05-21 04:12:37 -07: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/. */
|
2010-09-30 15:53:49 -07:00
|
|
|
|
2011-02-16 14:43:30 -08:00
|
|
|
#ifndef GFX_CANVASLAYERD3D10_H
|
|
|
|
#define GFX_CANVASLAYERD3D10_H
|
2010-09-30 15:53:49 -07:00
|
|
|
|
|
|
|
#include "LayerManagerD3D10.h"
|
|
|
|
#include "GLContext.h"
|
|
|
|
#include "gfxASurface.h"
|
|
|
|
|
2012-08-21 20:29:06 -07:00
|
|
|
#include "mozilla/Preferences.h"
|
|
|
|
|
2010-09-30 15:53:49 -07:00
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
|
|
|
class THEBES_API CanvasLayerD3D10 : public CanvasLayer,
|
|
|
|
public LayerD3D10
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CanvasLayerD3D10(LayerManagerD3D10 *aManager)
|
2011-02-10 12:03:51 -08:00
|
|
|
: CanvasLayer(aManager, NULL)
|
|
|
|
, LayerD3D10(aManager)
|
2011-10-17 07:59:28 -07:00
|
|
|
, mDataIsPremultiplied(false)
|
|
|
|
, mNeedsYFlip(false)
|
|
|
|
, mHasAlpha(true)
|
2010-09-30 15:53:49 -07:00
|
|
|
{
|
|
|
|
mImplData = static_cast<LayerD3D10*>(this);
|
2012-08-21 20:29:06 -07:00
|
|
|
mForceReadback = Preferences::GetBool("webgl.force-layers-readback", false);
|
2010-09-30 15:53:49 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
~CanvasLayerD3D10();
|
|
|
|
|
|
|
|
// CanvasLayer implementation
|
|
|
|
virtual void Initialize(const Data& aData);
|
|
|
|
|
|
|
|
// LayerD3D10 implementation
|
|
|
|
virtual Layer* GetLayer();
|
2010-11-08 01:06:15 -08:00
|
|
|
virtual void RenderLayer();
|
2010-09-30 15:53:49 -07:00
|
|
|
|
|
|
|
private:
|
|
|
|
typedef mozilla::gl::GLContext GLContext;
|
|
|
|
|
2011-03-27 16:59:46 -07:00
|
|
|
void UpdateSurface();
|
|
|
|
|
2010-09-30 15:53:49 -07:00
|
|
|
nsRefPtr<gfxASurface> mSurface;
|
2011-06-24 10:41:18 -07:00
|
|
|
mozilla::RefPtr<mozilla::gfx::DrawTarget> mDrawTarget;
|
2010-09-30 15:53:49 -07:00
|
|
|
nsRefPtr<GLContext> mGLContext;
|
|
|
|
nsRefPtr<ID3D10Texture2D> mTexture;
|
2013-02-13 15:26:24 -08:00
|
|
|
nsRefPtr<ID3D10ShaderResourceView> mUploadSRView;
|
2010-09-30 15:53:49 -07:00
|
|
|
nsRefPtr<ID3D10ShaderResourceView> mSRView;
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mDataIsPremultiplied;
|
|
|
|
bool mNeedsYFlip;
|
|
|
|
bool mIsD2DTexture;
|
|
|
|
bool mHasAlpha;
|
2012-08-21 20:29:06 -07:00
|
|
|
bool mForceReadback;
|
2012-03-25 12:50:26 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
nsAutoArrayPtr<uint8_t> mCachedTempBlob;
|
|
|
|
uint32_t mCachedTempBlob_Size;
|
2012-03-25 12:50:26 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint8_t* GetTempBlob(const uint32_t aSize)
|
2012-03-25 12:50:26 -07:00
|
|
|
{
|
2013-02-13 15:26:24 -08:00
|
|
|
if (!mCachedTempBlob || aSize != mCachedTempBlob_Size) {
|
|
|
|
mCachedTempBlob = new uint8_t[aSize];
|
|
|
|
mCachedTempBlob_Size = aSize;
|
|
|
|
}
|
2012-03-25 12:50:26 -07:00
|
|
|
|
2013-02-13 15:26:24 -08:00
|
|
|
return mCachedTempBlob;
|
2012-03-25 12:50:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void DiscardTempBlob()
|
|
|
|
{
|
2013-02-13 15:26:24 -08:00
|
|
|
mCachedTempBlob = nullptr;
|
2012-03-25 12:50:26 -07:00
|
|
|
}
|
2010-09-30 15:53:49 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
} /* layers */
|
|
|
|
} /* mozilla */
|
|
|
|
#endif /* GFX_CANVASLAYERD3D10_H */
|