gfx/layers/d3d10/ColorLayerD3D10.cpp

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

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 "ColorLayerD3D10.h"
michael@0 7
michael@0 8 #include "../d3d9/Nv3DVUtils.h"
michael@0 9
michael@0 10 namespace mozilla {
michael@0 11 namespace layers {
michael@0 12
michael@0 13 ColorLayerD3D10::ColorLayerD3D10(LayerManagerD3D10 *aManager)
michael@0 14 : ColorLayer(aManager, nullptr)
michael@0 15 , LayerD3D10(aManager)
michael@0 16 {
michael@0 17 mImplData = static_cast<LayerD3D10*>(this);
michael@0 18 }
michael@0 19
michael@0 20 Layer*
michael@0 21 ColorLayerD3D10::GetLayer()
michael@0 22 {
michael@0 23 return this;
michael@0 24 }
michael@0 25
michael@0 26 void
michael@0 27 ColorLayerD3D10::RenderLayer()
michael@0 28 {
michael@0 29 float color[4];
michael@0 30 // output color is premultiplied, so we need to adjust all channels.
michael@0 31 // mColor is not premultiplied.
michael@0 32 float opacity = GetEffectiveOpacity() * mColor.a;
michael@0 33 color[0] = (float)(mColor.r * opacity);
michael@0 34 color[1] = (float)(mColor.g * opacity);
michael@0 35 color[2] = (float)(mColor.b * opacity);
michael@0 36 color[3] = opacity;
michael@0 37
michael@0 38 const gfx::Matrix4x4& transform = GetEffectiveTransform();
michael@0 39 void* raw = &const_cast<gfx::Matrix4x4&>(transform)._11;
michael@0 40 effect()->GetVariableByName("mLayerTransform")->SetRawValue(raw, 0, 64);
michael@0 41 effect()->GetVariableByName("fLayerColor")->AsVector()->SetFloatVector(color);
michael@0 42
michael@0 43 ID3D10EffectTechnique *technique = SelectShader(SHADER_SOLID | LoadMaskTexture());
michael@0 44
michael@0 45 nsIntRect bounds = GetBounds();
michael@0 46
michael@0 47 effect()->GetVariableByName("vLayerQuad")->AsVector()->SetFloatVector(
michael@0 48 ShaderConstantRectD3D10(
michael@0 49 (float)bounds.x,
michael@0 50 (float)bounds.y,
michael@0 51 (float)bounds.width,
michael@0 52 (float)bounds.height)
michael@0 53 );
michael@0 54
michael@0 55 technique->GetPassByIndex(0)->Apply(0);
michael@0 56 device()->Draw(4, 0);
michael@0 57 }
michael@0 58
michael@0 59 } /* layers */
michael@0 60 } /* mozilla */

mercurial