2017-10-28 02:10:06 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
2013-05-01 09:03:25 +04:00
|
|
|
* 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/. */
|
|
|
|
|
2017-08-03 08:55:14 +03:00
|
|
|
#ifndef GFX_COPYABLECANVASRENDERER_H
|
|
|
|
#define GFX_COPYABLECANVASRENDERER_H
|
2013-05-01 09:03:25 +04:00
|
|
|
|
2013-08-12 03:17:23 +04:00
|
|
|
#include <stdint.h> // for uint32_t
|
2017-08-03 08:55:14 +03:00
|
|
|
#include "CanvasRenderer.h"
|
2013-09-07 06:11:41 +04:00
|
|
|
#include "GLContextTypes.h" // for GLContext
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "gfxContext.h" // for gfxContext, etc
|
2013-09-25 00:45:14 +04:00
|
|
|
#include "gfxTypes.h"
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "gfxPlatform.h" // for gfxImageFormat
|
|
|
|
#include "mozilla/Assertions.h" // for MOZ_ASSERT, etc
|
|
|
|
#include "mozilla/Preferences.h" // for Preferences
|
2015-10-18 08:24:48 +03:00
|
|
|
#include "mozilla/RefPtr.h" // for RefPtr
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "mozilla/gfx/2D.h" // for DrawTarget
|
|
|
|
#include "mozilla/mozalloc.h" // for operator delete, etc
|
2014-02-27 01:36:35 +04:00
|
|
|
#include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc
|
2013-05-01 09:03:25 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2015-04-22 09:29:24 +03:00
|
|
|
namespace gl {
|
|
|
|
class SharedSurface;
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace gl
|
2015-04-22 09:29:24 +03:00
|
|
|
|
|
|
|
namespace layers {
|
2013-05-01 09:03:25 +04:00
|
|
|
|
|
|
|
/**
|
2017-08-03 08:55:14 +03:00
|
|
|
* A shared CanvasRenderer implementation that supports copying
|
|
|
|
* its contents into a gfxASurface using RebackSurface.
|
2013-05-01 09:03:25 +04:00
|
|
|
*/
|
2017-08-03 08:55:14 +03:00
|
|
|
class CopyableCanvasRenderer : public CanvasRenderer {
|
2013-05-01 09:03:25 +04:00
|
|
|
public:
|
2017-08-03 08:55:14 +03:00
|
|
|
CopyableCanvasRenderer();
|
|
|
|
virtual ~CopyableCanvasRenderer();
|
2013-05-01 09:03:25 +04:00
|
|
|
|
2014-07-15 19:37:45 +04:00
|
|
|
public:
|
2017-08-03 08:55:14 +03:00
|
|
|
void Initialize(const CanvasInitializeData& aData) override;
|
|
|
|
bool IsDataValid(const CanvasInitializeData& aData) override;
|
|
|
|
|
|
|
|
void ClearCachedResources() override;
|
|
|
|
void Destroy() override;
|
2013-12-05 02:46:20 +04:00
|
|
|
|
2017-08-03 08:55:14 +03:00
|
|
|
CopyableCanvasRenderer* AsCopyableCanvasRenderer() override { return this; }
|
2013-05-01 09:03:25 +04:00
|
|
|
|
2017-08-03 08:55:14 +03:00
|
|
|
bool NeedsYFlip() const { return mOriginPos == gl::OriginPos::BottomLeft; }
|
|
|
|
bool HasGLContext() const { return !!mGLContext; }
|
|
|
|
bool IsOpaque() const { return mOpaque; }
|
|
|
|
|
|
|
|
PersistentBufferProvider* GetBufferProvider() { return mBufferProvider; }
|
|
|
|
|
|
|
|
already_AddRefed<gfx::SourceSurface> ReadbackSurface();
|
2014-05-15 02:31:23 +04:00
|
|
|
|
2013-05-01 09:03:25 +04:00
|
|
|
protected:
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<gl::GLContext> mGLContext;
|
|
|
|
RefPtr<PersistentBufferProvider> mBufferProvider;
|
2017-08-03 08:55:14 +03:00
|
|
|
RefPtr<AsyncCanvasRenderer> mAsyncRenderer;
|
2020-01-09 01:19:14 +03:00
|
|
|
RefPtr<OOPCanvasRenderer> mOOPRenderer;
|
2013-05-01 09:03:25 +04:00
|
|
|
|
2014-06-19 04:04:06 +04:00
|
|
|
bool mIsAlphaPremultiplied;
|
2014-11-18 04:02:19 +03:00
|
|
|
gl::OriginPos mOriginPos;
|
2013-05-01 09:03:25 +04:00
|
|
|
|
2017-08-03 08:55:14 +03:00
|
|
|
bool mOpaque;
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<gfx::DataSourceSurface> mCachedTempSurface;
|
2013-05-01 09:03:25 +04:00
|
|
|
|
2014-02-12 19:07:46 +04:00
|
|
|
gfx::DataSourceSurface* GetTempSurface(const gfx::IntSize& aSize,
|
|
|
|
const gfx::SurfaceFormat aFormat);
|
2013-05-01 09:03:25 +04:00
|
|
|
};
|
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace layers
|
|
|
|
} // namespace mozilla
|
2013-05-01 09:03:25 +04:00
|
|
|
|
|
|
|
#endif
|