OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2003, 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2003, 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. |
3 * Copyright (C) 2013 Google Inc. All rights reserved. | 3 * Copyright (C) 2013 Google Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 SkMatrix::kFill_ScaleToFit); | 326 SkMatrix::kFill_ScaleToFit); |
327 m_canvas->concat(pictureTransform); | 327 m_canvas->concat(pictureTransform); |
328 picturePaint.setImageFilter(SkPictureImageFilter::MakeForLocalSpace( | 328 picturePaint.setImageFilter(SkPictureImageFilter::MakeForLocalSpace( |
329 ToSkPicture(picture), sourceBounds, | 329 ToSkPicture(picture), sourceBounds, |
330 static_cast<SkFilterQuality>(imageInterpolationQuality()))); | 330 static_cast<SkFilterQuality>(imageInterpolationQuality()))); |
331 m_canvas->saveLayer(&sourceBounds, &picturePaint); | 331 m_canvas->saveLayer(&sourceBounds, &picturePaint); |
332 m_canvas->restore(); | 332 m_canvas->restore(); |
333 m_canvas->restore(); | 333 m_canvas->restore(); |
334 } | 334 } |
335 | 335 |
| 336 namespace { |
| 337 |
| 338 int adjustedFocusRingOffset(int offset) { |
| 339 #if OS(MACOSX) |
| 340 return offset + 2; |
| 341 #else |
| 342 return 0; |
| 343 #endif |
| 344 } |
| 345 |
| 346 } // anonymous ns |
| 347 |
| 348 int GraphicsContext::focusRingOutsetExtent(int offset, int width) { |
| 349 // Unlike normal outlines (whole width is outside of the offset), focus |
| 350 // rings are drawn with the center of the path aligned with the offset, so |
| 351 // only half of the width is outside of the offset. |
| 352 return adjustedFocusRingOffset(offset) + (width + 1) / 2; |
| 353 } |
| 354 |
336 void GraphicsContext::drawFocusRingPath(const SkPath& path, | 355 void GraphicsContext::drawFocusRingPath(const SkPath& path, |
337 const Color& color, | 356 const Color& color, |
338 float width) { | 357 float width) { |
339 drawPlatformFocusRing(path, m_canvas, color.rgb(), width); | 358 drawPlatformFocusRing(path, m_canvas, color.rgb(), width); |
340 } | 359 } |
341 | 360 |
342 void GraphicsContext::drawFocusRingRect(const SkRect& rect, | 361 void GraphicsContext::drawFocusRingRect(const SkRect& rect, |
343 const Color& color, | 362 const Color& color, |
344 float width) { | 363 float width) { |
345 drawPlatformFocusRing(rect, m_canvas, color.rgb(), width); | 364 drawPlatformFocusRing(rect, m_canvas, color.rgb(), width); |
(...skipping 15 matching lines...) Expand all Loading... |
361 int offset, | 380 int offset, |
362 const Color& color) { | 381 const Color& color) { |
363 if (contextDisabled()) | 382 if (contextDisabled()) |
364 return; | 383 return; |
365 | 384 |
366 unsigned rectCount = rects.size(); | 385 unsigned rectCount = rects.size(); |
367 if (!rectCount) | 386 if (!rectCount) |
368 return; | 387 return; |
369 | 388 |
370 SkRegion focusRingRegion; | 389 SkRegion focusRingRegion; |
371 offset = focusRingOffset(offset); | 390 offset = adjustedFocusRingOffset(offset); |
372 for (unsigned i = 0; i < rectCount; i++) { | 391 for (unsigned i = 0; i < rectCount; i++) { |
373 SkIRect r = rects[i]; | 392 SkIRect r = rects[i]; |
374 if (r.isEmpty()) | 393 if (r.isEmpty()) |
375 continue; | 394 continue; |
376 r.inset(-offset, -offset); | 395 r.outset(offset, offset); |
377 focusRingRegion.op(r, SkRegion::kUnion_Op); | 396 focusRingRegion.op(r, SkRegion::kUnion_Op); |
378 } | 397 } |
379 | 398 |
380 if (focusRingRegion.isEmpty()) | 399 if (focusRingRegion.isEmpty()) |
381 return; | 400 return; |
382 | 401 |
383 if (focusRingRegion.isRect()) { | 402 if (focusRingRegion.isRect()) { |
384 drawFocusRingRect(SkRect::Make(focusRingRegion.getBounds()), color, width); | 403 drawFocusRingRect(SkRect::Make(focusRingRegion.getBounds()), color, width); |
385 } else { | 404 } else { |
386 SkPath path; | 405 SkPath path; |
(...skipping 937 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1324 break; | 1343 break; |
1325 default: | 1344 default: |
1326 ASSERT_NOT_REACHED(); | 1345 ASSERT_NOT_REACHED(); |
1327 break; | 1346 break; |
1328 } | 1347 } |
1329 | 1348 |
1330 return nullptr; | 1349 return nullptr; |
1331 } | 1350 } |
1332 | 1351 |
1333 } // namespace blink | 1352 } // namespace blink |
OLD | NEW |