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

Side by Side Diff: chrome/renderer/extensions/extension_process_bindings.cc

Issue 333011: Fix premultiplication mismatch (Closed)
Patch Set: Created 11 years, 2 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 | « no previous file | 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 <map> 5 #include <map>
6 #include <set> 6 #include <set>
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "chrome/renderer/extensions/extension_process_bindings.h" 10 #include "chrome/renderer/extensions/extension_process_bindings.h"
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 return v8::Undefined(); 427 return v8::Undefined();
428 } 428 }
429 429
430 SkBitmap bitmap; 430 SkBitmap bitmap;
431 bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height); 431 bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height);
432 bitmap.allocPixels(); 432 bitmap.allocPixels();
433 bitmap.eraseARGB(0, 0, 0, 0); 433 bitmap.eraseARGB(0, 0, 0, 0);
434 434
435 uint32_t* pixels = bitmap.getAddr32(0, 0); 435 uint32_t* pixels = bitmap.getAddr32(0, 0);
436 for (int t = 0; t < width*height; t++) { 436 for (int t = 0; t < width*height; t++) {
437 // |data| is RGBA, pixels is ARGB. 437 // |data| is RGBA not premutiplied, pixels is ARGB premultiplied.
tony 2009/10/23 16:52:17 Drive-by-nit: third_party/skia/include/core/SkColo
438 pixels[t] = 438 uint32_t r = data->Get(v8::Integer::New(4*t + 0))->Int32Value();
439 ((data->Get(v8::Integer::New(4*t + 3))->Int32Value() & 0xFF) << 24) | 439 uint32_t g = data->Get(v8::Integer::New(4*t + 1))->Int32Value();
440 ((data->Get(v8::Integer::New(4*t + 0))->Int32Value() & 0xFF) << 16) | 440 uint32_t b = data->Get(v8::Integer::New(4*t + 2))->Int32Value();
441 ((data->Get(v8::Integer::New(4*t + 1))->Int32Value() & 0xFF) << 8) | 441 uint32_t a = data->Get(v8::Integer::New(4*t + 3))->Int32Value();
442 ((data->Get(v8::Integer::New(4*t + 2))->Int32Value() & 0xFF) << 0); 442 pixels[t] = (a & 0xFF) << 24 |
443 (r * a / 0xFF & 0xFF) << 16 |
444 (g * a / 0xFF & 0xFF) << 8 |
445 (b * a / 0xFF & 0xFF);
443 } 446 }
444 447
445 // Construct the Value object. 448 // Construct the Value object.
446 IPC::Message bitmap_pickle; 449 IPC::Message bitmap_pickle;
447 IPC::WriteParam(&bitmap_pickle, bitmap); 450 IPC::WriteParam(&bitmap_pickle, bitmap);
448 Value* bitmap_value = BinaryValue::CreateWithCopiedBuffer( 451 Value* bitmap_value = BinaryValue::CreateWithCopiedBuffer(
449 static_cast<const char*>(bitmap_pickle.data()), bitmap_pickle.size()); 452 static_cast<const char*>(bitmap_pickle.data()), bitmap_pickle.size());
450 453
451 DictionaryValue* dict = new DictionaryValue(); 454 DictionaryValue* dict = new DictionaryValue();
452 dict->Set(L"imageData", bitmap_value); 455 dict->Set(L"imageData", bitmap_value);
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 return; 607 return;
605 608
606 v8::HandleScope handle_scope; 609 v8::HandleScope handle_scope;
607 WebFrame* frame = view->mainFrame(); 610 WebFrame* frame = view->mainFrame();
608 v8::Local<v8::Context> context = frame->mainWorldScriptContext(); 611 v8::Local<v8::Context> context = frame->mainWorldScriptContext();
609 v8::Handle<v8::Value> argv[1]; 612 v8::Handle<v8::Value> argv[1];
610 argv[0] = v8::String::New(type_str); 613 argv[0] = v8::String::New(type_str);
611 bindings_utils::CallFunctionInContext(context, "setViewType", 614 bindings_utils::CallFunctionInContext(context, "setViewType",
612 arraysize(argv), argv); 615 arraysize(argv), argv);
613 } 616 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698