| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/browser/media/capture/aura_window_capture_machine.h" | 5 #include "content/browser/media/capture/aura_window_capture_machine.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/timer/timer.h" | 9 #include "base/timer/timer.h" |
| 10 #include "cc/output/copy_output_request.h" | 10 #include "cc/output/copy_output_request.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 #include "ui/aura/client/screen_position_client.h" | 23 #include "ui/aura/client/screen_position_client.h" |
| 24 #include "ui/aura/env.h" | 24 #include "ui/aura/env.h" |
| 25 #include "ui/aura/window.h" | 25 #include "ui/aura/window.h" |
| 26 #include "ui/aura/window_observer.h" | 26 #include "ui/aura/window_observer.h" |
| 27 #include "ui/aura/window_tree_host.h" | 27 #include "ui/aura/window_tree_host.h" |
| 28 #include "ui/base/cursor/cursors_aura.h" | 28 #include "ui/base/cursor/cursors_aura.h" |
| 29 #include "ui/compositor/compositor.h" | 29 #include "ui/compositor/compositor.h" |
| 30 #include "ui/compositor/dip_util.h" | 30 #include "ui/compositor/dip_util.h" |
| 31 #include "ui/compositor/layer.h" | 31 #include "ui/compositor/layer.h" |
| 32 #include "ui/gfx/screen.h" | 32 #include "ui/gfx/screen.h" |
| 33 #include "ui/wm/public/activation_client.h" |
| 33 | 34 |
| 34 namespace content { | 35 namespace content { |
| 35 | 36 |
| 36 namespace { | 37 namespace { |
| 37 | 38 |
| 38 int clip_byte(int x) { | 39 int clip_byte(int x) { |
| 39 return std::max(0, std::min(x, 255)); | 40 return std::max(0, std::min(x, 255)); |
| 40 } | 41 } |
| 41 | 42 |
| 42 int alpha_blend(int alpha, int src, int dst) { | 43 int alpha_blend(int alpha, int src, int dst) { |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 gfx::Point AuraWindowCaptureMachine::UpdateCursorState( | 407 gfx::Point AuraWindowCaptureMachine::UpdateCursorState( |
| 407 const gfx::Rect& region_in_frame) { | 408 const gfx::Rect& region_in_frame) { |
| 408 const gfx::Rect window_bounds = desktop_window_->GetBoundsInScreen(); | 409 const gfx::Rect window_bounds = desktop_window_->GetBoundsInScreen(); |
| 409 gfx::Point cursor_position = aura::Env::GetInstance()->last_mouse_location(); | 410 gfx::Point cursor_position = aura::Env::GetInstance()->last_mouse_location(); |
| 410 if (!window_bounds.Contains(cursor_position)) { | 411 if (!window_bounds.Contains(cursor_position)) { |
| 411 // Return early if there is no need to draw the cursor. | 412 // Return early if there is no need to draw the cursor. |
| 412 ClearCursorState(); | 413 ClearCursorState(); |
| 413 return gfx::Point(); | 414 return gfx::Point(); |
| 414 } | 415 } |
| 415 | 416 |
| 417 aura::client::ActivationClient* activation_client = |
| 418 aura::client::GetActivationClient(desktop_window_->GetRootWindow()); |
| 419 DCHECK(activation_client); |
| 420 aura::Window* active_window = activation_client->GetActiveWindow(); |
| 421 if (!desktop_window_->Contains(active_window)) { |
| 422 // Return early if the target window is not active. |
| 423 ClearCursorState(); |
| 424 return gfx::Point(); |
| 425 } |
| 426 |
| 416 gfx::NativeCursor cursor = desktop_window_->GetHost()->last_cursor(); | 427 gfx::NativeCursor cursor = desktop_window_->GetHost()->last_cursor(); |
| 417 gfx::Point cursor_hot_point; | 428 gfx::Point cursor_hot_point; |
| 418 if (last_cursor_ != cursor || | 429 if (last_cursor_ != cursor || |
| 419 window_size_when_cursor_last_updated_ != window_bounds.size()) { | 430 window_size_when_cursor_last_updated_ != window_bounds.size()) { |
| 420 SkBitmap cursor_bitmap; | 431 SkBitmap cursor_bitmap; |
| 421 if (ui::GetCursorBitmap(cursor, &cursor_bitmap, &cursor_hot_point)) { | 432 if (ui::GetCursorBitmap(cursor, &cursor_bitmap, &cursor_hot_point)) { |
| 422 const int scaled_width = cursor_bitmap.width() * | 433 const int scaled_width = cursor_bitmap.width() * |
| 423 region_in_frame.width() / window_bounds.width(); | 434 region_in_frame.width() / window_bounds.width(); |
| 424 const int scaled_height = cursor_bitmap.height() * | 435 const int scaled_height = cursor_bitmap.height() * |
| 425 region_in_frame.height() / window_bounds.height(); | 436 region_in_frame.height() / window_bounds.height(); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 // TODO(miu): The CopyOutputRequest should be made earlier, at WillCommit(). | 512 // TODO(miu): The CopyOutputRequest should be made earlier, at WillCommit(). |
| 502 // http://crbug.com/492839 | 513 // http://crbug.com/492839 |
| 503 BrowserThread::PostTask( | 514 BrowserThread::PostTask( |
| 504 BrowserThread::UI, | 515 BrowserThread::UI, |
| 505 FROM_HERE, | 516 FROM_HERE, |
| 506 base::Bind(&AuraWindowCaptureMachine::Capture, weak_factory_.GetWeakPtr(), | 517 base::Bind(&AuraWindowCaptureMachine::Capture, weak_factory_.GetWeakPtr(), |
| 507 true)); | 518 true)); |
| 508 } | 519 } |
| 509 | 520 |
| 510 } // namespace content | 521 } // namespace content |
| OLD | NEW |