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

Side by Side Diff: ui/surface/transport_dib_posix.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.cc ('k') | ui/surface/transport_dib_win.cc » ('j') | 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 <sys/stat.h> 7 #include <sys/stat.h>
8 #include <unistd.h> 8 #include <unistd.h>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...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 if ((!memory() && !Map()) || !VerifyCanvasSize(w, h)) 67 if ((!memory() && !Map()) || !VerifyCanvasSize(w, h))
68 return NULL; 68 return NULL;
69 return skia::CreatePlatformCanvas(w, h, true, 69 return skia::CreatePlatformCanvas(w, h, true,
70 reinterpret_cast<uint8_t*>(memory()), 70 reinterpret_cast<uint8_t*>(memory()),
71 skia::RETURN_NULL_ON_FAILURE); 71 skia::RETURN_NULL_ON_FAILURE);
72 } 72 }
73 73
74 bool TransportDIB::Map() { 74 bool TransportDIB::Map() {
75 if (!is_valid_handle(handle())) 75 if (!is_valid_handle(shared_memory_.handle()))
76 return false; 76 return false;
77 #if defined(OS_ANDROID) 77 #if defined(OS_ANDROID)
78 if (!shared_memory_.Map(0)) 78 if (!shared_memory_.Map(0))
79 return false; 79 return false;
80 size_ = shared_memory_.mapped_size(); 80 size_ = shared_memory_.mapped_size();
81 #else 81 #else
82 if (memory()) 82 if (memory())
83 return true; 83 return true;
84 84
85 int size = base::SharedMemory::GetSizeFromSharedMemoryHandle( 85 int size = base::SharedMemory::GetSizeFromSharedMemoryHandle(
86 shared_memory_.handle()); 86 shared_memory_.handle());
87 if (size == -1 || !shared_memory_.Map(size)) 87 if (size == -1 || !shared_memory_.Map(size))
88 return false; 88 return false;
89 89
90 size_ = size; 90 size_ = size;
91 #endif 91 #endif
92 return true; 92 return true;
93 } 93 }
94 94
95 void* TransportDIB::memory() const { 95 void* TransportDIB::memory() const {
96 return shared_memory_.memory(); 96 return shared_memory_.memory();
97 } 97 }
98 98
99 TransportDIB::Id TransportDIB::id() const { 99 TransportDIB::Id TransportDIB::id() const {
100 #if defined(OS_ANDROID) 100 #if defined(OS_ANDROID)
101 return handle(); 101 return shared_memory_.handle();
102 #else 102 #else
103 return shared_memory_.id(); 103 return shared_memory_.id();
104 #endif 104 #endif
105 } 105 }
106
107 TransportDIB::Handle TransportDIB::handle() const {
108 return shared_memory_.handle();
109 }
OLDNEW
« no previous file with comments | « ui/surface/transport_dib.cc ('k') | ui/surface/transport_dib_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698