|
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/. */ |
|
5 |
|
6 #include "ColorLayerD3D10.h" |
|
7 |
|
8 #include "../d3d9/Nv3DVUtils.h" |
|
9 |
|
10 namespace mozilla { |
|
11 namespace layers { |
|
12 |
|
13 ColorLayerD3D10::ColorLayerD3D10(LayerManagerD3D10 *aManager) |
|
14 : ColorLayer(aManager, nullptr) |
|
15 , LayerD3D10(aManager) |
|
16 { |
|
17 mImplData = static_cast<LayerD3D10*>(this); |
|
18 } |
|
19 |
|
20 Layer* |
|
21 ColorLayerD3D10::GetLayer() |
|
22 { |
|
23 return this; |
|
24 } |
|
25 |
|
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; |
|
37 |
|
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); |
|
42 |
|
43 ID3D10EffectTechnique *technique = SelectShader(SHADER_SOLID | LoadMaskTexture()); |
|
44 |
|
45 nsIntRect bounds = GetBounds(); |
|
46 |
|
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 ); |
|
54 |
|
55 technique->GetPassByIndex(0)->Apply(0); |
|
56 device()->Draw(4, 0); |
|
57 } |
|
58 |
|
59 } /* layers */ |
|
60 } /* mozilla */ |