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

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

Issue 2895953003: Use SkJpegEncoder in gfx jpeg_codec (Closed)
Patch Set: Remove brackets Created 3 years, 6 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 17 matching lines...) Expand all
28 const int64_t kTestMaxImageSize = 128 * 1024; 28 const int64_t kTestMaxImageSize = 128 * 1024;
29 29
30 bool CreateJPEGImage(int width, 30 bool CreateJPEGImage(int width,
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 constexpr int kQuality = 50;
39 if (!gfx::JPEGCodec::Encode( 39 if (!gfx::JPEGCodec::Encode(bitmap, kQuality, output)) {
40 static_cast<const unsigned char*>(bitmap.getPixels()),
41 gfx::JPEGCodec::FORMAT_SkBitmap, width, height,
42 static_cast<int>(bitmap.rowBytes()), kQuality, output)) {
43 LOG(ERROR) << "Unable to encode " << width << "x" << height << " bitmap"; 40 LOG(ERROR) << "Unable to encode " << width << "x" << height << " bitmap";
44 return false; 41 return false;
45 } 42 }
46 return true; 43 return true;
47 } 44 }
48 45
49 class Request { 46 class Request {
50 public: 47 public:
51 explicit Request(ImageDecoderImpl* decoder) : decoder_(decoder) {} 48 explicit Request(ImageDecoderImpl* decoder) : decoder_(decoder) {}
52 49
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 const char kRandomData[] = "u gycfy7xdjkhfgui bdui "; 152 const char kRandomData[] = "u gycfy7xdjkhfgui bdui ";
156 std::vector<unsigned char> jpg(kRandomData, 153 std::vector<unsigned char> jpg(kRandomData,
157 kRandomData + sizeof(kRandomData)); 154 kRandomData + sizeof(kRandomData));
158 155
159 Request request(decoder()); 156 Request request(decoder());
160 request.DecodeImage(jpg, false); 157 request.DecodeImage(jpg, false);
161 EXPECT_TRUE(request.bitmap().isNull()); 158 EXPECT_TRUE(request.bitmap().isNull());
162 } 159 }
163 160
164 } // namespace data_decoder 161 } // namespace data_decoder
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698