Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Side by Side Diff: components/exo/wayland/clients/client_base.cc

Issue 2843113002: make base::SharedMemoryHandle a class on POSIX. (Closed)
Patch Set: Fix test error. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "components/exo/wayland/clients/client_base.h" 5 #include "components/exo/wayland/clients/client_base.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <linux-dmabuf-unstable-v1-client-protocol.h> 8 #include <linux-dmabuf-unstable-v1-client-protocol.h>
9 #include <presentation-time-client-protocol.h> 9 #include <presentation-time-client-protocol.h>
10 #include <wayland-client-core.h> 10 #include <wayland-client-core.h>
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 buffer->sk_surface = SkSurface::MakeFromBackendTextureAsRenderTarget( 443 buffer->sk_surface = SkSurface::MakeFromBackendTextureAsRenderTarget(
444 gr_context_.get(), desc, nullptr); 444 gr_context_.get(), desc, nullptr);
445 DCHECK(buffer->sk_surface); 445 DCHECK(buffer->sk_surface);
446 return buffer; 446 return buffer;
447 } 447 }
448 #endif 448 #endif
449 449
450 size_t stride = width_ * kBytesPerPixel; 450 size_t stride = width_ * kBytesPerPixel;
451 buffer->shared_memory.reset(new base::SharedMemory()); 451 buffer->shared_memory.reset(new base::SharedMemory());
452 buffer->shared_memory->CreateAndMapAnonymous(stride * height_); 452 buffer->shared_memory->CreateAndMapAnonymous(stride * height_);
453 buffer->shm_pool.reset( 453 buffer->shm_pool.reset(wl_shm_create_pool(
454 wl_shm_create_pool(globals_.shm.get(), buffer->shared_memory->handle().fd, 454 globals_.shm.get(), buffer->shared_memory->handle().GetHandle(),
455 buffer->shared_memory->requested_size())); 455 buffer->shared_memory->requested_size()));
456 456
457 buffer->buffer.reset(static_cast<wl_buffer*>(wl_shm_pool_create_buffer( 457 buffer->buffer.reset(static_cast<wl_buffer*>(wl_shm_pool_create_buffer(
458 buffer->shm_pool.get(), 0, width_, height_, stride, kShmFormat))); 458 buffer->shm_pool.get(), 0, width_, height_, stride, kShmFormat)));
459 if (!buffer->buffer) { 459 if (!buffer->buffer) {
460 LOG(ERROR) << "Can't create buffer"; 460 LOG(ERROR) << "Can't create buffer";
461 return nullptr; 461 return nullptr;
462 } 462 }
463 463
464 buffer->sk_surface = SkSurface::MakeRasterDirect( 464 buffer->sk_surface = SkSurface::MakeRasterDirect(
465 SkImageInfo::Make(width_, height_, kColorType, kOpaque_SkAlphaType), 465 SkImageInfo::Make(width_, height_, kColorType, kOpaque_SkAlphaType),
466 static_cast<uint8_t*>(buffer->shared_memory->memory()), stride); 466 static_cast<uint8_t*>(buffer->shared_memory->memory()), stride);
467 DCHECK(buffer->sk_surface); 467 DCHECK(buffer->sk_surface);
468 return buffer; 468 return buffer;
469 } 469 }
470 470
471 } // namespace clients 471 } // namespace clients
472 } // namespace wayland 472 } // namespace wayland
473 } // namespace exo 473 } // namespace exo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698