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.
1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "ColorLayerD3D10.h"
8 #include "../d3d9/Nv3DVUtils.h"
10 namespace mozilla {
11 namespace layers {
13 ColorLayerD3D10::ColorLayerD3D10(LayerManagerD3D10 *aManager)
14 : ColorLayer(aManager, nullptr)
15 , LayerD3D10(aManager)
16 {
17 mImplData = static_cast<LayerD3D10*>(this);
18 }
20 Layer*
21 ColorLayerD3D10::GetLayer()
22 {
23 return this;
24 }
26 void
27 ColorLayerD3D10::RenderLayer()
28 {
29 float color[4];
30 // output color is premultiplied, so we need to adjust all channels.
31 // mColor is not premultiplied.
32 float opacity = GetEffectiveOpacity() * mColor.a;
33 color[0] = (float)(mColor.r * opacity);
34 color[1] = (float)(mColor.g * opacity);
35 color[2] = (float)(mColor.b * opacity);
36 color[3] = opacity;
38 const gfx::Matrix4x4& transform = GetEffectiveTransform();
39 void* raw = &const_cast<gfx::Matrix4x4&>(transform)._11;
40 effect()->GetVariableByName("mLayerTransform")->SetRawValue(raw, 0, 64);
41 effect()->GetVariableByName("fLayerColor")->AsVector()->SetFloatVector(color);
43 ID3D10EffectTechnique *technique = SelectShader(SHADER_SOLID | LoadMaskTexture());
45 nsIntRect bounds = GetBounds();
47 effect()->GetVariableByName("vLayerQuad")->AsVector()->SetFloatVector(
48 ShaderConstantRectD3D10(
49 (float)bounds.x,
50 (float)bounds.y,
51 (float)bounds.width,
52 (float)bounds.height)
53 );
55 technique->GetPassByIndex(0)->Apply(0);
56 device()->Draw(4, 0);
57 }
59 } /* layers */
60 } /* mozilla */