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

Side by Side Diff: content/renderer/renderer_clipboard_delegate.cc

Issue 2823003002: SkBitmap and SkPixelRef no longer need lock/unlock (Closed)
Patch Set: win fix after rebase Created 3 years, 8 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
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 // This file provides the embedder's side of the Clipboard interface. 5 // This file provides the embedder's side of the Clipboard interface.
6 6
7 #include "content/renderer/renderer_clipboard_delegate.h" 7 #include "content/renderer/renderer_clipboard_delegate.h"
8 8
9 #include "base/memory/shared_memory.h" 9 #include "base/memory/shared_memory.h"
10 #include "base/numerics/safe_math.h" 10 #include "base/numerics/safe_math.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 new ClipboardHostMsg_WriteBookmark(clipboard_type, url.spec(), title)); 116 new ClipboardHostMsg_WriteBookmark(clipboard_type, url.spec(), title));
117 } 117 }
118 118
119 bool RendererClipboardDelegate::WriteImage(ui::ClipboardType clipboard_type, 119 bool RendererClipboardDelegate::WriteImage(ui::ClipboardType clipboard_type,
120 const SkBitmap& bitmap) { 120 const SkBitmap& bitmap) {
121 // Only 32-bit bitmaps are supported. 121 // Only 32-bit bitmaps are supported.
122 DCHECK_EQ(bitmap.colorType(), kN32_SkColorType); 122 DCHECK_EQ(bitmap.colorType(), kN32_SkColorType);
123 123
124 const gfx::Size size(bitmap.width(), bitmap.height()); 124 const gfx::Size size(bitmap.width(), bitmap.height());
125 std::unique_ptr<base::SharedMemory> shared_buf; 125 std::unique_ptr<base::SharedMemory> shared_buf;
126
126 { 127 {
127 SkAutoLockPixels locked(bitmap);
128 void* pixels = bitmap.getPixels(); 128 void* pixels = bitmap.getPixels();
129 // TODO(piman): this should not be NULL, but it is. crbug.com/369621 129 // TODO(piman): this should not be NULL, but it is. crbug.com/369621
130 if (!pixels) 130 if (!pixels)
131 return false; 131 return false;
132 132
133 base::CheckedNumeric<uint32_t> checked_buf_size = 4; 133 base::CheckedNumeric<uint32_t> checked_buf_size = 4;
134 checked_buf_size *= size.width(); 134 checked_buf_size *= size.width();
135 checked_buf_size *= size.height(); 135 checked_buf_size *= size.height();
136 if (!checked_buf_size.IsValid()) 136 if (!checked_buf_size.IsValid())
137 return false; 137 return false;
(...skipping 15 matching lines...) Expand all
153 clipboard_type, size, shared_buf->handle())); 153 clipboard_type, size, shared_buf->handle()));
154 return true; 154 return true;
155 } 155 }
156 156
157 void RendererClipboardDelegate::CommitWrite(ui::ClipboardType clipboard_type) { 157 void RendererClipboardDelegate::CommitWrite(ui::ClipboardType clipboard_type) {
158 RenderThreadImpl::current()->Send( 158 RenderThreadImpl::current()->Send(
159 new ClipboardHostMsg_CommitWrite(clipboard_type)); 159 new ClipboardHostMsg_CommitWrite(clipboard_type));
160 } 160 }
161 161
162 } // namespace content 162 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/pepper/pepper_video_source_host.cc ('k') | content/shell/browser/layout_test/blink_test_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698