OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/renderer/set_icon_natives.h" | 5 #include "extensions/renderer/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 "content/public/common/common_param_traits.h" | 10 #include "content/public/common/common_param_traits.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 | 61 |
62 int data_length = | 62 int data_length = |
63 data->Get(v8::String::NewFromUtf8(isolate, "length"))->Int32Value(); | 63 data->Get(v8::String::NewFromUtf8(isolate, "length"))->Int32Value(); |
64 if (data_length != 4 * width * height) { | 64 if (data_length != 4 * width * height) { |
65 isolate->ThrowException( | 65 isolate->ThrowException( |
66 v8::Exception::Error(v8::String::NewFromUtf8(isolate, kInvalidData))); | 66 v8::Exception::Error(v8::String::NewFromUtf8(isolate, kInvalidData))); |
67 return false; | 67 return false; |
68 } | 68 } |
69 | 69 |
70 SkBitmap bitmap; | 70 SkBitmap bitmap; |
71 bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height); | 71 if (!bitmap.allocN32Pixels(width, height)) { |
72 if (!bitmap.allocPixels()) { | |
73 isolate->ThrowException( | 72 isolate->ThrowException( |
74 v8::Exception::Error(v8::String::NewFromUtf8(isolate, kNoMemory))); | 73 v8::Exception::Error(v8::String::NewFromUtf8(isolate, kNoMemory))); |
75 return false; | 74 return false; |
76 } | 75 } |
77 bitmap.eraseARGB(0, 0, 0, 0); | 76 bitmap.eraseARGB(0, 0, 0, 0); |
78 | 77 |
79 uint32_t* pixels = bitmap.getAddr32(0, 0); | 78 uint32_t* pixels = bitmap.getAddr32(0, 0); |
80 for (int t = 0; t < width * height; t++) { | 79 for (int t = 0; t < width * height; t++) { |
81 // |data| is RGBA, pixels is ARGB. | 80 // |data| is RGBA, pixels is ARGB. |
82 pixels[t] = SkPreMultiplyColor( | 81 pixels[t] = SkPreMultiplyColor( |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 std::string name = *v8::String::Utf8Value(args[0]); | 154 std::string name = *v8::String::Utf8Value(args[0]); |
156 int request_id = args[2]->Int32Value(); | 155 int request_id = args[2]->Int32Value(); |
157 bool has_callback = args[3]->BooleanValue(); | 156 bool has_callback = args[3]->BooleanValue(); |
158 bool for_io_thread = args[4]->BooleanValue(); | 157 bool for_io_thread = args[4]->BooleanValue(); |
159 | 158 |
160 request_sender_->StartRequest( | 159 request_sender_->StartRequest( |
161 context(), name, request_id, has_callback, for_io_thread, &list_value); | 160 context(), name, request_id, has_callback, for_io_thread, &list_value); |
162 } | 161 } |
163 | 162 |
164 } // namespace extensions | 163 } // namespace extensions |
OLD | NEW |