Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 17 matching lines...) Expand all Loading... | |
| 28 | 28 |
| 29 #include "platform/Length.h" | 29 #include "platform/Length.h" |
| 30 #include "platform/RuntimeEnabledFeatures.h" | 30 #include "platform/RuntimeEnabledFeatures.h" |
| 31 #include "platform/SharedBuffer.h" | 31 #include "platform/SharedBuffer.h" |
| 32 #include "platform/geometry/FloatPoint.h" | 32 #include "platform/geometry/FloatPoint.h" |
| 33 #include "platform/geometry/FloatRect.h" | 33 #include "platform/geometry/FloatRect.h" |
| 34 #include "platform/geometry/FloatSize.h" | 34 #include "platform/geometry/FloatSize.h" |
| 35 #include "platform/graphics/BitmapImage.h" | 35 #include "platform/graphics/BitmapImage.h" |
| 36 #include "platform/graphics/DeferredImageDecoder.h" | 36 #include "platform/graphics/DeferredImageDecoder.h" |
| 37 #include "platform/graphics/GraphicsContext.h" | 37 #include "platform/graphics/GraphicsContext.h" |
| 38 #include "platform/graphics/paint/PaintImage.h" | |
| 38 #include "platform/graphics/paint/PaintRecorder.h" | 39 #include "platform/graphics/paint/PaintRecorder.h" |
| 39 #include "platform/graphics/paint/PaintShader.h" | 40 #include "platform/graphics/paint/PaintShader.h" |
| 40 #include "platform/instrumentation/PlatformInstrumentation.h" | 41 #include "platform/instrumentation/PlatformInstrumentation.h" |
| 41 #include "platform/instrumentation/tracing/TraceEvent.h" | 42 #include "platform/instrumentation/tracing/TraceEvent.h" |
| 42 #include "platform/network/mime/MIMETypeRegistry.h" | 43 #include "platform/network/mime/MIMETypeRegistry.h" |
| 43 #include "platform/wtf/StdLibExtras.h" | 44 #include "platform/wtf/StdLibExtras.h" |
| 44 #include "public/platform/Platform.h" | 45 #include "public/platform/Platform.h" |
| 45 #include "public/platform/WebData.h" | 46 #include "public/platform/WebData.h" |
| 46 #include "third_party/skia/include/core/SkImage.h" | 47 #include "third_party/skia/include/core/SkImage.h" |
| 47 | 48 |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 222 StartAnimation(); | 223 StartAnimation(); |
| 223 } | 224 } |
| 224 | 225 |
| 225 namespace { | 226 namespace { |
| 226 | 227 |
| 227 sk_sp<PaintShader> CreatePatternShader(sk_sp<const SkImage> image, | 228 sk_sp<PaintShader> CreatePatternShader(sk_sp<const SkImage> image, |
| 228 const SkMatrix& shader_matrix, | 229 const SkMatrix& shader_matrix, |
| 229 const PaintFlags& paint, | 230 const PaintFlags& paint, |
| 230 const FloatSize& spacing, | 231 const FloatSize& spacing, |
| 231 SkShader::TileMode tmx, | 232 SkShader::TileMode tmx, |
| 232 SkShader::TileMode tmy) { | 233 SkShader::TileMode tmy, |
| 234 bool animated, | |
| 235 bool complete) { | |
| 233 if (spacing.IsZero()) | 236 if (spacing.IsZero()) |
| 234 return MakePaintShaderImage(image, tmx, tmy, &shader_matrix); | 237 return MakePaintShaderImage(image, tmx, tmy, &shader_matrix); |
| 235 | 238 |
| 236 // Arbitrary tiling is currently only supported for SkPictureShader, so we use | 239 // Arbitrary tiling is currently only supported for SkPictureShader, so we use |
| 237 // that instead of a plain bitmap shader to implement spacing. | 240 // that instead of a plain bitmap shader to implement spacing. |
| 238 const SkRect tile_rect = SkRect::MakeWH(image->width() + spacing.Width(), | 241 const SkRect tile_rect = SkRect::MakeWH(image->width() + spacing.Width(), |
| 239 image->height() + spacing.Height()); | 242 image->height() + spacing.Height()); |
| 240 | 243 |
| 241 PaintRecorder recorder; | 244 PaintRecorder recorder; |
| 242 PaintCanvas* canvas = recorder.beginRecording(tile_rect); | 245 PaintCanvas* canvas = recorder.beginRecording(tile_rect); |
| 243 canvas->drawImage(image, 0, 0, &paint); | 246 auto animation_type = animated ? PaintImage::AnimationType::ANIMATED |
| 247 : PaintImage::AnimationType::STATIC; | |
| 248 auto completion_state = complete | |
| 249 ? PaintImage::CompletionState::DONE | |
| 250 : PaintImage::CompletionState::PARTIALLY_DONE; | |
| 251 canvas->drawImage( | |
| 252 PaintImage(std::move(image), animation_type, completion_state), 0, 0, | |
|
pdr.
2017/04/12 17:37:05
It looks like PaintImage is used as a single-frame
vmpstr
2017/04/12 18:58:44
Yeah, that's the plan. I'm just trying to stage th
| |
| 253 &paint); | |
| 244 | 254 |
| 245 return MakePaintShaderRecord(recorder.finishRecordingAsPicture(), tmx, tmy, | 255 return MakePaintShaderRecord(recorder.finishRecordingAsPicture(), tmx, tmy, |
| 246 &shader_matrix, nullptr); | 256 &shader_matrix, nullptr); |
| 247 } | 257 } |
| 248 | 258 |
| 249 SkShader::TileMode ComputeTileMode(float left, | 259 SkShader::TileMode ComputeTileMode(float left, |
| 250 float right, | 260 float right, |
| 251 float min, | 261 float min, |
| 252 float max) { | 262 float max) { |
| 253 DCHECK(left < right); | 263 DCHECK(left < right); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 308 PaintFlags flags = context.FillFlags(); | 318 PaintFlags flags = context.FillFlags(); |
| 309 flags.setColor(SK_ColorBLACK); | 319 flags.setColor(SK_ColorBLACK); |
| 310 flags.setBlendMode(composite_op); | 320 flags.setBlendMode(composite_op); |
| 311 flags.setFilterQuality( | 321 flags.setFilterQuality( |
| 312 context.ComputeFilterQuality(this, dest_rect, norm_src_rect)); | 322 context.ComputeFilterQuality(this, dest_rect, norm_src_rect)); |
| 313 flags.setAntiAlias(context.ShouldAntialias()); | 323 flags.setAntiAlias(context.ShouldAntialias()); |
| 314 flags.setShader( | 324 flags.setShader( |
| 315 CreatePatternShader(std::move(image), local_matrix, flags, | 325 CreatePatternShader(std::move(image), local_matrix, flags, |
| 316 FloatSize(repeat_spacing.Width() / scale.Width(), | 326 FloatSize(repeat_spacing.Width() / scale.Width(), |
| 317 repeat_spacing.Height() / scale.Height()), | 327 repeat_spacing.Height() / scale.Height()), |
| 318 tmx, tmy)); | 328 tmx, tmy, MaybeAnimated(), CurrentFrameIsComplete())); |
| 319 // If the shader could not be instantiated (e.g. non-invertible matrix), | 329 // If the shader could not be instantiated (e.g. non-invertible matrix), |
| 320 // draw transparent. | 330 // draw transparent. |
| 321 // Note: we can't simply bail, because of arbitrary blend mode. | 331 // Note: we can't simply bail, because of arbitrary blend mode. |
| 322 if (!flags.getShader()) | 332 if (!flags.getShader()) |
| 323 flags.setColor(SK_ColorTRANSPARENT); | 333 flags.setColor(SK_ColorTRANSPARENT); |
| 324 | 334 |
| 325 context.DrawRect(dest_rect, flags); | 335 context.DrawRect(dest_rect, flags); |
| 326 | 336 |
| 327 if (CurrentFrameIsLazyDecoded()) | 337 if (CurrentFrameIsLazyDecoded()) |
| 328 PlatformInstrumentation::DidDrawLazyPixelRef(image_id); | 338 PlatformInstrumentation::DidDrawLazyPixelRef(image_id); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 380 FloatRect subset = dest; | 390 FloatRect subset = dest; |
| 381 subset.SetX((dest.X() - tile.X()) / scale.Width()); | 391 subset.SetX((dest.X() - tile.X()) / scale.Width()); |
| 382 subset.SetY((dest.Y() - tile.Y()) / scale.Height()); | 392 subset.SetY((dest.Y() - tile.Y()) / scale.Height()); |
| 383 subset.SetWidth(dest.Width() / scale.Width()); | 393 subset.SetWidth(dest.Width() / scale.Width()); |
| 384 subset.SetHeight(dest.Height() / scale.Height()); | 394 subset.SetHeight(dest.Height() / scale.Height()); |
| 385 | 395 |
| 386 return subset; | 396 return subset; |
| 387 } | 397 } |
| 388 | 398 |
| 389 } // namespace blink | 399 } // namespace blink |
| OLD | NEW |