| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/StaticBitmapImage.h" | 5 #include "platform/graphics/StaticBitmapImage.h" |
| 6 | 6 |
| 7 #include "platform/graphics/AcceleratedStaticBitmapImage.h" | 7 #include "platform/graphics/AcceleratedStaticBitmapImage.h" |
| 8 #include "platform/graphics/GraphicsContext.h" | 8 #include "platform/graphics/GraphicsContext.h" |
| 9 #include "platform/graphics/ImageObserver.h" | 9 #include "platform/graphics/ImageObserver.h" |
| 10 #include "platform/graphics/UnacceleratedStaticBitmapImage.h" | 10 #include "platform/graphics/UnacceleratedStaticBitmapImage.h" |
| 11 #include "platform/graphics/paint/PaintImage.h" | 11 #include "platform/graphics/paint/PaintImage.h" |
| 12 #include "third_party/skia/include/core/SkCanvas.h" | 12 #include "third_party/skia/include/core/SkCanvas.h" |
| 13 #include "third_party/skia/include/core/SkImage.h" | 13 #include "third_party/skia/include/core/SkImage.h" |
| 14 #include "third_party/skia/include/core/SkPaint.h" | 14 #include "third_party/skia/include/core/SkPaint.h" |
| 15 #include "v8/include/v8.h" |
| 15 | 16 |
| 16 namespace blink { | 17 namespace blink { |
| 17 | 18 |
| 18 PassRefPtr<StaticBitmapImage> StaticBitmapImage::Create(sk_sp<SkImage> image) { | 19 PassRefPtr<StaticBitmapImage> StaticBitmapImage::Create(sk_sp<SkImage> image) { |
| 19 if (!image) | 20 if (!image) |
| 20 return nullptr; | 21 return nullptr; |
| 21 if (image->isTextureBacked()) | 22 if (image->isTextureBacked()) |
| 22 return AcceleratedStaticBitmapImage::CreateFromSharedContextImage( | 23 return AcceleratedStaticBitmapImage::CreateFromSharedContextImage( |
| 23 std::move(image)); | 24 std::move(image)); |
| 24 return UnacceleratedStaticBitmapImage::Create(std::move(image)); | 25 return UnacceleratedStaticBitmapImage::Create(std::move(image)); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 40 : PaintImage::AnimationType::STATIC; | 41 : PaintImage::AnimationType::STATIC; |
| 41 auto completion_state = CurrentFrameIsComplete() | 42 auto completion_state = CurrentFrameIsComplete() |
| 42 ? PaintImage::CompletionState::DONE | 43 ? PaintImage::CompletionState::DONE |
| 43 : PaintImage::CompletionState::PARTIALLY_DONE; | 44 : PaintImage::CompletionState::PARTIALLY_DONE; |
| 44 canvas->drawImageRect( | 45 canvas->drawImageRect( |
| 45 PaintImage(std::move(image), animation_type, completion_state), | 46 PaintImage(std::move(image), animation_type, completion_state), |
| 46 adjusted_src_rect, dst_rect, &flags, | 47 adjusted_src_rect, dst_rect, &flags, |
| 47 WebCoreClampingModeToSkiaRectConstraint(clamp_mode)); | 48 WebCoreClampingModeToSkiaRectConstraint(clamp_mode)); |
| 48 } | 49 } |
| 49 | 50 |
| 51 void StaticBitmapImage::RegisterExternalAllocationWithCurrentContext() { |
| 52 int externallyAllocatedMemory = Size().Width() * Size().Height() * 4; |
| 53 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory( |
| 54 static_cast<int64_t>(externallyAllocatedMemory)); |
| 55 } |
| 56 |
| 57 void StaticBitmapImage::UnregisterExternalAllocationWithCurrentContext() { |
| 58 int externallyAllocatedMemory = Size().Width() * Size().Height() * 4; |
| 59 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory( |
| 60 -static_cast<int64_t>(externallyAllocatedMemory)); |
| 61 } |
| 62 |
| 50 } // namespace blink | 63 } // namespace blink |
| OLD | NEW |