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/browser/speech/speech_recognition_bubble.h" | 5 #include "chrome/browser/speech/speech_recognition_bubble.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "content/public/browser/web_contents.h" | 10 #include "content/public/browser/web_contents.h" |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 buffer_canvas.save(); | 230 buffer_canvas.save(); |
231 const int kVolumeSteps = 12; | 231 const int kVolumeSteps = 12; |
232 SkScalar clip_right = | 232 SkScalar clip_right = |
233 (((1.0f - volume) * (width * (kVolumeSteps + 1))) - width) / kVolumeSteps; | 233 (((1.0f - volume) * (width * (kVolumeSteps + 1))) - width) / kVolumeSteps; |
234 buffer_canvas.clipRect(SkRect::MakeLTRB(0, 0, | 234 buffer_canvas.clipRect(SkRect::MakeLTRB(0, 0, |
235 SkIntToScalar(width) - clip_right, SkIntToScalar(height))); | 235 SkIntToScalar(width) - clip_right, SkIntToScalar(height))); |
236 buffer_canvas.drawBitmap( | 236 buffer_canvas.drawBitmap( |
237 image.GetRepresentation(scale_factor_).sk_bitmap(), 0, 0); | 237 image.GetRepresentation(scale_factor_).sk_bitmap(), 0, 0); |
238 buffer_canvas.restore(); | 238 buffer_canvas.restore(); |
239 SkPaint multiply_paint; | 239 SkPaint multiply_paint; |
240 multiply_paint.setXfermode(SkXfermode::Create(SkXfermode::kMultiply_Mode)); | 240 multiply_paint.setXfermode(SkXfermode::Create(SkXfermode::kModulate_Mode)); |
241 buffer_canvas.drawBitmap( | 241 buffer_canvas.drawBitmap( |
242 g_images.Get().mic_mask()->GetRepresentation(scale_factor_).sk_bitmap(), | 242 g_images.Get().mic_mask()->GetRepresentation(scale_factor_).sk_bitmap(), |
243 -clip_right, 0, &multiply_paint); | 243 -clip_right, 0, &multiply_paint); |
244 | 244 |
245 canvas->drawBitmap(*buffer_image_.get(), 0, 0); | 245 canvas->drawBitmap(*buffer_image_.get(), 0, 0); |
246 } | 246 } |
247 | 247 |
248 void SpeechRecognitionBubbleBase::SetInputVolume(float volume, | 248 void SpeechRecognitionBubbleBase::SetInputVolume(float volume, |
249 float noise_volume) { | 249 float noise_volume) { |
250 mic_image_->eraseARGB(0, 0, 0, 0); | 250 mic_image_->eraseARGB(0, 0, 0, 0); |
(...skipping 16 matching lines...) Expand all Loading... |
267 } | 267 } |
268 | 268 |
269 void SpeechRecognitionBubbleBase::SetImage(const gfx::ImageSkia& image) { | 269 void SpeechRecognitionBubbleBase::SetImage(const gfx::ImageSkia& image) { |
270 icon_image_ = image; | 270 icon_image_ = image; |
271 UpdateImage(); | 271 UpdateImage(); |
272 } | 272 } |
273 | 273 |
274 gfx::ImageSkia SpeechRecognitionBubbleBase::icon_image() { | 274 gfx::ImageSkia SpeechRecognitionBubbleBase::icon_image() { |
275 return icon_image_; | 275 return icon_image_; |
276 } | 276 } |
OLD | NEW |