当前仓库属于关闭状态,部分功能使用受限,详情请查阅 仓库状态说明
11 Star 0 Fork 30

OpenHarmony-TPC/chromium_third_party_skia
关闭

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
BitmapRegionDecoderPriv.h 2.21 KB
一键复制 编辑 原始数据 按行查看 历史
李想 提交于 2023-11-11 15:55 +08:00 . chromium 99.0.4844.88 4.0release init
/*
* Copyright 2015 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef BitmapRegionDecoderPriv_DEFINED
#define BitmapRegionDecoderPriv_DEFINED
#include "include/core/SkRect.h"
enum SubsetType {
kFullyInside_SubsetType,
kPartiallyInside_SubsetType,
kOutside_SubsetType,
};
/*
* Corrects image subset offsets and dimensions in order to perform a valid decode.
* Also indicates if the image subset should be placed at an offset within the
* output bitmap.
*
* Values of output variables are undefined if the SubsetType is kInvalid.
*
* @param imageDims Original image dimensions.
* @param subset As input, the subset that the client requested.
* As output, the image subset that we will decode.
* @param outX The left offset of the image subset within the output bitmap.
* @param outY The top offset of the image subset within the output bitmap.
*
* @return An indication of how the subset is contained in the image.
* If the return value is kInvalid, values of output variables are undefined.
*/
inline SubsetType adjust_subset_rect(const SkISize& imageDims, SkIRect* subset, int* outX,
int* outY) {
// These must be at least zero, we can't start decoding the image at a negative coordinate.
int left = std::max(0, subset->fLeft);
int top = std::max(0, subset->fTop);
// If input offsets are less than zero, we decode to an offset location in the output bitmap.
*outX = left - subset->fLeft;
*outY = top - subset->fTop;
// Make sure we don't decode pixels past the edge of the image or past the edge of the subset.
int width = std::min(imageDims.width() - left, subset->width() - *outX);
int height = std::min(imageDims.height() - top, subset->height() - *outY);
if (width <= 0 || height <= 0) {
return SubsetType::kOutside_SubsetType;
}
subset->setXYWH(left, top, width, height);
if ((*outX != 0) || (*outY != 0) || (width != subset->width()) ||
(height != subset->height())) {
return SubsetType::kPartiallyInside_SubsetType;
}
return SubsetType::kFullyInside_SubsetType;
}
#endif // BitmapRegionDecoderPriv_DEFINED
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/openharmony-tpc/chromium_third_party_skia.git
git@gitee.com:openharmony-tpc/chromium_third_party_skia.git
openharmony-tpc
chromium_third_party_skia
chromium_third_party_skia
4.0_Release

搜索帮助