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

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

Issue 2661353002: ui/gfx: split out code that depends on paint (Closed)
Patch Set: Fix mac, chromeos build Created 3 years, 10 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/shadow_util.cc ('k') | ui/gfx/skia_paint_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) 2017 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_PAINT_UTIL_H_
6 #define UI_GFX_SKIA_UTIL_H_ 6 #define UI_GFX_SKIA_PAINT_UTIL_H_
7 7
8 #include <string>
9 #include <vector> 8 #include <vector>
10 9
11 #include "third_party/skia/include/core/SkColor.h"
12 #include "third_party/skia/include/core/SkRect.h"
13 #include "third_party/skia/include/core/SkShader.h" 10 #include "third_party/skia/include/core/SkShader.h"
14 #include "ui/gfx/geometry/quad_f.h"
15 #include "ui/gfx/geometry/size.h"
16 #include "ui/gfx/gfx_export.h" 11 #include "ui/gfx/gfx_export.h"
12 #include "ui/gfx/shadow_value.h"
17 13
18 class SkBitmap;
19 class SkDrawLooper; 14 class SkDrawLooper;
15 class SkMatrix;
20 16
21 namespace gfx { 17 namespace gfx {
22 18
23 class ImageSkiaRep; 19 class ImageSkiaRep;
24 class Point;
25 class PointF;
26 class Rect;
27 class RectF;
28 class ShadowValue;
29 class Transform;
30
31 // Convert between Skia and gfx types.
32 GFX_EXPORT SkPoint PointToSkPoint(const Point& point);
33 GFX_EXPORT SkIPoint PointToSkIPoint(const Point& point);
34 GFX_EXPORT SkPoint PointFToSkPoint(const PointF& point);
35 GFX_EXPORT SkRect RectToSkRect(const Rect& rect);
36 GFX_EXPORT SkIRect RectToSkIRect(const Rect& rect);
37 GFX_EXPORT Rect SkIRectToRect(const SkIRect& rect);
38 GFX_EXPORT SkRect RectFToSkRect(const RectF& rect);
39 GFX_EXPORT RectF SkRectToRectF(const SkRect& rect);
40 GFX_EXPORT SkSize SizeFToSkSize(const SizeF& size);
41 GFX_EXPORT SizeF SkSizeToSizeF(const SkSize& size);
42 GFX_EXPORT Size SkISizeToSize(const SkISize& size);
43
44 GFX_EXPORT void QuadFToSkPoints(const gfx::QuadF& quad, SkPoint points[4]);
45
46 GFX_EXPORT void TransformToFlattenedSkMatrix(const gfx::Transform& transform,
47 SkMatrix* flattened);
48 20
49 // Creates a bitmap shader for the image rep with the image rep's scale factor. 21 // Creates a bitmap shader for the image rep with the image rep's scale factor.
50 // Sets the created shader's local matrix such that it displays the image rep at 22 // Sets the created shader's local matrix such that it displays the image rep at
51 // the correct scale factor. 23 // the correct scale factor.
52 // The shader's local matrix should not be changed after the shader is created. 24 // The shader's local matrix should not be changed after the shader is created.
53 // TODO(pkotwicz): Allow shader's local matrix to be changed after the shader 25 // TODO(pkotwicz): Allow shader's local matrix to be changed after the shader
54 // is created. 26 // is created.
55 // 27 //
56 GFX_EXPORT sk_sp<SkShader> CreateImageRepShader( 28 GFX_EXPORT sk_sp<SkShader> CreateImageRepShader(
57 const gfx::ImageSkiaRep& image_rep, 29 const gfx::ImageSkiaRep& image_rep,
(...skipping 21 matching lines...) Expand all
79 GFX_EXPORT sk_sp<SkDrawLooper> CreateShadowDrawLooper( 51 GFX_EXPORT sk_sp<SkDrawLooper> CreateShadowDrawLooper(
80 const std::vector<ShadowValue>& shadows); 52 const std::vector<ShadowValue>& shadows);
81 53
82 // Creates a draw looper to generate |shadows|. This creates a looper with the 54 // Creates a draw looper to generate |shadows|. This creates a looper with the
83 // correct amount of blur. Callers of the existing CreateShadowDrawLooper may 55 // correct amount of blur. Callers of the existing CreateShadowDrawLooper may
84 // rely on the wrong amount of blur being applied but new code should use this 56 // rely on the wrong amount of blur being applied but new code should use this
85 // function. 57 // function.
86 GFX_EXPORT sk_sp<SkDrawLooper> CreateShadowDrawLooperCorrectBlur( 58 GFX_EXPORT sk_sp<SkDrawLooper> CreateShadowDrawLooperCorrectBlur(
87 const std::vector<ShadowValue>& shadows); 59 const std::vector<ShadowValue>& shadows);
88 60
89 // Returns true if the two bitmaps contain the same pixels.
90 GFX_EXPORT bool BitmapsAreEqual(const SkBitmap& bitmap1,
91 const SkBitmap& bitmap2);
92
93 // Converts Skia ARGB format pixels in |skia| to RGBA.
94 GFX_EXPORT void ConvertSkiaToRGBA(const unsigned char* skia,
95 int pixel_width,
96 unsigned char* rgba);
97
98 // Converts a Skia floating-point value to an int appropriate for hb_position_t.
99 GFX_EXPORT int SkiaScalarToHarfBuzzUnits(SkScalar value);
100
101 // Converts an hb_position_t to a Skia floating-point value.
102 GFX_EXPORT SkScalar HarfBuzzUnitsToSkiaScalar(int value);
103
104 // Converts an hb_position_t to a float.
105 GFX_EXPORT float HarfBuzzUnitsToFloat(int value);
106
107 } // namespace gfx 61 } // namespace gfx
108 62
109 #endif // UI_GFX_SKIA_UTIL_H_ 63 #endif // UI_GFX_SKIA_UTIL_H_
OLDNEW
« no previous file with comments | « ui/gfx/shadow_util.cc ('k') | ui/gfx/skia_paint_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698