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

Side by Side Diff: ui/gfx/skia_util.h

Issue 1001833005: Update from https://crrev.com/320343 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Supress Created 5 years, 9 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 | « ui/gfx/hud_font.cc ('k') | ui/gfx/skia_util.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 #ifndef UI_GFX_SKIA_UTIL_H_ 5 #ifndef UI_GFX_SKIA_UTIL_H_
6 #define UI_GFX_SKIA_UTIL_H_ 6 #define UI_GFX_SKIA_UTIL_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "skia/ext/refptr.h" 11 #include "skia/ext/refptr.h"
12 #include "third_party/skia/include/core/SkColor.h" 12 #include "third_party/skia/include/core/SkColor.h"
13 #include "third_party/skia/include/core/SkRect.h" 13 #include "third_party/skia/include/core/SkRect.h"
14 #include "third_party/skia/include/core/SkShader.h" 14 #include "third_party/skia/include/core/SkShader.h"
15 #include "ui/gfx/geometry/quad_f.h"
16 #include "ui/gfx/geometry/size.h"
15 #include "ui/gfx/gfx_export.h" 17 #include "ui/gfx/gfx_export.h"
16 18
17 class SkBitmap; 19 class SkBitmap;
18 class SkDrawLooper; 20 class SkDrawLooper;
19 21
20 namespace gfx { 22 namespace gfx {
21 23
22 class ImageSkiaRep; 24 class ImageSkiaRep;
23 class Rect; 25 class Rect;
24 class RectF; 26 class RectF;
25 class ShadowValue; 27 class ShadowValue;
26 class Transform; 28 class Transform;
27 29
28 // Convert between Skia and gfx rect types. 30 // Convert between Skia and gfx rect types.
29 GFX_EXPORT SkRect RectToSkRect(const Rect& rect); 31 GFX_EXPORT SkRect RectToSkRect(const Rect& rect);
30 GFX_EXPORT SkIRect RectToSkIRect(const Rect& rect); 32 GFX_EXPORT SkIRect RectToSkIRect(const Rect& rect);
31 GFX_EXPORT Rect SkIRectToRect(const SkIRect& rect); 33 GFX_EXPORT Rect SkIRectToRect(const SkIRect& rect);
32 GFX_EXPORT SkRect RectFToSkRect(const RectF& rect); 34 GFX_EXPORT SkRect RectFToSkRect(const RectF& rect);
33 GFX_EXPORT RectF SkRectToRectF(const SkRect& rect); 35 GFX_EXPORT RectF SkRectToRectF(const SkRect& rect);
36 GFX_EXPORT SkSize SizeFToSkSize(const SizeF& size);
37 GFX_EXPORT SizeF SkSizeToSizeF(const SkSize& size);
38
39 GFX_EXPORT void QuadFToSkPoints(const gfx::QuadF& quad, SkPoint points[4]);
34 40
35 GFX_EXPORT void TransformToFlattenedSkMatrix(const gfx::Transform& transform, 41 GFX_EXPORT void TransformToFlattenedSkMatrix(const gfx::Transform& transform,
36 SkMatrix* flattened); 42 SkMatrix* flattened);
37 43
44 // Creates a bitmap shader for the image rep with the image rep's scale factor.
45 // Sets the created shader's local matrix such that it displays the image rep at
46 // the correct scale factor.
47 // The shader's local matrix should not be changed after the shader is created.
48 // TODO(pkotwicz): Allow shader's local matrix to be changed after the shader
49 // is created.
50 //
51 GFX_EXPORT skia::RefPtr<SkShader> CreateImageRepShader(
52 const gfx::ImageSkiaRep& image_rep,
53 SkShader::TileMode tile_mode,
54 const SkMatrix& local_matrix);
55
56 // Creates a bitmap shader for the image rep with the passed in scale factor.
57 GFX_EXPORT skia::RefPtr<SkShader> CreateImageRepShaderForScale(
58 const gfx::ImageSkiaRep& image_rep,
59 SkShader::TileMode tile_mode,
60 const SkMatrix& local_matrix,
61 SkScalar scale);
62
38 // Creates a vertical gradient shader. The caller owns the shader. 63 // Creates a vertical gradient shader. The caller owns the shader.
39 // Example usage to avoid leaks: 64 // Example usage to avoid leaks:
40 GFX_EXPORT skia::RefPtr<SkShader> CreateGradientShader(int start_point, 65 GFX_EXPORT skia::RefPtr<SkShader> CreateGradientShader(int start_point,
41 int end_point, 66 int end_point,
42 SkColor start_color, 67 SkColor start_color,
43 SkColor end_color); 68 SkColor end_color);
44 69
70 // Creates a draw looper to generate |shadows|. The caller owns the draw looper.
71 // NULL is returned if |shadows| is empty since no draw looper is needed in
72 // this case.
73 GFX_EXPORT skia::RefPtr<SkDrawLooper> CreateShadowDrawLooper(
74 const std::vector<ShadowValue>& shadows);
75
45 // Returns true if the two bitmaps contain the same pixels. 76 // Returns true if the two bitmaps contain the same pixels.
46 GFX_EXPORT bool BitmapsAreEqual(const SkBitmap& bitmap1, 77 GFX_EXPORT bool BitmapsAreEqual(const SkBitmap& bitmap1,
47 const SkBitmap& bitmap2); 78 const SkBitmap& bitmap2);
48 79
49 // Converts Skia ARGB format pixels in |skia| to RGBA. 80 // Converts Skia ARGB format pixels in |skia| to RGBA.
50 GFX_EXPORT void ConvertSkiaToRGBA(const unsigned char* skia, 81 GFX_EXPORT void ConvertSkiaToRGBA(const unsigned char* skia,
51 int pixel_width, 82 int pixel_width,
52 unsigned char* rgba); 83 unsigned char* rgba);
53 84
54 } // namespace gfx 85 } // namespace gfx
55 86
56 #endif // UI_GFX_SKIA_UTIL_H_ 87 #endif // UI_GFX_SKIA_UTIL_H_
OLDNEW
« no previous file with comments | « ui/gfx/hud_font.cc ('k') | ui/gfx/skia_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698