2010-09-30 15:53:49 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
2012-05-21 04:12:37 -07:00
|
|
|
* 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/. */
|
2010-09-30 15:53:49 -07:00
|
|
|
|
|
|
|
#include "ColorLayerD3D10.h"
|
|
|
|
|
2011-08-09 12:38:26 -07:00
|
|
|
#include "../d3d9/Nv3DVUtils.h"
|
|
|
|
|
2010-09-30 15:53:49 -07:00
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
|
|
|
ColorLayerD3D10::ColorLayerD3D10(LayerManagerD3D10 *aManager)
|
|
|
|
: ColorLayer(aManager, NULL)
|
|
|
|
, LayerD3D10(aManager)
|
|
|
|
{
|
|
|
|
mImplData = static_cast<LayerD3D10*>(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
Layer*
|
|
|
|
ColorLayerD3D10::GetLayer()
|
|
|
|
{
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-11-08 01:06:15 -08:00
|
|
|
ColorLayerD3D10::RenderLayer()
|
2010-09-30 15:53:49 -07:00
|
|
|
{
|
|
|
|
float color[4];
|
2011-01-19 00:27:54 -08:00
|
|
|
// output color is premultiplied, so we need to adjust all channels.
|
|
|
|
// mColor is not premultiplied.
|
|
|
|
float opacity = GetEffectiveOpacity() * mColor.a;
|
2010-11-08 01:06:15 -08:00
|
|
|
color[0] = (float)(mColor.r * opacity);
|
|
|
|
color[1] = (float)(mColor.g * opacity);
|
|
|
|
color[2] = (float)(mColor.b * opacity);
|
2011-01-25 00:45:49 -08:00
|
|
|
color[3] = opacity;
|
2010-09-30 15:53:49 -07:00
|
|
|
|
2010-11-08 01:06:15 -08:00
|
|
|
const gfx3DMatrix& transform = GetEffectiveTransform();
|
|
|
|
void* raw = &const_cast<gfx3DMatrix&>(transform)._11;
|
|
|
|
effect()->GetVariableByName("mLayerTransform")->SetRawValue(raw, 0, 64);
|
2010-09-30 15:53:49 -07:00
|
|
|
effect()->GetVariableByName("fLayerColor")->AsVector()->SetFloatVector(color);
|
|
|
|
|
2012-03-01 09:29:30 -08:00
|
|
|
ID3D10EffectTechnique *technique = SelectShader(SHADER_SOLID | LoadMaskTexture());
|
2010-09-30 15:53:49 -07:00
|
|
|
|
|
|
|
nsIntRegionRectIterator iter(mVisibleRegion);
|
|
|
|
|
|
|
|
const nsIntRect *iterRect;
|
|
|
|
while ((iterRect = iter.Next())) {
|
|
|
|
effect()->GetVariableByName("vLayerQuad")->AsVector()->SetFloatVector(
|
|
|
|
ShaderConstantRectD3D10(
|
|
|
|
(float)iterRect->x,
|
|
|
|
(float)iterRect->y,
|
|
|
|
(float)iterRect->width,
|
|
|
|
(float)iterRect->height)
|
|
|
|
);
|
|
|
|
|
|
|
|
technique->GetPassByIndex(0)->Apply(0);
|
|
|
|
device()->Draw(4, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} /* layers */
|
|
|
|
} /* mozilla */
|