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

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp

Issue 2290903002: Change (Pass)RefPtr<SkXxx> into sk_sp<SkXxx>. (Closed)
Patch Set: Rebasing... Created 4 years, 3 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) 2004, 2006, 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved.
3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> 3 * Copyright (C) 2007 Alp Toker <alp@atoker.com>
4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. 4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 // misinterpreted as a user-input value 109 // misinterpreted as a user-input value
110 const int UndefinedQualityValue = -1.0; 110 const int UndefinedQualityValue = -1.0;
111 111
112 // Default image mime type for toDataURL and toBlob functions 112 // Default image mime type for toDataURL and toBlob functions
113 const char DefaultMimeType[] = "image/png"; 113 const char DefaultMimeType[] = "image/png";
114 114
115 PassRefPtr<Image> createTransparentImage(const IntSize& size) 115 PassRefPtr<Image> createTransparentImage(const IntSize& size)
116 { 116 {
117 DCHECK(ImageBuffer::canCreateImageBuffer(size)); 117 DCHECK(ImageBuffer::canCreateImageBuffer(size));
118 sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul(size.width(), size .height()); 118 sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul(size.width(), size .height());
119 return StaticBitmapImage::create(fromSkSp(surface->makeImageSnapshot())); 119 return StaticBitmapImage::create(surface->makeImageSnapshot());
120 } 120 }
121 121
122 } // namespace 122 } // namespace
123 123
124 inline HTMLCanvasElement::HTMLCanvasElement(Document& document) 124 inline HTMLCanvasElement::HTMLCanvasElement(Document& document)
125 : HTMLElement(canvasTag, document) 125 : HTMLElement(canvasTag, document)
126 , ContextLifecycleObserver(&document) 126 , ContextLifecycleObserver(&document)
127 , PageVisibilityObserver(document.page()) 127 , PageVisibilityObserver(document.page())
128 , m_size(DefaultWidth, DefaultHeight) 128 , m_size(DefaultWidth, DefaultHeight)
129 , m_ignoreReset(false) 129 , m_ignoreReset(false)
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 if (listener->needsNewFrame()) { 447 if (listener->needsNewFrame()) {
448 listenerNeedsNewFrameCapture = true; 448 listenerNeedsNewFrameCapture = true;
449 } 449 }
450 } 450 }
451 451
452 if (listenerNeedsNewFrameCapture) { 452 if (listenerNeedsNewFrameCapture) {
453 SourceImageStatus status; 453 SourceImageStatus status;
454 RefPtr<Image> sourceImage = getSourceImageForCanvas(&status, PreferNoAcc eleration, SnapshotReasonCanvasListenerCapture, FloatSize()); 454 RefPtr<Image> sourceImage = getSourceImageForCanvas(&status, PreferNoAcc eleration, SnapshotReasonCanvasListenerCapture, FloatSize());
455 if (status != NormalSourceImageStatus) 455 if (status != NormalSourceImageStatus)
456 return; 456 return;
457 RefPtr<SkImage> image = sourceImage->imageForCurrentFrame(); 457 sk_sp<SkImage> image = sourceImage->imageForCurrentFrame();
458 for (CanvasDrawListener* listener : m_listeners) { 458 for (CanvasDrawListener* listener : m_listeners) {
459 if (listener->needsNewFrame()) { 459 if (listener->needsNewFrame()) {
460 listener->sendNewFrame(image); 460 listener->sendNewFrame(image);
461 } 461 }
462 } 462 }
463 } 463 }
464 464
465 } 465 }
466 466
467 void HTMLCanvasElement::paint(GraphicsContext& context, const LayoutRect& r) 467 void HTMLCanvasElement::paint(GraphicsContext& context, const LayoutRect& r)
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 { 596 {
597 ImageData* imageData; 597 ImageData* imageData;
598 if (is3D()) { 598 if (is3D()) {
599 // Get non-premultiplied data because of inaccurate premultiplied alpha conversion of buffer()->toDataURL(). 599 // Get non-premultiplied data because of inaccurate premultiplied alpha conversion of buffer()->toDataURL().
600 imageData = m_context->paintRenderingResultsToImageData(sourceBuffer); 600 imageData = m_context->paintRenderingResultsToImageData(sourceBuffer);
601 if (imageData) 601 if (imageData)
602 return imageData; 602 return imageData;
603 603
604 m_context->paintRenderingResultsToCanvas(sourceBuffer); 604 m_context->paintRenderingResultsToCanvas(sourceBuffer);
605 imageData = ImageData::create(m_size); 605 imageData = ImageData::create(m_size);
606 RefPtr<SkImage> snapshot = buffer()->newSkImageSnapshot(PreferNoAccelera tion, reason); 606 sk_sp<SkImage> snapshot = buffer()->newSkImageSnapshot(PreferNoAccelerat ion, reason);
607 if (snapshot) { 607 if (snapshot) {
608 SkImageInfo imageInfo = SkImageInfo::Make(width(), height(), kRGBA_8 888_SkColorType, kUnpremul_SkAlphaType); 608 SkImageInfo imageInfo = SkImageInfo::Make(width(), height(), kRGBA_8 888_SkColorType, kUnpremul_SkAlphaType);
609 snapshot->readPixels(imageInfo, imageData->data()->data(), imageInfo .minRowBytes(), 0, 0); 609 snapshot->readPixels(imageInfo, imageData->data()->data(), imageInfo .minRowBytes(), 0, 0);
610 } 610 }
611 return imageData; 611 return imageData;
612 } 612 }
613 613
614 imageData = ImageData::create(m_size); 614 imageData = ImageData::create(m_size);
615 615
616 if (!m_context) 616 if (!m_context)
617 return imageData; 617 return imageData;
618 618
619 DCHECK(m_context->is2d()); 619 DCHECK(m_context->is2d());
620 RefPtr<SkImage> snapshot = buffer()->newSkImageSnapshot(PreferNoAcceleration , reason); 620 sk_sp<SkImage> snapshot = buffer()->newSkImageSnapshot(PreferNoAcceleration, reason);
621 if (snapshot) { 621 if (snapshot) {
622 SkImageInfo imageInfo = SkImageInfo::Make(width(), height(), kRGBA_8888_ SkColorType, kUnpremul_SkAlphaType); 622 SkImageInfo imageInfo = SkImageInfo::Make(width(), height(), kRGBA_8888_ SkColorType, kUnpremul_SkAlphaType);
623 snapshot->readPixels(imageInfo, imageData->data()->data(), imageInfo.min RowBytes(), 0, 0); 623 snapshot->readPixels(imageInfo, imageData->data()->data(), imageInfo.min RowBytes(), 0, 0);
624 } 624 }
625 625
626 return imageData; 626 return imageData;
627 } 627 }
628 628
629 String HTMLCanvasElement::toDataURLInternal(const String& mimeType, const double & quality, SourceDrawingBuffer sourceBuffer) const 629 String HTMLCanvasElement::toDataURLInternal(const String& mimeType, const double & quality, SourceDrawingBuffer sourceBuffer) const
630 { 630 {
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
1123 1123
1124 if (!m_context) { 1124 if (!m_context) {
1125 *status = NormalSourceImageStatus; 1125 *status = NormalSourceImageStatus;
1126 return createTransparentImage(size()); 1126 return createTransparentImage(size());
1127 } 1127 }
1128 1128
1129 if (m_context->is3d()) { 1129 if (m_context->is3d()) {
1130 m_context->paintRenderingResultsToCanvas(BackBuffer); 1130 m_context->paintRenderingResultsToCanvas(BackBuffer);
1131 } 1131 }
1132 1132
1133 RefPtr<SkImage> skImage; 1133 sk_sp<SkImage> skImage;
1134 RefPtr<blink::Image> image = renderingContext()->getImage(reason); 1134 RefPtr<blink::Image> image = renderingContext()->getImage(reason);
1135 1135
1136 if (image) 1136 if (image)
1137 skImage = image->imageForCurrentFrame(); 1137 skImage = image->imageForCurrentFrame();
1138 1138
1139 if (skImage) { 1139 if (skImage) {
1140 *status = NormalSourceImageStatus; 1140 *status = NormalSourceImageStatus;
1141 return StaticBitmapImage::create(skImage.release()); 1141 return StaticBitmapImage::create(std::move(skImage));
1142 } 1142 }
1143 1143
1144 *status = InvalidSourceImageStatus; 1144 *status = InvalidSourceImageStatus;
1145 return nullptr; 1145 return nullptr;
1146 } 1146 }
1147 1147
1148 bool HTMLCanvasElement::wouldTaintOrigin(SecurityOrigin*) const 1148 bool HTMLCanvasElement::wouldTaintOrigin(SecurityOrigin*) const
1149 { 1149 {
1150 return !originClean(); 1150 return !originClean();
1151 } 1151 }
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1250 1250
1251 bool HTMLCanvasElement::createSurfaceLayer() 1251 bool HTMLCanvasElement::createSurfaceLayer()
1252 { 1252 {
1253 DCHECK(!m_surfaceLayerBridge); 1253 DCHECK(!m_surfaceLayerBridge);
1254 std::unique_ptr<CanvasSurfaceLayerBridgeClient> bridgeClient = wrapUnique(ne w CanvasSurfaceLayerBridgeClientImpl()); 1254 std::unique_ptr<CanvasSurfaceLayerBridgeClient> bridgeClient = wrapUnique(ne w CanvasSurfaceLayerBridgeClientImpl());
1255 m_surfaceLayerBridge = wrapUnique(new CanvasSurfaceLayerBridge(std::move(bri dgeClient))); 1255 m_surfaceLayerBridge = wrapUnique(new CanvasSurfaceLayerBridge(std::move(bri dgeClient)));
1256 return m_surfaceLayerBridge->createSurfaceLayer(this->width(), this->height( )); 1256 return m_surfaceLayerBridge->createSurfaceLayer(this->width(), this->height( ));
1257 } 1257 }
1258 1258
1259 } // namespace blink 1259 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/LocalFrame.cpp ('k') | third_party/WebKit/Source/core/html/canvas/CanvasDrawListener.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698