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

Side by Side Diff: ui/surface/transport_dib_win.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/surface/transport_dib_posix.cc ('k') | no next file » | 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 <windows.h> 7 #include <windows.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 // This DIB already mapped the file into this process, but PlatformCanvas 64 // This DIB already mapped the file into this process, but PlatformCanvas
65 // will map it again. 65 // will map it again.
66 DCHECK(!memory()) << "Mapped file twice in the same process."; 66 DCHECK(!memory()) << "Mapped file twice in the same process.";
67 67
68 // We can't check the canvas size before mapping, but it's safe because 68 // We can't check the canvas size before mapping, but it's safe because
69 // Windows will fail to map the section if the dimensions of the canvas 69 // Windows will fail to map the section if the dimensions of the canvas
70 // are too large. 70 // are too large.
71 std::unique_ptr<SkCanvas> canvas = skia::CreatePlatformCanvas( 71 std::unique_ptr<SkCanvas> canvas =
72 w, h, opaque, shared_memory_.handle().GetHandle(), 72 skia::CreatePlatformCanvasWithSharedSection(
73 skia::RETURN_NULL_ON_FAILURE); 73 w, h, opaque, shared_memory_.handle().GetHandle(),
74 skia::RETURN_NULL_ON_FAILURE);
74 75
75 // Calculate the size for the memory region backing the canvas. 76 // Calculate the size for the memory region backing the canvas.
76 if (canvas) 77 if (canvas)
77 size_ = skia::PlatformCanvasStrideForWidth(w) * h; 78 size_ = skia::PlatformCanvasStrideForWidth(w) * h;
78 79
79 return canvas; 80 return canvas;
80 } 81 }
81 82
82 bool TransportDIB::Map() { 83 bool TransportDIB::Map() {
83 if (!is_valid_handle(shared_memory_.handle())) 84 if (!is_valid_handle(shared_memory_.handle()))
84 return false; 85 return false;
85 if (memory()) 86 if (memory())
86 return true; 87 return true;
87 88
88 if (!shared_memory_.Map(0 /* map whole shared memory segment */)) { 89 if (!shared_memory_.Map(0 /* map whole shared memory segment */)) {
89 LOG(ERROR) << "Failed to map transport DIB" 90 LOG(ERROR) << "Failed to map transport DIB"
90 << " handle:" << shared_memory_.handle().GetHandle() 91 << " handle:" << shared_memory_.handle().GetHandle()
91 << " error:" << ::GetLastError(); 92 << " error:" << ::GetLastError();
92 return false; 93 return false;
93 } 94 }
94 95
95 size_ = shared_memory_.mapped_size(); 96 size_ = shared_memory_.mapped_size();
96 return true; 97 return true;
97 } 98 }
98 99
99 void* TransportDIB::memory() const { 100 void* TransportDIB::memory() const {
100 return shared_memory_.memory(); 101 return shared_memory_.memory();
101 } 102 }
OLDNEW
« no previous file with comments | « ui/surface/transport_dib_posix.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698