| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/surface/transport_dib.h" | 5 #include "ui/surface/transport_dib.h" |
| 6 | 6 |
| 7 #include <stddef.h> |
| 8 #include <stdint.h> |
| 7 #include <sys/stat.h> | 9 #include <sys/stat.h> |
| 8 #include <unistd.h> | 10 #include <unistd.h> |
| 9 | 11 |
| 10 #include "base/logging.h" | 12 #include "base/logging.h" |
| 11 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/shared_memory.h" | 14 #include "base/memory/shared_memory.h" |
| 15 #include "build/build_config.h" |
| 13 #include "skia/ext/platform_canvas.h" | 16 #include "skia/ext/platform_canvas.h" |
| 14 | 17 |
| 15 TransportDIB::TransportDIB() | 18 TransportDIB::TransportDIB() |
| 16 : size_(0) { | 19 : size_(0) { |
| 17 } | 20 } |
| 18 | 21 |
| 19 TransportDIB::TransportDIB(TransportDIB::Handle dib) | 22 TransportDIB::TransportDIB(TransportDIB::Handle dib) |
| 20 : shared_memory_(dib, false /* read write */), | 23 : shared_memory_(dib, false /* read write */), |
| 21 size_(0) { | 24 size_(0) { |
| 22 } | 25 } |
| 23 | 26 |
| 24 TransportDIB::~TransportDIB() { | 27 TransportDIB::~TransportDIB() { |
| 25 } | 28 } |
| 26 | 29 |
| 27 // static | 30 // static |
| 28 TransportDIB* TransportDIB::Create(size_t size, uint32 sequence_num) { | 31 TransportDIB* TransportDIB::Create(size_t size, uint32_t sequence_num) { |
| 29 TransportDIB* dib = new TransportDIB; | 32 TransportDIB* dib = new TransportDIB; |
| 30 if (!dib->shared_memory_.CreateAndMapAnonymous(size)) { | 33 if (!dib->shared_memory_.CreateAndMapAnonymous(size)) { |
| 31 delete dib; | 34 delete dib; |
| 32 return NULL; | 35 return NULL; |
| 33 } | 36 } |
| 34 | 37 |
| 35 dib->size_ = size; | 38 dib->size_ = size; |
| 36 return dib; | 39 return dib; |
| 37 } | 40 } |
| 38 | 41 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 return false; | 84 return false; |
| 82 | 85 |
| 83 size_ = size; | 86 size_ = size; |
| 84 #endif | 87 #endif |
| 85 return true; | 88 return true; |
| 86 } | 89 } |
| 87 | 90 |
| 88 void* TransportDIB::memory() const { | 91 void* TransportDIB::memory() const { |
| 89 return shared_memory_.memory(); | 92 return shared_memory_.memory(); |
| 90 } | 93 } |
| OLD | NEW |