1 // Copyright 2016 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CC_TILES_MIPMAP_UTIL_H_
6 #define CC_TILES_MIPMAP_UTIL_H_
8 #include "cc/cc_export.h"
9 #include "third_party/skia/include/core/SkSize.h"
10 #include "ui/gfx/geometry/skia_conversions.h"
14 class CC_EXPORT MipMapUtil {
16 // Determine the smallest mip level that is larger than |target_size|. Each
17 // mip level corresponds to a power of two scale of the image - for instance,
18 // level 0 is original size, level 1 is 2x smaller, level 2 is 4x smaller,
19 // etc... This function does not do error checking and must be called with a
20 // valid src_size (width/height > 0) and mip_level (>= 0).
21 static int GetLevelForSize(const gfx::Size& src_size,
22 const gfx::Size& target_size);
24 // Determines the scale factor for the given |mip_level|. This function does
25 // not do error checking and must be called with a valid src_size
26 // (width/height > 0) and mip_level (>= 0).
27 static SkSize GetScaleAdjustmentForLevel(const gfx::Size& src_size,
30 // Determine the size of the given |mip_level|. This function does not do
31 // error checking and must be called with a valid src_size (width/height > 0)
32 // and mip_level (>= 0).
33 static gfx::Size GetSizeForLevel(const gfx::Size& src_size, int mip_level);
35 // Determines the scale factor for the smallest mip level that is larger than
36 // |target_size|. This function does not do error checking and must be called
37 // with a valid src_size (width/height > 0) and mip_level (>= 0).
38 static SkSize GetScaleAdjustmentForSize(const gfx::Size& src_size,
39 const gfx::Size& target_size);
44 #endif // CC_TILES_MIPMAP_UTIL_H_