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

Side by Side Diff: third_party/WebKit/Source/core/frame/ImageBitmap.cpp

Issue 2825183002: Plumb CanvasColorParams to canvas image classes (Closed)
Patch Set: 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "core/frame/ImageBitmap.h" 5 #include "core/frame/ImageBitmap.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include "core/html/HTMLCanvasElement.h" 8 #include "core/html/HTMLCanvasElement.h"
9 #include "core/html/HTMLVideoElement.h" 9 #include "core/html/HTMLVideoElement.h"
10 #include "core/html/ImageData.h" 10 #include "core/html/ImageData.h"
(...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 data->GetSkColorSpace())); 889 data->GetSkColorSpace()));
890 } else { 890 } else {
891 image_ = StaticBitmapImage::Create(sk_image); 891 image_ = StaticBitmapImage::Create(sk_image);
892 } 892 }
893 if (!image_) 893 if (!image_)
894 return; 894 return;
895 image_->SetPremultiplied(parsed_options.premultiply_alpha); 895 image_->SetPremultiplied(parsed_options.premultiply_alpha);
896 return; 896 return;
897 } 897 }
898 898
899 std::unique_ptr<ImageBuffer> buffer = 899 // TODO(ccameron): Retrieve full CanvasColorParams from ImageData.
ccameron 2017/04/18 21:23:50 I suspect we should make some changes to ImageData
900 ImageBuffer::Create(parsed_options.crop_rect.Size(), kNonOpaque, 900 ImageDataColorSettings color_settings;
901 kDoNotInitializeImagePixels, data->GetSkColorSpace()); 901 data->getColorSettings(color_settings);
902 CanvasColorSpace canvas_color_space =
903 ImageData::GetCanvasColorSpace(color_settings.colorSpace());
904 CanvasPixelFormat canvas_pixel_format = kRGBA8CanvasPixelFormat;
zakerinasab 2017/04/18 21:46:58 I think we need to set the canvas pixel format for
ccameron 2017/04/18 22:10:45 Good point -- done.
905 std::unique_ptr<ImageBuffer> buffer = ImageBuffer::Create(
906 parsed_options.crop_rect.Size(), kNonOpaque, kDoNotInitializeImagePixels,
907 CanvasColorParams(canvas_color_space, canvas_pixel_format));
902 if (!buffer) 908 if (!buffer)
903 return; 909 return;
904 910
905 if (src_rect.IsEmpty()) { 911 if (src_rect.IsEmpty()) {
906 image_ = StaticBitmapImage::Create(buffer->NewSkImageSnapshot( 912 image_ = StaticBitmapImage::Create(buffer->NewSkImageSnapshot(
907 kPreferNoAcceleration, kSnapshotReasonUnknown)); 913 kPreferNoAcceleration, kSnapshotReasonUnknown));
908 return; 914 return;
909 } 915 }
910 916
911 IntPoint dst_point = IntPoint(std::min(0, -parsed_options.crop_rect.X()), 917 IntPoint dst_point = IntPoint(std::min(0, -parsed_options.crop_rect.X()),
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
1138 void ImageBitmap::AdjustDrawRects(FloatRect* src_rect, 1144 void ImageBitmap::AdjustDrawRects(FloatRect* src_rect,
1139 FloatRect* dst_rect) const {} 1145 FloatRect* dst_rect) const {}
1140 1146
1141 FloatSize ImageBitmap::ElementSize(const FloatSize&) const { 1147 FloatSize ImageBitmap::ElementSize(const FloatSize&) const {
1142 return FloatSize(width(), height()); 1148 return FloatSize(width(), height());
1143 } 1149 }
1144 1150
1145 DEFINE_TRACE(ImageBitmap) {} 1151 DEFINE_TRACE(ImageBitmap) {}
1146 1152
1147 } // namespace blink 1153 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698