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

Side by Side Diff: trunk/src/ui/gfx/skia_util.cc

Issue 24262008: Revert 224473 "Remove dependency on ui::ScaleFactor from ui/gfx" (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « trunk/src/ui/gfx/image/image_util.cc ('k') | trunk/src/ui/gfx/win/dpi.cc » ('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 (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/skia_util.h" 5 #include "ui/gfx/skia_util.h"
6 6
7 #include "third_party/skia/include/core/SkBitmap.h" 7 #include "third_party/skia/include/core/SkBitmap.h"
8 #include "third_party/skia/include/core/SkColorFilter.h" 8 #include "third_party/skia/include/core/SkColorFilter.h"
9 #include "third_party/skia/include/core/SkColorPriv.h" 9 #include "third_party/skia/include/core/SkColorPriv.h"
10 #include "third_party/skia/include/core/SkUnPreMultiply.h" 10 #include "third_party/skia/include/core/SkUnPreMultiply.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 flattened->set(8, SkDoubleToScalar(transform.matrix().getDouble(3, 3))); 61 flattened->set(8, SkDoubleToScalar(transform.matrix().getDouble(3, 3)));
62 } 62 }
63 63
64 skia::RefPtr<SkShader> CreateImageRepShader(const gfx::ImageSkiaRep& image_rep, 64 skia::RefPtr<SkShader> CreateImageRepShader(const gfx::ImageSkiaRep& image_rep,
65 SkShader::TileMode tile_mode, 65 SkShader::TileMode tile_mode,
66 const SkMatrix& local_matrix) { 66 const SkMatrix& local_matrix) {
67 skia::RefPtr<SkShader> shader = skia::AdoptRef(SkShader::CreateBitmapShader( 67 skia::RefPtr<SkShader> shader = skia::AdoptRef(SkShader::CreateBitmapShader(
68 image_rep.sk_bitmap(), tile_mode, tile_mode)); 68 image_rep.sk_bitmap(), tile_mode, tile_mode));
69 SkScalar scale_x = local_matrix.getScaleX(); 69 SkScalar scale_x = local_matrix.getScaleX();
70 SkScalar scale_y = local_matrix.getScaleY(); 70 SkScalar scale_y = local_matrix.getScaleY();
71 SkScalar bitmap_scale = SkFloatToScalar(image_rep.scale()); 71 SkScalar bitmap_scale = SkFloatToScalar(image_rep.GetScale());
72 72
73 // Unscale matrix by |bitmap_scale| such that the bitmap is drawn at the 73 // Unscale matrix by |bitmap_scale| such that the bitmap is drawn at the
74 // correct density. 74 // correct density.
75 // Convert skew and translation to pixel coordinates. 75 // Convert skew and translation to pixel coordinates.
76 // Thus, for |bitmap_scale| = 2: 76 // Thus, for |bitmap_scale| = 2:
77 // x scale = 2, x translation = 1 DIP, 77 // x scale = 2, x translation = 1 DIP,
78 // should be converted to 78 // should be converted to
79 // x scale = 1, x translation = 2 pixels. 79 // x scale = 1, x translation = 2 pixels.
80 SkMatrix shader_scale = local_matrix; 80 SkMatrix shader_scale = local_matrix;
81 shader_scale.preScale(bitmap_scale, bitmap_scale); 81 shader_scale.preScale(bitmap_scale, bitmap_scale);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 } else { 175 } else {
176 rgba[i + 0] = SkGetPackedR32(pixel_in); 176 rgba[i + 0] = SkGetPackedR32(pixel_in);
177 rgba[i + 1] = SkGetPackedG32(pixel_in); 177 rgba[i + 1] = SkGetPackedG32(pixel_in);
178 rgba[i + 2] = SkGetPackedB32(pixel_in); 178 rgba[i + 2] = SkGetPackedB32(pixel_in);
179 rgba[i + 3] = alpha; 179 rgba[i + 3] = alpha;
180 } 180 }
181 } 181 }
182 } 182 }
183 183
184 } // namespace gfx 184 } // namespace gfx
OLDNEW
« no previous file with comments | « trunk/src/ui/gfx/image/image_util.cc ('k') | trunk/src/ui/gfx/win/dpi.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698