| 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> |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 // static | 51 // static |
| 52 TransportDIB* TransportDIB::CreateWithHandle(Handle handle) { | 52 TransportDIB* TransportDIB::CreateWithHandle(Handle handle) { |
| 53 return new TransportDIB(handle); | 53 return new TransportDIB(handle); |
| 54 } | 54 } |
| 55 | 55 |
| 56 // static | 56 // static |
| 57 bool TransportDIB::is_valid_handle(Handle dib) { | 57 bool TransportDIB::is_valid_handle(Handle dib) { |
| 58 return base::SharedMemory::IsHandleValid(dib); | 58 return base::SharedMemory::IsHandleValid(dib); |
| 59 } | 59 } |
| 60 | 60 |
| 61 SkCanvas* TransportDIB::GetPlatformCanvas(int w, int h, bool opaque) { | 61 std::unique_ptr<SkCanvas> TransportDIB::GetPlatformCanvas(int w, |
| 62 int h, |
| 63 bool opaque) { |
| 62 if ((!memory() && !Map()) || !VerifyCanvasSize(w, h)) | 64 if ((!memory() && !Map()) || !VerifyCanvasSize(w, h)) |
| 63 return NULL; | 65 return NULL; |
| 64 return skia::CreatePlatformCanvas(w, h, opaque, | 66 return skia::CreatePlatformCanvas(w, h, opaque, |
| 65 reinterpret_cast<uint8_t*>(memory()), | 67 reinterpret_cast<uint8_t*>(memory()), |
| 66 skia::RETURN_NULL_ON_FAILURE); | 68 skia::RETURN_NULL_ON_FAILURE); |
| 67 } | 69 } |
| 68 | 70 |
| 69 bool TransportDIB::Map() { | 71 bool TransportDIB::Map() { |
| 70 if (!is_valid_handle(shared_memory_.handle())) | 72 if (!is_valid_handle(shared_memory_.handle())) |
| 71 return false; | 73 return false; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 84 return false; | 86 return false; |
| 85 | 87 |
| 86 size_ = size; | 88 size_ = size; |
| 87 #endif | 89 #endif |
| 88 return true; | 90 return true; |
| 89 } | 91 } |
| 90 | 92 |
| 91 void* TransportDIB::memory() const { | 93 void* TransportDIB::memory() const { |
| 92 return shared_memory_.memory(); | 94 return shared_memory_.memory(); |
| 93 } | 95 } |
| OLD | NEW |