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 std::unique_ptr<SkCanvas> TransportDIB::GetPlatformCanvas(int w, | 61 SkCanvas* TransportDIB::GetPlatformCanvas(int w, int h, bool opaque) { |
62 int h, | |
63 bool opaque) { | |
64 if ((!memory() && !Map()) || !VerifyCanvasSize(w, h)) | 62 if ((!memory() && !Map()) || !VerifyCanvasSize(w, h)) |
65 return NULL; | 63 return NULL; |
66 return skia::CreatePlatformCanvas(w, h, opaque, | 64 return skia::CreatePlatformCanvas(w, h, opaque, |
67 reinterpret_cast<uint8_t*>(memory()), | 65 reinterpret_cast<uint8_t*>(memory()), |
68 skia::RETURN_NULL_ON_FAILURE); | 66 skia::RETURN_NULL_ON_FAILURE); |
69 } | 67 } |
70 | 68 |
71 bool TransportDIB::Map() { | 69 bool TransportDIB::Map() { |
72 if (!is_valid_handle(shared_memory_.handle())) | 70 if (!is_valid_handle(shared_memory_.handle())) |
73 return false; | 71 return false; |
(...skipping 12 matching lines...) Expand all Loading... |
86 return false; | 84 return false; |
87 | 85 |
88 size_ = size; | 86 size_ = size; |
89 #endif | 87 #endif |
90 return true; | 88 return true; |
91 } | 89 } |
92 | 90 |
93 void* TransportDIB::memory() const { | 91 void* TransportDIB::memory() const { |
94 return shared_memory_.memory(); | 92 return shared_memory_.memory(); |
95 } | 93 } |
OLD | NEW |