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: 2; 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 GFX_BASICTHEBESLAYER_H |
michael@0 | 7 | #define GFX_BASICTHEBESLAYER_H |
michael@0 | 8 | |
michael@0 | 9 | #include "Layers.h" // for ThebesLayer, LayerManager, etc |
michael@0 | 10 | #include "RotatedBuffer.h" // for RotatedContentBuffer, etc |
michael@0 | 11 | #include "BasicImplData.h" // for BasicImplData |
michael@0 | 12 | #include "BasicLayers.h" // for BasicLayerManager |
michael@0 | 13 | #include "gfxPoint.h" // for gfxPoint |
michael@0 | 14 | #include "mozilla/RefPtr.h" // for RefPtr |
michael@0 | 15 | #include "mozilla/gfx/BasePoint.h" // for BasePoint |
michael@0 | 16 | #include "mozilla/layers/ContentClient.h" // for ContentClientBasic |
michael@0 | 17 | #include "mozilla/mozalloc.h" // for operator delete |
michael@0 | 18 | #include "nsDebug.h" // for NS_ASSERTION |
michael@0 | 19 | #include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc |
michael@0 | 20 | #include "nsRegion.h" // for nsIntRegion |
michael@0 | 21 | class gfxContext; |
michael@0 | 22 | |
michael@0 | 23 | namespace mozilla { |
michael@0 | 24 | namespace layers { |
michael@0 | 25 | |
michael@0 | 26 | class ReadbackProcessor; |
michael@0 | 27 | |
michael@0 | 28 | class BasicThebesLayer : public ThebesLayer, public BasicImplData { |
michael@0 | 29 | public: |
michael@0 | 30 | typedef RotatedContentBuffer::PaintState PaintState; |
michael@0 | 31 | typedef RotatedContentBuffer::ContentType ContentType; |
michael@0 | 32 | |
michael@0 | 33 | BasicThebesLayer(BasicLayerManager* aLayerManager) : |
michael@0 | 34 | ThebesLayer(aLayerManager, |
michael@0 | 35 | static_cast<BasicImplData*>(MOZ_THIS_IN_INITIALIZER_LIST())), |
michael@0 | 36 | mContentClient(nullptr) |
michael@0 | 37 | { |
michael@0 | 38 | MOZ_COUNT_CTOR(BasicThebesLayer); |
michael@0 | 39 | } |
michael@0 | 40 | virtual ~BasicThebesLayer() |
michael@0 | 41 | { |
michael@0 | 42 | MOZ_COUNT_DTOR(BasicThebesLayer); |
michael@0 | 43 | } |
michael@0 | 44 | |
michael@0 | 45 | virtual void SetVisibleRegion(const nsIntRegion& aRegion) |
michael@0 | 46 | { |
michael@0 | 47 | NS_ASSERTION(BasicManager()->InConstruction(), |
michael@0 | 48 | "Can only set properties in construction phase"); |
michael@0 | 49 | ThebesLayer::SetVisibleRegion(aRegion); |
michael@0 | 50 | } |
michael@0 | 51 | virtual void InvalidateRegion(const nsIntRegion& aRegion) |
michael@0 | 52 | { |
michael@0 | 53 | NS_ASSERTION(BasicManager()->InConstruction(), |
michael@0 | 54 | "Can only set properties in construction phase"); |
michael@0 | 55 | mInvalidRegion.Or(mInvalidRegion, aRegion); |
michael@0 | 56 | mInvalidRegion.SimplifyOutward(20); |
michael@0 | 57 | mValidRegion.Sub(mValidRegion, mInvalidRegion); |
michael@0 | 58 | } |
michael@0 | 59 | |
michael@0 | 60 | virtual void PaintThebes(gfxContext* aContext, |
michael@0 | 61 | Layer* aMaskLayer, |
michael@0 | 62 | LayerManager::DrawThebesLayerCallback aCallback, |
michael@0 | 63 | void* aCallbackData, |
michael@0 | 64 | ReadbackProcessor* aReadback); |
michael@0 | 65 | |
michael@0 | 66 | virtual void Validate(LayerManager::DrawThebesLayerCallback aCallback, |
michael@0 | 67 | void* aCallbackData) MOZ_OVERRIDE; |
michael@0 | 68 | |
michael@0 | 69 | virtual void ClearCachedResources() |
michael@0 | 70 | { |
michael@0 | 71 | if (mContentClient) { |
michael@0 | 72 | mContentClient->Clear(); |
michael@0 | 73 | } |
michael@0 | 74 | mValidRegion.SetEmpty(); |
michael@0 | 75 | } |
michael@0 | 76 | |
michael@0 | 77 | virtual void ComputeEffectiveTransforms(const gfx::Matrix4x4& aTransformToSurface) |
michael@0 | 78 | { |
michael@0 | 79 | if (!BasicManager()->IsRetained()) { |
michael@0 | 80 | // Don't do any snapping of our transform, since we're just going to |
michael@0 | 81 | // draw straight through without intermediate buffers. |
michael@0 | 82 | mEffectiveTransform = GetLocalTransform() * aTransformToSurface; |
michael@0 | 83 | if (gfxPoint(0,0) != mResidualTranslation) { |
michael@0 | 84 | mResidualTranslation = gfxPoint(0,0); |
michael@0 | 85 | mValidRegion.SetEmpty(); |
michael@0 | 86 | } |
michael@0 | 87 | ComputeEffectiveTransformForMaskLayer(aTransformToSurface); |
michael@0 | 88 | return; |
michael@0 | 89 | } |
michael@0 | 90 | ThebesLayer::ComputeEffectiveTransforms(aTransformToSurface); |
michael@0 | 91 | } |
michael@0 | 92 | |
michael@0 | 93 | BasicLayerManager* BasicManager() |
michael@0 | 94 | { |
michael@0 | 95 | return static_cast<BasicLayerManager*>(mManager); |
michael@0 | 96 | } |
michael@0 | 97 | |
michael@0 | 98 | protected: |
michael@0 | 99 | virtual void |
michael@0 | 100 | PaintBuffer(gfxContext* aContext, |
michael@0 | 101 | const nsIntRegion& aRegionToDraw, |
michael@0 | 102 | const nsIntRegion& aExtendedRegionToDraw, |
michael@0 | 103 | const nsIntRegion& aRegionToInvalidate, |
michael@0 | 104 | bool aDidSelfCopy, |
michael@0 | 105 | DrawRegionClip aClip, |
michael@0 | 106 | LayerManager::DrawThebesLayerCallback aCallback, |
michael@0 | 107 | void* aCallbackData) |
michael@0 | 108 | { |
michael@0 | 109 | if (!aCallback) { |
michael@0 | 110 | BasicManager()->SetTransactionIncomplete(); |
michael@0 | 111 | return; |
michael@0 | 112 | } |
michael@0 | 113 | aCallback(this, aContext, aExtendedRegionToDraw, aClip, |
michael@0 | 114 | aRegionToInvalidate, aCallbackData); |
michael@0 | 115 | // Everything that's visible has been validated. Do this instead of just |
michael@0 | 116 | // OR-ing with aRegionToDraw, since that can lead to a very complex region |
michael@0 | 117 | // here (OR doesn't automatically simplify to the simplest possible |
michael@0 | 118 | // representation of a region.) |
michael@0 | 119 | nsIntRegion tmp; |
michael@0 | 120 | tmp.Or(mVisibleRegion, aExtendedRegionToDraw); |
michael@0 | 121 | mValidRegion.Or(mValidRegion, tmp); |
michael@0 | 122 | } |
michael@0 | 123 | |
michael@0 | 124 | RefPtr<ContentClientBasic> mContentClient; |
michael@0 | 125 | }; |
michael@0 | 126 | |
michael@0 | 127 | } |
michael@0 | 128 | } |
michael@0 | 129 | |
michael@0 | 130 | #endif |