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

Side by Side Diff: ui/surface/transport_dib_mac.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, 9 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
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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 bool TransportDIB::is_valid_handle(Handle dib) { 54 bool TransportDIB::is_valid_handle(Handle dib) {
55 return dib.fd >= 0; 55 return dib.fd >= 0;
56 } 56 }
57 57
58 // static 58 // static
59 bool TransportDIB::is_valid_id(Id id) { 59 bool TransportDIB::is_valid_id(Id id) {
60 return id != 0; 60 return id != 0;
61 } 61 }
62 62
63 skia::PlatformCanvas* TransportDIB::GetPlatformCanvas(int w, int h) { 63 skia::PlatformCanvas* TransportDIB::GetPlatformCanvas(int w, int h) {
64 if (!memory() && !Map()) 64 if ((!memory() && !Map()) || !VerifyCanvasSize(w, h))
apatrick_chromium 2013/03/18 17:32:10 Do you want to evaluate VerifyCanvasSize(w, h) fir
jschuh 2013/03/21 01:08:03 Same answer as Android.
65 return NULL; 65 return NULL;
66 return skia::CreatePlatformCanvas(w, h, true, 66 return skia::CreatePlatformCanvas(w, h, true,
67 reinterpret_cast<uint8_t*>(memory()), 67 reinterpret_cast<uint8_t*>(memory()),
68 skia::RETURN_NULL_ON_FAILURE); 68 skia::RETURN_NULL_ON_FAILURE);
69 } 69 }
70 70
71 bool TransportDIB::Map() { 71 bool TransportDIB::Map() {
72 if (!is_valid_handle(handle())) 72 if (!is_valid_handle(handle()))
73 return false; 73 return false;
74 if (memory()) 74 if (memory())
(...skipping 13 matching lines...) Expand all
88 return shared_memory_.memory(); 88 return shared_memory_.memory();
89 } 89 }
90 90
91 TransportDIB::Id TransportDIB::id() const { 91 TransportDIB::Id TransportDIB::id() const {
92 return shared_memory_.id(); 92 return shared_memory_.id();
93 } 93 }
94 94
95 TransportDIB::Handle TransportDIB::handle() const { 95 TransportDIB::Handle TransportDIB::handle() const {
96 return shared_memory_.handle(); 96 return shared_memory_.handle();
97 } 97 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698