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

Side by Side Diff: services/data_decoder/image_decoder_impl_unittest.cc

Issue 2895953003: Use SkJpegEncoder in gfx jpeg_codec (Closed)
Patch Set: Created 3 years, 7 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 // 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 <memory> 5 #include <memory>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 20 matching lines...) Expand all
31 int height, 31 int height,
32 SkColor color, 32 SkColor color,
33 std::vector<unsigned char>* output) { 33 std::vector<unsigned char>* output) {
34 SkBitmap bitmap; 34 SkBitmap bitmap;
35 bitmap.allocN32Pixels(width, height); 35 bitmap.allocN32Pixels(width, height);
36 bitmap.eraseColor(color); 36 bitmap.eraseColor(color);
37 37
38 const int kQuality = 50; 38 const int kQuality = 50;
39 if (!gfx::JPEGCodec::Encode( 39 if (!gfx::JPEGCodec::Encode(
40 static_cast<const unsigned char*>(bitmap.getPixels()), 40 static_cast<const unsigned char*>(bitmap.getPixels()),
41 gfx::JPEGCodec::FORMAT_SkBitmap, width, height, 41 kN32_SkColorType, width, height, static_cast<int>(bitmap.rowBytes()),
42 static_cast<int>(bitmap.rowBytes()), kQuality, output)) { 42 kQuality, output)) {
43 LOG(ERROR) << "Unable to encode " << width << "x" << height << " bitmap"; 43 LOG(ERROR) << "Unable to encode " << width << "x" << height << " bitmap";
44 return false; 44 return false;
45 } 45 }
46 return true; 46 return true;
47 } 47 }
48 48
49 class Request { 49 class Request {
50 public: 50 public:
51 explicit Request(ImageDecoderImpl* decoder) : decoder_(decoder) {} 51 explicit Request(ImageDecoderImpl* decoder) : decoder_(decoder) {}
52 52
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 const char kRandomData[] = "u gycfy7xdjkhfgui bdui "; 155 const char kRandomData[] = "u gycfy7xdjkhfgui bdui ";
156 std::vector<unsigned char> jpg(kRandomData, 156 std::vector<unsigned char> jpg(kRandomData,
157 kRandomData + sizeof(kRandomData)); 157 kRandomData + sizeof(kRandomData));
158 158
159 Request request(decoder()); 159 Request request(decoder());
160 request.DecodeImage(jpg, false); 160 request.DecodeImage(jpg, false);
161 EXPECT_TRUE(request.bitmap().isNull()); 161 EXPECT_TRUE(request.bitmap().isNull());
162 } 162 }
163 163
164 } // namespace data_decoder 164 } // namespace data_decoder
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698