| 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> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <sys/stat.h> | 9 #include <sys/stat.h> |
| 10 #include <unistd.h> | 10 #include <unistd.h> |
| 11 | 11 |
| 12 #include <memory> |
| 13 |
| 12 #include "base/logging.h" | 14 #include "base/logging.h" |
| 13 #include "base/memory/scoped_ptr.h" | |
| 14 #include "base/memory/shared_memory.h" | 15 #include "base/memory/shared_memory.h" |
| 15 #include "build/build_config.h" | 16 #include "build/build_config.h" |
| 16 #include "skia/ext/platform_canvas.h" | 17 #include "skia/ext/platform_canvas.h" |
| 17 | 18 |
| 18 TransportDIB::TransportDIB() | 19 TransportDIB::TransportDIB() |
| 19 : size_(0) { | 20 : size_(0) { |
| 20 } | 21 } |
| 21 | 22 |
| 22 TransportDIB::TransportDIB(TransportDIB::Handle dib) | 23 TransportDIB::TransportDIB(TransportDIB::Handle dib) |
| 23 : shared_memory_(dib, false /* read write */), | 24 : shared_memory_(dib, false /* read write */), |
| (...skipping 10 matching lines...) Expand all Loading... |
| 34 delete dib; | 35 delete dib; |
| 35 return NULL; | 36 return NULL; |
| 36 } | 37 } |
| 37 | 38 |
| 38 dib->size_ = size; | 39 dib->size_ = size; |
| 39 return dib; | 40 return dib; |
| 40 } | 41 } |
| 41 | 42 |
| 42 // static | 43 // static |
| 43 TransportDIB* TransportDIB::Map(Handle handle) { | 44 TransportDIB* TransportDIB::Map(Handle handle) { |
| 44 scoped_ptr<TransportDIB> dib(CreateWithHandle(handle)); | 45 std::unique_ptr<TransportDIB> dib(CreateWithHandle(handle)); |
| 45 if (!dib->Map()) | 46 if (!dib->Map()) |
| 46 return NULL; | 47 return NULL; |
| 47 return dib.release(); | 48 return dib.release(); |
| 48 } | 49 } |
| 49 | 50 |
| 50 // static | 51 // static |
| 51 TransportDIB* TransportDIB::CreateWithHandle(Handle handle) { | 52 TransportDIB* TransportDIB::CreateWithHandle(Handle handle) { |
| 52 return new TransportDIB(handle); | 53 return new TransportDIB(handle); |
| 53 } | 54 } |
| 54 | 55 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 83 return false; | 84 return false; |
| 84 | 85 |
| 85 size_ = size; | 86 size_ = size; |
| 86 #endif | 87 #endif |
| 87 return true; | 88 return true; |
| 88 } | 89 } |
| 89 | 90 |
| 90 void* TransportDIB::memory() const { | 91 void* TransportDIB::memory() const { |
| 91 return shared_memory_.memory(); | 92 return shared_memory_.memory(); |
| 92 } | 93 } |
| OLD | NEW |