Files
tubestation/gfx/layers/basic/BasicCanvasLayer.cpp
Nicholas Nethercote e04159e24b Bug 1211324 (part 4) - Replace GraphicsFilter constants with gfx::Filter equivalents. r=mattwoodrow.
The conversion is as follows:

- GraphicsFilter::FILTER_NEAREST == gfx::Filter::POINT
- GraphicsFilter::FILTER_GOOD    == gfx::Filter::GOOD
- GraphicsFilter::FILTER_BEST    == gfx::Filter::LINEAR

Also typedef GraphicsFilter to gfx::Filter; this will be removed in the next
patch.

These changes mean ToFilter() and ThebesFilter() are no longer needed.
2015-10-05 17:12:46 -07:00

74 lines
2.0 KiB
C++

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* 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/. */
#include "BasicCanvasLayer.h"
#include "basic/BasicLayers.h" // for BasicLayerManager
#include "basic/BasicLayersImpl.h" // for GetEffectiveOperator
#include "mozilla/mozalloc.h" // for operator new
#include "nsAutoPtr.h" // for nsRefPtr
#include "nsCOMPtr.h" // for already_AddRefed
#include "nsISupportsImpl.h" // for Layer::AddRef, etc
#include "gfx2DGlue.h"
class gfxContext;
using namespace mozilla::gfx;
using namespace mozilla::gl;
namespace mozilla {
namespace layers {
void
BasicCanvasLayer::Paint(DrawTarget* aDT,
const Point& aDeviceOffset,
Layer* aMaskLayer)
{
if (IsHidden())
return;
if (IsDirty()) {
Painted();
FirePreTransactionCallback();
UpdateTarget();
FireDidTransactionCallback();
}
if (!mSurface) {
return;
}
const bool needsYFlip = (mOriginPos == gl::OriginPos::BottomLeft);
Matrix oldTM;
if (needsYFlip) {
oldTM = aDT->GetTransform();
aDT->SetTransform(Matrix(oldTM).
PreTranslate(0.0f, mBounds.height).
PreScale(1.0f, -1.0f));
}
FillRectWithMask(aDT, aDeviceOffset,
Rect(0, 0, mBounds.width, mBounds.height),
mSurface, mFilter,
DrawOptions(GetEffectiveOpacity(), GetEffectiveOperator(this)),
aMaskLayer);
if (needsYFlip) {
aDT->SetTransform(oldTM);
}
}
already_AddRefed<CanvasLayer>
BasicLayerManager::CreateCanvasLayer()
{
NS_ASSERTION(InConstruction(), "Only allowed in construction phase");
nsRefPtr<CanvasLayer> layer = new BasicCanvasLayer(this);
return layer.forget();
}
} // namespace layers
} // namespace mozilla