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

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

Issue 2476113002: Change call-sites now that SkCanvas is not ref-counted (Closed)
Patch Set: no need for unique check on unique_ptr Created 4 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
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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <sys/stat.h> 9 #include <sys/stat.h>
10 #include <unistd.h> 10 #include <unistd.h>
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 // static 56 // static
57 bool TransportDIB::is_valid_handle(Handle dib) { 57 bool TransportDIB::is_valid_handle(Handle dib) {
58 return base::SharedMemory::IsHandleValid(dib); 58 return base::SharedMemory::IsHandleValid(dib);
59 } 59 }
60 60
61 SkCanvas* TransportDIB::GetPlatformCanvas(int w, int h, bool opaque) { 61 SkCanvas* TransportDIB::GetPlatformCanvas(int w, int h, bool opaque) {
62 if ((!memory() && !Map()) || !VerifyCanvasSize(w, h)) 62 if ((!memory() && !Map()) || !VerifyCanvasSize(w, h))
63 return NULL; 63 return NULL;
64 return skia::CreatePlatformCanvas(w, h, opaque, 64 return skia::CreatePlatformCanvas(w, h, opaque,
65 reinterpret_cast<uint8_t*>(memory()), 65 reinterpret_cast<uint8_t*>(memory()),
66 skia::RETURN_NULL_ON_FAILURE); 66 skia::RETURN_NULL_ON_FAILURE)
67 .release();
danakj 2016/11/14 19:35:15 Please make GetPlatformCanvas return a unique_ptr
reed1 2016/11/14 20:50:08 Done.
67 } 68 }
68 69
69 bool TransportDIB::Map() { 70 bool TransportDIB::Map() {
70 if (!is_valid_handle(shared_memory_.handle())) 71 if (!is_valid_handle(shared_memory_.handle()))
71 return false; 72 return false;
72 #if defined(OS_ANDROID) 73 #if defined(OS_ANDROID)
73 if (!shared_memory_.Map(0)) 74 if (!shared_memory_.Map(0))
74 return false; 75 return false;
75 size_ = shared_memory_.mapped_size(); 76 size_ = shared_memory_.mapped_size();
76 #else 77 #else
77 if (memory()) 78 if (memory())
78 return true; 79 return true;
79 80
80 size_t size; 81 size_t size;
81 bool success = base::SharedMemory::GetSizeFromSharedMemoryHandle( 82 bool success = base::SharedMemory::GetSizeFromSharedMemoryHandle(
82 shared_memory_.handle(), &size); 83 shared_memory_.handle(), &size);
83 if (!success || !shared_memory_.Map(size)) 84 if (!success || !shared_memory_.Map(size))
84 return false; 85 return false;
85 86
86 size_ = size; 87 size_ = size;
87 #endif 88 #endif
88 return true; 89 return true;
89 } 90 }
90 91
91 void* TransportDIB::memory() const { 92 void* TransportDIB::memory() const {
92 return shared_memory_.memory(); 93 return shared_memory_.memory();
93 } 94 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698