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

Side by Side Diff: ui/gfx/image/image_util.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/gfx/image/image_util.h" 5 #include "ui/gfx/image/image_util.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 std::vector<unsigned char>* dst) { 58 std::vector<unsigned char>* dst) {
59 const gfx::ImageSkiaRep& image_skia_rep = 59 const gfx::ImageSkiaRep& image_skia_rep =
60 image.AsImageSkia().GetRepresentation(1.0f); 60 image.AsImageSkia().GetRepresentation(1.0f);
61 if (image_skia_rep.scale() != 1.0f) 61 if (image_skia_rep.scale() != 1.0f)
62 return false; 62 return false;
63 63
64 const SkBitmap& bitmap = image_skia_rep.sk_bitmap(); 64 const SkBitmap& bitmap = image_skia_rep.sk_bitmap();
65 if (!bitmap.readyToDraw()) 65 if (!bitmap.readyToDraw())
66 return false; 66 return false;
67 67
68 return gfx::JPEGCodec::Encode( 68 return gfx::JPEGCodec::Encode(bitmap, quality, dst);
69 reinterpret_cast<unsigned char*>(bitmap.getAddr32(0, 0)),
70 gfx::JPEGCodec::FORMAT_SkBitmap, bitmap.width(),
71 bitmap.height(),
72 static_cast<int>(bitmap.rowBytes()), quality,
73 dst);
74 } 69 }
75 #endif // !defined(OS_IOS) 70 #endif // !defined(OS_IOS)
76 71
77 void GetVisibleMargins(const ImageSkia& image, int* left, int* right) { 72 void GetVisibleMargins(const ImageSkia& image, int* left, int* right) {
78 *left = 0; 73 *left = 0;
79 *right = 0; 74 *right = 0;
80 if (!image.HasRepresentation(1.f)) 75 if (!image.HasRepresentation(1.f))
81 return; 76 return;
82 const SkBitmap& bitmap = image.GetRepresentation(1.f).sk_bitmap(); 77 const SkBitmap& bitmap = image.GetRepresentation(1.f).sk_bitmap();
83 if (bitmap.drawsNothing() || bitmap.isOpaque()) 78 if (bitmap.drawsNothing() || bitmap.isOpaque())
(...skipping 18 matching lines...) Expand all
102 // Since we already know column *left is non-transparent, we can avoid 97 // Since we already know column *left is non-transparent, we can avoid
103 // rechecking that column; hence the '>' here. 98 // rechecking that column; hence the '>' here.
104 for (x = bitmap.width() - 1; x > *left; --x) { 99 for (x = bitmap.width() - 1; x > *left; --x) {
105 if (ColumnHasVisiblePixels(bitmap, x)) 100 if (ColumnHasVisiblePixels(bitmap, x))
106 break; 101 break;
107 } 102 }
108 *right = bitmap.width() - 1 - x; 103 *right = bitmap.width() - 1 - x;
109 } 104 }
110 105
111 } // namespace gfx 106 } // namespace gfx
OLDNEW
« pdf/pdfium/pdfium_engine.cc ('K') | « ui/gfx/codec/jpeg_codec_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698