Wed, 31 Dec 2014 06:09:35 +0100
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: 20; 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 MOZILLA_GFX_BASICCOMPOSITOR_H |
michael@0 | 7 | #define MOZILLA_GFX_BASICCOMPOSITOR_H |
michael@0 | 8 | |
michael@0 | 9 | #include "mozilla/layers/Compositor.h" |
michael@0 | 10 | #include "mozilla/layers/TextureHost.h" |
michael@0 | 11 | #include "mozilla/gfx/2D.h" |
michael@0 | 12 | #include "nsAutoPtr.h" |
michael@0 | 13 | |
michael@0 | 14 | class gfxContext; |
michael@0 | 15 | |
michael@0 | 16 | namespace mozilla { |
michael@0 | 17 | namespace layers { |
michael@0 | 18 | |
michael@0 | 19 | class BasicCompositingRenderTarget : public CompositingRenderTarget |
michael@0 | 20 | { |
michael@0 | 21 | public: |
michael@0 | 22 | BasicCompositingRenderTarget(gfx::DrawTarget* aDrawTarget, const gfx::IntRect& aRect) |
michael@0 | 23 | : CompositingRenderTarget(aRect.TopLeft()) |
michael@0 | 24 | , mDrawTarget(aDrawTarget) |
michael@0 | 25 | , mSize(aRect.Size()) |
michael@0 | 26 | { } |
michael@0 | 27 | |
michael@0 | 28 | virtual gfx::IntSize GetSize() const MOZ_OVERRIDE { return mSize; } |
michael@0 | 29 | |
michael@0 | 30 | virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE |
michael@0 | 31 | { |
michael@0 | 32 | return mDrawTarget ? mDrawTarget->GetFormat() |
michael@0 | 33 | : gfx::SurfaceFormat(gfx::SurfaceFormat::UNKNOWN); |
michael@0 | 34 | } |
michael@0 | 35 | |
michael@0 | 36 | RefPtr<gfx::DrawTarget> mDrawTarget; |
michael@0 | 37 | gfx::IntSize mSize; |
michael@0 | 38 | }; |
michael@0 | 39 | |
michael@0 | 40 | class BasicCompositor : public Compositor |
michael@0 | 41 | { |
michael@0 | 42 | public: |
michael@0 | 43 | BasicCompositor(nsIWidget *aWidget); |
michael@0 | 44 | |
michael@0 | 45 | virtual ~BasicCompositor(); |
michael@0 | 46 | |
michael@0 | 47 | |
michael@0 | 48 | virtual bool Initialize() MOZ_OVERRIDE { return true; }; |
michael@0 | 49 | |
michael@0 | 50 | virtual void Destroy() MOZ_OVERRIDE; |
michael@0 | 51 | |
michael@0 | 52 | virtual TextureFactoryIdentifier GetTextureFactoryIdentifier() MOZ_OVERRIDE |
michael@0 | 53 | { |
michael@0 | 54 | return TextureFactoryIdentifier(LayersBackend::LAYERS_BASIC, |
michael@0 | 55 | XRE_GetProcessType(), |
michael@0 | 56 | GetMaxTextureSize()); |
michael@0 | 57 | } |
michael@0 | 58 | |
michael@0 | 59 | virtual TemporaryRef<CompositingRenderTarget> |
michael@0 | 60 | CreateRenderTarget(const gfx::IntRect &aRect, SurfaceInitMode aInit) MOZ_OVERRIDE; |
michael@0 | 61 | |
michael@0 | 62 | virtual TemporaryRef<CompositingRenderTarget> |
michael@0 | 63 | CreateRenderTargetFromSource(const gfx::IntRect &aRect, |
michael@0 | 64 | const CompositingRenderTarget *aSource, |
michael@0 | 65 | const gfx::IntPoint &aSourcePoint) MOZ_OVERRIDE; |
michael@0 | 66 | |
michael@0 | 67 | virtual TemporaryRef<DataTextureSource> |
michael@0 | 68 | CreateDataTextureSource(TextureFlags aFlags = 0) MOZ_OVERRIDE; |
michael@0 | 69 | |
michael@0 | 70 | virtual bool SupportsEffect(EffectTypes aEffect) MOZ_OVERRIDE; |
michael@0 | 71 | |
michael@0 | 72 | virtual void SetRenderTarget(CompositingRenderTarget *aSource) MOZ_OVERRIDE |
michael@0 | 73 | { |
michael@0 | 74 | mRenderTarget = static_cast<BasicCompositingRenderTarget*>(aSource); |
michael@0 | 75 | } |
michael@0 | 76 | virtual CompositingRenderTarget* GetCurrentRenderTarget() const MOZ_OVERRIDE |
michael@0 | 77 | { |
michael@0 | 78 | return mRenderTarget; |
michael@0 | 79 | } |
michael@0 | 80 | |
michael@0 | 81 | virtual void DrawQuad(const gfx::Rect& aRect, |
michael@0 | 82 | const gfx::Rect& aClipRect, |
michael@0 | 83 | const EffectChain &aEffectChain, |
michael@0 | 84 | gfx::Float aOpacity, |
michael@0 | 85 | const gfx::Matrix4x4 &aTransform) MOZ_OVERRIDE; |
michael@0 | 86 | |
michael@0 | 87 | virtual void BeginFrame(const nsIntRegion& aInvalidRegion, |
michael@0 | 88 | const gfx::Rect *aClipRectIn, |
michael@0 | 89 | const gfx::Matrix& aTransform, |
michael@0 | 90 | const gfx::Rect& aRenderBounds, |
michael@0 | 91 | gfx::Rect *aClipRectOut = nullptr, |
michael@0 | 92 | gfx::Rect *aRenderBoundsOut = nullptr) MOZ_OVERRIDE; |
michael@0 | 93 | virtual void EndFrame() MOZ_OVERRIDE; |
michael@0 | 94 | virtual void EndFrameForExternalComposition(const gfx::Matrix& aTransform) MOZ_OVERRIDE |
michael@0 | 95 | { |
michael@0 | 96 | NS_RUNTIMEABORT("We shouldn't ever hit this"); |
michael@0 | 97 | } |
michael@0 | 98 | virtual void AbortFrame() MOZ_OVERRIDE; |
michael@0 | 99 | |
michael@0 | 100 | virtual bool SupportsPartialTextureUpdate() { return true; } |
michael@0 | 101 | virtual bool CanUseCanvasLayerForSize(const gfx::IntSize &aSize) MOZ_OVERRIDE { return true; } |
michael@0 | 102 | virtual int32_t GetMaxTextureSize() const MOZ_OVERRIDE { return INT32_MAX; } |
michael@0 | 103 | virtual void SetDestinationSurfaceSize(const gfx::IntSize& aSize) MOZ_OVERRIDE { } |
michael@0 | 104 | virtual void SetTargetContext(gfx::DrawTarget* aTarget) MOZ_OVERRIDE |
michael@0 | 105 | { |
michael@0 | 106 | mCopyTarget = aTarget; |
michael@0 | 107 | } |
michael@0 | 108 | |
michael@0 | 109 | virtual void SetScreenRenderOffset(const ScreenPoint& aOffset) MOZ_OVERRIDE { |
michael@0 | 110 | } |
michael@0 | 111 | |
michael@0 | 112 | virtual void MakeCurrent(MakeCurrentFlags aFlags = 0) { } |
michael@0 | 113 | |
michael@0 | 114 | virtual void PrepareViewport(const gfx::IntSize& aSize, |
michael@0 | 115 | const gfx::Matrix& aWorldTransform) MOZ_OVERRIDE { } |
michael@0 | 116 | |
michael@0 | 117 | virtual const char* Name() const { return "Basic"; } |
michael@0 | 118 | |
michael@0 | 119 | virtual LayersBackend GetBackendType() const MOZ_OVERRIDE { |
michael@0 | 120 | return LayersBackend::LAYERS_BASIC; |
michael@0 | 121 | } |
michael@0 | 122 | |
michael@0 | 123 | virtual nsIWidget* GetWidget() const MOZ_OVERRIDE { return mWidget; } |
michael@0 | 124 | |
michael@0 | 125 | gfx::DrawTarget *GetDrawTarget() { return mDrawTarget; } |
michael@0 | 126 | |
michael@0 | 127 | private: |
michael@0 | 128 | |
michael@0 | 129 | virtual gfx::IntSize GetWidgetSize() const MOZ_OVERRIDE { return mWidgetSize; } |
michael@0 | 130 | |
michael@0 | 131 | // Widget associated with this compositor |
michael@0 | 132 | nsIWidget *mWidget; |
michael@0 | 133 | gfx::IntSize mWidgetSize; |
michael@0 | 134 | |
michael@0 | 135 | // The final destination surface |
michael@0 | 136 | RefPtr<gfx::DrawTarget> mDrawTarget; |
michael@0 | 137 | // The current render target for drawing |
michael@0 | 138 | RefPtr<BasicCompositingRenderTarget> mRenderTarget; |
michael@0 | 139 | // An optional destination target to copy the results |
michael@0 | 140 | // to after drawing is completed. |
michael@0 | 141 | RefPtr<gfx::DrawTarget> mCopyTarget; |
michael@0 | 142 | |
michael@0 | 143 | gfx::IntRect mInvalidRect; |
michael@0 | 144 | nsIntRegion mInvalidRegion; |
michael@0 | 145 | }; |
michael@0 | 146 | |
michael@0 | 147 | } // namespace layers |
michael@0 | 148 | } // namespace mozilla |
michael@0 | 149 | |
michael@0 | 150 | #endif /* MOZILLA_GFX_BASICCOMPOSITOR_H */ |