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

Side by Side Diff: third_party/WebKit/WebCore/platform/graphics/skia/ImageSkia.cpp

Issue 21201: Transparency (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2008, Google Inc. All rights reserved. 2 * Copyright (c) 2008, Google 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 destBitmapSubset.bottom() + destRect.fTop }; 218 destBitmapSubset.bottom() + destRect.fTop };
219 219
220 canvas.drawBitmapRect(resampled, 0, offsetDestRect, &paint); 220 canvas.drawBitmapRect(resampled, 0, offsetDestRect, &paint);
221 } 221 }
222 } 222 }
223 223
224 static void paintSkBitmap(PlatformContextSkia* platformContext, const NativeImag eSkia& bitmap, const SkIRect& srcRect, const SkRect& destRect, const SkPorterDuf f::Mode& compOp) 224 static void paintSkBitmap(PlatformContextSkia* platformContext, const NativeImag eSkia& bitmap, const SkIRect& srcRect, const SkRect& destRect, const SkPorterDuf f::Mode& compOp)
225 { 225 {
226 SkPaint paint; 226 SkPaint paint;
227 paint.setPorterDuffXfermode(compOp); 227 paint.setPorterDuffXfermode(compOp);
228 paint.setFilterBitmap(true);
228 229
229 skia::PlatformCanvas* canvas = platformContext->canvas(); 230 skia::PlatformCanvas* canvas = platformContext->canvas();
230 231
231 ResamplingMode resampling = platformContext->isPrinting() ? RESAMPLE_NONE : 232 ResamplingMode resampling = platformContext->isPrinting() ? RESAMPLE_NONE :
232 computeResamplingMode(bitmap, srcRect.width(), srcRect.height(), 233 computeResamplingMode(bitmap, srcRect.width(), srcRect.height(),
233 SkScalarToFloat(destRect.width()), 234 SkScalarToFloat(destRect.width()),
234 SkScalarToFloat(destRect.height())); 235 SkScalarToFloat(destRect.height()));
235 if (resampling == RESAMPLE_AWESOME) { 236 if (resampling == RESAMPLE_AWESOME) {
236 paint.setFilterBitmap(false);
237 drawResampledBitmap(*canvas, paint, bitmap, srcRect, destRect); 237 drawResampledBitmap(*canvas, paint, bitmap, srcRect, destRect);
238 } else { 238 } else {
239 // No resampling necessary, we can just draw the bitmap. We want to 239 // No resampling necessary, we can just draw the bitmap. We want to
240 // filter it if we decided to do linear interpolation above, or if there 240 // filter it if we decided to do linear interpolation above, or if there
241 // is something interesting going on with the matrix (like a rotation). 241 // is something interesting going on with the matrix (like a rotation).
242 // Note: for serialization, we will want to subset the bitmap first so 242 // Note: for serialization, we will want to subset the bitmap first so
243 // we don't send extra pixels. 243 // we don't send extra pixels.
244 paint.setFilterBitmap(resampling == RESAMPLE_LINEAR);
245 canvas->drawBitmapRect(bitmap, &srcRect, destRect, &paint); 244 canvas->drawBitmapRect(bitmap, &srcRect, destRect, &paint);
246 } 245 }
247 } 246 }
248 247
249 // Transforms the given dimensions with the given matrix. Used to see how big 248 // Transforms the given dimensions with the given matrix. Used to see how big
250 // images will be once transformed. 249 // images will be once transformed.
251 static void TransformDimensions(const SkMatrix& matrix, float srcWidth, float sr cHeight, float* destWidth, float* destHeight) { 250 static void TransformDimensions(const SkMatrix& matrix, float srcWidth, float sr cHeight, float* destWidth, float* destHeight) {
252 // Transform 3 points to see how long each side of the bitmap will be. 251 // Transform 3 points to see how long each side of the bitmap will be.
253 SkPoint src_points[3]; // (0, 0), (width, 0), (0, height). 252 SkPoint src_points[3]; // (0, 0), (width, 0), (0, height).
254 src_points[0].set(0, 0); 253 src_points[0].set(0, 0);
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 452
454 PassRefPtr<BitmapImageSingleFrameSkia> BitmapImageSingleFrameSkia::create(const SkBitmap& bitmap) 453 PassRefPtr<BitmapImageSingleFrameSkia> BitmapImageSingleFrameSkia::create(const SkBitmap& bitmap)
455 { 454 {
456 RefPtr<BitmapImageSingleFrameSkia> image(adoptRef(new BitmapImageSingleFrame Skia())); 455 RefPtr<BitmapImageSingleFrameSkia> image(adoptRef(new BitmapImageSingleFrame Skia()));
457 if (!bitmap.copyTo(&image->m_nativeImage, bitmap.config())) 456 if (!bitmap.copyTo(&image->m_nativeImage, bitmap.config()))
458 return 0; 457 return 0;
459 return image.release(); 458 return image.release();
460 } 459 }
461 460
462 } // namespace WebCore 461 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698