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

Side by Side Diff: third_party/WebKit/Source/platform/DragImage.cpp

Issue 2119623003: Do not clear canvas with transparent color after creating SkSurface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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) 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2007 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 if (!surface) 100 if (!surface)
101 return nullptr; 101 return nullptr;
102 102
103 SkPaint paint; 103 SkPaint paint;
104 ASSERT(opacity >= 0 && opacity <= 1); 104 ASSERT(opacity >= 0 && opacity <= 1);
105 paint.setAlpha(opacity * 255); 105 paint.setAlpha(opacity * 255);
106 paint.setFilterQuality(interpolationQuality == InterpolationNone 106 paint.setFilterQuality(interpolationQuality == InterpolationNone
107 ? kNone_SkFilterQuality : kHigh_SkFilterQuality); 107 ? kNone_SkFilterQuality : kHigh_SkFilterQuality);
108 108
109 SkCanvas* canvas = surface->getCanvas(); 109 SkCanvas* canvas = surface->getCanvas();
110 canvas->clear(SK_ColorTRANSPARENT);
111 canvas->concat(affineTransformToSkMatrix(transform)); 110 canvas->concat(affineTransformToSkMatrix(transform));
112 canvas->drawImage(image.get(), 0, 0, &paint); 111 canvas->drawImage(image.get(), 0, 0, &paint);
113 112
114 return fromSkSp(surface->makeImageSnapshot()); 113 return fromSkSp(surface->makeImageSnapshot());
115 } 114 }
116 115
117 FloatSize DragImage::clampedImageScale(const IntSize& imageSize, const IntSize& size, 116 FloatSize DragImage::clampedImageScale(const IntSize& imageSize, const IntSize& size,
118 const IntSize& maxSize) 117 const IntSize& maxSize)
119 { 118 {
120 // Non-uniform scaling for size mapping. 119 // Non-uniform scaling for size mapping.
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 267
269 void DragImage::scale(float scaleX, float scaleY) 268 void DragImage::scale(float scaleX, float scaleY)
270 { 269 {
271 skia::ImageOperations::ResizeMethod resizeMethod = m_interpolationQuality == InterpolationNone ? skia::ImageOperations::RESIZE_BOX : skia::ImageOperations:: RESIZE_LANCZOS3; 270 skia::ImageOperations::ResizeMethod resizeMethod = m_interpolationQuality == InterpolationNone ? skia::ImageOperations::RESIZE_BOX : skia::ImageOperations:: RESIZE_LANCZOS3;
272 int imageWidth = scaleX * m_bitmap.width(); 271 int imageWidth = scaleX * m_bitmap.width();
273 int imageHeight = scaleY * m_bitmap.height(); 272 int imageHeight = scaleY * m_bitmap.height();
274 m_bitmap = skia::ImageOperations::Resize(m_bitmap, resizeMethod, imageWidth, imageHeight); 273 m_bitmap = skia::ImageOperations::Resize(m_bitmap, resizeMethod, imageWidth, imageHeight);
275 } 274 }
276 275
277 } // namespace blink 276 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698