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

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

Powered by Google App Engine
This is Rietveld 408576698