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

Side by Side Diff: base/clipboard_linux.cc

Issue 87016: Eliminate a circular dependency by making BGRAToRGBA() generic... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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 | Annotate | Revision Log
« no previous file with comments | « base/base.gyp ('k') | base/gfx/gtk_util.h » ('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 #include "base/clipboard.h" 5 #include "base/clipboard.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 #include <utility> 11 #include <utility>
12 12
13 #include "base/gfx/gtk_util.h" 13 #include "base/linux_util.h"
14 #include "base/string_util.h" 14 #include "base/string_util.h"
15 15
16 namespace { 16 namespace {
17 17
18 const char* kMimeBmp = "image/bmp"; 18 const char* kMimeBmp = "image/bmp";
19 const char* kMimeHtml = "text/html"; 19 const char* kMimeHtml = "text/html";
20 const char* kMimeText = "text/plain"; 20 const char* kMimeText = "text/plain";
21 const char* kMimeWebkitSmartPaste = "chromium-internal/webkit-paste"; 21 const char* kMimeWebkitSmartPaste = "chromium-internal/webkit-paste";
22 22
23 std::string GdkAtomToString(const GdkAtom& atom) { 23 std::string GdkAtomToString(const GdkAtom& atom) {
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 171
172 // Write an extra flavor that signifies WebKit was the last to modify the 172 // Write an extra flavor that signifies WebKit was the last to modify the
173 // pasteboard. This flavor has no data. 173 // pasteboard. This flavor has no data.
174 void Clipboard::WriteWebSmartPaste() { 174 void Clipboard::WriteWebSmartPaste() {
175 InsertMapping(kMimeWebkitSmartPaste, NULL, 0); 175 InsertMapping(kMimeWebkitSmartPaste, NULL, 0);
176 } 176 }
177 177
178 void Clipboard::WriteBitmap(const char* pixel_data, const char* size_data) { 178 void Clipboard::WriteBitmap(const char* pixel_data, const char* size_data) {
179 const gfx::Size* size = reinterpret_cast<const gfx::Size*>(size_data); 179 const gfx::Size* size = reinterpret_cast<const gfx::Size*>(size_data);
180 180
181 guchar* data = gfx::BGRAToRGBA(reinterpret_cast<const uint8_t*>(pixel_data), 181 guchar* data = base::BGRAToRGBA(reinterpret_cast<const uint8_t*>(pixel_data),
182 size->width(), size->height(), 0); 182 size->width(), size->height(), 0);
183 183
184 GdkPixbuf* pixbuf = 184 GdkPixbuf* pixbuf =
185 gdk_pixbuf_new_from_data(data, GDK_COLORSPACE_RGB, TRUE, 185 gdk_pixbuf_new_from_data(data, GDK_COLORSPACE_RGB, TRUE,
186 8, size->width(), size->height(), 186 8, size->width(), size->height(),
187 size->width() * 4, GdkPixbufFree, NULL); 187 size->width() * 4, GdkPixbufFree, NULL);
188 // We store the GdkPixbuf*, and the size_t half of the pair is meaningless. 188 // We store the GdkPixbuf*, and the size_t half of the pair is meaningless.
189 // Note that this contrasts with the vast majority of entries in our target 189 // Note that this contrasts with the vast majority of entries in our target
190 // map, which directly store the data and its length. 190 // map, which directly store the data and its length.
191 InsertMapping(kMimeBmp, reinterpret_cast<char*>(pixbuf), 0); 191 InsertMapping(kMimeBmp, reinterpret_cast<char*>(pixbuf), 0);
192 } 192 }
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 317
318 if (iter != clipboard_data_->end()) { 318 if (iter != clipboard_data_->end()) {
319 if (strcmp(kMimeBmp, key) == 0) 319 if (strcmp(kMimeBmp, key) == 0)
320 g_object_unref(reinterpret_cast<GdkPixbuf*>(iter->second.first)); 320 g_object_unref(reinterpret_cast<GdkPixbuf*>(iter->second.first));
321 else 321 else
322 delete[] iter->second.first; 322 delete[] iter->second.first;
323 } 323 }
324 324
325 (*clipboard_data_)[key] = std::make_pair(data, data_len); 325 (*clipboard_data_)[key] = std::make_pair(data, data_len);
326 } 326 }
OLDNEW
« no previous file with comments | « base/base.gyp ('k') | base/gfx/gtk_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698