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.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
michael@0 | 2 | * This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #include "ColorLayerD3D9.h" |
michael@0 | 7 | |
michael@0 | 8 | namespace mozilla { |
michael@0 | 9 | namespace layers { |
michael@0 | 10 | |
michael@0 | 11 | Layer* |
michael@0 | 12 | ColorLayerD3D9::GetLayer() |
michael@0 | 13 | { |
michael@0 | 14 | return this; |
michael@0 | 15 | } |
michael@0 | 16 | |
michael@0 | 17 | static void |
michael@0 | 18 | RenderColorLayerD3D9(ColorLayer* aLayer, LayerManagerD3D9 *aManager) |
michael@0 | 19 | { |
michael@0 | 20 | // XXX we might be able to improve performance by using |
michael@0 | 21 | // IDirect3DDevice9::Clear |
michael@0 | 22 | if (aManager->CompositingDisabled()) { |
michael@0 | 23 | return; |
michael@0 | 24 | } |
michael@0 | 25 | |
michael@0 | 26 | nsIntRect bounds = aLayer->GetBounds(); |
michael@0 | 27 | |
michael@0 | 28 | aManager->device()->SetVertexShaderConstantF( |
michael@0 | 29 | CBvLayerQuad, |
michael@0 | 30 | ShaderConstantRect(bounds.x, |
michael@0 | 31 | bounds.y, |
michael@0 | 32 | bounds.width, |
michael@0 | 33 | bounds.height), |
michael@0 | 34 | 1); |
michael@0 | 35 | |
michael@0 | 36 | const gfx::Matrix4x4& transform = aLayer->GetEffectiveTransform(); |
michael@0 | 37 | aManager->device()->SetVertexShaderConstantF(CBmLayerTransform, &transform._11, 4); |
michael@0 | 38 | |
michael@0 | 39 | gfxRGBA layerColor(aLayer->GetColor()); |
michael@0 | 40 | float color[4]; |
michael@0 | 41 | float opacity = aLayer->GetEffectiveOpacity() * layerColor.a; |
michael@0 | 42 | // output color is premultiplied, so we need to adjust all channels. |
michael@0 | 43 | // mColor is not premultiplied. |
michael@0 | 44 | color[0] = (float)(layerColor.r * opacity); |
michael@0 | 45 | color[1] = (float)(layerColor.g * opacity); |
michael@0 | 46 | color[2] = (float)(layerColor.b * opacity); |
michael@0 | 47 | color[3] = (float)(opacity); |
michael@0 | 48 | |
michael@0 | 49 | aManager->device()->SetPixelShaderConstantF(CBvColor, color, 1); |
michael@0 | 50 | |
michael@0 | 51 | aManager->SetShaderMode(DeviceManagerD3D9::SOLIDCOLORLAYER, |
michael@0 | 52 | aLayer->GetMaskLayer()); |
michael@0 | 53 | |
michael@0 | 54 | aManager->device()->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2); |
michael@0 | 55 | } |
michael@0 | 56 | |
michael@0 | 57 | void |
michael@0 | 58 | ColorLayerD3D9::RenderLayer() |
michael@0 | 59 | { |
michael@0 | 60 | return RenderColorLayerD3D9(this, mD3DManager); |
michael@0 | 61 | } |
michael@0 | 62 | |
michael@0 | 63 | } /* layers */ |
michael@0 | 64 | } /* mozilla */ |