| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "app/surface/transport_dib.h" | 5 #include "app/surface/transport_dib.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 | 8 |
| 9 #include <limits> | 9 #include <limits> |
| 10 | 10 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 return NULL; | 49 return NULL; |
| 50 return dib.release(); | 50 return dib.release(); |
| 51 } | 51 } |
| 52 | 52 |
| 53 // static | 53 // static |
| 54 TransportDIB* TransportDIB::CreateWithHandle(Handle handle) { | 54 TransportDIB* TransportDIB::CreateWithHandle(Handle handle) { |
| 55 return new TransportDIB(handle); | 55 return new TransportDIB(handle); |
| 56 } | 56 } |
| 57 | 57 |
| 58 // static | 58 // static |
| 59 bool TransportDIB::is_valid(Handle dib) { | 59 bool TransportDIB::is_valid_handle(Handle dib) { |
| 60 return dib != NULL; | 60 return dib != NULL; |
| 61 } | 61 } |
| 62 | 62 |
| 63 // static |
| 64 bool TransportDIB::is_valid_id(TransportDIB::Id id) { |
| 65 return is_valid_handle(id.handle); |
| 66 } |
| 67 |
| 63 skia::PlatformCanvas* TransportDIB::GetPlatformCanvas(int w, int h) { | 68 skia::PlatformCanvas* TransportDIB::GetPlatformCanvas(int w, int h) { |
| 64 // This DIB already mapped the file into this process, but PlatformCanvas | 69 // This DIB already mapped the file into this process, but PlatformCanvas |
| 65 // will map it again. | 70 // will map it again. |
| 66 DCHECK(!memory()) << "Mapped file twice in the same process."; | 71 DCHECK(!memory()) << "Mapped file twice in the same process."; |
| 67 | 72 |
| 68 scoped_ptr<skia::PlatformCanvas> canvas(new skia::PlatformCanvas); | 73 scoped_ptr<skia::PlatformCanvas> canvas(new skia::PlatformCanvas); |
| 69 if (!canvas->initialize(w, h, true, handle())) | 74 if (!canvas->initialize(w, h, true, handle())) |
| 70 return NULL; | 75 return NULL; |
| 71 return canvas.release(); | 76 return canvas.release(); |
| 72 } | 77 } |
| 73 | 78 |
| 74 bool TransportDIB::Map() { | 79 bool TransportDIB::Map() { |
| 75 if (!is_valid(handle())) | 80 if (!is_valid_handle(handle())) |
| 76 return false; | 81 return false; |
| 77 if (memory()) | 82 if (memory()) |
| 78 return true; | 83 return true; |
| 79 | 84 |
| 80 if (!shared_memory_.Map(0 /* map whole shared memory segment */)) { | 85 if (!shared_memory_.Map(0 /* map whole shared memory segment */)) { |
| 81 LOG(ERROR) << "Failed to map transport DIB" | 86 LOG(ERROR) << "Failed to map transport DIB" |
| 82 << " handle:" << shared_memory_.handle() | 87 << " handle:" << shared_memory_.handle() |
| 83 << " error:" << ::GetLastError(); | 88 << " error:" << ::GetLastError(); |
| 84 return false; | 89 return false; |
| 85 } | 90 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 96 return shared_memory_.memory(); | 101 return shared_memory_.memory(); |
| 97 } | 102 } |
| 98 | 103 |
| 99 TransportDIB::Handle TransportDIB::handle() const { | 104 TransportDIB::Handle TransportDIB::handle() const { |
| 100 return shared_memory_.handle(); | 105 return shared_memory_.handle(); |
| 101 } | 106 } |
| 102 | 107 |
| 103 TransportDIB::Id TransportDIB::id() const { | 108 TransportDIB::Id TransportDIB::id() const { |
| 104 return Id(handle(), sequence_num_); | 109 return Id(handle(), sequence_num_); |
| 105 } | 110 } |
| OLD | NEW |