Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(112)

Side by Side Diff: third_party/WebKit/Source/platform/graphics/GraphicsContext.cpp

Issue 1814473003: Revert of Add sk_sp helpers and switch Blink SkShader clients to the new APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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<SkPicture> GraphicsContext::endRecording() 306 PassRefPtr<const SkPicture> GraphicsContext::endRecording()
307 { 307 {
308 if (contextDisabled()) 308 if (contextDisabled())
309 return nullptr; 309 return nullptr;
310 310
311 RefPtr<SkPicture> picture = adoptRef(m_pictureRecorder.endRecordingAsPicture ()); 311 RefPtr<const SkPicture> picture = adoptRef(m_pictureRecorder.endRecordingAsP icture());
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
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));
638 640
639 SkPaint paint; 641 SkPaint paint;
640 paint.setShader(SkShader::MakeBitmapShader( 642 paint.setShader(shader.get());
641 *misspellBitmap[index], SkShader::kRepeat_TileMode, SkShader::kRepeat_Ti leMode, &localMatrix));
642 643
643 SkRect rect; 644 SkRect rect;
644 rect.set(originX, originY, originX + WebCoreFloatToSkScalar(width) * deviceS caleFactor, originY + SkIntToScalar(misspellBitmap[index]->height())); 645 rect.set(originX, originY, originX + WebCoreFloatToSkScalar(width) * deviceS caleFactor, originY + SkIntToScalar(misspellBitmap[index]->height()));
645 646
646 if (deviceScaleFactor == 2) { 647 if (deviceScaleFactor == 2) {
647 save(); 648 save();
648 scale(0.5, 0.5); 649 scale(0.5, 0.5);
649 } 650 }
650 drawRect(rect, paint); 651 drawRect(rect, paint);
651 if (deviceScaleFactor == 2) 652 if (deviceScaleFactor == 2)
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after
1359 static const SkPMColor colors[] = { 1360 static const SkPMColor colors[] = {
1360 SkPreMultiplyARGB(0x60, 0xFF, 0x00, 0x00), // More transparent red 1361 SkPreMultiplyARGB(0x60, 0xFF, 0x00, 0x00), // More transparent red
1361 SkPreMultiplyARGB(0x60, 0xC0, 0xC0, 0xC0) // More transparent gray 1362 SkPreMultiplyARGB(0x60, 0xC0, 0xC0, 0xC0) // More transparent gray
1362 }; 1363 };
1363 1364
1364 return colors[index]; 1365 return colors[index];
1365 } 1366 }
1366 #endif 1367 #endif
1367 1368
1368 } // namespace blink 1369 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/GraphicsContext.h ('k') | third_party/WebKit/Source/platform/graphics/Image.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698