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

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

Issue 12537014: Make SharedMemory track the size that was actually mapped (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « ui/surface/transport_dib_android.cc ('k') | ui/surface/transport_dib_mac.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 <errno.h> 7 #include <errno.h>
8 #include <stdlib.h> 8 #include <stdlib.h>
9 #include <sys/ipc.h> 9 #include <sys/ipc.h>
10 #include <sys/shm.h> 10 #include <sys/shm.h>
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 bool TransportDIB::is_valid_handle(Handle dib) { 85 bool TransportDIB::is_valid_handle(Handle dib) {
86 return dib >= 0; 86 return dib >= 0;
87 } 87 }
88 88
89 // static 89 // static
90 bool TransportDIB::is_valid_id(Id id) { 90 bool TransportDIB::is_valid_id(Id id) {
91 return id.shmkey != -1; 91 return id.shmkey != -1;
92 } 92 }
93 93
94 skia::PlatformCanvas* TransportDIB::GetPlatformCanvas(int w, int h) { 94 skia::PlatformCanvas* TransportDIB::GetPlatformCanvas(int w, int h) {
95 if (address_ == kInvalidAddress && !Map()) 95 if ((address_ == kInvalidAddress && !Map()) || !VerifyCanvasSize(w, h))
96 return NULL; 96 return NULL;
97 return skia::CreatePlatformCanvas(w, h, true, 97 return skia::CreatePlatformCanvas(w, h, true,
98 reinterpret_cast<uint8_t*>(memory()), 98 reinterpret_cast<uint8_t*>(memory()),
99 skia::RETURN_NULL_ON_FAILURE); 99 skia::RETURN_NULL_ON_FAILURE);
100 } 100 }
101 101
102 bool TransportDIB::Map() { 102 bool TransportDIB::Map() {
103 if (!is_valid_id(key_)) 103 if (!is_valid_id(key_))
104 return false; 104 return false;
105 if (address_ != kInvalidAddress) 105 if (address_ != kInvalidAddress)
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 if (!inflight_counter_ && detached_) 146 if (!inflight_counter_ && detached_)
147 delete this; 147 delete this;
148 } 148 }
149 149
150 void TransportDIB::Detach() { 150 void TransportDIB::Detach() {
151 CHECK(!detached_); 151 CHECK(!detached_);
152 detached_ = true; 152 detached_ = true;
153 if (!inflight_counter_) 153 if (!inflight_counter_)
154 delete this; 154 delete this;
155 } 155 }
OLDNEW
« no previous file with comments | « ui/surface/transport_dib_android.cc ('k') | ui/surface/transport_dib_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698