gfx/layers/basic/BasicCanvasLayer.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/layers/basic/BasicCanvasLayer.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,68 @@
     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 +#include "BasicCanvasLayer.h"
    1.10 +#include "basic/BasicLayers.h"          // for BasicLayerManager
    1.11 +#include "basic/BasicLayersImpl.h"      // for GetEffectiveOperator
    1.12 +#include "mozilla/mozalloc.h"           // for operator new
    1.13 +#include "nsAutoPtr.h"                  // for nsRefPtr
    1.14 +#include "nsCOMPtr.h"                   // for already_AddRefed
    1.15 +#include "nsISupportsImpl.h"            // for Layer::AddRef, etc
    1.16 +#include "gfx2DGlue.h"
    1.17 +
    1.18 +class gfxContext;
    1.19 +
    1.20 +using namespace mozilla::gfx;
    1.21 +using namespace mozilla::gl;
    1.22 +
    1.23 +namespace mozilla {
    1.24 +namespace layers {
    1.25 +
    1.26 +void
    1.27 +BasicCanvasLayer::Paint(DrawTarget* aDT,
    1.28 +                        const Point& aDeviceOffset,
    1.29 +                        Layer* aMaskLayer)
    1.30 +{
    1.31 +  if (IsHidden())
    1.32 +    return;
    1.33 +
    1.34 +  FirePreTransactionCallback();
    1.35 +  UpdateTarget();
    1.36 +  FireDidTransactionCallback();
    1.37 +
    1.38 +  if (!mSurface) {
    1.39 +    return;
    1.40 +  }
    1.41 +
    1.42 +  Matrix m;
    1.43 +  if (mNeedsYFlip) {
    1.44 +    m = aDT->GetTransform();
    1.45 +    Matrix newTransform = m;
    1.46 +    newTransform.Translate(0.0f, mBounds.height);
    1.47 +    newTransform.Scale(1.0f, -1.0f);
    1.48 +    aDT->SetTransform(newTransform);
    1.49 +  }
    1.50 +
    1.51 +  FillRectWithMask(aDT, aDeviceOffset,
    1.52 +                   Rect(0, 0, mBounds.width, mBounds.height),
    1.53 +                   mSurface, ToFilter(mFilter),
    1.54 +                   DrawOptions(GetEffectiveOpacity(), GetEffectiveOperator(this)),
    1.55 +                   aMaskLayer);
    1.56 +
    1.57 +  if (mNeedsYFlip) {
    1.58 +    aDT->SetTransform(m);
    1.59 +  }
    1.60 +}
    1.61 +
    1.62 +already_AddRefed<CanvasLayer>
    1.63 +BasicLayerManager::CreateCanvasLayer()
    1.64 +{
    1.65 +  NS_ASSERTION(InConstruction(), "Only allowed in construction phase");
    1.66 +  nsRefPtr<CanvasLayer> layer = new BasicCanvasLayer(this);
    1.67 +  return layer.forget();
    1.68 +}
    1.69 +
    1.70 +}
    1.71 +}

mercurial