OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 #endif // !defined(WEBRTC_ARCH_LITTLE_ENDIAN) | 43 #endif // !defined(WEBRTC_ARCH_LITTLE_ENDIAN) |
44 | 44 |
45 const int kBytesPerPixel = DesktopFrame::kBytesPerPixel; | 45 const int kBytesPerPixel = DesktopFrame::kBytesPerPixel; |
46 | 46 |
47 // Pixel colors used when generating cursor outlines. | 47 // Pixel colors used when generating cursor outlines. |
48 const uint32_t kPixelRgbaBlack = RGBA(0, 0, 0, 0xff); | 48 const uint32_t kPixelRgbaBlack = RGBA(0, 0, 0, 0xff); |
49 const uint32_t kPixelRgbaWhite = RGBA(0xff, 0xff, 0xff, 0xff); | 49 const uint32_t kPixelRgbaWhite = RGBA(0xff, 0xff, 0xff, 0xff); |
50 const uint32_t kPixelRgbaTransparent = RGBA(0, 0, 0, 0); | 50 const uint32_t kPixelRgbaTransparent = RGBA(0, 0, 0, 0); |
51 | 51 |
52 const uint32_t kPixelRgbWhite = RGB(0xff, 0xff, 0xff); | 52 const uint32_t kPixelRgbWhite = RGB(0xff, 0xff, 0xff); |
53 const uint32_t kPixelRgbBlack = RGB(0, 0, 0); | |
54 | 53 |
55 // Expands the cursor shape to add a white outline for visibility against | 54 // Expands the cursor shape to add a white outline for visibility against |
56 // dark backgrounds. | 55 // dark backgrounds. |
57 void AddCursorOutline(int width, int height, uint32_t* data) { | 56 void AddCursorOutline(int width, int height, uint32_t* data) { |
58 for (int y = 0; y < height; y++) { | 57 for (int y = 0; y < height; y++) { |
59 for (int x = 0; x < width; x++) { | 58 for (int x = 0; x < width; x++) { |
60 // If this is a transparent pixel (bgr == 0 and alpha = 0), check the | 59 // If this is a transparent pixel (bgr == 0 and alpha = 0), check the |
61 // neighbor pixels to see if this should be changed to an outline pixel. | 60 // neighbor pixels to see if this should be changed to an outline pixel. |
62 if (*data == kPixelRgbaTransparent) { | 61 if (*data == kPixelRgbaTransparent) { |
63 // Change to white pixel if any neighbors (top, bottom, left, right) | 62 // Change to white pixel if any neighbors (top, bottom, left, right) |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 | 239 |
241 // Pre-multiply the resulting pixels since MouseCursor uses premultiplied | 240 // Pre-multiply the resulting pixels since MouseCursor uses premultiplied |
242 // images. | 241 // images. |
243 AlphaMul(reinterpret_cast<uint32_t*>(image->data()), width, height); | 242 AlphaMul(reinterpret_cast<uint32_t*>(image->data()), width, height); |
244 | 243 |
245 return new MouseCursor( | 244 return new MouseCursor( |
246 image.release(), DesktopVector(hotspot_x, hotspot_y)); | 245 image.release(), DesktopVector(hotspot_x, hotspot_y)); |
247 } | 246 } |
248 | 247 |
249 } // namespace webrtc | 248 } // namespace webrtc |
OLD | NEW |