1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/layers/d3d9/ColorLayerD3D9.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,64 @@ 1.4 +/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- 1.5 + * This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#include "ColorLayerD3D9.h" 1.10 + 1.11 +namespace mozilla { 1.12 +namespace layers { 1.13 + 1.14 +Layer* 1.15 +ColorLayerD3D9::GetLayer() 1.16 +{ 1.17 + return this; 1.18 +} 1.19 + 1.20 +static void 1.21 +RenderColorLayerD3D9(ColorLayer* aLayer, LayerManagerD3D9 *aManager) 1.22 +{ 1.23 + // XXX we might be able to improve performance by using 1.24 + // IDirect3DDevice9::Clear 1.25 + if (aManager->CompositingDisabled()) { 1.26 + return; 1.27 + } 1.28 + 1.29 + nsIntRect bounds = aLayer->GetBounds(); 1.30 + 1.31 + aManager->device()->SetVertexShaderConstantF( 1.32 + CBvLayerQuad, 1.33 + ShaderConstantRect(bounds.x, 1.34 + bounds.y, 1.35 + bounds.width, 1.36 + bounds.height), 1.37 + 1); 1.38 + 1.39 + const gfx::Matrix4x4& transform = aLayer->GetEffectiveTransform(); 1.40 + aManager->device()->SetVertexShaderConstantF(CBmLayerTransform, &transform._11, 4); 1.41 + 1.42 + gfxRGBA layerColor(aLayer->GetColor()); 1.43 + float color[4]; 1.44 + float opacity = aLayer->GetEffectiveOpacity() * layerColor.a; 1.45 + // output color is premultiplied, so we need to adjust all channels. 1.46 + // mColor is not premultiplied. 1.47 + color[0] = (float)(layerColor.r * opacity); 1.48 + color[1] = (float)(layerColor.g * opacity); 1.49 + color[2] = (float)(layerColor.b * opacity); 1.50 + color[3] = (float)(opacity); 1.51 + 1.52 + aManager->device()->SetPixelShaderConstantF(CBvColor, color, 1); 1.53 + 1.54 + aManager->SetShaderMode(DeviceManagerD3D9::SOLIDCOLORLAYER, 1.55 + aLayer->GetMaskLayer()); 1.56 + 1.57 + aManager->device()->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2); 1.58 +} 1.59 + 1.60 +void 1.61 +ColorLayerD3D9::RenderLayer() 1.62 +{ 1.63 + return RenderColorLayerD3D9(this, mD3DManager); 1.64 +} 1.65 + 1.66 +} /* layers */ 1.67 +} /* mozilla */