1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/layers/d3d10/ColorLayerD3D10.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,60 @@ 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 "ColorLayerD3D10.h" 1.10 + 1.11 +#include "../d3d9/Nv3DVUtils.h" 1.12 + 1.13 +namespace mozilla { 1.14 +namespace layers { 1.15 + 1.16 +ColorLayerD3D10::ColorLayerD3D10(LayerManagerD3D10 *aManager) 1.17 + : ColorLayer(aManager, nullptr) 1.18 + , LayerD3D10(aManager) 1.19 +{ 1.20 + mImplData = static_cast<LayerD3D10*>(this); 1.21 +} 1.22 + 1.23 +Layer* 1.24 +ColorLayerD3D10::GetLayer() 1.25 +{ 1.26 + return this; 1.27 +} 1.28 + 1.29 +void 1.30 +ColorLayerD3D10::RenderLayer() 1.31 +{ 1.32 + float color[4]; 1.33 + // output color is premultiplied, so we need to adjust all channels. 1.34 + // mColor is not premultiplied. 1.35 + float opacity = GetEffectiveOpacity() * mColor.a; 1.36 + color[0] = (float)(mColor.r * opacity); 1.37 + color[1] = (float)(mColor.g * opacity); 1.38 + color[2] = (float)(mColor.b * opacity); 1.39 + color[3] = opacity; 1.40 + 1.41 + const gfx::Matrix4x4& transform = GetEffectiveTransform(); 1.42 + void* raw = &const_cast<gfx::Matrix4x4&>(transform)._11; 1.43 + effect()->GetVariableByName("mLayerTransform")->SetRawValue(raw, 0, 64); 1.44 + effect()->GetVariableByName("fLayerColor")->AsVector()->SetFloatVector(color); 1.45 + 1.46 + ID3D10EffectTechnique *technique = SelectShader(SHADER_SOLID | LoadMaskTexture()); 1.47 + 1.48 + nsIntRect bounds = GetBounds(); 1.49 + 1.50 + effect()->GetVariableByName("vLayerQuad")->AsVector()->SetFloatVector( 1.51 + ShaderConstantRectD3D10( 1.52 + (float)bounds.x, 1.53 + (float)bounds.y, 1.54 + (float)bounds.width, 1.55 + (float)bounds.height) 1.56 + ); 1.57 + 1.58 + technique->GetPassByIndex(0)->Apply(0); 1.59 + device()->Draw(4, 0); 1.60 +} 1.61 + 1.62 +} /* layers */ 1.63 +} /* mozilla */