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 "media/video/capture/screen/screen_capturer.h" | 5 #include "media/video/capture/screen/screen_capturer.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 set_thread_execution_state_failed_(false) { | 210 set_thread_execution_state_failed_(false) { |
211 if (disable_aero) { | 211 if (disable_aero) { |
212 // Load dwmapi.dll dynamically since it is not available on XP. | 212 // Load dwmapi.dll dynamically since it is not available on XP. |
213 if (!dwmapi_library_.is_valid()) { | 213 if (!dwmapi_library_.is_valid()) { |
214 base::FilePath path(base::GetNativeLibraryName( | 214 base::FilePath path(base::GetNativeLibraryName( |
215 UTF8ToUTF16(kDwmapiLibraryName))); | 215 UTF8ToUTF16(kDwmapiLibraryName))); |
216 dwmapi_library_.Reset(base::LoadNativeLibrary(path, NULL)); | 216 dwmapi_library_.Reset(base::LoadNativeLibrary(path, NULL)); |
217 } | 217 } |
218 | 218 |
219 if (dwmapi_library_.is_valid() && composition_func_ == NULL) { | 219 if (dwmapi_library_.is_valid() && composition_func_ == NULL) { |
220 composition_func_ = static_cast<DwmEnableCompositionFunc>( | 220 composition_func_ = reinterpret_cast<DwmEnableCompositionFunc>( |
221 dwmapi_library_.GetFunctionPointer("DwmEnableComposition")); | 221 dwmapi_library_.GetFunctionPointer("DwmEnableComposition")); |
222 } | 222 } |
223 } | 223 } |
224 } | 224 } |
225 | 225 |
226 ScreenCapturerWin::~ScreenCapturerWin() { | 226 ScreenCapturerWin::~ScreenCapturerWin() { |
227 } | 227 } |
228 | 228 |
229 void ScreenCapturerWin::InvalidateRegion(const SkRegion& invalid_region) { | 229 void ScreenCapturerWin::InvalidateRegion(const SkRegion& invalid_region) { |
230 helper_.InvalidateRegion(invalid_region); | 230 helper_.InvalidateRegion(invalid_region); |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 return; | 535 return; |
536 } | 536 } |
537 uint8* and_mask = mask.get(); | 537 uint8* and_mask = mask.get(); |
538 uint8* xor_mask = mask.get() + height * row_bytes; | 538 uint8* xor_mask = mask.get() + height * row_bytes; |
539 uint8* dst = cursor_dst_data; | 539 uint8* dst = cursor_dst_data; |
540 bool add_outline = false; | 540 bool add_outline = false; |
541 for (int y = 0; y < height; y++) { | 541 for (int y = 0; y < height; y++) { |
542 for (int x = 0; x < width; x++) { | 542 for (int x = 0; x < width; x++) { |
543 int byte = y * row_bytes + x / 8; | 543 int byte = y * row_bytes + x / 8; |
544 int bit = 7 - x % 8; | 544 int bit = 7 - x % 8; |
545 int and = and_mask[byte] & (1 << bit); | 545 int and_bit = and_mask[byte] & (1 << bit); |
546 int xor = xor_mask[byte] & (1 << bit); | 546 int xor_bit = xor_mask[byte] & (1 << bit); |
547 | 547 |
548 // The two cursor masks combine as follows: | 548 // The two cursor masks combine as follows: |
549 // AND XOR Windows Result Our result RGB Alpha | 549 // AND XOR Windows Result Our result RGB Alpha |
550 // 0 0 Black Black 00 ff | 550 // 0 0 Black Black 00 ff |
551 // 0 1 White White ff ff | 551 // 0 1 White White ff ff |
552 // 1 0 Screen Transparent 00 00 | 552 // 1 0 Screen Transparent 00 00 |
553 // 1 1 Reverse-screen Black 00 ff | 553 // 1 1 Reverse-screen Black 00 ff |
554 // Since we don't support XOR cursors, we replace the "Reverse Screen" | 554 // Since we don't support XOR cursors, we replace the "Reverse Screen" |
555 // with black. In this case, we also add an outline around the cursor | 555 // with black. In this case, we also add an outline around the cursor |
556 // so that it is visible against a dark background. | 556 // so that it is visible against a dark background. |
557 int rgb = (!and && xor) ? 0xff : 0x00; | 557 int rgb = (!and_bit && xor_bit) ? 0xff : 0x00; |
558 int alpha = (and && !xor) ? 0x00 : 0xff; | 558 int alpha = (and_bit && !xor_bit) ? 0x00 : 0xff; |
559 *dst++ = rgb; | 559 *dst++ = rgb; |
560 *dst++ = rgb; | 560 *dst++ = rgb; |
561 *dst++ = rgb; | 561 *dst++ = rgb; |
562 *dst++ = alpha; | 562 *dst++ = alpha; |
563 if (and && xor) { | 563 if (and_bit && xor_bit) { |
564 add_outline = true; | 564 add_outline = true; |
565 } | 565 } |
566 } | 566 } |
567 } | 567 } |
568 if (add_outline) { | 568 if (add_outline) { |
569 AddCursorOutline(width, height, | 569 AddCursorOutline(width, height, |
570 reinterpret_cast<uint32*>(cursor_dst_data)); | 570 reinterpret_cast<uint32*>(cursor_dst_data)); |
571 } | 571 } |
572 } | 572 } |
573 | 573 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
606 return CreateWithDisableAero(true); | 606 return CreateWithDisableAero(true); |
607 } | 607 } |
608 | 608 |
609 // static | 609 // static |
610 scoped_ptr<ScreenCapturer> ScreenCapturer::CreateWithDisableAero( | 610 scoped_ptr<ScreenCapturer> ScreenCapturer::CreateWithDisableAero( |
611 bool disable_aero) { | 611 bool disable_aero) { |
612 return scoped_ptr<ScreenCapturer>(new ScreenCapturerWin(disable_aero)); | 612 return scoped_ptr<ScreenCapturer>(new ScreenCapturerWin(disable_aero)); |
613 } | 613 } |
614 | 614 |
615 } // namespace media | 615 } // namespace media |
OLD | NEW |