2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 40; 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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifndef nsICanvasRenderingContextInternal_h___
|
|
|
|
#define nsICanvasRenderingContextInternal_h___
|
|
|
|
|
|
|
|
#include "nsISupports.h"
|
|
|
|
#include "nsIInputStream.h"
|
2009-08-09 13:29:56 -07:00
|
|
|
#include "nsIDocShell.h"
|
2012-06-06 00:42:47 -07:00
|
|
|
#include "nsHTMLCanvasElement.h"
|
2009-06-17 13:31:18 -07:00
|
|
|
#include "gfxPattern.h"
|
2011-06-24 10:41:18 -07:00
|
|
|
#include "mozilla/RefPtr.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#define NS_ICANVASRENDERINGCONTEXTINTERNAL_IID \
|
2012-06-06 00:42:47 -07:00
|
|
|
{ 0x8b8da863, 0xd151, 0x4014, \
|
|
|
|
{ 0x8b, 0xdc, 0x62, 0xb5, 0x0d, 0xc0, 0x2b, 0x62 } }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-09-25 13:46:08 -07:00
|
|
|
class gfxContext;
|
2008-04-30 10:04:46 -07:00
|
|
|
class gfxASurface;
|
2010-11-16 20:33:03 -08:00
|
|
|
class nsIPropertyBag;
|
2011-03-27 16:59:47 -07:00
|
|
|
class nsDisplayListBuilder;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-03-24 03:47:18 -07:00
|
|
|
namespace mozilla {
|
2010-05-17 21:04:22 -07:00
|
|
|
namespace layers {
|
|
|
|
class CanvasLayer;
|
|
|
|
class LayerManager;
|
|
|
|
}
|
2010-03-24 03:47:18 -07:00
|
|
|
namespace ipc {
|
|
|
|
class Shmem;
|
|
|
|
}
|
2011-06-24 10:41:18 -07:00
|
|
|
namespace gfx {
|
|
|
|
class SourceSurface;
|
|
|
|
}
|
2010-03-24 03:47:18 -07:00
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
class nsICanvasRenderingContextInternal : public nsISupports {
|
|
|
|
public:
|
2010-05-17 21:04:22 -07:00
|
|
|
typedef mozilla::layers::CanvasLayer CanvasLayer;
|
|
|
|
typedef mozilla::layers::LayerManager LayerManager;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICANVASRENDERINGCONTEXTINTERNAL_IID)
|
|
|
|
|
2012-03-23 15:10:50 -07:00
|
|
|
enum {
|
|
|
|
RenderFlagPremultAlpha = 0x1
|
|
|
|
};
|
|
|
|
|
2012-06-06 00:42:47 -07:00
|
|
|
void SetCanvasElement(nsHTMLCanvasElement* aParentCanvas)
|
|
|
|
{
|
|
|
|
mCanvasElement = aParentCanvas;
|
|
|
|
}
|
2012-06-04 12:41:51 -07:00
|
|
|
nsHTMLCanvasElement* GetParentObject() const
|
|
|
|
{
|
|
|
|
return mCanvasElement;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Sets the dimensions of the canvas, in pixels. Called
|
|
|
|
// whenever the size of the element changes.
|
2012-08-22 08:56:38 -07:00
|
|
|
NS_IMETHOD SetDimensions(int32_t width, int32_t height) = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
NS_IMETHOD InitializeWithSurface(nsIDocShell *docShell, gfxASurface *surface, int32_t width, int32_t height) = 0;
|
2009-08-04 14:36:02 -07:00
|
|
|
|
2007-09-25 13:46:08 -07:00
|
|
|
// Render the canvas at the origin of the given gfxContext
|
2012-03-23 15:10:50 -07:00
|
|
|
NS_IMETHOD Render(gfxContext *ctx,
|
|
|
|
gfxPattern::GraphicsFilter aFilter,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t aFlags = RenderFlagPremultAlpha) = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Gives you a stream containing the image represented by this context.
|
|
|
|
// The format is given in aMimeTime, for example "image/png".
|
|
|
|
//
|
|
|
|
// If the image format does not support transparency or aIncludeTransparency
|
|
|
|
// is false, alpha will be discarded and the result will be the image
|
|
|
|
// composited on black.
|
2007-09-25 13:46:08 -07:00
|
|
|
NS_IMETHOD GetInputStream(const char *aMimeType,
|
|
|
|
const PRUnichar *aEncoderOptions,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIInputStream **aStream) = 0;
|
2008-04-30 10:04:46 -07:00
|
|
|
|
|
|
|
// If this canvas context can be represented with a simple Thebes surface,
|
|
|
|
// return the surface. Otherwise returns an error.
|
|
|
|
NS_IMETHOD GetThebesSurface(gfxASurface **surface) = 0;
|
2011-06-24 10:41:18 -07:00
|
|
|
|
|
|
|
// This gets an Azure SourceSurface for the canvas, this will be a snapshot
|
2012-10-16 19:57:30 -07:00
|
|
|
// of the canvas at the time it was called.
|
2011-06-24 10:41:18 -07:00
|
|
|
virtual mozilla::TemporaryRef<mozilla::gfx::SourceSurface> GetSurfaceSnapshot() = 0;
|
2008-06-03 17:00:32 -07:00
|
|
|
|
|
|
|
// If this context is opaque, the backing store of the canvas should
|
|
|
|
// be created as opaque; all compositing operators should assume the
|
|
|
|
// dst alpha is always 1.0. If this is never called, the context
|
|
|
|
// defaults to false (not opaque).
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHOD SetIsOpaque(bool isOpaque) = 0;
|
2009-10-29 10:58:31 -07:00
|
|
|
|
2010-08-19 08:22:46 -07:00
|
|
|
// Invalidate this context and release any held resources, in preperation
|
|
|
|
// for possibly reinitializing with SetDimensions/InitializeWithSurface.
|
|
|
|
NS_IMETHOD Reset() = 0;
|
|
|
|
|
2010-05-17 21:04:22 -07:00
|
|
|
// Return the CanvasLayer for this context, creating
|
|
|
|
// one for the given layer manager if not available.
|
2011-03-27 16:59:47 -07:00
|
|
|
virtual already_AddRefed<CanvasLayer> GetCanvasLayer(nsDisplayListBuilder* aBuilder,
|
|
|
|
CanvasLayer *aOldLayer,
|
2010-07-15 14:07:46 -07:00
|
|
|
LayerManager *aManager) = 0;
|
2010-05-17 21:04:22 -07:00
|
|
|
|
2011-07-08 03:42:21 -07:00
|
|
|
// Return true if the canvas should be forced to be "inactive" to ensure
|
|
|
|
// it can be drawn to the screen even if it's too large to be blitted by
|
|
|
|
// an accelerated CanvasLayer.
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool ShouldForceInactiveLayer(LayerManager *aManager) { return false; }
|
2011-07-08 03:42:21 -07:00
|
|
|
|
2010-05-17 21:04:22 -07:00
|
|
|
virtual void MarkContextClean() = 0;
|
2010-05-24 07:45:59 -07:00
|
|
|
|
2009-10-29 10:58:31 -07:00
|
|
|
// Redraw the dirty rectangle of this canvas.
|
|
|
|
NS_IMETHOD Redraw(const gfxRect &dirty) = 0;
|
2010-03-24 03:47:18 -07:00
|
|
|
|
2010-11-16 20:33:03 -08:00
|
|
|
// Passes a generic nsIPropertyBag options argument, along with the
|
|
|
|
// previous one, if any. Optional.
|
|
|
|
NS_IMETHOD SetContextOptions(nsIPropertyBag *aNewOptions) { return NS_OK; }
|
|
|
|
|
|
|
|
//
|
|
|
|
// shmem support
|
|
|
|
//
|
|
|
|
|
2010-03-24 03:47:18 -07:00
|
|
|
// If this context can be set to use Mozilla's Shmem segments as its backing
|
|
|
|
// store, this will set it to that state. Note that if you have drawn
|
|
|
|
// anything into this canvas before changing the shmem state, it will be
|
|
|
|
// lost.
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHOD SetIsIPC(bool isIPC) = 0;
|
2012-06-06 00:42:47 -07:00
|
|
|
|
|
|
|
protected:
|
|
|
|
nsRefPtr<nsHTMLCanvasElement> mCanvasElement;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
2012-05-21 14:30:07 -07:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(nsICanvasRenderingContextInternal,
|
|
|
|
NS_ICANVASRENDERINGCONTEXTINTERNAL_IID)
|
|
|
|
|
|
|
|
#endif /* nsICanvasRenderingContextInternal_h___ */
|