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 "ColorLayerD3D9.h" michael@0: michael@0: namespace mozilla { michael@0: namespace layers { michael@0: michael@0: Layer* michael@0: ColorLayerD3D9::GetLayer() michael@0: { michael@0: return this; michael@0: } michael@0: michael@0: static void michael@0: RenderColorLayerD3D9(ColorLayer* aLayer, LayerManagerD3D9 *aManager) michael@0: { michael@0: // XXX we might be able to improve performance by using michael@0: // IDirect3DDevice9::Clear michael@0: if (aManager->CompositingDisabled()) { michael@0: return; michael@0: } michael@0: michael@0: nsIntRect bounds = aLayer->GetBounds(); michael@0: michael@0: aManager->device()->SetVertexShaderConstantF( michael@0: CBvLayerQuad, michael@0: ShaderConstantRect(bounds.x, michael@0: bounds.y, michael@0: bounds.width, michael@0: bounds.height), michael@0: 1); michael@0: michael@0: const gfx::Matrix4x4& transform = aLayer->GetEffectiveTransform(); michael@0: aManager->device()->SetVertexShaderConstantF(CBmLayerTransform, &transform._11, 4); michael@0: michael@0: gfxRGBA layerColor(aLayer->GetColor()); michael@0: float color[4]; michael@0: float opacity = aLayer->GetEffectiveOpacity() * layerColor.a; michael@0: // output color is premultiplied, so we need to adjust all channels. michael@0: // mColor is not premultiplied. michael@0: color[0] = (float)(layerColor.r * opacity); michael@0: color[1] = (float)(layerColor.g * opacity); michael@0: color[2] = (float)(layerColor.b * opacity); michael@0: color[3] = (float)(opacity); michael@0: michael@0: aManager->device()->SetPixelShaderConstantF(CBvColor, color, 1); michael@0: michael@0: aManager->SetShaderMode(DeviceManagerD3D9::SOLIDCOLORLAYER, michael@0: aLayer->GetMaskLayer()); michael@0: michael@0: aManager->device()->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2); michael@0: } michael@0: michael@0: void michael@0: ColorLayerD3D9::RenderLayer() michael@0: { michael@0: return RenderColorLayerD3D9(this, mD3DManager); michael@0: } michael@0: michael@0: } /* layers */ michael@0: } /* mozilla */