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 <windows.h> | 7 #include <windows.h> |
8 | 8 |
9 #include <limits> | 9 #include <limits> |
10 | 10 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 // static | 63 // static |
64 bool TransportDIB::is_valid_id(TransportDIB::Id id) { | 64 bool TransportDIB::is_valid_id(TransportDIB::Id id) { |
65 return is_valid_handle(id.handle); | 65 return is_valid_handle(id.handle); |
66 } | 66 } |
67 | 67 |
68 skia::PlatformCanvas* TransportDIB::GetPlatformCanvas(int w, int h) { | 68 skia::PlatformCanvas* TransportDIB::GetPlatformCanvas(int w, int h) { |
69 // This DIB already mapped the file into this process, but PlatformCanvas | 69 // This DIB already mapped the file into this process, but PlatformCanvas |
70 // will map it again. | 70 // will map it again. |
71 DCHECK(!memory()) << "Mapped file twice in the same process."; | 71 DCHECK(!memory()) << "Mapped file twice in the same process."; |
72 | 72 |
73 scoped_ptr<skia::PlatformCanvas> canvas(new skia::PlatformCanvas); | 73 return skia::CreatePlatformCanvas(w, h, true, handle(), |
74 if (!canvas->initialize(w, h, true, handle())) | 74 skia::RETURN_NULL_ON_FAILURE); |
75 return NULL; | |
76 return canvas.release(); | |
77 } | 75 } |
78 | 76 |
79 bool TransportDIB::Map() { | 77 bool TransportDIB::Map() { |
80 if (!is_valid_handle(handle())) | 78 if (!is_valid_handle(handle())) |
81 return false; | 79 return false; |
82 if (memory()) | 80 if (memory()) |
83 return true; | 81 return true; |
84 | 82 |
85 if (!shared_memory_.Map(0 /* map whole shared memory segment */)) { | 83 if (!shared_memory_.Map(0 /* map whole shared memory segment */)) { |
86 LOG(ERROR) << "Failed to map transport DIB" | 84 LOG(ERROR) << "Failed to map transport DIB" |
(...skipping 14 matching lines...) Expand all Loading... |
101 return shared_memory_.memory(); | 99 return shared_memory_.memory(); |
102 } | 100 } |
103 | 101 |
104 TransportDIB::Handle TransportDIB::handle() const { | 102 TransportDIB::Handle TransportDIB::handle() const { |
105 return shared_memory_.handle(); | 103 return shared_memory_.handle(); |
106 } | 104 } |
107 | 105 |
108 TransportDIB::Id TransportDIB::id() const { | 106 TransportDIB::Id TransportDIB::id() const { |
109 return Id(handle(), sequence_num_); | 107 return Id(handle(), sequence_num_); |
110 } | 108 } |
OLD | NEW |