Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/gfx/thebes/gfxAlphaRecovery.cpp
Line
Count
Source (jump to first uncovered line)
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/. */
5
6
#include "gfxAlphaRecovery.h"
7
8
#include "gfxImageSurface.h"
9
10
#define MOZILLA_SSE_INCLUDE_HEADER_FOR_SSE2
11
#include "mozilla/SSE.h"
12
13
/* static */ bool
14
gfxAlphaRecovery::RecoverAlpha(gfxImageSurface* blackSurf,
15
                               const gfxImageSurface* whiteSurf)
16
0
{
17
0
    mozilla::gfx::IntSize size = blackSurf->GetSize();
18
0
19
0
    if (size != whiteSurf->GetSize() ||
20
0
        (blackSurf->Format() != mozilla::gfx::SurfaceFormat::A8R8G8B8_UINT32 &&
21
0
         blackSurf->Format() != mozilla::gfx::SurfaceFormat::X8R8G8B8_UINT32) ||
22
0
        (whiteSurf->Format() != mozilla::gfx::SurfaceFormat::A8R8G8B8_UINT32 &&
23
0
         whiteSurf->Format() != mozilla::gfx::SurfaceFormat::X8R8G8B8_UINT32))
24
0
        return false;
25
0
26
0
#ifdef MOZILLA_MAY_SUPPORT_SSE2
27
0
    if (mozilla::supports_sse2() &&
28
0
        RecoverAlphaSSE2(blackSurf, whiteSurf)) {
29
0
        return true;
30
0
    }
31
0
#endif
32
0
33
0
    blackSurf->Flush();
34
0
    whiteSurf->Flush();
35
0
36
0
    unsigned char* blackData = blackSurf->Data();
37
0
    unsigned char* whiteData = whiteSurf->Data();
38
0
39
0
    for (int32_t i = 0; i < size.height; ++i) {
40
0
        uint32_t* blackPixel = reinterpret_cast<uint32_t*>(blackData);
41
0
        const uint32_t* whitePixel = reinterpret_cast<uint32_t*>(whiteData);
42
0
        for (int32_t j = 0; j < size.width; ++j) {
43
0
            uint32_t recovered = RecoverPixel(blackPixel[j], whitePixel[j]);
44
0
            blackPixel[j] = recovered;
45
0
        }
46
0
        blackData += blackSurf->Stride();
47
0
        whiteData += whiteSurf->Stride();
48
0
    }
49
0
50
0
    blackSurf->MarkDirty();
51
0
52
0
    return true;
53
0
}