michael@0: /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "ColorLayerD3D10.h" michael@0: michael@0: #include "../d3d9/Nv3DVUtils.h" michael@0: michael@0: namespace mozilla { michael@0: namespace layers { michael@0: michael@0: ColorLayerD3D10::ColorLayerD3D10(LayerManagerD3D10 *aManager) michael@0: : ColorLayer(aManager, nullptr) michael@0: , LayerD3D10(aManager) michael@0: { michael@0: mImplData = static_cast(this); michael@0: } michael@0: michael@0: Layer* michael@0: ColorLayerD3D10::GetLayer() michael@0: { michael@0: return this; michael@0: } michael@0: michael@0: void michael@0: ColorLayerD3D10::RenderLayer() michael@0: { michael@0: float color[4]; michael@0: // output color is premultiplied, so we need to adjust all channels. michael@0: // mColor is not premultiplied. michael@0: float opacity = GetEffectiveOpacity() * mColor.a; michael@0: color[0] = (float)(mColor.r * opacity); michael@0: color[1] = (float)(mColor.g * opacity); michael@0: color[2] = (float)(mColor.b * opacity); michael@0: color[3] = opacity; michael@0: michael@0: const gfx::Matrix4x4& transform = GetEffectiveTransform(); michael@0: void* raw = &const_cast(transform)._11; michael@0: effect()->GetVariableByName("mLayerTransform")->SetRawValue(raw, 0, 64); michael@0: effect()->GetVariableByName("fLayerColor")->AsVector()->SetFloatVector(color); michael@0: michael@0: ID3D10EffectTechnique *technique = SelectShader(SHADER_SOLID | LoadMaskTexture()); michael@0: michael@0: nsIntRect bounds = GetBounds(); michael@0: michael@0: effect()->GetVariableByName("vLayerQuad")->AsVector()->SetFloatVector( michael@0: ShaderConstantRectD3D10( michael@0: (float)bounds.x, michael@0: (float)bounds.y, michael@0: (float)bounds.width, michael@0: (float)bounds.height) michael@0: ); michael@0: michael@0: technique->GetPassByIndex(0)->Apply(0); michael@0: device()->Draw(4, 0); michael@0: } michael@0: michael@0: } /* layers */ michael@0: } /* mozilla */