| 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 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 // static | 51 // static |
| 52 TransportDIB* TransportDIB::CreateWithHandle(Handle handle) { | 52 TransportDIB* TransportDIB::CreateWithHandle(Handle handle) { |
| 53 return new TransportDIB(handle); | 53 return new TransportDIB(handle); |
| 54 } | 54 } |
| 55 | 55 |
| 56 // static | 56 // static |
| 57 bool TransportDIB::is_valid_handle(Handle dib) { | 57 bool TransportDIB::is_valid_handle(Handle dib) { |
| 58 return dib.IsValid(); | 58 return dib.IsValid(); |
| 59 } | 59 } |
| 60 | 60 |
| 61 std::unique_ptr<SkCanvas> TransportDIB::GetPlatformCanvas(int w, | 61 SkCanvas* TransportDIB::GetPlatformCanvas(int w, int h, |
| 62 int h, | 62 bool opaque) { |
| 63 bool opaque) { | |
| 64 // This DIB already mapped the file into this process, but PlatformCanvas | 63 // This DIB already mapped the file into this process, but PlatformCanvas |
| 65 // will map it again. | 64 // will map it again. |
| 66 DCHECK(!memory()) << "Mapped file twice in the same process."; | 65 DCHECK(!memory()) << "Mapped file twice in the same process."; |
| 67 | 66 |
| 68 // We can't check the canvas size before mapping, but it's safe because | 67 // We can't check the canvas size before mapping, but it's safe because |
| 69 // Windows will fail to map the section if the dimensions of the canvas | 68 // Windows will fail to map the section if the dimensions of the canvas |
| 70 // are too large. | 69 // are too large. |
| 71 std::unique_ptr<SkCanvas> canvas = skia::CreatePlatformCanvas( | 70 SkCanvas* canvas = skia::CreatePlatformCanvas( |
| 72 w, h, opaque, shared_memory_.handle().GetHandle(), | 71 w, h, opaque, shared_memory_.handle().GetHandle(), |
| 73 skia::RETURN_NULL_ON_FAILURE); | 72 skia::RETURN_NULL_ON_FAILURE); |
| 74 | 73 |
| 75 // Calculate the size for the memory region backing the canvas. | 74 // Calculate the size for the memory region backing the canvas. |
| 76 if (canvas) | 75 if (canvas) |
| 77 size_ = skia::PlatformCanvasStrideForWidth(w) * h; | 76 size_ = skia::PlatformCanvasStrideForWidth(w) * h; |
| 78 | 77 |
| 79 return canvas; | 78 return canvas; |
| 80 } | 79 } |
| 81 | 80 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 92 return false; | 91 return false; |
| 93 } | 92 } |
| 94 | 93 |
| 95 size_ = shared_memory_.mapped_size(); | 94 size_ = shared_memory_.mapped_size(); |
| 96 return true; | 95 return true; |
| 97 } | 96 } |
| 98 | 97 |
| 99 void* TransportDIB::memory() const { | 98 void* TransportDIB::memory() const { |
| 100 return shared_memory_.memory(); | 99 return shared_memory_.memory(); |
| 101 } | 100 } |
| OLD | NEW |