| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/graphics/PlaceholderImage.h" | 5 #include "platform/graphics/PlaceholderImage.h" |
| 6 | 6 |
| 7 #include "platform/geometry/FloatRect.h" | 7 #include "platform/geometry/FloatRect.h" |
| 8 #include "platform/graphics/Color.h" | 8 #include "platform/graphics/Color.h" |
| 9 #include "platform/graphics/ImageObserver.h" | 9 #include "platform/graphics/ImageObserver.h" |
| 10 #include "platform/graphics/paint/PaintRecord.h" | 10 #include "platform/graphics/paint/PaintRecord.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 if (image_for_current_frame_) | 28 if (image_for_current_frame_) |
| 29 return image_for_current_frame_; | 29 return image_for_current_frame_; |
| 30 | 30 |
| 31 const FloatRect dest_rect(0.0f, 0.0f, static_cast<float>(size_.Width()), | 31 const FloatRect dest_rect(0.0f, 0.0f, static_cast<float>(size_.Width()), |
| 32 static_cast<float>(size_.Height())); | 32 static_cast<float>(size_.Height())); |
| 33 PaintRecorder paint_recorder; | 33 PaintRecorder paint_recorder; |
| 34 Draw(paint_recorder.beginRecording(dest_rect), PaintFlags(), dest_rect, | 34 Draw(paint_recorder.beginRecording(dest_rect), PaintFlags(), dest_rect, |
| 35 dest_rect, kDoNotRespectImageOrientation, kClampImageToSourceRect); | 35 dest_rect, kDoNotRespectImageOrientation, kClampImageToSourceRect); |
| 36 | 36 |
| 37 image_for_current_frame_ = SkImage::MakeFromPicture( | 37 image_for_current_frame_ = SkImage::MakeFromPicture( |
| 38 ToSkPicture(paint_recorder.finishRecordingAsPicture()), | 38 ToSkPicture(paint_recorder.finishRecordingAsPicture(), dest_rect), |
| 39 SkISize::Make(size_.Width(), size_.Height()), nullptr, nullptr, | 39 SkISize::Make(size_.Width(), size_.Height()), nullptr, nullptr, |
| 40 SkImage::BitDepth::kU8, SkColorSpace::MakeSRGB()); | 40 SkImage::BitDepth::kU8, SkColorSpace::MakeSRGB()); |
| 41 | 41 |
| 42 return image_for_current_frame_; | 42 return image_for_current_frame_; |
| 43 } | 43 } |
| 44 | 44 |
| 45 void PlaceholderImage::Draw(PaintCanvas* canvas, | 45 void PlaceholderImage::Draw(PaintCanvas* canvas, |
| 46 const PaintFlags& base_flags, | 46 const PaintFlags& base_flags, |
| 47 const FloatRect& dest_rect, | 47 const FloatRect& dest_rect, |
| 48 const FloatRect& src_rect, | 48 const FloatRect& src_rect, |
| 49 RespectImageOrientationEnum, | 49 RespectImageOrientationEnum, |
| 50 ImageClampingMode) { | 50 ImageClampingMode) { |
| 51 if (!src_rect.Intersects(FloatRect(0.0f, 0.0f, | 51 if (!src_rect.Intersects(FloatRect(0.0f, 0.0f, |
| 52 static_cast<float>(size_.Width()), | 52 static_cast<float>(size_.Width()), |
| 53 static_cast<float>(size_.Height())))) { | 53 static_cast<float>(size_.Height())))) { |
| 54 return; | 54 return; |
| 55 } | 55 } |
| 56 | 56 |
| 57 PaintFlags flags(base_flags); | 57 PaintFlags flags(base_flags); |
| 58 flags.setStyle(PaintFlags::kFill_Style); | 58 flags.setStyle(PaintFlags::kFill_Style); |
| 59 flags.setColor(kFillColor); | 59 flags.setColor(kFillColor); |
| 60 canvas->drawRect(dest_rect, flags); | 60 canvas->drawRect(dest_rect, flags); |
| 61 } | 61 } |
| 62 | 62 |
| 63 void PlaceholderImage::DestroyDecodedData() { | 63 void PlaceholderImage::DestroyDecodedData() { |
| 64 image_for_current_frame_.reset(); | 64 image_for_current_frame_.reset(); |
| 65 } | 65 } |
| 66 | 66 |
| 67 } // namespace blink | 67 } // namespace blink |
| OLD | NEW |