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 // Desktop GTK Linux builds use the old-style SYSV SHM based DIBs. | |
8 // Linux Aura and Chrome OS do too. This will change very soon. | |
9 #if !defined(TOOLKIT_GTK) && !(defined(OS_LINUX) && defined(USE_AURA)) | |
10 | |
7 #include <sys/stat.h> | 11 #include <sys/stat.h> |
8 #include <unistd.h> | 12 #include <unistd.h> |
9 | 13 |
10 #include "base/logging.h" | 14 #include "base/logging.h" |
11 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
12 #include "base/memory/shared_memory.h" | 16 #include "base/memory/shared_memory.h" |
13 #include "base/posix/eintr_wrapper.h" | 17 #include "base/posix/eintr_wrapper.h" |
14 #include "skia/ext/platform_canvas.h" | 18 #include "skia/ext/platform_canvas.h" |
15 | 19 |
16 TransportDIB::TransportDIB() | 20 TransportDIB::TransportDIB() |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
50 return new TransportDIB(handle); | 54 return new TransportDIB(handle); |
51 } | 55 } |
52 | 56 |
53 // static | 57 // static |
54 bool TransportDIB::is_valid_handle(Handle dib) { | 58 bool TransportDIB::is_valid_handle(Handle dib) { |
55 return dib.fd >= 0; | 59 return dib.fd >= 0; |
56 } | 60 } |
57 | 61 |
58 // static | 62 // static |
59 bool TransportDIB::is_valid_id(Id id) { | 63 bool TransportDIB::is_valid_id(Id id) { |
64 #if defined(OS_ANDROID) | |
65 return is_valid_handle(id); | |
66 #else | |
60 return id != 0; | 67 return id != 0; |
68 #endif | |
61 } | 69 } |
62 | 70 |
63 skia::PlatformCanvas* TransportDIB::GetPlatformCanvas(int w, int h) { | 71 skia::PlatformCanvas* TransportDIB::GetPlatformCanvas(int w, int h) { |
64 if ((!memory() && !Map()) || !VerifyCanvasSize(w, h)) | 72 if ((!memory() && !Map()) || !VerifyCanvasSize(w, h)) |
65 return NULL; | 73 return NULL; |
66 return skia::CreatePlatformCanvas(w, h, true, | 74 return skia::CreatePlatformCanvas(w, h, true, |
67 reinterpret_cast<uint8_t*>(memory()), | 75 reinterpret_cast<uint8_t*>(memory()), |
68 skia::RETURN_NULL_ON_FAILURE); | 76 skia::RETURN_NULL_ON_FAILURE); |
69 } | 77 } |
70 | 78 |
(...skipping 11 matching lines...) Expand all Loading... | |
82 | 90 |
83 size_ = st.st_size; | 91 size_ = st.st_size; |
84 return true; | 92 return true; |
85 } | 93 } |
86 | 94 |
87 void* TransportDIB::memory() const { | 95 void* TransportDIB::memory() const { |
88 return shared_memory_.memory(); | 96 return shared_memory_.memory(); |
89 } | 97 } |
90 | 98 |
91 TransportDIB::Id TransportDIB::id() const { | 99 TransportDIB::Id TransportDIB::id() const { |
100 #if defined(OS_ANDROID) | |
101 return handle(); | |
102 #else | |
92 return shared_memory_.id(); | 103 return shared_memory_.id(); |
104 #endif | |
93 } | 105 } |
94 | 106 |
95 TransportDIB::Handle TransportDIB::handle() const { | 107 TransportDIB::Handle TransportDIB::handle() const { |
96 return shared_memory_.handle(); | 108 return shared_memory_.handle(); |
97 } | 109 } |
110 | |
111 #endif | |
Ken Russell (switch to Gerrit)
2013/04/04 18:52:12
Comment which #ifdef this matches since it's so fa
| |
112 | |
OLD | NEW |