content/canvas/public/nsICanvasRenderingContextInternal.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 40; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #ifndef nsICanvasRenderingContextInternal_h___
michael@0 7 #define nsICanvasRenderingContextInternal_h___
michael@0 8
michael@0 9 #include "mozilla/gfx/2D.h"
michael@0 10 #include "nsISupports.h"
michael@0 11 #include "nsIInputStream.h"
michael@0 12 #include "nsIDocShell.h"
michael@0 13 #include "mozilla/dom/HTMLCanvasElement.h"
michael@0 14 #include "GraphicsFilter.h"
michael@0 15 #include "mozilla/RefPtr.h"
michael@0 16
michael@0 17 #define NS_ICANVASRENDERINGCONTEXTINTERNAL_IID \
michael@0 18 { 0x3cc9e801, 0x1806, 0x4ff6, \
michael@0 19 { 0x86, 0x14, 0xf9, 0xd0, 0xf4, 0xfb, 0x3b, 0x08 } }
michael@0 20
michael@0 21 class gfxContext;
michael@0 22 class gfxASurface;
michael@0 23 class nsDisplayListBuilder;
michael@0 24
michael@0 25 namespace mozilla {
michael@0 26 namespace layers {
michael@0 27 class CanvasLayer;
michael@0 28 class LayerManager;
michael@0 29 }
michael@0 30 namespace ipc {
michael@0 31 class Shmem;
michael@0 32 }
michael@0 33 namespace gfx {
michael@0 34 class SourceSurface;
michael@0 35 }
michael@0 36 }
michael@0 37
michael@0 38 class nsICanvasRenderingContextInternal : public nsISupports {
michael@0 39 public:
michael@0 40 typedef mozilla::layers::CanvasLayer CanvasLayer;
michael@0 41 typedef mozilla::layers::LayerManager LayerManager;
michael@0 42
michael@0 43 NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICANVASRENDERINGCONTEXTINTERNAL_IID)
michael@0 44
michael@0 45 void SetCanvasElement(mozilla::dom::HTMLCanvasElement* aParentCanvas)
michael@0 46 {
michael@0 47 mCanvasElement = aParentCanvas;
michael@0 48 }
michael@0 49 mozilla::dom::HTMLCanvasElement* GetParentObject() const
michael@0 50 {
michael@0 51 return mCanvasElement;
michael@0 52 }
michael@0 53
michael@0 54 #ifdef DEBUG
michael@0 55 // Useful for testing
michael@0 56 virtual int32_t GetWidth() const = 0;
michael@0 57 virtual int32_t GetHeight() const = 0;
michael@0 58 #endif
michael@0 59
michael@0 60 // Sets the dimensions of the canvas, in pixels. Called
michael@0 61 // whenever the size of the element changes.
michael@0 62 NS_IMETHOD SetDimensions(int32_t width, int32_t height) = 0;
michael@0 63
michael@0 64 NS_IMETHOD InitializeWithSurface(nsIDocShell *docShell, gfxASurface *surface, int32_t width, int32_t height) = 0;
michael@0 65
michael@0 66 // Creates an image buffer. Returns null on failure.
michael@0 67 virtual void GetImageBuffer(uint8_t** aImageBuffer, int32_t* aFormat) = 0;
michael@0 68
michael@0 69 // Gives you a stream containing the image represented by this context.
michael@0 70 // The format is given in aMimeTime, for example "image/png".
michael@0 71 //
michael@0 72 // If the image format does not support transparency or aIncludeTransparency
michael@0 73 // is false, alpha will be discarded and the result will be the image
michael@0 74 // composited on black.
michael@0 75 NS_IMETHOD GetInputStream(const char *aMimeType,
michael@0 76 const char16_t *aEncoderOptions,
michael@0 77 nsIInputStream **aStream) = 0;
michael@0 78
michael@0 79 // This gets an Azure SourceSurface for the canvas, this will be a snapshot
michael@0 80 // of the canvas at the time it was called.
michael@0 81 // If aPremultAlpha is provided, then it assumed the callee can handle
michael@0 82 // un-premultiplied surfaces, and *aPremultAlpha will be set to false
michael@0 83 // if one is returned.
michael@0 84 virtual mozilla::TemporaryRef<mozilla::gfx::SourceSurface> GetSurfaceSnapshot(bool* aPremultAlpha = nullptr) = 0;
michael@0 85
michael@0 86 // If this context is opaque, the backing store of the canvas should
michael@0 87 // be created as opaque; all compositing operators should assume the
michael@0 88 // dst alpha is always 1.0. If this is never called, the context
michael@0 89 // defaults to false (not opaque).
michael@0 90 NS_IMETHOD SetIsOpaque(bool isOpaque) = 0;
michael@0 91 virtual bool GetIsOpaque() = 0;
michael@0 92
michael@0 93 // Invalidate this context and release any held resources, in preperation
michael@0 94 // for possibly reinitializing with SetDimensions/InitializeWithSurface.
michael@0 95 NS_IMETHOD Reset() = 0;
michael@0 96
michael@0 97 // Return the CanvasLayer for this context, creating
michael@0 98 // one for the given layer manager if not available.
michael@0 99 virtual already_AddRefed<CanvasLayer> GetCanvasLayer(nsDisplayListBuilder* aBuilder,
michael@0 100 CanvasLayer *aOldLayer,
michael@0 101 LayerManager *aManager) = 0;
michael@0 102
michael@0 103 // Return true if the canvas should be forced to be "inactive" to ensure
michael@0 104 // it can be drawn to the screen even if it's too large to be blitted by
michael@0 105 // an accelerated CanvasLayer.
michael@0 106 virtual bool ShouldForceInactiveLayer(LayerManager *aManager) { return false; }
michael@0 107
michael@0 108 virtual void MarkContextClean() = 0;
michael@0 109
michael@0 110 // Redraw the dirty rectangle of this canvas.
michael@0 111 NS_IMETHOD Redraw(const gfxRect &dirty) = 0;
michael@0 112
michael@0 113 NS_IMETHOD SetContextOptions(JSContext* aCx, JS::Handle<JS::Value> aOptions) { return NS_OK; }
michael@0 114
michael@0 115 //
michael@0 116 // shmem support
michael@0 117 //
michael@0 118
michael@0 119 // If this context can be set to use Mozilla's Shmem segments as its backing
michael@0 120 // store, this will set it to that state. Note that if you have drawn
michael@0 121 // anything into this canvas before changing the shmem state, it will be
michael@0 122 // lost.
michael@0 123 NS_IMETHOD SetIsIPC(bool isIPC) = 0;
michael@0 124
michael@0 125 protected:
michael@0 126 nsRefPtr<mozilla::dom::HTMLCanvasElement> mCanvasElement;
michael@0 127 };
michael@0 128
michael@0 129 namespace mozilla {
michael@0 130 namespace dom {
michael@0 131
michael@0 132 }
michael@0 133 }
michael@0 134
michael@0 135 NS_DEFINE_STATIC_IID_ACCESSOR(nsICanvasRenderingContextInternal,
michael@0 136 NS_ICANVASRENDERINGCONTEXTINTERNAL_IID)
michael@0 137
michael@0 138 #endif /* nsICanvasRenderingContextInternal_h___ */

mercurial