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