gfx/layers/d3d9/ColorLayerD3D9.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.

     1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
     2  * This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #include "ColorLayerD3D9.h"
     8 namespace mozilla {
     9 namespace layers {
    11 Layer*
    12 ColorLayerD3D9::GetLayer()
    13 {
    14   return this;
    15 }
    17 static void
    18 RenderColorLayerD3D9(ColorLayer* aLayer, LayerManagerD3D9 *aManager)
    19 {
    20   // XXX we might be able to improve performance by using
    21   // IDirect3DDevice9::Clear
    22   if (aManager->CompositingDisabled()) {
    23     return;
    24   }
    26   nsIntRect bounds = aLayer->GetBounds();
    28   aManager->device()->SetVertexShaderConstantF(
    29     CBvLayerQuad,
    30     ShaderConstantRect(bounds.x,
    31                        bounds.y,
    32                        bounds.width,
    33                        bounds.height),
    34     1);
    36   const gfx::Matrix4x4& transform = aLayer->GetEffectiveTransform();
    37   aManager->device()->SetVertexShaderConstantF(CBmLayerTransform, &transform._11, 4);
    39   gfxRGBA layerColor(aLayer->GetColor());
    40   float color[4];
    41   float opacity = aLayer->GetEffectiveOpacity() * layerColor.a;
    42   // output color is premultiplied, so we need to adjust all channels.
    43   // mColor is not premultiplied.
    44   color[0] = (float)(layerColor.r * opacity);
    45   color[1] = (float)(layerColor.g * opacity);
    46   color[2] = (float)(layerColor.b * opacity);
    47   color[3] = (float)(opacity);
    49   aManager->device()->SetPixelShaderConstantF(CBvColor, color, 1);
    51   aManager->SetShaderMode(DeviceManagerD3D9::SOLIDCOLORLAYER,
    52                           aLayer->GetMaskLayer());
    54   aManager->device()->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
    55 }
    57 void
    58 ColorLayerD3D9::RenderLayer()
    59 {
    60   return RenderColorLayerD3D9(this, mD3DManager);
    61 }
    63 } /* layers */
    64 } /* mozilla */

mercurial