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

Side by Side Diff: chrome/renderer/renderer_glue.cc

Issue 28119: Chromium changes to use new WebKit, WebKitClient, and WebClipboard interfaces... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « chrome/renderer/renderer.vcproj ('k') | webkit/build/WebKit/SConscript » ('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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 random webkit glue functions. 5 // This file provides the embedder's side of random webkit glue functions.
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #if defined(OS_WIN) 9 #if defined(OS_WIN)
10 #include <windows.h> 10 #include <windows.h>
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 cur_capacity_ = stack_capacity; 77 cur_capacity_ = stack_capacity;
78 } 78 }
79 } 79 }
80 80
81 T stack_buffer_[stack_capacity]; 81 T stack_buffer_[stack_capacity];
82 T* cur_buffer_; 82 T* cur_buffer_;
83 size_t cur_capacity_; 83 size_t cur_capacity_;
84 }; 84 };
85 85
86 #if defined(OS_WIN) 86 #if defined(OS_WIN)
87 // This definition of WriteBitmap uses shared memory to communicate across 87 // This definition of WriteBitmapFromPixels uses shared memory to communicate
88 // processes. 88 // across processes.
89 void ScopedClipboardWriterGlue::WriteBitmap(const SkBitmap& bitmap) { 89 void ScopedClipboardWriterGlue::WriteBitmapFromPixels(const void* pixels,
90 // do not try to write a bitmap more than once 90 const gfx::Size& size) {
91 // Do not try to write a bitmap more than once
91 if (shared_buf_) 92 if (shared_buf_)
92 return; 93 return;
93 94
94 size_t buf_size = bitmap.getSize(); 95 size_t buf_size = 4 * size.width() * size.height();
95 gfx::Size size(bitmap.width(), bitmap.height());
96 96
97 // Allocate a shared memory buffer to hold the bitmap bits 97 // Allocate a shared memory buffer to hold the bitmap bits
98 shared_buf_ = new base::SharedMemory; 98 shared_buf_ = new base::SharedMemory;
99 shared_buf_->Create(L"", false /* read write */, true /* open existing */, 99 shared_buf_->Create(L"", false /* read write */, true /* open existing */,
100 buf_size); 100 buf_size);
101 if (!shared_buf_ || !shared_buf_->Map(buf_size)) { 101 if (!shared_buf_ || !shared_buf_->Map(buf_size)) {
102 NOTREACHED(); 102 NOTREACHED();
103 return; 103 return;
104 } 104 }
105 105
106 // Copy the bits into shared memory 106 // Copy the bits into shared memory
107 SkAutoLockPixels bitmap_lock(bitmap); 107 memcpy(shared_buf_->memory(), pixels, buf_size);
108 memcpy(shared_buf_->memory(), bitmap.getPixels(), buf_size);
109 shared_buf_->Unmap(); 108 shared_buf_->Unmap();
110 109
111 Clipboard::ObjectMapParam param1, param2; 110 Clipboard::ObjectMapParam param1, param2;
112 base::SharedMemoryHandle smh = shared_buf_->handle(); 111 base::SharedMemoryHandle smh = shared_buf_->handle();
113 112
114 const char* shared_handle = reinterpret_cast<const char*>(&smh); 113 const char* shared_handle = reinterpret_cast<const char*>(&smh);
115 for (size_t i = 0; i < sizeof base::SharedMemoryHandle; i++) 114 for (size_t i = 0; i < sizeof base::SharedMemoryHandle; i++)
116 param1.push_back(shared_handle[i]); 115 param1.push_back(shared_handle[i]);
117 116
118 const char* size_data = reinterpret_cast<const char*>(&size); 117 const char* size_data = reinterpret_cast<const char*>(&size);
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 // Update the browser about our cache 356 // Update the browser about our cache
358 // NOTE: Since this can be called from the plugin process, we might not have 357 // NOTE: Since this can be called from the plugin process, we might not have
359 // a RenderThread. Do nothing in that case. 358 // a RenderThread. Do nothing in that case.
360 if (!IsPluginProcess()) 359 if (!IsPluginProcess())
361 RenderThread::current()->InformHostOfCacheStatsLater(); 360 RenderThread::current()->InformHostOfCacheStatsLater();
362 } 361 }
363 362
364 #endif // !USING_SIMPLE_RESOURCE_LOADER_BRIDGE 363 #endif // !USING_SIMPLE_RESOURCE_LOADER_BRIDGE
365 364
366 } // namespace webkit_glue 365 } // namespace webkit_glue
OLDNEW
« no previous file with comments | « chrome/renderer/renderer.vcproj ('k') | webkit/build/WebKit/SConscript » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698