OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
7 #include "base/memory/shared_memory.h" | 7 #include "base/memory/shared_memory.h" |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 #include "skia/ext/platform_canvas.h" | 9 #include "skia/ext/platform_canvas.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 ASSERT_EQ(expected, *bitmap.getAddr32(x, y)); | 57 ASSERT_EQ(expected, *bitmap.getAddr32(x, y)); |
58 } | 58 } |
59 } | 59 } |
60 } | 60 } |
61 | 61 |
62 } // namespace | 62 } // namespace |
63 | 63 |
64 TEST(Blit, ScrollCanvas) { | 64 TEST(Blit, ScrollCanvas) { |
65 static const int kCanvasWidth = 5; | 65 static const int kCanvasWidth = 5; |
66 static const int kCanvasHeight = 5; | 66 static const int kCanvasHeight = 5; |
67 std::unique_ptr<SkCanvas> canvas = | 67 sk_sp<SkCanvas> canvas( |
68 skia::CreatePlatformCanvas(kCanvasWidth, kCanvasHeight, true); | 68 skia::CreatePlatformCanvas(kCanvasWidth, kCanvasHeight, true)); |
69 uint8_t initial_values[kCanvasHeight][kCanvasWidth] = { | 69 uint8_t initial_values[kCanvasHeight][kCanvasWidth] = { |
70 {0x00, 0x01, 0x02, 0x03, 0x04}, | 70 {0x00, 0x01, 0x02, 0x03, 0x04}, |
71 {0x10, 0x11, 0x12, 0x13, 0x14}, | 71 {0x10, 0x11, 0x12, 0x13, 0x14}, |
72 {0x20, 0x21, 0x22, 0x23, 0x24}, | 72 {0x20, 0x21, 0x22, 0x23, 0x24}, |
73 {0x30, 0x31, 0x32, 0x33, 0x34}, | 73 {0x30, 0x31, 0x32, 0x33, 0x34}, |
74 {0x40, 0x41, 0x42, 0x43, 0x44}}; | 74 {0x40, 0x41, 0x42, 0x43, 0x44}}; |
75 SetToCanvas<5, 5>(canvas.get(), initial_values); | 75 SetToCanvas<5, 5>(canvas.get(), initial_values); |
76 | 76 |
77 // Sanity check on input. | 77 // Sanity check on input. |
78 VerifyCanvasValues<5, 5>(canvas.get(), initial_values); | 78 VerifyCanvasValues<5, 5>(canvas.get(), initial_values); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 } | 145 } |
146 | 146 |
147 #if defined(OS_WIN) | 147 #if defined(OS_WIN) |
148 | 148 |
149 TEST(Blit, WithSharedMemory) { | 149 TEST(Blit, WithSharedMemory) { |
150 const int kCanvasWidth = 5; | 150 const int kCanvasWidth = 5; |
151 const int kCanvasHeight = 5; | 151 const int kCanvasHeight = 5; |
152 base::SharedMemory shared_mem; | 152 base::SharedMemory shared_mem; |
153 ASSERT_TRUE(shared_mem.CreateAnonymous(kCanvasWidth * kCanvasHeight)); | 153 ASSERT_TRUE(shared_mem.CreateAnonymous(kCanvasWidth * kCanvasHeight)); |
154 base::SharedMemoryHandle section = shared_mem.handle(); | 154 base::SharedMemoryHandle section = shared_mem.handle(); |
155 std::unique_ptr<SkCanvas> canvas = skia::CreatePlatformCanvas( | 155 sk_sp<SkCanvas> canvas(skia::CreatePlatformCanvas( |
156 kCanvasWidth, kCanvasHeight, true, section.GetHandle(), | 156 kCanvasWidth, kCanvasHeight, true, section.GetHandle(), |
157 skia::RETURN_NULL_ON_FAILURE); | 157 skia::RETURN_NULL_ON_FAILURE)); |
158 ASSERT_TRUE(canvas); | 158 ASSERT_TRUE(canvas); |
159 shared_mem.Close(); | 159 shared_mem.Close(); |
160 | 160 |
161 uint8_t initial_values[kCanvasHeight][kCanvasWidth] = { | 161 uint8_t initial_values[kCanvasHeight][kCanvasWidth] = { |
162 {0x00, 0x01, 0x02, 0x03, 0x04}, | 162 {0x00, 0x01, 0x02, 0x03, 0x04}, |
163 {0x10, 0x11, 0x12, 0x13, 0x14}, | 163 {0x10, 0x11, 0x12, 0x13, 0x14}, |
164 {0x20, 0x21, 0x22, 0x23, 0x24}, | 164 {0x20, 0x21, 0x22, 0x23, 0x24}, |
165 {0x30, 0x31, 0x32, 0x33, 0x34}, | 165 {0x30, 0x31, 0x32, 0x33, 0x34}, |
166 {0x40, 0x41, 0x42, 0x43, 0x44}}; | 166 {0x40, 0x41, 0x42, 0x43, 0x44}}; |
167 SetToCanvas<5, 5>(canvas.get(), initial_values); | 167 SetToCanvas<5, 5>(canvas.get(), initial_values); |
168 | 168 |
169 // Sanity check on input. | 169 // Sanity check on input. |
170 VerifyCanvasValues<5, 5>(canvas.get(), initial_values); | 170 VerifyCanvasValues<5, 5>(canvas.get(), initial_values); |
171 } | 171 } |
172 | 172 |
173 #endif | 173 #endif |
174 | 174 |
OLD | NEW |