Commit a4ae44e5 authored by Alexandr Ilin's avatar Alexandr Ilin Committed by Commit Bot

gfx:: Convert blit_unittest to the new shared memory API

This CL replaces deprecated base::SharedMemory and
base::SharedMemoryHandle classes with the new classes for shared memory.

Bug: None
Change-Id: I96073aef72ecd56153fcc49d96f0ab526003f3ef
Reviewed-on: https://chromium-review.googlesource.com/c/1296537
Commit-Queue: Alexandr Ilin <alexilin@chromium.org>
Reviewed-by: default avatarMichael Wasserman <msw@chromium.org>
Reviewed-by: default avatarRobert Sesek <rsesek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#602376}
parent aec5d4fc
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include <stdint.h> #include <stdint.h>
#include "base/memory/shared_memory.h" #include "base/memory/platform_shared_memory_region.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "skia/ext/platform_canvas.h" #include "skia/ext/platform_canvas.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
...@@ -148,15 +148,17 @@ TEST(Blit, ScrollCanvas) { ...@@ -148,15 +148,17 @@ TEST(Blit, ScrollCanvas) {
TEST(Blit, WithSharedMemory) { TEST(Blit, WithSharedMemory) {
const int kCanvasWidth = 5; const int kCanvasWidth = 5;
const int kCanvasHeight = 5; const int kCanvasHeight = 5;
base::SharedMemory shared_mem; base::subtle::PlatformSharedMemoryRegion section =
ASSERT_TRUE(shared_mem.CreateAnonymous(kCanvasWidth * kCanvasHeight)); base::subtle::PlatformSharedMemoryRegion::CreateWritable(kCanvasWidth *
base::SharedMemoryHandle section = shared_mem.handle(); kCanvasHeight);
ASSERT_TRUE(section.IsValid());
std::unique_ptr<SkCanvas> canvas = std::unique_ptr<SkCanvas> canvas =
skia::CreatePlatformCanvasWithSharedSection(kCanvasWidth, kCanvasHeight, skia::CreatePlatformCanvasWithSharedSection(
false, section.GetHandle(), kCanvasWidth, kCanvasHeight, false, section.GetPlatformHandle(),
skia::RETURN_NULL_ON_FAILURE); skia::RETURN_NULL_ON_FAILURE);
ASSERT_TRUE(canvas); ASSERT_TRUE(canvas);
shared_mem.Close(); // Closes a HANDLE associated with |section|, |canvas| must remain valid.
section = base::subtle::PlatformSharedMemoryRegion();
uint8_t initial_values[kCanvasHeight][kCanvasWidth] = { uint8_t initial_values[kCanvasHeight][kCanvasWidth] = {
{0x00, 0x01, 0x02, 0x03, 0x04}, {0x00, 0x01, 0x02, 0x03, 0x04},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment