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

Side by Side Diff: ui/surface/transport_dib_android.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.cc ('k') | ui/surface/transport_dib_linux.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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 return dib.fd >= 0; 56 return dib.fd >= 0;
57 } 57 }
58 58
59 // static 59 // static
60 bool TransportDIB::is_valid_id(Id id) { 60 bool TransportDIB::is_valid_id(Id id) {
61 // Same as is_valid_handle(). 61 // Same as is_valid_handle().
62 return id.fd >= 0; 62 return id.fd >= 0;
63 } 63 }
64 64
65 skia::PlatformCanvas* TransportDIB::GetPlatformCanvas(int w, int h) { 65 skia::PlatformCanvas* TransportDIB::GetPlatformCanvas(int w, int h) {
66 if (!memory() && !Map()) 66 if ((!memory() && !Map()) || !VerifyCanvasSize(w, h))
67 return NULL; 67 return NULL;
68 return skia::CreatePlatformCanvas(w, h, true, 68 return skia::CreatePlatformCanvas(w, h, true,
69 reinterpret_cast<uint8_t*>(memory()), 69 reinterpret_cast<uint8_t*>(memory()),
70 skia::RETURN_NULL_ON_FAILURE); 70 skia::RETURN_NULL_ON_FAILURE);
71 } 71 }
72 72
73 bool TransportDIB::Map() { 73 bool TransportDIB::Map() {
74 if (!is_valid_handle(handle())) 74 if (!is_valid_handle(handle()) || !shared_memory_.Map(0))
75 return false;
76 // We will use ashmem_get_size_region() to figure out the size in Map(size).
77 if (!shared_memory_.Map(0))
78 return false; 75 return false;
79 76
80 // TODO: Note that using created_size() below is a hack. See the comment in 77 size_ = shared_memory_.mapped_size();
81 // SharedMemory::Map().
82 size_ = shared_memory_.created_size();
83 return true; 78 return true;
84 } 79 }
85 80
86 void* TransportDIB::memory() const { 81 void* TransportDIB::memory() const {
87 return shared_memory_.memory(); 82 return shared_memory_.memory();
88 } 83 }
89 84
90 TransportDIB::Id TransportDIB::id() const { 85 TransportDIB::Id TransportDIB::id() const {
91 // Use FileDescriptor as id. 86 // Use FileDescriptor as id.
92 return shared_memory_.handle(); 87 return shared_memory_.handle();
93 } 88 }
94 89
95 TransportDIB::Handle TransportDIB::handle() const { 90 TransportDIB::Handle TransportDIB::handle() const {
96 return shared_memory_.handle(); 91 return shared_memory_.handle();
97 } 92 }
OLDNEW
« no previous file with comments | « ui/surface/transport_dib.cc ('k') | ui/surface/transport_dib_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698