| Index: ui/gfx/blit_unittest.cc
|
| diff --git a/ui/gfx/blit_unittest.cc b/ui/gfx/blit_unittest.cc
|
| index cac364b848f8c7ae44b0d568531b70a79ab55f55..e6245916f76c33da40744ae8ba041523d6b09474 100644
|
| --- a/ui/gfx/blit_unittest.cc
|
| +++ b/ui/gfx/blit_unittest.cc
|
| @@ -2,8 +2,10 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "base/basictypes.h"
|
| +#include <stdint.h>
|
| +
|
| #include "base/memory/shared_memory.h"
|
| +#include "build/build_config.h"
|
| #include "skia/ext/platform_canvas.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| #include "ui/gfx/blit.h"
|
| @@ -18,17 +20,17 @@ namespace {
|
| // Example values = {{0x0, 0x01}, {0x12, 0xFF}} would give a canvas with:
|
| // 0x00000000 0x01010101
|
| // 0x12121212 0xFFFFFFFF
|
| -template<int w, int h>
|
| -void SetToCanvas(skia::PlatformCanvas* canvas, uint8 values[h][w]) {
|
| +template <int w, int h>
|
| +void SetToCanvas(skia::PlatformCanvas* canvas, uint8_t values[h][w]) {
|
| ASSERT_EQ(w, canvas->imageInfo().width());
|
| ASSERT_EQ(h, canvas->imageInfo().height());
|
|
|
| // This wouldn't be necessary if we extended the values in the inputs, but
|
| - // the uint8 values are a little bit easier to read and maintain.
|
| + // the uint8_t values are a little bit easier to read and maintain.
|
| uint32_t extendedValues[w*h];
|
| for (int y = 0; y < h; y++) {
|
| for (int x = 0; x < w; x++) {
|
| - uint8 value = values[y][x];
|
| + uint8_t value = values[y][x];
|
| extendedValues[y*w+x] =
|
| (value << 24) | (value << 16) | (value << 8) | value;
|
| }
|
| @@ -41,8 +43,8 @@ void SetToCanvas(skia::PlatformCanvas* canvas, uint8 values[h][w]) {
|
| // Checks each pixel in the given canvas and see if it is made up of the given
|
| // values, where each value has been duplicated into each channel of the given
|
| // bitmap (see SetToCanvas above).
|
| -template<int w, int h>
|
| -void VerifyCanvasValues(skia::PlatformCanvas* canvas, uint8 values[h][w]) {
|
| +template <int w, int h>
|
| +void VerifyCanvasValues(skia::PlatformCanvas* canvas, uint8_t values[h][w]) {
|
| SkBitmap bitmap = skia::ReadPixels(canvas);
|
| SkAutoLockPixels lock(bitmap);
|
| ASSERT_EQ(w, bitmap.width());
|
| @@ -50,9 +52,8 @@ void VerifyCanvasValues(skia::PlatformCanvas* canvas, uint8 values[h][w]) {
|
|
|
| for (int y = 0; y < h; y++) {
|
| for (int x = 0; x < w; x++) {
|
| - uint8 value = values[y][x];
|
| - uint32 expected =
|
| - (value << 24) | (value << 16) | (value << 8) | value;
|
| + uint8_t value = values[y][x];
|
| + uint32_t expected = (value << 24) | (value << 16) | (value << 8) | value;
|
| ASSERT_EQ(expected, *bitmap.getAddr32(x, y));
|
| }
|
| }
|
| @@ -65,12 +66,12 @@ TEST(Blit, ScrollCanvas) {
|
| static const int kCanvasHeight = 5;
|
| skia::RefPtr<SkCanvas> canvas = skia::AdoptRef(
|
| skia::CreatePlatformCanvas(kCanvasWidth, kCanvasHeight, true));
|
| - uint8 initial_values[kCanvasHeight][kCanvasWidth] = {
|
| - { 0x00, 0x01, 0x02, 0x03, 0x04 },
|
| - { 0x10, 0x11, 0x12, 0x13, 0x14 },
|
| - { 0x20, 0x21, 0x22, 0x23, 0x24 },
|
| - { 0x30, 0x31, 0x32, 0x33, 0x34 },
|
| - { 0x40, 0x41, 0x42, 0x43, 0x44 }};
|
| + uint8_t initial_values[kCanvasHeight][kCanvasWidth] = {
|
| + {0x00, 0x01, 0x02, 0x03, 0x04},
|
| + {0x10, 0x11, 0x12, 0x13, 0x14},
|
| + {0x20, 0x21, 0x22, 0x23, 0x24},
|
| + {0x30, 0x31, 0x32, 0x33, 0x34},
|
| + {0x40, 0x41, 0x42, 0x43, 0x44}};
|
| SetToCanvas<5, 5>(canvas.get(), initial_values);
|
|
|
| // Sanity check on input.
|
| @@ -90,56 +91,56 @@ TEST(Blit, ScrollCanvas) {
|
| // Scroll the center 3 pixels up one.
|
| gfx::Rect center_three(1, 1, 3, 3);
|
| gfx::ScrollCanvas(canvas.get(), center_three, gfx::Vector2d(0, -1));
|
| - uint8 scroll_up_expected[kCanvasHeight][kCanvasWidth] = {
|
| - { 0x00, 0x01, 0x02, 0x03, 0x04 },
|
| - { 0x10, 0x21, 0x22, 0x23, 0x14 },
|
| - { 0x20, 0x31, 0x32, 0x33, 0x24 },
|
| - { 0x30, 0x31, 0x32, 0x33, 0x34 },
|
| - { 0x40, 0x41, 0x42, 0x43, 0x44 }};
|
| + uint8_t scroll_up_expected[kCanvasHeight][kCanvasWidth] = {
|
| + {0x00, 0x01, 0x02, 0x03, 0x04},
|
| + {0x10, 0x21, 0x22, 0x23, 0x14},
|
| + {0x20, 0x31, 0x32, 0x33, 0x24},
|
| + {0x30, 0x31, 0x32, 0x33, 0x34},
|
| + {0x40, 0x41, 0x42, 0x43, 0x44}};
|
| VerifyCanvasValues<5, 5>(canvas.get(), scroll_up_expected);
|
|
|
| // Reset and scroll the center 3 pixels down one.
|
| SetToCanvas<5, 5>(canvas.get(), initial_values);
|
| gfx::ScrollCanvas(canvas.get(), center_three, gfx::Vector2d(0, 1));
|
| - uint8 scroll_down_expected[kCanvasHeight][kCanvasWidth] = {
|
| - { 0x00, 0x01, 0x02, 0x03, 0x04 },
|
| - { 0x10, 0x11, 0x12, 0x13, 0x14 },
|
| - { 0x20, 0x11, 0x12, 0x13, 0x24 },
|
| - { 0x30, 0x21, 0x22, 0x23, 0x34 },
|
| - { 0x40, 0x41, 0x42, 0x43, 0x44 }};
|
| + uint8_t scroll_down_expected[kCanvasHeight][kCanvasWidth] = {
|
| + {0x00, 0x01, 0x02, 0x03, 0x04},
|
| + {0x10, 0x11, 0x12, 0x13, 0x14},
|
| + {0x20, 0x11, 0x12, 0x13, 0x24},
|
| + {0x30, 0x21, 0x22, 0x23, 0x34},
|
| + {0x40, 0x41, 0x42, 0x43, 0x44}};
|
| VerifyCanvasValues<5, 5>(canvas.get(), scroll_down_expected);
|
|
|
| // Reset and scroll the center 3 pixels right one.
|
| SetToCanvas<5, 5>(canvas.get(), initial_values);
|
| gfx::ScrollCanvas(canvas.get(), center_three, gfx::Vector2d(1, 0));
|
| - uint8 scroll_right_expected[kCanvasHeight][kCanvasWidth] = {
|
| - { 0x00, 0x01, 0x02, 0x03, 0x04 },
|
| - { 0x10, 0x11, 0x11, 0x12, 0x14 },
|
| - { 0x20, 0x21, 0x21, 0x22, 0x24 },
|
| - { 0x30, 0x31, 0x31, 0x32, 0x34 },
|
| - { 0x40, 0x41, 0x42, 0x43, 0x44 }};
|
| + uint8_t scroll_right_expected[kCanvasHeight][kCanvasWidth] = {
|
| + {0x00, 0x01, 0x02, 0x03, 0x04},
|
| + {0x10, 0x11, 0x11, 0x12, 0x14},
|
| + {0x20, 0x21, 0x21, 0x22, 0x24},
|
| + {0x30, 0x31, 0x31, 0x32, 0x34},
|
| + {0x40, 0x41, 0x42, 0x43, 0x44}};
|
| VerifyCanvasValues<5, 5>(canvas.get(), scroll_right_expected);
|
|
|
| // Reset and scroll the center 3 pixels left one.
|
| SetToCanvas<5, 5>(canvas.get(), initial_values);
|
| gfx::ScrollCanvas(canvas.get(), center_three, gfx::Vector2d(-1, 0));
|
| - uint8 scroll_left_expected[kCanvasHeight][kCanvasWidth] = {
|
| - { 0x00, 0x01, 0x02, 0x03, 0x04 },
|
| - { 0x10, 0x12, 0x13, 0x13, 0x14 },
|
| - { 0x20, 0x22, 0x23, 0x23, 0x24 },
|
| - { 0x30, 0x32, 0x33, 0x33, 0x34 },
|
| - { 0x40, 0x41, 0x42, 0x43, 0x44 }};
|
| + uint8_t scroll_left_expected[kCanvasHeight][kCanvasWidth] = {
|
| + {0x00, 0x01, 0x02, 0x03, 0x04},
|
| + {0x10, 0x12, 0x13, 0x13, 0x14},
|
| + {0x20, 0x22, 0x23, 0x23, 0x24},
|
| + {0x30, 0x32, 0x33, 0x33, 0x34},
|
| + {0x40, 0x41, 0x42, 0x43, 0x44}};
|
| VerifyCanvasValues<5, 5>(canvas.get(), scroll_left_expected);
|
|
|
| // Diagonal scroll.
|
| SetToCanvas<5, 5>(canvas.get(), initial_values);
|
| gfx::ScrollCanvas(canvas.get(), center_three, gfx::Vector2d(2, 2));
|
| - uint8 scroll_diagonal_expected[kCanvasHeight][kCanvasWidth] = {
|
| - { 0x00, 0x01, 0x02, 0x03, 0x04 },
|
| - { 0x10, 0x11, 0x12, 0x13, 0x14 },
|
| - { 0x20, 0x21, 0x22, 0x23, 0x24 },
|
| - { 0x30, 0x31, 0x32, 0x11, 0x34 },
|
| - { 0x40, 0x41, 0x42, 0x43, 0x44 }};
|
| + uint8_t scroll_diagonal_expected[kCanvasHeight][kCanvasWidth] = {
|
| + {0x00, 0x01, 0x02, 0x03, 0x04},
|
| + {0x10, 0x11, 0x12, 0x13, 0x14},
|
| + {0x20, 0x21, 0x22, 0x23, 0x24},
|
| + {0x30, 0x31, 0x32, 0x11, 0x34},
|
| + {0x40, 0x41, 0x42, 0x43, 0x44}};
|
| VerifyCanvasValues<5, 5>(canvas.get(), scroll_diagonal_expected);
|
| }
|
|
|
| @@ -157,12 +158,12 @@ TEST(Blit, WithSharedMemory) {
|
| ASSERT_TRUE(canvas);
|
| shared_mem.Close();
|
|
|
| - uint8 initial_values[kCanvasHeight][kCanvasWidth] = {
|
| - { 0x00, 0x01, 0x02, 0x03, 0x04 },
|
| - { 0x10, 0x11, 0x12, 0x13, 0x14 },
|
| - { 0x20, 0x21, 0x22, 0x23, 0x24 },
|
| - { 0x30, 0x31, 0x32, 0x33, 0x34 },
|
| - { 0x40, 0x41, 0x42, 0x43, 0x44 }};
|
| + uint8_t initial_values[kCanvasHeight][kCanvasWidth] = {
|
| + {0x00, 0x01, 0x02, 0x03, 0x04},
|
| + {0x10, 0x11, 0x12, 0x13, 0x14},
|
| + {0x20, 0x21, 0x22, 0x23, 0x24},
|
| + {0x30, 0x31, 0x32, 0x33, 0x34},
|
| + {0x40, 0x41, 0x42, 0x43, 0x44}};
|
| SetToCanvas<5, 5>(canvas.get(), initial_values);
|
|
|
| // Sanity check on input.
|
|
|