|
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 "ColorLayerD3D9.h" |
|
7 |
|
8 namespace mozilla { |
|
9 namespace layers { |
|
10 |
|
11 Layer* |
|
12 ColorLayerD3D9::GetLayer() |
|
13 { |
|
14 return this; |
|
15 } |
|
16 |
|
17 static void |
|
18 RenderColorLayerD3D9(ColorLayer* aLayer, LayerManagerD3D9 *aManager) |
|
19 { |
|
20 // XXX we might be able to improve performance by using |
|
21 // IDirect3DDevice9::Clear |
|
22 if (aManager->CompositingDisabled()) { |
|
23 return; |
|
24 } |
|
25 |
|
26 nsIntRect bounds = aLayer->GetBounds(); |
|
27 |
|
28 aManager->device()->SetVertexShaderConstantF( |
|
29 CBvLayerQuad, |
|
30 ShaderConstantRect(bounds.x, |
|
31 bounds.y, |
|
32 bounds.width, |
|
33 bounds.height), |
|
34 1); |
|
35 |
|
36 const gfx::Matrix4x4& transform = aLayer->GetEffectiveTransform(); |
|
37 aManager->device()->SetVertexShaderConstantF(CBmLayerTransform, &transform._11, 4); |
|
38 |
|
39 gfxRGBA layerColor(aLayer->GetColor()); |
|
40 float color[4]; |
|
41 float opacity = aLayer->GetEffectiveOpacity() * layerColor.a; |
|
42 // output color is premultiplied, so we need to adjust all channels. |
|
43 // mColor is not premultiplied. |
|
44 color[0] = (float)(layerColor.r * opacity); |
|
45 color[1] = (float)(layerColor.g * opacity); |
|
46 color[2] = (float)(layerColor.b * opacity); |
|
47 color[3] = (float)(opacity); |
|
48 |
|
49 aManager->device()->SetPixelShaderConstantF(CBvColor, color, 1); |
|
50 |
|
51 aManager->SetShaderMode(DeviceManagerD3D9::SOLIDCOLORLAYER, |
|
52 aLayer->GetMaskLayer()); |
|
53 |
|
54 aManager->device()->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2); |
|
55 } |
|
56 |
|
57 void |
|
58 ColorLayerD3D9::RenderLayer() |
|
59 { |
|
60 return RenderColorLayerD3D9(this, mD3DManager); |
|
61 } |
|
62 |
|
63 } /* layers */ |
|
64 } /* mozilla */ |