Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: ui/surface/transport_dib_win.cc

Issue 1145893009: Change transport dib API to not make copies of SharedMemoryHandle. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@shared_memory_pepper_rename
Patch Set: Comments from jbauman. Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/surface/transport_dib_posix.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 65
66 skia::PlatformCanvas* TransportDIB::GetPlatformCanvas(int w, int h) { 66 skia::PlatformCanvas* TransportDIB::GetPlatformCanvas(int w, int h) {
67 // This DIB already mapped the file into this process, but PlatformCanvas 67 // This DIB already mapped the file into this process, but PlatformCanvas
68 // will map it again. 68 // will map it again.
69 DCHECK(!memory()) << "Mapped file twice in the same process."; 69 DCHECK(!memory()) << "Mapped file twice in the same process.";
70 70
71 // We can't check the canvas size before mapping, but it's safe because 71 // We can't check the canvas size before mapping, but it's safe because
72 // Windows will fail to map the section if the dimensions of the canvas 72 // Windows will fail to map the section if the dimensions of the canvas
73 // are too large. 73 // are too large.
74 skia::PlatformCanvas* canvas = 74 skia::PlatformCanvas* canvas =
75 skia::CreatePlatformCanvas(w, h, true, handle(), 75 skia::CreatePlatformCanvas(w, h, true, shared_memory_.handle(),
76 skia::RETURN_NULL_ON_FAILURE); 76 skia::RETURN_NULL_ON_FAILURE);
77 77
78 // Calculate the size for the memory region backing the canvas. 78 // Calculate the size for the memory region backing the canvas.
79 if (canvas) 79 if (canvas)
80 size_ = skia::PlatformCanvasStrideForWidth(w) * h; 80 size_ = skia::PlatformCanvasStrideForWidth(w) * h;
81 81
82 return canvas; 82 return canvas;
83 } 83 }
84 84
85 bool TransportDIB::Map() { 85 bool TransportDIB::Map() {
86 if (!is_valid_handle(handle())) 86 if (!is_valid_handle(shared_memory_.handle()))
87 return false; 87 return false;
88 if (memory()) 88 if (memory())
89 return true; 89 return true;
90 90
91 if (!shared_memory_.Map(0 /* map whole shared memory segment */)) { 91 if (!shared_memory_.Map(0 /* map whole shared memory segment */)) {
92 LOG(ERROR) << "Failed to map transport DIB" 92 LOG(ERROR) << "Failed to map transport DIB"
93 << " handle:" << shared_memory_.handle() 93 << " handle:" << shared_memory_.handle()
94 << " error:" << ::GetLastError(); 94 << " error:" << ::GetLastError();
95 return false; 95 return false;
96 } 96 }
97 97
98 size_ = shared_memory_.mapped_size(); 98 size_ = shared_memory_.mapped_size();
99 return true; 99 return true;
100 } 100 }
101 101
102 void* TransportDIB::memory() const { 102 void* TransportDIB::memory() const {
103 return shared_memory_.memory(); 103 return shared_memory_.memory();
104 } 104 }
105 105
106 TransportDIB::Handle TransportDIB::handle() const { 106 TransportDIB::Id TransportDIB::id() const {
107 return shared_memory_.handle(); 107 return Id(shared_memory_.handle(), sequence_num_);
108 } 108 }
109
110 TransportDIB::Id TransportDIB::id() const {
111 return Id(handle(), sequence_num_);
112 }
OLDNEW
« no previous file with comments | « ui/surface/transport_dib_posix.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698