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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/ImageBuffer.cpp

Issue 2812763002: paint: Introduce PaintImage that wraps SkImage in paint calls. (Closed)
Patch Set: update Created 3 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2008, Google Inc. All rights reserved. 2 * Copyright (c) 2008, Google Inc. All rights reserved.
3 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> 3 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org>
4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. 4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. 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 are 7 * modification, are permitted provided that the following conditions are
8 * met: 8 * met:
9 * 9 *
10 * * Redistributions of source code must retain the above copyright 10 * * Redistributions of source code must retain the above copyright
(...skipping 28 matching lines...) Expand all
39 #include "platform/RuntimeEnabledFeatures.h" 39 #include "platform/RuntimeEnabledFeatures.h"
40 #include "platform/geometry/IntRect.h" 40 #include "platform/geometry/IntRect.h"
41 #include "platform/graphics/ExpensiveCanvasHeuristicParameters.h" 41 #include "platform/graphics/ExpensiveCanvasHeuristicParameters.h"
42 #include "platform/graphics/GraphicsContext.h" 42 #include "platform/graphics/GraphicsContext.h"
43 #include "platform/graphics/ImageBufferClient.h" 43 #include "platform/graphics/ImageBufferClient.h"
44 #include "platform/graphics/RecordingImageBufferSurface.h" 44 #include "platform/graphics/RecordingImageBufferSurface.h"
45 #include "platform/graphics/StaticBitmapImage.h" 45 #include "platform/graphics/StaticBitmapImage.h"
46 #include "platform/graphics/UnacceleratedImageBufferSurface.h" 46 #include "platform/graphics/UnacceleratedImageBufferSurface.h"
47 #include "platform/graphics/gpu/DrawingBuffer.h" 47 #include "platform/graphics/gpu/DrawingBuffer.h"
48 #include "platform/graphics/gpu/Extensions3DUtil.h" 48 #include "platform/graphics/gpu/Extensions3DUtil.h"
49 #include "platform/graphics/paint/PaintImage.h"
49 #include "platform/graphics/paint/PaintRecord.h" 50 #include "platform/graphics/paint/PaintRecord.h"
50 #include "platform/graphics/skia/SkiaUtils.h" 51 #include "platform/graphics/skia/SkiaUtils.h"
51 #include "platform/image-encoders/JPEGImageEncoder.h" 52 #include "platform/image-encoders/JPEGImageEncoder.h"
52 #include "platform/image-encoders/PNGImageEncoder.h" 53 #include "platform/image-encoders/PNGImageEncoder.h"
53 #include "platform/image-encoders/WEBPImageEncoder.h" 54 #include "platform/image-encoders/WEBPImageEncoder.h"
54 #include "platform/network/mime/MIMETypeRegistry.h" 55 #include "platform/network/mime/MIMETypeRegistry.h"
55 #include "platform/wtf/CheckedNumeric.h" 56 #include "platform/wtf/CheckedNumeric.h"
56 #include "platform/wtf/MathExtras.h" 57 #include "platform/wtf/MathExtras.h"
57 #include "platform/wtf/PtrUtil.h" 58 #include "platform/wtf/PtrUtil.h"
58 #include "platform/wtf/Vector.h" 59 #include "platform/wtf/Vector.h"
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 // abort the surface switch to reatain the old surface which is still 578 // abort the surface switch to reatain the old surface which is still
578 // functional. 579 // functional.
579 if (!image) 580 if (!image)
580 return; 581 return;
581 582
582 if (surface->IsRecording()) { 583 if (surface->IsRecording()) {
583 // Using a GPU-backed image with RecordingImageBufferSurface 584 // Using a GPU-backed image with RecordingImageBufferSurface
584 // will fail at playback time. 585 // will fail at playback time.
585 image = image->makeNonTextureImage(); 586 image = image->makeNonTextureImage();
586 } 587 }
587 surface->Canvas()->drawImage(std::move(image), 0, 0); 588 // TODO(vmpstr): Figure out actual values for this.
589 auto animation_type = PaintImage::AnimationType::UNKNOWN;
590 auto completion_state = PaintImage::CompletionState::UNKNOWN;
591 surface->Canvas()->drawImage(
592 PaintImage(std::move(image), animation_type, completion_state), 0, 0);
588 593
589 surface->SetImageBuffer(this); 594 surface->SetImageBuffer(this);
590 if (client_) 595 if (client_)
591 client_->RestoreCanvasMatrixClipStack(surface->Canvas()); 596 client_->RestoreCanvasMatrixClipStack(surface->Canvas());
592 surface_ = std::move(surface); 597 surface_ = std::move(surface);
593 598
594 UpdateGPUMemoryUsage(); 599 UpdateGPUMemoryUsage();
595 } 600 }
596 601
597 bool ImageDataBuffer::EncodeImage(const String& mime_type, 602 bool ImageDataBuffer::EncodeImage(const String& mime_type,
(...skipping 22 matching lines...) Expand all
620 DCHECK(MIMETypeRegistry::IsSupportedImageMIMETypeForEncoding(mime_type)); 625 DCHECK(MIMETypeRegistry::IsSupportedImageMIMETypeForEncoding(mime_type));
621 626
622 Vector<unsigned char> result; 627 Vector<unsigned char> result;
623 if (!EncodeImage(mime_type, quality, &result)) 628 if (!EncodeImage(mime_type, quality, &result))
624 return "data:,"; 629 return "data:,";
625 630
626 return "data:" + mime_type + ";base64," + Base64Encode(result); 631 return "data:" + mime_type + ";base64," + Base64Encode(result);
627 } 632 }
628 633
629 } // namespace blink 634 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698