OLD | NEW |
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 "chrome/renderer/extensions/set_icon_natives.h" | 5 #include "chrome/renderer/extensions/set_icon_natives.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "chrome/common/render_messages.h" | 10 #include "chrome/common/render_messages.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 isolate->ThrowException( | 73 isolate->ThrowException( |
74 v8::Exception::Error(v8::String::NewFromUtf8(isolate, kNoMemory))); | 74 v8::Exception::Error(v8::String::NewFromUtf8(isolate, kNoMemory))); |
75 return false; | 75 return false; |
76 } | 76 } |
77 bitmap.eraseARGB(0, 0, 0, 0); | 77 bitmap.eraseARGB(0, 0, 0, 0); |
78 | 78 |
79 uint32_t* pixels = bitmap.getAddr32(0, 0); | 79 uint32_t* pixels = bitmap.getAddr32(0, 0); |
80 for (int t = 0; t < width*height; t++) { | 80 for (int t = 0; t < width*height; t++) { |
81 // |data| is RGBA, pixels is ARGB. | 81 // |data| is RGBA, pixels is ARGB. |
82 pixels[t] = SkPreMultiplyColor( | 82 pixels[t] = SkPreMultiplyColor( |
83 ((data->Get(v8::Integer::New(4*t + 3))->Int32Value() & 0xFF) << 24) | | 83 ((data->Get(v8::Integer::New(isolate, 4*t + 3))->Int32Value() & 0xFF) |
84 ((data->Get(v8::Integer::New(4*t + 0))->Int32Value() & 0xFF) << 16) | | 84 << 24) | |
85 ((data->Get(v8::Integer::New(4*t + 1))->Int32Value() & 0xFF) << 8) | | 85 ((data->Get(v8::Integer::New(isolate, 4*t + 0))->Int32Value() & 0xFF) |
86 ((data->Get(v8::Integer::New(4*t + 2))->Int32Value() & 0xFF) << 0)); | 86 << 16) | |
| 87 ((data->Get(v8::Integer::New(isolate, 4*t + 1))->Int32Value() & 0xFF) |
| 88 << 8) | |
| 89 ((data->Get(v8::Integer::New(isolate, 4*t + 2))->Int32Value() & 0xFF) |
| 90 << 0)); |
87 } | 91 } |
88 | 92 |
89 // Construct the Value object. | 93 // Construct the Value object. |
90 IPC::Message bitmap_pickle; | 94 IPC::Message bitmap_pickle; |
91 IPC::WriteParam(&bitmap_pickle, bitmap); | 95 IPC::WriteParam(&bitmap_pickle, bitmap); |
92 *bitmap_value = base::BinaryValue::CreateWithCopiedBuffer( | 96 *bitmap_value = base::BinaryValue::CreateWithCopiedBuffer( |
93 static_cast<const char*>(bitmap_pickle.data()), bitmap_pickle.size()); | 97 static_cast<const char*>(bitmap_pickle.data()), bitmap_pickle.size()); |
94 | 98 |
95 return true; | 99 return true; |
96 } | 100 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 | 155 |
152 request_sender_->StartRequest(context(), | 156 request_sender_->StartRequest(context(), |
153 name, | 157 name, |
154 request_id, | 158 request_id, |
155 has_callback, | 159 has_callback, |
156 for_io_thread, | 160 for_io_thread, |
157 &list_value); | 161 &list_value); |
158 } | 162 } |
159 | 163 |
160 } // namespace extensions | 164 } // namespace extensions |
OLD | NEW |