gfx/layers/CopyableCanvasLayer.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/layers/CopyableCanvasLayer.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,76 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
     1.5 + * This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef GFX_COPYABLECANVASLAYER_H
    1.10 +#define GFX_COPYABLECANVASLAYER_H
    1.11 +
    1.12 +#include <stdint.h>                     // for uint32_t
    1.13 +#include "GLContextTypes.h"             // for GLContext
    1.14 +#include "Layers.h"                     // for CanvasLayer, etc
    1.15 +#include "gfxContext.h"                 // for gfxContext, etc
    1.16 +#include "gfxTypes.h"
    1.17 +#include "gfxPlatform.h"                // for gfxImageFormat
    1.18 +#include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
    1.19 +#include "mozilla/Preferences.h"        // for Preferences
    1.20 +#include "mozilla/RefPtr.h"             // for RefPtr
    1.21 +#include "mozilla/gfx/2D.h"             // for DrawTarget
    1.22 +#include "mozilla/mozalloc.h"           // for operator delete, etc
    1.23 +#include "nsAutoPtr.h"                  // for nsRefPtr
    1.24 +#include "nsISupportsImpl.h"            // for MOZ_COUNT_CTOR, etc
    1.25 +
    1.26 +namespace mozilla {
    1.27 +
    1.28 +namespace gfx {
    1.29 +class SurfaceStream;
    1.30 +class SharedSurface;
    1.31 +class SurfaceFactory;
    1.32 +}
    1.33 +
    1.34 +namespace layers {
    1.35 +
    1.36 +class CanvasClientWebGL;
    1.37 +
    1.38 +/**
    1.39 + * A shared CanvasLayer implementation that supports copying
    1.40 + * its contents into a gfxASurface using UpdateSurface.
    1.41 + */
    1.42 +class CopyableCanvasLayer : public CanvasLayer
    1.43 +{
    1.44 +public:
    1.45 +  CopyableCanvasLayer(LayerManager* aLayerManager, void *aImplData);
    1.46 +  virtual ~CopyableCanvasLayer();
    1.47 +
    1.48 +  virtual void Initialize(const Data& aData);
    1.49 +
    1.50 +  virtual bool IsDataValid(const Data& aData);
    1.51 +
    1.52 +protected:
    1.53 +  void UpdateTarget(gfx::DrawTarget* aDestTarget = nullptr);
    1.54 +
    1.55 +  RefPtr<gfx::SourceSurface> mSurface;
    1.56 +  nsRefPtr<mozilla::gl::GLContext> mGLContext;
    1.57 +  mozilla::RefPtr<mozilla::gfx::DrawTarget> mDrawTarget;
    1.58 +
    1.59 +  RefPtr<gfx::SurfaceStream> mStream;
    1.60 +
    1.61 +  uint32_t mCanvasFramebuffer;
    1.62 +
    1.63 +  bool mIsGLAlphaPremult;
    1.64 +  bool mNeedsYFlip;
    1.65 +
    1.66 +  RefPtr<gfx::DataSourceSurface> mCachedTempSurface;
    1.67 +  gfx::IntSize mCachedSize;
    1.68 +  gfx::SurfaceFormat mCachedFormat;
    1.69 +
    1.70 +  gfx::DataSourceSurface* GetTempSurface(const gfx::IntSize& aSize,
    1.71 +                                         const gfx::SurfaceFormat aFormat);
    1.72 +
    1.73 +  void DiscardTempSurface();
    1.74 +};
    1.75 +
    1.76 +}
    1.77 +}
    1.78 +
    1.79 +#endif

mercurial