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

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

Issue 2595023002: clean-up and clarify CreatePlatformCanvas methods (Closed)
Patch Set: single decl of CreatePlatformCanvasWithPixels Created 3 years, 12 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
« no previous file with comments | « ui/gfx/blit_unittest.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 <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 std::unique_ptr<SkCanvas> TransportDIB::GetPlatformCanvas(int w, 61 std::unique_ptr<SkCanvas> TransportDIB::GetPlatformCanvas(int w,
62 int h, 62 int h,
63 bool opaque) { 63 bool opaque) {
64 if ((!memory() && !Map()) || !VerifyCanvasSize(w, h)) 64 if ((!memory() && !Map()) || !VerifyCanvasSize(w, h))
65 return NULL; 65 return NULL;
66 return skia::CreatePlatformCanvas(w, h, opaque, 66 return skia::CreatePlatformCanvasWithPixels(
67 reinterpret_cast<uint8_t*>(memory()), 67 w, h, opaque, 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(shared_memory_.handle())) 72 if (!is_valid_handle(shared_memory_.handle()))
73 return false; 73 return false;
74 #if defined(OS_ANDROID) 74 #if defined(OS_ANDROID)
75 if (!shared_memory_.Map(0)) 75 if (!shared_memory_.Map(0))
76 return false; 76 return false;
77 size_ = shared_memory_.mapped_size(); 77 size_ = shared_memory_.mapped_size();
78 #else 78 #else
79 if (memory()) 79 if (memory())
80 return true; 80 return true;
81 81
82 size_t size; 82 size_t size;
83 bool success = base::SharedMemory::GetSizeFromSharedMemoryHandle( 83 bool success = base::SharedMemory::GetSizeFromSharedMemoryHandle(
84 shared_memory_.handle(), &size); 84 shared_memory_.handle(), &size);
85 if (!success || !shared_memory_.Map(size)) 85 if (!success || !shared_memory_.Map(size))
86 return false; 86 return false;
87 87
88 size_ = size; 88 size_ = size;
89 #endif 89 #endif
90 return true; 90 return true;
91 } 91 }
92 92
93 void* TransportDIB::memory() const { 93 void* TransportDIB::memory() const {
94 return shared_memory_.memory(); 94 return shared_memory_.memory();
95 } 95 }
OLDNEW
« no previous file with comments | « ui/gfx/blit_unittest.cc ('k') | ui/surface/transport_dib_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698