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

Side by Side Diff: Source/platform/graphics/Image.cpp

Issue 1093673002: Removing the dependency on GraphicsContext for drawing images in 2D canvas (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 8 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) 2006 Samuel Weinig (sam.weinig@gmail.com) 2 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
3 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved. 3 * Copyright (C) 2004, 2005, 2006 Apple Computer, 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 oneTileRect.setY(destRect.y() + fmodf(fmodf(-srcPoint.y(), actualTileSize.he ight()) - actualTileSize.height(), actualTileSize.height())); 145 oneTileRect.setY(destRect.y() + fmodf(fmodf(-srcPoint.y(), actualTileSize.he ight()) - actualTileSize.height(), actualTileSize.height()));
146 oneTileRect.setSize(scaledTileSize); 146 oneTileRect.setSize(scaledTileSize);
147 147
148 // Check and see if a single draw of the image can cover the entire area we are supposed to tile. 148 // Check and see if a single draw of the image can cover the entire area we are supposed to tile.
149 if (oneTileRect.contains(destRect)) { 149 if (oneTileRect.contains(destRect)) {
150 FloatRect visibleSrcRect; 150 FloatRect visibleSrcRect;
151 visibleSrcRect.setX((destRect.x() - oneTileRect.x()) / scale.width()); 151 visibleSrcRect.setX((destRect.x() - oneTileRect.x()) / scale.width());
152 visibleSrcRect.setY((destRect.y() - oneTileRect.y()) / scale.height()); 152 visibleSrcRect.setY((destRect.y() - oneTileRect.y()) / scale.height());
153 visibleSrcRect.setWidth(destRect.width() / scale.width()); 153 visibleSrcRect.setWidth(destRect.width() / scale.width());
154 visibleSrcRect.setHeight(destRect.height() / scale.height()); 154 visibleSrcRect.setHeight(destRect.height() / scale.height());
155 draw(ctxt, destRect, visibleSrcRect, op, DoNotRespectImageOrientation); 155 ctxt->drawImage(this, destRect, visibleSrcRect, op, DoNotRespectImageOri entation);
156 return; 156 return;
157 } 157 }
158 158
159 FloatRect tileRect(FloatPoint(), intrinsicTileSize); 159 FloatRect tileRect(FloatPoint(), intrinsicTileSize);
160 drawPattern(ctxt, tileRect, scale, oneTileRect.location(), op, destRect, rep eatSpacing); 160 drawPattern(ctxt, tileRect, scale, oneTileRect.location(), op, destRect, rep eatSpacing);
161 161
162 startAnimation(); 162 startAnimation();
163 } 163 }
164 164
165 // FIXME: Merge with the other drawTiled eventually, since we need a combination of both for some things. 165 // FIXME: Merge with the other drawTiled eventually, since we need a combination of both for some things.
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 AffineTransform ctm = context->getCTM(); 271 AffineTransform ctm = context->getCTM();
272 ctmScaleX = ctm.xScale(); 272 ctmScaleX = ctm.xScale();
273 ctmScaleY = ctm.yScale(); 273 ctmScaleY = ctm.yScale();
274 } 274 }
275 275
276 bitmapToPaint = createBitmapWithSpace( 276 bitmapToPaint = createBitmapWithSpace(
277 bitmapToPaint, 277 bitmapToPaint,
278 repeatSpacing.width() * ctmScaleX / scale.width(), 278 repeatSpacing.width() * ctmScaleX / scale.width(),
279 repeatSpacing.height() * ctmScaleY / scale.height()); 279 repeatSpacing.height() * ctmScaleY / scale.height());
280 } 280 }
281 RefPtr<SkShader> shader = adoptRef(SkShader::CreateBitmapShader(bitmapToPain t, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode, &localMatrix));
282 281
283 bool isLazyDecoded = DeferredImageDecoder::isLazyDecoded(bitmap);
284 { 282 {
285 SkPaint paint; 283 SkPaint paint = context->fillPaint();
286 int initialSaveCount = context->preparePaintForDrawRectToRect(&paint, fl oatSrcRect, 284 paint.setXfermodeMode(compositeOp);
287 destRect, compositeOp, !bitmap.isOpaque(), isLazyDecoded, bitmap.isI mmutable()); 285 paint.setFilterQuality(context->getFilterQuality(this, destRect, floatSr cRect));
286 RefPtr<SkShader> shader = adoptRef(SkShader::CreateBitmapShader(bitmapTo Paint, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode, &localMatrix));
288 paint.setShader(shader.get()); 287 paint.setShader(shader.get());
289 context->drawRect(destRect, paint); 288 context->drawRect(destRect, paint);
290 context->canvas()->restoreToCount(initialSaveCount);
291 } 289 }
292 290
293 if (isLazyDecoded) 291 if (DeferredImageDecoder::isLazyDecoded(bitmap))
294 PlatformInstrumentation::didDrawLazyPixelRef(bitmap.getGenerationID()); 292 PlatformInstrumentation::didDrawLazyPixelRef(bitmap.getGenerationID());
295 } 293 }
296 294
297 void Image::computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsic Height, FloatSize& intrinsicRatio) 295 void Image::computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsic Height, FloatSize& intrinsicRatio)
298 { 296 {
299 intrinsicRatio = size(); 297 intrinsicRatio = size();
300 intrinsicWidth = Length(intrinsicRatio.width(), Fixed); 298 intrinsicWidth = Length(intrinsicRatio.width(), Fixed);
301 intrinsicHeight = Length(intrinsicRatio.height(), Fixed); 299 intrinsicHeight = Length(intrinsicRatio.height(), Fixed);
302 } 300 }
303 301
304 PassRefPtr<Image> Image::imageForDefaultFrame() 302 PassRefPtr<Image> Image::imageForDefaultFrame()
305 { 303 {
306 RefPtr<Image> image(this); 304 RefPtr<Image> image(this);
307 305
308 return image.release(); 306 return image.release();
309 } 307 }
310 308
311 bool Image::bitmapForCurrentFrame(SkBitmap* bitmap) 309 bool Image::bitmapForCurrentFrame(SkBitmap* bitmap)
312 { 310 {
313 return false; 311 return false;
314 } 312 }
315 313
316 PassRefPtr<SkImage> Image::skImage() 314 PassRefPtr<SkImage> Image::skImage()
317 { 315 {
318 return nullptr; 316 return nullptr;
319 } 317 }
320 318
321 } // namespace blink 319 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698