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

Side by Side Diff: third_party/WebKit/Source/core/svg/graphics/SVGImage.cpp

Issue 2893083002: cc: Move SkShader construction to a single spot in PaintShader (Closed)
Patch Set: update Created 3 years, 6 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) 2006 Eric Seidel <eric@webkit.org> 2 * Copyright (C) 2006 Eric Seidel <eric@webkit.org>
3 * Copyright (C) 2008, 2009 Apple Inc. All rights reserved. 3 * Copyright (C) 2008, 2009 Apple Inc. All rights reserved.
4 * Copyright (C) Research In Motion Limited 2011. All rights reserved. 4 * Copyright (C) Research In Motion Limited 2011. 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 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 DrawForContainer(builder.Context().Canvas(), flags, container_size, zoom, 348 DrawForContainer(builder.Context().Canvas(), flags, container_size, zoom,
349 tile, src_rect, url); 349 tile, src_rect, url);
350 } 350 }
351 sk_sp<PaintRecord> record = builder.EndRecording(); 351 sk_sp<PaintRecord> record = builder.EndRecording();
352 352
353 SkMatrix pattern_transform; 353 SkMatrix pattern_transform;
354 pattern_transform.setTranslate(phase.X() + spaced_tile.X(), 354 pattern_transform.setTranslate(phase.X() + spaced_tile.X(),
355 phase.Y() + spaced_tile.Y()); 355 phase.Y() + spaced_tile.Y());
356 356
357 PaintFlags flags; 357 PaintFlags flags;
358 flags.setShader( 358 flags.setShader(PaintShader::MakePaintRecord(
359 MakePaintShaderRecord(record, spaced_tile, SkShader::kRepeat_TileMode, 359 record, spaced_tile, SkShader::kRepeat_TileMode,
360 SkShader::kRepeat_TileMode, &pattern_transform)); 360 SkShader::kRepeat_TileMode, &pattern_transform));
361 // If the shader could not be instantiated (e.g. non-invertible matrix), 361 // If the shader could not be instantiated (e.g. non-invertible matrix),
362 // draw transparent. 362 // draw transparent.
363 // Note: we can't simply bail, because of arbitrary blend mode. 363 // Note: we can't simply bail, because of arbitrary blend mode.
364 if (!flags.getShader()) 364 if (!flags.HasShader())
365 flags.setColor(SK_ColorTRANSPARENT); 365 flags.setColor(SK_ColorTRANSPARENT);
366 366
367 flags.setBlendMode(composite_op); 367 flags.setBlendMode(composite_op);
368 flags.setColorFilter(sk_ref_sp(context.GetColorFilter())); 368 flags.setColorFilter(sk_ref_sp(context.GetColorFilter()));
369 context.DrawRect(dst_rect, flags); 369 context.DrawRect(dst_rect, flags);
370 } 370 }
371 371
372 sk_sp<SkImage> SVGImage::ImageForCurrentFrameForContainer( 372 sk_sp<SkImage> SVGImage::ImageForCurrentFrameForContainer(
373 const KURL& url, 373 const KURL& url,
374 const IntSize& container_size) { 374 const IntSize& container_size) {
(...skipping 21 matching lines...) Expand all
396 396
397 bool SVGImage::ApplyShaderInternal(PaintFlags& flags, 397 bool SVGImage::ApplyShaderInternal(PaintFlags& flags,
398 const SkMatrix& local_matrix, 398 const SkMatrix& local_matrix,
399 const KURL& url) { 399 const KURL& url) {
400 const IntSize size(ContainerSize()); 400 const IntSize size(ContainerSize());
401 if (size.IsEmpty()) 401 if (size.IsEmpty())
402 return false; 402 return false;
403 403
404 IntRect bounds(IntPoint(), size); 404 IntRect bounds(IntPoint(), size);
405 405
406 flags.setShader(MakePaintShaderRecord( 406 flags.setShader(PaintShader::MakePaintRecord(
407 PaintRecordForCurrentFrame(bounds, url), bounds, 407 PaintRecordForCurrentFrame(bounds, url), bounds,
408 SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode, &local_matrix)); 408 SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode, &local_matrix));
409 409
410 // Animation is normally refreshed in draw() impls, which we don't reach when 410 // Animation is normally refreshed in draw() impls, which we don't reach when
411 // painting via shaders. 411 // painting via shaders.
412 StartAnimation(); 412 StartAnimation();
413 413
414 return true; 414 return true;
415 } 415 }
416 416
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 785
786 NOTREACHED(); 786 NOTREACHED();
787 return kSizeAvailable; 787 return kSizeAvailable;
788 } 788 }
789 789
790 String SVGImage::FilenameExtension() const { 790 String SVGImage::FilenameExtension() const {
791 return "svg"; 791 return "svg";
792 } 792 }
793 793
794 } // namespace blink 794 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698