OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/gfx/surface/transport_dib.h" | 5 #include "ui/gfx/surface/transport_dib.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <stdlib.h> | 8 #include <stdlib.h> |
9 #include <sys/ipc.h> | 9 #include <sys/ipc.h> |
10 #include <sys/shm.h> | 10 #include <sys/shm.h> |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
87 | 87 |
88 // static | 88 // static |
89 bool TransportDIB::is_valid_id(Id id) { | 89 bool TransportDIB::is_valid_id(Id id) { |
90 return id.shmkey != -1; | 90 return id.shmkey != -1; |
91 } | 91 } |
92 | 92 |
93 skia::PlatformCanvas* TransportDIB::GetPlatformCanvas(int w, int h) { | 93 skia::PlatformCanvas* TransportDIB::GetPlatformCanvas(int w, int h) { |
94 if (address_ == kInvalidAddress && !Map()) | 94 if (address_ == kInvalidAddress && !Map()) |
95 return NULL; | 95 return NULL; |
96 scoped_ptr<skia::PlatformCanvas> canvas(new skia::PlatformCanvas); | 96 scoped_ptr<skia::PlatformCanvas> canvas(new skia::PlatformCanvas); |
97 if (!canvas->initialize(w, h, true, reinterpret_cast<uint8_t*>(memory()))) | 97 if (!canvas->initialize( |
98 w, h, | |
99 skia::PlatformDevice::FLAGS_OPAQUE | | |
100 skia::PlatformDevice::FLAGS_INITIALIZED, | |
Jeff Timanus
2012/02/23 22:14:10
The canvas can be explicitly cleared in the variou
| |
101 reinterpret_cast<uint8_t*>(memory()))) | |
98 return NULL; | 102 return NULL; |
99 return canvas.release(); | 103 return canvas.release(); |
100 } | 104 } |
101 | 105 |
102 bool TransportDIB::Map() { | 106 bool TransportDIB::Map() { |
103 if (!is_valid_id(key_)) | 107 if (!is_valid_id(key_)) |
104 return false; | 108 return false; |
105 if (address_ != kInvalidAddress) | 109 if (address_ != kInvalidAddress) |
106 return true; | 110 return true; |
107 | 111 |
(...skipping 24 matching lines...) Expand all Loading... | |
132 } | 136 } |
133 | 137 |
134 XID TransportDIB::MapToX(Display* display) { | 138 XID TransportDIB::MapToX(Display* display) { |
135 if (!x_shm_) { | 139 if (!x_shm_) { |
136 x_shm_ = ui::AttachSharedMemory(display, key_.shmkey); | 140 x_shm_ = ui::AttachSharedMemory(display, key_.shmkey); |
137 display_ = display; | 141 display_ = display; |
138 } | 142 } |
139 | 143 |
140 return x_shm_; | 144 return x_shm_; |
141 } | 145 } |
OLD | NEW |