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

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

Issue 6665029: Adds a TransportDIB::Id value that is explicitly invalid and use it when compositing (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: mebbe this one compiles? Created 9 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "app/surface/transport_dib.h" 5 #include "app/surface/transport_dib.h"
6 6
7 #include <unistd.h> 7 #include <unistd.h>
8 #include <sys/stat.h> 8 #include <sys/stat.h>
9 9
10 #include "base/eintr_wrapper.h" 10 #include "base/eintr_wrapper.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 return NULL; 44 return NULL;
45 return dib.release(); 45 return dib.release();
46 } 46 }
47 47
48 // static 48 // static
49 TransportDIB* TransportDIB::CreateWithHandle(Handle handle) { 49 TransportDIB* TransportDIB::CreateWithHandle(Handle handle) {
50 return new TransportDIB(handle); 50 return new TransportDIB(handle);
51 } 51 }
52 52
53 // static 53 // static
54 bool TransportDIB::is_valid(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
59 bool TransportDIB::is_valid_id(Id id) {
60 return id != 0;
61 }
62
58 skia::PlatformCanvas* TransportDIB::GetPlatformCanvas(int w, int h) { 63 skia::PlatformCanvas* TransportDIB::GetPlatformCanvas(int w, int h) {
59 if (!memory() && !Map()) 64 if (!memory() && !Map())
60 return NULL; 65 return NULL;
61 scoped_ptr<skia::PlatformCanvas> canvas(new skia::PlatformCanvas); 66 scoped_ptr<skia::PlatformCanvas> canvas(new skia::PlatformCanvas);
62 if (!canvas->initialize(w, h, true, reinterpret_cast<uint8_t*>(memory()))) 67 if (!canvas->initialize(w, h, true, reinterpret_cast<uint8_t*>(memory())))
63 return NULL; 68 return NULL;
64 return canvas.release(); 69 return canvas.release();
65 } 70 }
66 71
67 bool TransportDIB::Map() { 72 bool TransportDIB::Map() {
68 if (!is_valid(handle())) 73 if (!is_valid_handle(handle()))
69 return false; 74 return false;
70 if (memory()) 75 if (memory())
71 return true; 76 return true;
72 77
73 struct stat st; 78 struct stat st;
74 if ((fstat(shared_memory_.handle().fd, &st) != 0) || 79 if ((fstat(shared_memory_.handle().fd, &st) != 0) ||
75 (!shared_memory_.Map(st.st_size))) { 80 (!shared_memory_.Map(st.st_size))) {
76 return false; 81 return false;
77 } 82 }
78 83
79 size_ = st.st_size; 84 size_ = st.st_size;
80 return true; 85 return true;
81 } 86 }
82 87
83 void* TransportDIB::memory() const { 88 void* TransportDIB::memory() const {
84 return shared_memory_.memory(); 89 return shared_memory_.memory();
85 } 90 }
86 91
87 TransportDIB::Id TransportDIB::id() const { 92 TransportDIB::Id TransportDIB::id() const {
88 return shared_memory_.id(); 93 return shared_memory_.id();
89 } 94 }
90 95
91 TransportDIB::Handle TransportDIB::handle() const { 96 TransportDIB::Handle TransportDIB::handle() const {
92 return shared_memory_.handle(); 97 return shared_memory_.handle();
93 } 98 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698