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

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

Issue 11138024: Simplify platform_canvas.h by recognizing that PlatformCanvas does not actually extend (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 1 month 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_linux.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/eintr_wrapper.h" 10 #include "base/eintr_wrapper.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
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())
65 return NULL; 65 return NULL;
66 scoped_ptr<skia::PlatformCanvas> canvas(new skia::PlatformCanvas); 66 return skia::CreatePlatformCanvas(w, h, true,
67 if (!canvas->initialize(w, h, true, reinterpret_cast<uint8_t*>(memory()))) 67 reinterpret_cast<uint8_t*>(memory()),
68 return NULL; 68 skia::RETURN_NULL_ON_FAILURE);
69 return canvas.release();
70 } 69 }
71 70
72 bool TransportDIB::Map() { 71 bool TransportDIB::Map() {
73 if (!is_valid_handle(handle())) 72 if (!is_valid_handle(handle()))
74 return false; 73 return false;
75 if (memory()) 74 if (memory())
76 return true; 75 return true;
77 76
78 struct stat st; 77 struct stat st;
79 if ((fstat(shared_memory_.handle().fd, &st) != 0) || 78 if ((fstat(shared_memory_.handle().fd, &st) != 0) ||
80 (!shared_memory_.Map(st.st_size))) { 79 (!shared_memory_.Map(st.st_size))) {
81 return false; 80 return false;
82 } 81 }
83 82
84 size_ = st.st_size; 83 size_ = st.st_size;
85 return true; 84 return true;
86 } 85 }
87 86
88 void* TransportDIB::memory() const { 87 void* TransportDIB::memory() const {
89 return shared_memory_.memory(); 88 return shared_memory_.memory();
90 } 89 }
91 90
92 TransportDIB::Id TransportDIB::id() const { 91 TransportDIB::Id TransportDIB::id() const {
93 return shared_memory_.id(); 92 return shared_memory_.id();
94 } 93 }
95 94
96 TransportDIB::Handle TransportDIB::handle() const { 95 TransportDIB::Handle TransportDIB::handle() const {
97 return shared_memory_.handle(); 96 return shared_memory_.handle();
98 } 97 }
OLDNEW
« no previous file with comments | « ui/surface/transport_dib_linux.cc ('k') | ui/surface/transport_dib_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698