Chromium Code Reviews| 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 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 296 void GraphicsContext::beginRecording(const FloatRect& bounds) | 296 void GraphicsContext::beginRecording(const FloatRect& bounds) |
| 297 { | 297 { |
| 298 if (contextDisabled()) | 298 if (contextDisabled()) |
| 299 return; | 299 return; |
| 300 | 300 |
| 301 m_canvas = m_pictureRecorder.beginRecording(bounds, 0); | 301 m_canvas = m_pictureRecorder.beginRecording(bounds, 0); |
| 302 if (m_hasMetaData) | 302 if (m_hasMetaData) |
| 303 skia::GetMetaData(*m_canvas) = m_metaData; | 303 skia::GetMetaData(*m_canvas) = m_metaData; |
| 304 } | 304 } |
| 305 | 305 |
| 306 PassRefPtr<const SkPicture> GraphicsContext::endRecording() | 306 PassRefPtr<SkPicture> GraphicsContext::endRecording() |
| 307 { | 307 { |
| 308 if (contextDisabled()) | 308 if (contextDisabled()) |
| 309 return nullptr; | 309 return nullptr; |
| 310 | 310 |
| 311 RefPtr<const SkPicture> picture = adoptRef(m_pictureRecorder.endRecordingAsP icture()); | 311 RefPtr<SkPicture> picture = adoptRef(m_pictureRecorder.endRecordingAsPicture ()); |
|
Stephen White
2016/03/18 14:48:27
Not related to this patch, but are there plans to
| |
| 312 m_canvas = nullptr; | 312 m_canvas = nullptr; |
| 313 ASSERT(picture); | 313 ASSERT(picture); |
| 314 return picture.release(); | 314 return picture.release(); |
| 315 } | 315 } |
| 316 | 316 |
| 317 void GraphicsContext::drawPicture(const SkPicture* picture) | 317 void GraphicsContext::drawPicture(const SkPicture* picture) |
| 318 { | 318 { |
| 319 if (contextDisabled() || !picture || picture->cullRect().isEmpty()) | 319 if (contextDisabled() || !picture || picture->cullRect().isEmpty()) |
| 320 return; | 320 return; |
| 321 | 321 |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 628 SkScalar originX = WebCoreFloatToSkScalar(pt.x()); | 628 SkScalar originX = WebCoreFloatToSkScalar(pt.x()); |
| 629 | 629 |
| 630 // Offset it vertically by 1 so that there's some space under the text. | 630 // Offset it vertically by 1 so that there's some space under the text. |
| 631 SkScalar originY = WebCoreFloatToSkScalar(pt.y()) + 1; | 631 SkScalar originY = WebCoreFloatToSkScalar(pt.y()) + 1; |
| 632 originX *= deviceScaleFactor; | 632 originX *= deviceScaleFactor; |
| 633 originY *= deviceScaleFactor; | 633 originY *= deviceScaleFactor; |
| 634 #endif | 634 #endif |
| 635 | 635 |
| 636 SkMatrix localMatrix; | 636 SkMatrix localMatrix; |
| 637 localMatrix.setTranslate(originX, originY); | 637 localMatrix.setTranslate(originX, originY); |
| 638 RefPtr<SkShader> shader = adoptRef(SkShader::CreateBitmapShader( | |
| 639 *misspellBitmap[index], SkShader::kRepeat_TileMode, SkShader::kRepeat_Ti leMode, &localMatrix)); | |
| 640 | 638 |
| 641 SkPaint paint; | 639 SkPaint paint; |
| 642 paint.setShader(shader.get()); | 640 paint.setShader(SkShader::MakeBitmapShader( |
| 641 *misspellBitmap[index], SkShader::kRepeat_TileMode, SkShader::kRepeat_Ti leMode, &localMatrix)); | |
| 643 | 642 |
| 644 SkRect rect; | 643 SkRect rect; |
| 645 rect.set(originX, originY, originX + WebCoreFloatToSkScalar(width) * deviceS caleFactor, originY + SkIntToScalar(misspellBitmap[index]->height())); | 644 rect.set(originX, originY, originX + WebCoreFloatToSkScalar(width) * deviceS caleFactor, originY + SkIntToScalar(misspellBitmap[index]->height())); |
| 646 | 645 |
| 647 if (deviceScaleFactor == 2) { | 646 if (deviceScaleFactor == 2) { |
| 648 save(); | 647 save(); |
| 649 scale(0.5, 0.5); | 648 scale(0.5, 0.5); |
| 650 } | 649 } |
| 651 drawRect(rect, paint); | 650 drawRect(rect, paint); |
| 652 if (deviceScaleFactor == 2) | 651 if (deviceScaleFactor == 2) |
| (...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1360 static const SkPMColor colors[] = { | 1359 static const SkPMColor colors[] = { |
| 1361 SkPreMultiplyARGB(0x60, 0xFF, 0x00, 0x00), // More transparent red | 1360 SkPreMultiplyARGB(0x60, 0xFF, 0x00, 0x00), // More transparent red |
| 1362 SkPreMultiplyARGB(0x60, 0xC0, 0xC0, 0xC0) // More transparent gray | 1361 SkPreMultiplyARGB(0x60, 0xC0, 0xC0, 0xC0) // More transparent gray |
| 1363 }; | 1362 }; |
| 1364 | 1363 |
| 1365 return colors[index]; | 1364 return colors[index]; |
| 1366 } | 1365 } |
| 1367 #endif | 1366 #endif |
| 1368 | 1367 |
| 1369 } // namespace blink | 1368 } // namespace blink |
| OLD | NEW |