Mark LoadSession() and RemoveSession() as never reached
[chromium-blink-merge.git] / ui / gfx / skia_util.h
blob44c9a09e0330dedbb3ee3d004b50142b27dc52ae
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
3 // found in the LICENSE file.
5 #ifndef UI_GFX_SKIA_UTIL_H_
6 #define UI_GFX_SKIA_UTIL_H_
8 #include <string>
9 #include <vector>
11 #include "skia/ext/refptr.h"
12 #include "third_party/skia/include/core/SkColor.h"
13 #include "third_party/skia/include/core/SkRect.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"
17 #include "ui/gfx/gfx_export.h"
19 class SkBitmap;
20 class SkDrawLooper;
22 namespace gfx {
24 class ImageSkiaRep;
25 class Rect;
26 class RectF;
27 class ShadowValue;
28 class Transform;
30 // Convert between Skia and gfx rect types.
31 GFX_EXPORT SkRect RectToSkRect(const Rect& rect);
32 GFX_EXPORT SkIRect RectToSkIRect(const Rect& rect);
33 GFX_EXPORT Rect SkIRectToRect(const SkIRect& rect);
34 GFX_EXPORT SkRect RectFToSkRect(const RectF& 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);
39 GFX_EXPORT void QuadFToSkPoints(const gfx::QuadF& quad, SkPoint points[4]);
41 GFX_EXPORT void TransformToFlattenedSkMatrix(const gfx::Transform& transform,
42 SkMatrix* flattened);
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.
51 GFX_EXPORT skia::RefPtr<SkShader> CreateImageRepShader(
52 const gfx::ImageSkiaRep& image_rep,
53 SkShader::TileMode tile_mode,
54 const SkMatrix& local_matrix);
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);
63 // Creates a vertical gradient shader. The caller owns the shader.
64 // Example usage to avoid leaks:
65 GFX_EXPORT skia::RefPtr<SkShader> CreateGradientShader(int start_point,
66 int end_point,
67 SkColor start_color,
68 SkColor end_color);
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);
76 // Returns true if the two bitmaps contain the same pixels.
77 GFX_EXPORT bool BitmapsAreEqual(const SkBitmap& bitmap1,
78 const SkBitmap& bitmap2);
80 // Converts Skia ARGB format pixels in |skia| to RGBA.
81 GFX_EXPORT void ConvertSkiaToRGBA(const unsigned char* skia,
82 int pixel_width,
83 unsigned char* rgba);
85 } // namespace gfx
87 #endif // UI_GFX_SKIA_UTIL_H_