| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/common/transport_dib.h" | 5 #include "chrome/common/transport_dib.h" |
| 6 | 6 |
| 7 #include <unistd.h> | 7 #include <unistd.h> |
| 8 #include <sys/stat.h> | 8 #include <sys/stat.h> |
| 9 | 9 |
| 10 #include "base/eintr_wrapper.h" | 10 #include "base/eintr_wrapper.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 // static | 39 // static |
| 40 TransportDIB* TransportDIB::Map(TransportDIB::Handle handle) { | 40 TransportDIB* TransportDIB::Map(TransportDIB::Handle handle) { |
| 41 TransportDIB* dib = new TransportDIB(handle); | 41 TransportDIB* dib = new TransportDIB(handle); |
| 42 struct stat st; | 42 struct stat st; |
| 43 fstat(handle.fd, &st); | 43 fstat(handle.fd, &st); |
| 44 | 44 |
| 45 if (!dib->shared_memory_.Map(st.st_size)) { | 45 if (!dib->shared_memory_.Map(st.st_size)) { |
| 46 delete dib; | 46 delete dib; |
| 47 HANDLE_EINTR(close(handle.fd)); | 47 HANDLE_EINTR(close(handle.fd)); |
| 48 return false; | 48 return NULL; |
| 49 } | 49 } |
| 50 | 50 |
| 51 dib->size_ = st.st_size; | 51 dib->size_ = st.st_size; |
| 52 | 52 |
| 53 return dib; | 53 return dib; |
| 54 } | 54 } |
| 55 | 55 |
| 56 skia::PlatformCanvas* TransportDIB::GetPlatformCanvas(int w, int h) { | 56 skia::PlatformCanvas* TransportDIB::GetPlatformCanvas(int w, int h) { |
| 57 return new skia::PlatformCanvas(w, h, true, | 57 return new skia::PlatformCanvas(w, h, true, |
| 58 reinterpret_cast<uint8_t*>(memory())); | 58 reinterpret_cast<uint8_t*>(memory())); |
| 59 } | 59 } |
| 60 | 60 |
| 61 void* TransportDIB::memory() const { | 61 void* TransportDIB::memory() const { |
| 62 return shared_memory_.memory(); | 62 return shared_memory_.memory(); |
| 63 } | 63 } |
| 64 | 64 |
| 65 TransportDIB::Id TransportDIB::id() const { | 65 TransportDIB::Id TransportDIB::id() const { |
| 66 return shared_memory_.id(); | 66 return shared_memory_.id(); |
| 67 } | 67 } |
| 68 | 68 |
| 69 TransportDIB::Handle TransportDIB::handle() const { | 69 TransportDIB::Handle TransportDIB::handle() const { |
| 70 return shared_memory_.handle(); | 70 return shared_memory_.handle(); |
| 71 } | 71 } |
| OLD | NEW |