LCOV - code coverage report
Current view: top level - gfx/layers - BufferUnrotate.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 40 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 1 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
       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 <algorithm> // min & max
       7             : #include <cstdlib>
       8             : #include <stdint.h>
       9             : #include <stdio.h>
      10             : #include <stdlib.h>
      11             : #include <string.h>
      12             : 
      13           0 : void BufferUnrotate(uint8_t* aBuffer, int aByteWidth, int aHeight,
      14             :                     int aByteStride, int aXBoundary, int aYBoundary)
      15             : {
      16           0 :   if (aXBoundary != 0) {
      17           0 :     uint8_t* line = new uint8_t[aByteWidth];
      18           0 :     uint32_t smallStart = 0;
      19           0 :     uint32_t smallLen = aXBoundary;
      20           0 :     uint32_t smallDest = aByteWidth - aXBoundary;
      21           0 :     uint32_t largeStart = aXBoundary;
      22           0 :     uint32_t largeLen = aByteWidth - aXBoundary;
      23           0 :     uint32_t largeDest = 0;
      24           0 :     if (aXBoundary > aByteWidth / 2) {
      25           0 :       smallStart = aXBoundary;
      26           0 :       smallLen = aByteWidth - aXBoundary;
      27           0 :       smallDest = 0;
      28           0 :       largeStart = 0;
      29           0 :       largeLen = aXBoundary;
      30           0 :       largeDest = smallLen;
      31             :     }
      32             : 
      33           0 :     for (int y = 0; y < aHeight; y++) {
      34           0 :       int yOffset = y * aByteStride;
      35           0 :       memcpy(line, &aBuffer[yOffset + smallStart], smallLen);
      36           0 :       memmove(&aBuffer[yOffset + largeDest], &aBuffer[yOffset + largeStart], largeLen);
      37           0 :       memcpy(&aBuffer[yOffset + smallDest], line, smallLen);
      38             :     }
      39             : 
      40           0 :     delete[] line;
      41             :   }
      42             : 
      43           0 :   if (aYBoundary != 0) {
      44           0 :     uint32_t smallestHeight = std::min(aHeight - aYBoundary, aYBoundary);
      45           0 :     uint32_t largestHeight = std::max(aHeight - aYBoundary, aYBoundary);
      46           0 :     uint32_t smallOffset = 0;
      47           0 :     uint32_t largeOffset = aYBoundary * aByteStride;
      48           0 :     uint32_t largeDestOffset = 0;
      49           0 :     uint32_t smallDestOffset = largestHeight * aByteStride;
      50           0 :     if (aYBoundary > aHeight / 2) {
      51           0 :       smallOffset = aYBoundary * aByteStride;
      52           0 :       largeOffset = 0;
      53           0 :       largeDestOffset = smallestHeight * aByteStride;
      54           0 :       smallDestOffset = 0;
      55             :     }
      56             : 
      57           0 :     uint8_t* smallestSide = new uint8_t[aByteStride * smallestHeight];
      58           0 :     memcpy(smallestSide, &aBuffer[smallOffset], aByteStride * smallestHeight);
      59           0 :     memmove(&aBuffer[largeDestOffset], &aBuffer[largeOffset], aByteStride * largestHeight);
      60           0 :     memcpy(&aBuffer[smallDestOffset], smallestSide, aByteStride * smallestHeight);
      61           0 :     delete[] smallestSide;
      62             :   }
      63           0 : }
      64             : 

Generated by: LCOV version 1.13