blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 3
264
| content_id
stringlengths 40
40
| detected_licenses
listlengths 0
85
| license_type
stringclasses 2
values | repo_name
stringlengths 5
140
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringclasses 986
values | visit_date
timestamp[us] | revision_date
timestamp[us] | committer_date
timestamp[us] | github_id
int64 3.89k
681M
⌀ | star_events_count
int64 0
209k
| fork_events_count
int64 0
110k
| gha_license_id
stringclasses 23
values | gha_event_created_at
timestamp[us] | gha_created_at
timestamp[us] | gha_language
stringclasses 145
values | src_encoding
stringclasses 34
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 2
classes | length_bytes
int64 3
10.4M
| extension
stringclasses 122
values | content
stringlengths 3
10.4M
| authors
listlengths 1
1
| author_id
stringlengths 0
158
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
a32ff185583a7d825975c3861ea03cb23e473f26
|
e0e025b0b186e047461d2d74ea5fa84fb8a21f7b
|
/.history/8_cosuri_20210307090917.cpp
|
79f95437541417130d298b3728d4e126e31ad6fd
|
[] |
no_license
|
xKristee29/1nfo
|
fbd4b9c1b50f45fbd10b968f39d342a47a007da7
|
1aa9ec38f24a54c76cab8d94212bd33df616082d
|
refs/heads/main
| 2023-03-20T02:04:51.730374
| 2021-03-08T20:24:55
| 2021-03-08T20:24:55
| 345,783,580
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,012
|
cpp
|
#include <bits/stdc++.h>
using namespace std;
ifstream f("cosuri.in");
ofstream g("cosuri.out");
vector<int> v;
int n,cerinta,x,sum,prevsum;
void cer1(){
int min1=1000005,
min2=1000005,mins,
max1=-1,
max2=-1,maxs;
for(int i=1;i<=2*n;++i){
f>>x;
if(x<min1){
min2=min1;
min1=x;
}
else if(x<min2){
min2=x;
}
if(x>max2){
max1=max2;
max2=x;
}
else if(x>max1){
max1=x;
}
}
mins=min1+min2;
maxs=max1+max2;
g<<mins<<' '<<maxs;
}
void cer2(){
for(int i=1;i<=2*n;++i){
f>>x;
v.push_back(x);
}
sort(v.begin(), v.end());
prevsum=v[v.size()-1]+v[0];
for(int i=1;i<n;++i){
sum=v[v.size()-1-i]+v[i];
if(prevsum!=sum){
cout<<""
}
}
}
int main(){
f>>cerinta>>n;
if(cerinta==1){
cer1();
}
else{
cer2();
}
return 0;
}
|
[
"c90717489@gmail.com"
] |
c90717489@gmail.com
|
8e5a4ed7c32325965aa6585f4ec6b3e3c84dc05a
|
e549363a6c9c445ddb8b13b8ee283d343a4d9e94
|
/pruebaSFML/src/game/setup/screens.h
|
70b71191162b380d3d493274204fe83010b57543
|
[] |
no_license
|
frankvega2010/SFML-Template
|
4e1bd6283a611bdfc2a496960519a503601927d3
|
db1da550c10292b2887083cc4fe56a6543e64d10
|
refs/heads/master
| 2020-04-06T09:52:20.088069
| 2018-11-16T15:53:47
| 2018-11-16T15:53:47
| 157,360,062
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 450
|
h
|
#ifndef SCREENS_H
#define SCREENS_H
namespace Juego
{
class Screens
{
private:
bool _hasScreenFinished;
public:
Screens();
~Screens();
bool getHasScreenFinished();
void setHasScreenFinished(bool hasScreenFinished);
virtual void init() = 0;
virtual void input() = 0;
virtual void update() = 0;
virtual void draw() = 0;
virtual void deInit() = 0;
virtual bool finish() = 0;
};
}
#endif // SCREENS_H
|
[
"franco_vega@msn.com"
] |
franco_vega@msn.com
|
65da106f074abfbc0121e80113730e5309e629f9
|
0d0e78c6262417fb1dff53901c6087b29fe260a0
|
/ckafka/src/v20190819/model/DescribeConsumerGroupResponse.cpp
|
c2dfcaf956a3fbfeba08f95a9f317aadddb18ab6
|
[
"Apache-2.0"
] |
permissive
|
li5ch/tencentcloud-sdk-cpp
|
ae35ffb0c36773fd28e1b1a58d11755682ade2ee
|
12ebfd75a399ee2791f6ac1220a79ce8a9faf7c4
|
refs/heads/master
| 2022-12-04T15:33:08.729850
| 2020-07-20T00:52:24
| 2020-07-20T00:52:24
| 281,135,686
| 1
| 0
|
Apache-2.0
| 2020-07-20T14:14:47
| 2020-07-20T14:14:46
| null |
UTF-8
|
C++
| false
| false
| 3,192
|
cpp
|
/*
* Copyright (c) 2017-2019 THL A29 Limited, a Tencent company. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <tencentcloud/ckafka/v20190819/model/DescribeConsumerGroupResponse.h>
#include <tencentcloud/core/utils/rapidjson/document.h>
#include <tencentcloud/core/utils/rapidjson/writer.h>
#include <tencentcloud/core/utils/rapidjson/stringbuffer.h>
using TencentCloud::CoreInternalOutcome;
using namespace TencentCloud::Ckafka::V20190819::Model;
using namespace rapidjson;
using namespace std;
DescribeConsumerGroupResponse::DescribeConsumerGroupResponse() :
m_resultHasBeenSet(false)
{
}
CoreInternalOutcome DescribeConsumerGroupResponse::Deserialize(const string &payload)
{
Document d;
d.Parse(payload.c_str());
if (d.HasParseError() || !d.IsObject())
{
return CoreInternalOutcome(Error("response not json format"));
}
if (!d.HasMember("Response") || !d["Response"].IsObject())
{
return CoreInternalOutcome(Error("response `Response` is null or not object"));
}
Value &rsp = d["Response"];
if (!rsp.HasMember("RequestId") || !rsp["RequestId"].IsString())
{
return CoreInternalOutcome(Error("response `Response.RequestId` is null or not string"));
}
string requestId(rsp["RequestId"].GetString());
SetRequestId(requestId);
if (rsp.HasMember("Error"))
{
if (!rsp["Error"].IsObject() ||
!rsp["Error"].HasMember("Code") || !rsp["Error"]["Code"].IsString() ||
!rsp["Error"].HasMember("Message") || !rsp["Error"]["Message"].IsString())
{
return CoreInternalOutcome(Error("response `Response.Error` format error").SetRequestId(requestId));
}
string errorCode(rsp["Error"]["Code"].GetString());
string errorMsg(rsp["Error"]["Message"].GetString());
return CoreInternalOutcome(Error(errorCode, errorMsg).SetRequestId(requestId));
}
if (rsp.HasMember("Result") && !rsp["Result"].IsNull())
{
if (!rsp["Result"].IsObject())
{
return CoreInternalOutcome(Error("response `Result` is not object type").SetRequestId(requestId));
}
CoreInternalOutcome outcome = m_result.Deserialize(rsp["Result"]);
if (!outcome.IsSuccess())
{
outcome.GetError().SetRequestId(requestId);
return outcome;
}
m_resultHasBeenSet = true;
}
return CoreInternalOutcome(true);
}
ConsumerGroupResponse DescribeConsumerGroupResponse::GetResult() const
{
return m_result;
}
bool DescribeConsumerGroupResponse::ResultHasBeenSet() const
{
return m_resultHasBeenSet;
}
|
[
"zhiqiangfan@tencent.com"
] |
zhiqiangfan@tencent.com
|
089c941220c92578ba6bb05582ba29b4cb05b2a1
|
8dc84558f0058d90dfc4955e905dab1b22d12c08
|
/third_party/blink/renderer/core/paint/clip_path_clipper_test.cc
|
88530ea7bda330cbfac3a49932887c2e1df76b3b
|
[
"LGPL-2.0-only",
"BSD-2-Clause",
"LGPL-2.1-only",
"LicenseRef-scancode-unknown-license-reference",
"BSD-3-Clause",
"LGPL-2.0-or-later",
"GPL-1.0-or-later",
"MIT",
"Apache-2.0"
] |
permissive
|
meniossin/src
|
42a95cc6c4a9c71d43d62bc4311224ca1fd61e03
|
44f73f7e76119e5ab415d4593ac66485e65d700a
|
refs/heads/master
| 2022-12-16T20:17:03.747113
| 2020-09-03T10:43:12
| 2020-09-03T10:43:12
| 263,710,168
| 1
| 0
|
BSD-3-Clause
| 2020-05-13T18:20:09
| 2020-05-13T18:20:08
| null |
UTF-8
|
C++
| false
| false
| 970
|
cc
|
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "third_party/blink/renderer/core/paint/clip_path_clipper.h"
#include <gtest/gtest.h>
#include "third_party/blink/renderer/core/testing/core_unit_test_helper.h"
namespace blink {
namespace {
using ClipPathClipperTest = RenderingTest;
TEST_F(ClipPathClipperTest, ClipPathBoundingBoxClamped) {
SetBodyInnerHTML(R"HTML(
<!DOCTYPE html>
<div id="e" style="width:1000px; height:1000px; will-change:transform;
clip-path:circle(1000000000%);">
</div>
)HTML");
auto& object = *GetLayoutObjectByElementId("e");
base::Optional<FloatRect> bounding_box =
ClipPathClipper::LocalClipPathBoundingBox(object);
ASSERT_TRUE(bounding_box.has_value());
EXPECT_EQ(LayoutRect::InfiniteIntRect(), *bounding_box);
}
} // unnamed namespace
} // namespace blink
|
[
"arnaud@geometry.ee"
] |
arnaud@geometry.ee
|
5b7aaa81b5c1c3bf5e56f8a1c1094c9cdd47f4af
|
9ec67e83200f643f9f55ed90e0b2cae4581ebcb6
|
/JavaParserLib/JavaSyntaxStatement.cpp
|
f50ac2dff7ecfc279658dc18cdce37602f63970e
|
[] |
no_license
|
andrewpaterson/Codaphela.Library
|
465770eaf2839589fc305660725abb38033f8aa2
|
2a4722ba0a4b98a304a297a9d74c9b6811fa4ac5
|
refs/heads/master
| 2023-05-25T13:01:45.587888
| 2023-05-14T11:46:36
| 2023-05-14T11:46:36
| 3,248,841
| 1
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,651
|
cpp
|
#include "JavaSyntaxStatement.h"
//////////////////////////////////////////////////////////////////////////
//
//
//////////////////////////////////////////////////////////////////////////
void CJavaSyntaxStatement::Init(CJavaSyntaxTree* pcTree, CJavaSyntax* pcParent)
{
CJavaSyntax::Init(pcTree, pcParent);
}
//////////////////////////////////////////////////////////////////////////
//
//
//////////////////////////////////////////////////////////////////////////
void CJavaSyntaxStatement::Kill(void)
{
CJavaSyntax::Kill();
}
//////////////////////////////////////////////////////////////////////////
//
//
//////////////////////////////////////////////////////////////////////////
char* CJavaSyntaxStatement::GetType(void)
{
return "Statement";
}
//////////////////////////////////////////////////////////////////////////
//
//
//////////////////////////////////////////////////////////////////////////
void CJavaSyntaxStatement::TypePrint(CChars* pszDest, int iDepth)
{
CJavaSyntax::TypePrint(pszDest, iDepth);
}
//////////////////////////////////////////////////////////////////////////
//
//
//////////////////////////////////////////////////////////////////////////
bool CJavaSyntaxStatement::IsStatement(void)
{
return true;
}
//////////////////////////////////////////////////////////////////////////
//
//
//////////////////////////////////////////////////////////////////////////
void CJavaSyntaxStatement::PrintModifiers(CChars* pszDest, CJavaModifiers cModifiers)
{
cModifiers.Print(pszDest);
if (!cModifiers.IsNone())
{
pszDest->Append(' ');
}
}
|
[
"andrew.ian.paterson@gmail.com"
] |
andrew.ian.paterson@gmail.com
|
e7131ebb00f85ad433318e1b338cbe9bcf8753ba
|
c61c856258294fed5eb2a8b17c28d94db6f86fae
|
/exceptions/application_exceptions.hpp
|
9fbfd2efcc34590f3847376cd0762389966181df
|
[
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
hmito/hmLib
|
18b5cd5493e29168b5dc8ca488ed425caae42a8b
|
3d10a18cc9b4dbba52b5060208263bbb5bb29c4b
|
refs/heads/master
| 2023-08-16T22:47:45.550228
| 2022-05-10T03:01:21
| 2022-05-10T03:01:21
| 29,452,438
| 0
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,206
|
hpp
|
#ifndef HMLIB_EXCEPTIONS_APPLICATIONEXCEPTIONS_INC
#define HMLIB_EXCEPTIONS_APPLICATIONEXCEPTIONS_INC 100
#
#include"exception.hpp"
namespace hmLib{
namespace application_exceptions {
//applicationに関わる例外処理
class application_exception :public exceptions::exception {
typedef exceptions::exception base_type;
public:
explicit application_exception(const std::string& Message_) :base_type(Message_.c_str()) {}
explicit application_exception(const char* Message_) :base_type(Message_) {}
};
//実行引数の数が異常
class invalid_arguments_number :public application_exception {
typedef application_exception base_type;
public:
explicit invalid_arguments_number(const std::string& Message_) :base_type(Message_.c_str()) {}
explicit invalid_arguments_number(const char* Message_) :base_type(Message_) {}
};
//実行引数の値が異常
class invalid_argument_value :public application_exception {
typedef application_exception base_type;
public:
explicit invalid_argument_value(const std::string& Message_) :base_type(Message_.c_str()) {}
explicit invalid_argument_value(const char* Message_) :base_type(Message_) {}
};
}
}
#
#endif
|
[
"hmito@outlook.com"
] |
hmito@outlook.com
|
7100223ffcd60a7d6900c326680c7ed12df938b7
|
6901385058db4adecafc671745a3d0a301d09868
|
/Road_of_Gold/updateGroups.cpp
|
dec6e3d10ca8fe5cf2519de70bf48690fed40026
|
[
"MIT"
] |
permissive
|
66588257/Road_of_Gold
|
91d45cbf8032c4ea015950db1ac8942f4e1b5b2a
|
848fabebc438db2cfc03eab03098205219e62a17
|
refs/heads/master
| 2021-01-21T01:03:21.178456
| 2017-08-30T08:10:11
| 2017-08-30T08:10:11
| 101,868,046
| 1
| 0
| null | 2017-08-30T10:20:42
| 2017-08-30T10:20:42
| null |
SHIFT_JIS
|
C++
| false
| false
| 877
|
cpp
|
#include"Planet.h"
#include"Group.h"
#include"Vehicle.h"
#include"Wallet.h"
#include"Planet.h"
double tmr = 0.0;
void updateGroups()
{
tmr += planet.timeSpeed;
if (tmr > 0.0)
{
tmr -= 50.0;
//下位1/4の事業見直し
for (int i = 0; i < int(vehicles.size() / 10); i++)
{
int min = 0;
Vehicle* target = nullptr;
for (auto& v : vehicles)
{
if (!v.stopFlag && (target == nullptr || min > v.wallet().money))
{
target = &v;
min = v.wallet().money;
}
}
if (i == 0) Log(L"最低:", min);
if (target != nullptr) target->stopFlag = true;
}
int avg = 0;
for (auto& v : vehicles) avg += v.wallet().money;
Log(L"平均:", avg / double(vehicles.size()));
for (auto& v : vehicles)
{
if (v.wallet().money <= 0) v.stopFlag = true;
v.wallet().money = 0;
v.wallet().expenses = 0;
v.wallet().income = 0;
}
}
}
|
[
"sknjpn@gmail.com"
] |
sknjpn@gmail.com
|
d42a6df0f44af402bdef7c55f2e0eeb0854303e8
|
a1cb6411fee13060d2e44d35de79945d49b3134a
|
/unit_tests/verify_seqs.hh
|
6825e26ab8f94d1bfbbea10bfe1981bfa02f1723
|
[
"MIT"
] |
permissive
|
bruce2008github/PEGTL
|
72d4981df0092c10133222240ae122b899aa4c1f
|
2bbdde0f99e11fbce55607d4133bd4110b810428
|
refs/heads/master
| 2021-01-15T20:08:22.374235
| 2015-02-27T12:45:22
| 2015-02-27T12:45:22
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,991
|
hh
|
// Copyright (c) 2014-2015 Dr. Colin Hirsch and Daniel Frey
// Please see LICENSE for license or visit https://github.com/ColinH/PEGTL/
#ifndef PEGTL_UNIT_TESTS_VERIFY_SEQS_HH
#define PEGTL_UNIT_TESTS_VERIFY_SEQS_HH
#include <pegtl.hh>
#include "verify_rule.hh"
#include "verify_analyze.hh"
namespace pegtl
{
template< template< typename ... > class S >
void verify_seqs( const result_type failure = result_type::LOCAL_FAILURE )
{
verify_analyze< S< any > >( __LINE__, __FILE__, true );
verify_analyze< S< eof > >( __LINE__, __FILE__, false );
verify_analyze< S< any, eof > >( __LINE__, __FILE__, true );
verify_analyze< S< opt< any >, eof > >( __LINE__, __FILE__, false );
verify_rule< S< eof > >( __LINE__, __FILE__, "", result_type::SUCCESS, 0 );
verify_rule< S< eof > >( __LINE__, __FILE__, "a", failure, 1 );
verify_rule< S< one< 'c' > > >( __LINE__, __FILE__, "", failure, 0 );
verify_rule< S< one< 'c' >, eof > >( __LINE__, __FILE__, "", failure, 0 );
verify_rule< S< one< 'c' > > >( __LINE__, __FILE__, "c", result_type::SUCCESS, 0 );
verify_rule< S< one< 'c' > > >( __LINE__, __FILE__, "a", failure, 1 );
verify_rule< S< one< 'c' > > >( __LINE__, __FILE__, "b", failure, 1 );
verify_rule< S< one< 'c' > > >( __LINE__, __FILE__, "cc", result_type::SUCCESS, 1 );
verify_rule< S< one< 'c' > > >( __LINE__, __FILE__, "bc", failure, 2 );
verify_rule< S< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "", failure, 0 );
verify_rule< S< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "a", failure, 1 );
verify_rule< S< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "b", failure, 1 );
verify_rule< S< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "c", failure, 1 );
verify_rule< S< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ab", result_type::SUCCESS, 0 );
verify_rule< S< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "aba", result_type::SUCCESS, 1 );
verify_rule< S< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "abb", result_type::SUCCESS, 1 );
verify_rule< S< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "abc", result_type::SUCCESS, 1 );
verify_rule< S< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "abab", result_type::SUCCESS, 2 );
verify_rule< S< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "", failure, 0 );
verify_rule< S< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "a", failure, 1 );
verify_rule< S< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "ab", failure, 2 );
verify_rule< S< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "abc", result_type::SUCCESS, 0 );
verify_rule< S< one< 'a' >, one< 'b' >, one< 'c' >, eof > >( __LINE__, __FILE__, "abc", result_type::SUCCESS, 0 );
verify_rule< S< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "abcd", result_type::SUCCESS, 1 );
}
} // pegtl
#endif
|
[
"colinh-github-06134@icemx.net"
] |
colinh-github-06134@icemx.net
|
e0a2afcb919433bb677c43bc745491e14666954d
|
bf5bbd1248cf94942cbb622c6e9383a0ceca3921
|
/BulletSwift/bullet-2.87/BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.h
|
04e648d39c46b69c24733fa3735587fd33d477a3
|
[] |
no_license
|
yohei-yoshihara/BulletSwift
|
0ea3bcee10f988f312ea0b6a3f25cd2e2ae255c8
|
eb6f0a91068769f32959319509fe8f1c5dbace86
|
refs/heads/master
| 2021-07-02T09:23:19.798915
| 2020-09-12T08:07:11
| 2020-09-12T08:07:11
| 150,093,949
| 4
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,919
|
h
|
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdocumentation"
#pragma clang diagnostic ignored "-Wcomma"
#pragma clang diagnostic ignored "-Wunused-function"
#pragma clang diagnostic ignored "-Wunused-variable"
#pragma clang diagnostic ignored "-Wunreachable-code"
#pragma clang diagnostic ignored "-Wconditional-uninitialized"
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef BT_CONTINUOUS_COLLISION_CONVEX_CAST_H
#define BT_CONTINUOUS_COLLISION_CONVEX_CAST_H
#include "btConvexCast.h"
#include "btSimplexSolverInterface.h"
class btConvexPenetrationDepthSolver;
class btConvexShape;
class btStaticPlaneShape;
/// btContinuousConvexCollision implements angular and linear time of impact for convex objects.
/// Based on Brian Mirtich's Conservative Advancement idea (PhD thesis).
/// Algorithm operates in worldspace, in order to keep inbetween motion globally consistent.
/// It uses GJK at the moment. Future improvement would use minkowski sum / supporting vertex, merging innerloops
class btContinuousConvexCollision : public btConvexCast
{
btSimplexSolverInterface* m_simplexSolver;
btConvexPenetrationDepthSolver* m_penetrationDepthSolver;
const btConvexShape* m_convexA;
//second object is either a convex or a plane (code sharing)
const btConvexShape* m_convexB1;
const btStaticPlaneShape* m_planeShape;
void computeClosestPoints( const btTransform& transA, const btTransform& transB,struct btPointCollector& pointCollector);
public:
btContinuousConvexCollision (const btConvexShape* shapeA,const btConvexShape* shapeB ,btSimplexSolverInterface* simplexSolver,btConvexPenetrationDepthSolver* penetrationDepthSolver);
btContinuousConvexCollision(const btConvexShape* shapeA,const btStaticPlaneShape* plane );
virtual bool calcTimeOfImpact(
const btTransform& fromA,
const btTransform& toA,
const btTransform& fromB,
const btTransform& toB,
CastResult& result);
};
#endif //BT_CONTINUOUS_COLLISION_CONVEX_CAST_H
#pragma clang diagnostic pop
|
[
"yohei_yoshihara@cx5software.com"
] |
yohei_yoshihara@cx5software.com
|
f2325b065a9cce22d9ec83ca7bd31f8a2cbda780
|
a8504d0806086082a9caf4c00ead73eb0c143abc
|
/chinchiller/include/drivers/lcd.h
|
5959aa979dbd32bcb7a22229db80879c302bb28c
|
[
"MIT"
] |
permissive
|
lucianodasilva/chinchiller
|
9b9d618af590bc1b97532c673c589f2ff54c7d06
|
67b50e5997f1bed18d3f68168a8e5b0734e6aaab
|
refs/heads/master
| 2021-01-23T01:12:10.583594
| 2017-07-21T16:50:17
| 2017-07-21T16:50:17
| 92,857,443
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 4,459
|
h
|
#pragma once
#ifndef _common_drivers_lcd_h_
#define _common_drivers_lcd_h_
#include "common/mcu.h"
namespace drivers {
struct pos {
uint8_t x, y;
};
template <
mcu::io::pin_num_t _rs_pin_n,
mcu::io::pin_num_t _e_pin_n,
mcu::io::pin_num_t _data0_pin_n,
mcu::io::pin_num_t _data1_pin_n,
mcu::io::pin_num_t _data2_pin_n,
mcu::io::pin_num_t _data3_pin_n
>
struct lcd {
mcu::io::pin < _rs_pin_n > rs_pin = {mcu::io::pin_mode::output};
mcu::io::pin < _e_pin_n > e_pin = {mcu::io::pin_mode::output};
mcu::io::pin < _data0_pin_n > data0_pin = {mcu::io::pin_mode::output};
mcu::io::pin < _data1_pin_n > data1_pin = {mcu::io::pin_mode::output};
mcu::io::pin < _data2_pin_n > data2_pin = {mcu::io::pin_mode::output};
mcu::io::pin < _data3_pin_n > data3_pin = {mcu::io::pin_mode::output};
inline void clear () const {
command (cmd_clear);
mcu::delay(2);
}
inline void home () const {
command (cmd_return_home);
mcu::delay(2);
}
inline void set_display_on () {
_disp_ctrl |= ctrl_display_on;
command (cmd_display_control, _disp_ctrl);
}
inline void set_display_off () {
_disp_ctrl &= ~ctrl_display_on;
command (cmd_display_control, _disp_ctrl);
}
inline void set_cursor (uint8_t x, uint8_t y) const {
uint8_t c_index = x + (y * 40);
command (cmd_set_ddramaddr, c_index);
}
void init () {
// function flags
_disp_func
= 0x00 /* 4 bit */
| 0x08 /* 2 line */
| 0x00 /* 5x8 dot */;
// wait for lcd init
mcu::delay (50);
// reset pins
rs_pin .set_low();
e_pin .set_low();
// set command sequence for 4 bit mode
write_4(0x03);
mcu::delay_us(4500);
write_4(0x03);
mcu::delay_us(4500);
write_4(0x03);
mcu::delay_us(150);
write_4(0x02);
command(cmd_function_set, _disp_func);
// set default display control mode
_disp_ctrl = ctrl_display_on | ctrl_cursor_off | ctrl_blink_off;
set_display_on();
clear();
// set default display mode
_disp_mode = mode_entry_left | mode_entry_shift_dec;
command (cmd_entry_mode_set, _disp_mode);
}
inline void set_precision (uint8_t v) {
_precision = v;
}
inline lcd & operator << (const pos & p) {
set_cursor(p.x, p.y);
return *this;
}
lcd & operator << (const char * s) {
while (*s)
send (*s++, 1);
return *this;
}
lcd & operator << (int32_t v) {
char buffer [16];
itoa(v, +buffer, 10);
return operator << (+buffer);
}
lcd & operator << (uint32_t v) {
char buffer [16];
utoa(v, +buffer, 10);
return operator << (+buffer);
}
lcd & operator << (double v) {
char buffer [16];
dtostrf(v, 0, _precision, +buffer);
return operator << (+buffer);
}
private:
inline void command (uint8_t c, uint8_t p = 0) const {
send (c | p, 0);
}
inline void send (uint8_t value, uint8_t rs_mode) const {
rs_pin.set(rs_mode);
write(value);
}
inline void write (uint8_t v) const {
write_4 (v >> 4);
write_4 (v);
}
inline void write_4 (uint8_t v) const {
write_to(v, data0_pin, data1_pin, data2_pin, data3_pin);
pulse();
}
template < class _pin_t >
inline void write_to (uint8_t & v, _pin_t & p) const {
p.set(v);
v = v >> 1;
}
template < class _pin0_t, class ... _pin_t >
inline void write_to (uint8_t v, _pin0_t & pin0, _pin_t & ... pins) const {
write_to < _pin0_t > (v, pin0);
write_to (v, pins...);
}
inline void pulse () const {
e_pin.set_low();
mcu::delay_us(1);
e_pin.set_high();
mcu::delay_us(1);
e_pin.set_low();
mcu::delay_us(100);
}
uint8_t _disp_func;
uint8_t _disp_ctrl;
uint8_t _disp_mode;
uint8_t _precision = 2;
static constexpr uint8_t const
// commands
cmd_clear = 0x01,
cmd_return_home = 0x02,
cmd_entry_mode_set = 0x04,
cmd_display_control = 0x08,
cmd_cursor_shift = 0x10,
cmd_function_set = 0x20,
cmd_set_cgramaddr = 0x40,
cmd_set_ddramaddr = 0x80,
// display entry mode
mode_entry_right = 0x00,
mode_entry_left = 0x02,
mode_entry_shift_inc = 0x01,
mode_entry_shift_dec = 0x00,
// display on / off
ctrl_display_on = 0x04,
ctrl_display_off = 0x00,
ctrl_cursor_on = 0x02,
ctrl_cursor_off = 0x00,
ctrl_blink_on = 0x01,
ctrl_blink_off = 0x00,
// display/cursor shift
cursor_display_move = 0x08,
cursor_cursor_move = 0x00,
cursor_move_right = 0x04,
cursor_move_left = 0x00;
};
}
#endif
|
[
"luciano.silva@live.com.pt"
] |
luciano.silva@live.com.pt
|
0a53e613cecf1e5ca7ee48b8a5f830fae0c544eb
|
03a975e0188b19d3d3d32d37b27651285dc5412e
|
/tools/topology_tools.cpp
|
859928b64d5d27fb769f4cc3a649b42ec0ebc4f7
|
[] |
no_license
|
UG4/plugin_ProMesh
|
30b42eaaa7698d61aeee8076d9fe1940b5aa1d33
|
df97012b1c204b9f8ff01d49932da715e741e58f
|
refs/heads/master
| 2021-06-14T15:50:52.279213
| 2021-03-20T22:06:10
| 2021-03-20T22:06:10
| 47,968,484
| 4
| 10
| null | 2021-03-20T22:06:10
| 2015-12-14T10:39:25
|
C++
|
UTF-8
|
C++
| false
| false
| 13,672
|
cpp
|
/*
* Copyright (c) 2013-2017: G-CSC, Goethe University Frankfurt
* Author: Sebastian Reiter
*
* This file is part of UG4.
*
* UG4 is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License version 3 (as published by the
* Free Software Foundation) with the following additional attribution
* requirements (according to LGPL/GPL v3 §7):
*
* (1) The following notice must be displayed in the Appropriate Legal Notices
* of covered and combined works: "Based on UG4 (www.ug4.org/license)".
*
* (2) The following notice must be displayed at a prominent place in the
* terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
*
* (3) The following bibliography is recommended for citation and must be
* preserved in all covered files:
* "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
* parallel geometric multigrid solver on hierarchically distributed grids.
* Computing and visualization in science 16, 4 (2013), 151-164"
* "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
* flexible software system for simulating pde based models on high performance
* computers. Computing and visualization in science 16, 4 (2013), 165-179"
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*/
#include <vector>
#include "topology_tools.h"
#include "lib_grid/algorithms/hexahedron_util.h"
#include "lib_grid/callbacks/selection_callbacks.h"
using namespace std;
namespace ug{
namespace promesh{
void EraseSelectedElements(
Mesh* obj,
bool eraseUnusedVrts,
bool eraseUnusedEdges,
bool eraseUnusedFaces)
{
// adjust selection
Selector& sel = obj->selector();
SelectAssociatedEdges(sel, sel.begin<Vertex>(), sel.end<Vertex>());
SelectAssociatedFaces(sel, sel.begin<Edge>(), sel.end<Edge>());
SelectAssociatedVolumes(sel, sel.begin<Face>(), sel.end<Face>());
if(eraseUnusedFaces)
SelectInnerSelectionFaces(sel);
if(eraseUnusedEdges)
SelectInnerSelectionEdges(sel);
if(eraseUnusedVrts)
SelectInnerSelectionVertices(sel);
// erase selected elements
Grid& grid = obj->grid();
grid.erase(sel.begin<Volume>(), sel.end<Volume>());
grid.erase(sel.begin<Face>(), sel.end<Face>());
grid.erase(sel.begin<Edge>(), sel.end<Edge>());
grid.erase(sel.begin<Vertex>(), sel.end<Vertex>());
}
/// returns the number of removed vertices
size_t RemoveDoubles(Mesh* obj, number threshold)
{
Grid& grid = obj->grid();
Selector& sel = obj->selector();
size_t numVrts = grid.num<Vertex>();
ug::RemoveDoubles<3>(grid, sel.begin<Vertex>(), sel.end<Vertex>(),
obj->position_attachment(), threshold);
return numVrts - grid.num<Vertex>();
}
size_t RemoveDoubleEdges(Mesh* obj)
{
Grid& grid = obj->grid();
Selector& sel = obj->selector();
size_t numEdges= grid.num<Edge>();
RemoveDuplicates(grid, sel.begin<Edge>(), sel.end<Edge>());
return numEdges - grid.num<Edge>();
}
size_t RemoveDoubleFaces(Mesh* obj)
{
Grid& grid = obj->grid();
Selector& sel = obj->selector();
size_t numFaces= grid.num<Face>();
RemoveDuplicates(grid, sel.begin<Face>(), sel.end<Face>());
return numFaces - grid.num<Face>();
}
void MergeAtFirst(Mesh* obj)
{
Grid& grid = obj->grid();
Selector& sel = obj->selector();
Mesh::position_accessor_t& aaPos = obj->position_accessor();
SelectAssociatedGridObjects(sel);
vector3 first = aaPos[*sel.vertices_begin()];
Vertex* vrt = MergeMultipleVertices(grid, sel.vertices_begin(), sel.vertices_end());
if(vrt)
aaPos[vrt] = first;
}
void MergeAtCenter(Mesh* obj)
{
Grid& grid = obj->grid();
Selector& sel = obj->selector();
Mesh::position_accessor_t& aaPos = obj->position_accessor();
SelectAssociatedGridObjects(sel);
vector3 center;
CalculateCenter(center, sel, aaPos);
Vertex* vrt = MergeMultipleVertices(grid, sel.vertices_begin(), sel.vertices_end());
if(vrt)
aaPos[vrt] = center;
}
void MergeAtLast(Mesh* obj)
{
Mesh::position_accessor_t& aaPos = obj->position_accessor();
Grid& grid = obj->grid();
Selector& sel = obj->selector();
SelectAssociatedGridObjects(sel);
// todo: This iteration shouldn't be necessary!
VertexIterator vrtIter = sel.begin<Vertex>();
Vertex* lastVrt = *vrtIter;
for(; vrtIter != sel.end<Vertex>(); ++vrtIter)
lastVrt = *vrtIter;
vector3 last = aaPos[lastVrt];
Vertex* vrt = MergeMultipleVertices(grid, sel.vertices_begin(), sel.vertices_end());
if(vrt)
aaPos[vrt] = last;
}
void CollapseEdge(Mesh* obj)
{
using namespace std;
Grid& grid = obj->grid();
Selector& sel = obj->selector();
Mesh::position_accessor_t& aaPos = obj->position_accessor();
vector<Face*> vFaces;
vector<Edge*> vEdges;
while(sel.num<Edge>() > 0){
Edge* e = *sel.begin<Edge>();
// to make sure that all selected edges are collapsed,
// we have to check the adjacent triangles
CollectFaces(vFaces, grid, e);
for(size_t i = 0; i < vFaces.size(); ++i){
Face* f = vFaces[i];
if(f->num_edges() == 3){
CollectEdges(vEdges, grid, f);
int counter = 0;
for(size_t j = 0; j < 3; ++j){
if(sel.is_selected(vEdges[j]))
++counter;
}
// if two edges are selected, we have
// to mark the unselected edge, too (since we
// don't know which will be removed).
if(counter == 2){
for(size_t j = 0; j < 3; ++j)
sel.select(vEdges[j]);
}
}
}
// calculate the center
VecAdd(aaPos[e->vertex(0)], aaPos[e->vertex(0)], aaPos[e->vertex(1)]);
VecScale(aaPos[e->vertex(0)], aaPos[e->vertex(0)], 0.5);
// perform collapse
CollapseEdge(grid, e, e->vertex(0));
}
}
void SplitEdge(Mesh* obj)
{
using namespace std;
// collect all edges that shall be splitted in a vector
// since new edges will be automatically selected again.
Grid& grid = obj->grid();
Selector& sel = obj->selector();
Mesh::position_accessor_t& aaPos = obj->position_accessor();
vector<Edge*> vEdges;
for(EdgeIterator iter = sel.begin<Edge>();
iter != sel.end<Edge>(); ++iter)
{
vEdges.push_back(*iter);
}
// iterate through all edges in the vector and split them
for(size_t i = 0; i < vEdges.size(); ++i){
vector3 center = CalculateCenter(vEdges[i], aaPos);
RegularVertex* vrt = ug::SplitEdge<RegularVertex>(grid, vEdges[i]);
aaPos[vrt] = center;
}
}
void SwapEdge(Mesh* obj)
{
using namespace std;
// collect all edges that shall be swapped in a vector
// since new edges will be automatically selected again.
Grid& grid = obj->grid();
Selector& sel = obj->selector();
vector<Edge*> vEdges;
for(EdgeIterator iter = sel.begin<Edge>();
iter != sel.end<Edge>(); ++iter)
{
vEdges.push_back(*iter);
}
// iterate through all edges in the vector and swap them
// if they are adjacent to two triangles
Face* faces[2];
for(size_t i = 0; i < vEdges.size(); ++i){
int numFaces = GetAssociatedFaces(faces, grid, vEdges[i], 2);
if(numFaces == 2){
if(faces[0]->num_vertices() == 3 && faces[1]->num_vertices() == 3){
SwapEdge(grid, vEdges[i]);
}
}
}
}
void PlaneCut(Mesh* obj, const vector3& p, const vector3& n)
{
Selector& sel = obj->selector();
CutEdgesWithPlane(sel, p, n);
}
void AdjustEdgeOrientation(Mesh* obj)
{
Grid& grid = obj->grid();
Selector& sel = obj->selector();
AdjustEdgeOrientationToFaceOrientation(
grid,
sel.begin<Edge>(),
sel.end<Edge>(),
IsSelected(sel));
}
void FixFaceOrientation(Mesh* obj)
{
Grid& grid = obj->grid();
Selector& sel = obj->selector();
FixFaceOrientation(grid, sel.begin<Face>(),
sel.end<Face>());
}
void FixFaceSubsetOrientations(Mesh* obj)
{
Grid& grid = obj->grid();
SubsetHandler& sh = obj->subset_handler();
for(int i = 0; i < sh.num_subsets(); ++i){
FixFaceOrientation(grid, sh.begin<Face>(i), sh.end<Face>(i));
}
}
int FixVolumeOrientation(Mesh* obj)
{
Grid& grid = obj->grid();
Selector& sel = obj->selector();
Mesh::position_accessor_t& aaPos = obj->position_accessor();
return FixOrientation(grid, sel.begin<Volume>(), sel.end<Volume>(), aaPos);
}
void InvertFaceOrientation(Mesh* obj)
{
Grid& grid = obj->grid();
Selector& sel = obj->selector();
InvertOrientation(grid, sel.begin<Face>(), sel.end<Face>());
}
void ResolveEdgeIntersection(Mesh* obj, number snapThreshold)
{
Grid& grid = obj->grid();
Selector& sel = obj->selector();
Mesh::position_accessor_t& aaPos = obj->position_accessor();
// the grid may now contain some degenerated triangles. We'll try to
// remove most of them by projecting vertices onto close edges
SelectAssociatedVertices(sel, sel.begin<Edge>(), sel.end<Edge>());
ProjectVerticesToCloseEdges(grid, sel.get_grid_objects(),
obj->position_attachment(), snapThreshold);
IntersectCloseEdges(grid, sel, aaPos, snapThreshold);
// remove doubles now
ug::RemoveDoubles<3>(grid, sel.begin<Vertex>(), sel.end<Vertex>(),
obj->position_attachment(), snapThreshold);
}
void ResolveTriangleIntersections(Mesh* obj, number snapThreshold)
{
Grid& grid = obj->grid();
Selector& sel = obj->selector();
// Mesh::position_accessor_t& aaPos = obj->position_accessor();
// first we'll resolve triangle-triangle intersections
ug::ResolveTriangleIntersections(grid, sel.begin<Triangle>(),
sel.end<Triangle>(), snapThreshold,
obj->position_attachment());
// the grid may now contain some degenerated triangles. We'll try to
// remove most of them by projecting vertices onto close edges
SelectAssociatedVertices(sel, sel.begin<Triangle>(), sel.end<Triangle>());
SelectAssociatedEdges(sel, sel.begin<Triangle>(), sel.end<Triangle>());
ProjectVerticesToCloseEdges(grid, sel.get_grid_objects(),
obj->position_attachment(), snapThreshold);
// remove doubles now
ug::RemoveDoubles<3>(grid, sel.begin<Vertex>(), sel.end<Vertex>(),
obj->position_attachment(), snapThreshold);
}
void ProjectVerticesToCloseEdges(Mesh* obj, number snapThreshold)
{
Grid& grid = obj->grid();
Selector& sel = obj->selector();
// Mesh::position_accessor_t& aaPos = obj->position_accessor();
ProjectVerticesToCloseEdges(grid, sel.get_grid_objects(),
obj->position_attachment(), snapThreshold);
// remove doubles now
ug::RemoveDoubles<3>(grid, sel.begin<Vertex>(), sel.end<Vertex>(),
obj->position_attachment(), snapThreshold);
}
void ProjectVerticesToCloseFaces(Mesh* obj, number snapThreshold)
{
Grid& grid = obj->grid();
Selector& sel = obj->selector();
//Mesh::position_accessor_t& aaPos = obj->position_accessor();
ProjectVerticesToCloseFaces(grid, sel,
obj->position_attachment(), snapThreshold);
// remove doubles now
ug::RemoveDoubles<3>(grid, sel.begin<Vertex>(), sel.end<Vertex>(),
obj->position_attachment(), snapThreshold);
}
void IntersectCloseEdges(Mesh* obj, number snapThreshold)
{
Grid& grid = obj->grid();
Selector& sel = obj->selector();
Mesh::position_accessor_t& aaPos = obj->position_accessor();
IntersectCloseEdges(grid, sel, aaPos, snapThreshold);
}
void ResolveSelfIntersections(Mesh* obj, number snapThreshold)
{
Grid& grid = obj->grid();
Selector& sel = obj->selector();
Mesh::position_accessor_t& aaPos = obj->position_accessor();
Triangulate(grid, sel.begin<Quadrilateral>(), sel.end<Quadrilateral>(), &aaPos);
bool intersectFaces = sel.num<Face>() > 0;
SelectAssociatedEdges(sel, sel.begin<Face>(), sel.end<Face>());
SelectAssociatedVertices(sel, sel.begin<Face>(), sel.end<Face>());
// remove doubles again
ug::RemoveDoubles<3>(grid, sel.begin<Vertex>(), sel.end<Vertex>(),
obj->position_attachment(), snapThreshold);
if(intersectFaces)
ProjectVerticesToCloseFaces(grid, sel,
obj->position_attachment(), snapThreshold);
ProjectVerticesToCloseEdges(grid, sel.get_grid_objects(),
obj->position_attachment(), snapThreshold);
// resolve face intersections
if(intersectFaces){
ug::ResolveTriangleIntersections(grid, sel.begin<Triangle>(),
sel.end<Triangle>(), snapThreshold,
obj->position_attachment());
// the grid may now contain some degenerated Faces. We'll try to
// remove most of them by projecting vertices onto close edges
SelectAssociatedEdges(sel, sel.begin<Face>(), sel.end<Face>());
SelectAssociatedVertices(sel, sel.begin<Face>(), sel.end<Face>());
ProjectVerticesToCloseEdges(grid, sel.get_grid_objects(),
obj->position_attachment(), snapThreshold);
}
else{
Mesh::position_accessor_t& aaPos = obj->position_accessor();
IntersectCloseEdges(grid, sel, aaPos, snapThreshold);
}
// remove doubles again
ug::RemoveDoubles<3>(grid, sel.begin<Vertex>(), sel.end<Vertex>(),
obj->position_attachment(), snapThreshold);
}
void CreateHexahedraFromSelectedPrisms(Mesh* obj)
{
// todo: better worst case performance
vector<Volume*> delVols;
vector<Volume*> newVols;
Grid& grid = obj->grid();
Selector& sel = obj->selector();
for(PrismIterator iprism = sel.begin<Prism>();
iprism != sel.end<Prism>(); ++iprism)
{
Prism* p0 = *iprism;
PrismIterator iOtherPrism = iprism;
++iOtherPrism;
for(;iOtherPrism != sel.end<Prism>(); ++iOtherPrism)
{
Prism* p1 = *iOtherPrism;
Hexahedron* hex = CreateHexahedronFromPrisms(grid, p0, p1);
if(hex){
newVols.push_back(hex);
delVols.push_back(p0);
delVols.push_back(p1);
sel.deselect(p1);
break;
}
}
}
sel.clear();
if(!delVols.empty()){
sel.select(delVols.begin(), delVols.end());
EraseSelectedElements(obj, true, true, true);
}
if(!newVols.empty())
sel.select(newVols.begin(), newVols.end());
}
}}// end of namespace
|
[
"s.b.reiter@gmail.com"
] |
s.b.reiter@gmail.com
|
809db6d3baec3ebe0758d12b4613f32c3ed08941
|
ebb02bef87ad5a560cd4c942f656b2a415a3fdeb
|
/src/material/metal.hpp
|
c74441f97d1978d5d1b3667f7b0d52bd063fed93
|
[] |
no_license
|
muramasa8191/raytracer_cpp
|
731414abde3f2fef4831d12104e9a3fac7dc743c
|
3249aa84834d8540114dfe2607f3b61d4a436673
|
refs/heads/master
| 2020-04-11T04:08:50.607049
| 2019-01-04T04:24:42
| 2019-01-04T04:24:42
| 161,502,605
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 773
|
hpp
|
#ifndef RAYTRACER_CPP_METAL_HPP_
#define RAYTRACER_CPP_METAL_HPP_
#include <iostream>
#include "material.hpp"
#include "ray.hpp"
#include "utils.hpp"
#include "vector.hpp"
namespace raytracer {
class Metal : public Material {
public:
Metal(const Vec3 &albedo, float fuzz) : albedo_(albedo), fuzz_(fuzz) {}
virtual ~Metal() = default;
virtual bool scatter(const Ray &ray, const HitRecord &rec, Vec3 &attenuation, Ray &scattered) const override {
Vec3 reflected = reflect(UnitVector(ray.GetDirection()), rec.normal);
scattered = Ray(rec.p, reflected + fuzz_ * RandomInUnitSphere());
attenuation = albedo_;
return (Dot(scattered.GetDirection(), rec.normal) > 0.0);
}
private:
Vec3 albedo_;
float fuzz_;
};
}
#endif // RAYTRACER_CPP_METAL_HPP_
|
[
"muramasa8191@gmail.com"
] |
muramasa8191@gmail.com
|
bd01faf30f3a2293c8ea359f8e548081ead6d39d
|
9da7b17ab5b601735a8ec1a97853945185b76e7f
|
/olfaction-demo/src/ptu/ptu_control/src/ptu_control.cpp
|
e69b649ec582353abb9b5062015c8bcd3b77b4e5
|
[] |
no_license
|
AsifArain/ros-catkin-ws
|
137556337b7ed08d23bbfd48dc52bc376d85fe2d
|
75c75075138eeae2ba50076bb3f2007dd6735570
|
refs/heads/master
| 2023-03-09T10:24:10.824014
| 2018-07-03T16:32:20
| 2018-07-03T16:32:20
| 342,039,263
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 19,040
|
cpp
|
//=============================================================
// Node Name: ptu_control.cpp
// Version: 01
// Date: August 12th, 2013
// Description: Integrates joystick ptu control
// as well as service requests from other modules
//==============================================================
#include "ptu_control.h"
//-------------------------------------------------------
// Joystick callback
//-------------------------------------------------------
void joyCallback(const sensor_msgs::Joy::ConstPtr& joy)
{
if (joy->buttons[reset_button]==1 && (!is_scan_ptu_requested && !is_gas_scan_requested)){
is_reset_ptu_requested=true;
ROS_INFO("Here");
}
else if (joy->buttons[scan_button]==1 && (!is_scan_ptu_requested && !is_gas_scan_requested)){
is_scan_ptu_requested=true;
}
else if (joy->buttons[gas_scan_button]==1 && (!is_scan_ptu_requested && !is_gas_scan_requested)){
is_gas_scan_requested=true;
}
else {
if ((lock_trigger && joy->axes[lock_button] > 0 && is_lock_ptu_requested) || (!lock_trigger && joy->buttons[lock_button]==0 && is_lock_ptu_requested) )
is_lock_ptu_requested=false;
else if((lock_trigger && joy->axes[lock_button] <=0) || (!lock_trigger && joy->buttons[lock_button]==1 ) ){
is_lock_ptu_requested=true;
ptu_horizontal_request=joy->axes[3];
ptu_vertical_request=joy->axes[4];
}
}
}
//-------------------------------------------------------
// Pan callback
//-------------------------------------------------------
void panCallback(const amtec::AmtecState::ConstPtr& data_in)
{
pan_location_deg=rad2deg(data_in->position);
}
//-------------------------------------------------------
// tilt callback
//-------------------------------------------------------
void tiltCallback(const amtec::AmtecState::ConstPtr& data_in)
{
tilt_location_deg=rad2deg(data_in->position);
}
//-------------------------------------------------------
// Service callback
//-------------------------------------------------------
bool sweepRequestCallback(ptu_control::commandSweep::Request &req, ptu_control::commandSweep::Response& resp)
{
min_pan_srv= req.min_pan;
min_tilt_srv=req.min_tilt;
max_pan_srv=req.max_pan;
max_tilt_srv=req.max_tilt;
n_pan_srv=req.n_pan;
n_tilt_srv=req.n_tilt;
samp_delay_srv=req.samp_delay;
service_running=true;
return true;
}
//******************************************************************
//******************************************************************
//* Main Function *
//******************************************************************
//******************************************************************
int main(int argc, char **argv)
{
ROS_INFO("*****************************************************");
ROS_INFO(" %s Node starting...",DEVICE_NAME);
ROS_INFO("*****************************************************");
ros::init(argc, argv, DEVICE_NAME);
ros::NodeHandle n;
ros::Publisher state_pub = n.advertise<std_msgs::Int16>("/ptu_control/state", 1000);
ros::ServiceServer service = n.advertiseService("/ptu_control/sweep", sweepRequestCallback);
retrieveLaunchParameters(n);
ros::Subscriber sub1 = n.subscribe(joystick_topic.c_str(), 1000, joyCallback);
ros::Subscriber sub2 = n.subscribe("/amtec/pan_state", 1000, panCallback);
ros::Subscriber sub3 = n.subscribe("/amtec/tilt_state", 1000, tiltCallback);
ros::ServiceClient client = n.serviceClient<amtec::SetPosition>("/amtec/set_position");
ros::ServiceClient clientStatus = n.serviceClient<amtec::GetStatus>("/amtec/get_status");
amtec::SetPosition srv;
ros::Rate loop_rate(10);
service_running=false;
is_gas_scan_requested=false;
is_lock_ptu_requested=false;
is_reset_ptu_requested=false;
is_scan_ptu_requested=false;
amtec::GetStatus srvState;
controller_state=IDLE;
resetPTUPosition(state_pub, client,clientStatus);
while (ros::ok()){
if(joystick_control_enabled && !service_running) {
//Joystick requests
if(is_reset_ptu_requested){
ROS_INFO("Going to (0,0) position");
resetPTUPosition(state_pub, client,clientStatus);
is_reset_ptu_requested=false;
}
else if(is_gas_scan_requested){
ROS_INFO("Scanning for gas");
//AZIF: if condition to perform or not the initian scan
if (enable_environment_scan){
performSceneScan(state_pub, scan_min_tilt_deg, scan_max_tilt_deg, client,clientStatus);
}
sleep(1);
performGasScan(state_pub, scan_min_tilt_deg, scan_max_tilt_deg, scan_min_pan_deg, scan_max_pan_deg, n_pan_joy, n_tilt_joy,samp_delay_joy,client,clientStatus);
sleep(1);
resetPTUPosition(state_pub, client,clientStatus);
is_gas_scan_requested=false;
}
else if(is_scan_ptu_requested){
ROS_INFO("Scene scanning");
performSceneScan(state_pub, scan_min_tilt_deg, scan_max_tilt_deg, client,clientStatus);
is_scan_ptu_requested=false;
}
else if(is_lock_ptu_requested){
bool info_received=false;
double target_pan_deg=0;
double target_tilt_deg=0;
amtec::GetStatus srvState;
do{
if(clientStatus.call(srvState)){
info_received=true;
target_pan_deg=rad2deg(srvState.response.position_pan);
target_tilt_deg=rad2deg(srvState.response.position_tilt);
}
else{
info_received=false;
}
sleep(0.1);
}while(!info_received);
//ROS_INFO("--- PTU locked, position %f,%f",target_pan_deg,target_tilt_deg);
if (ptu_horizontal_request > 0){
target_pan_deg = target_pan_deg + interp(angle_increments_deg,fabs(ptu_horizontal_request),N_DELTA_DEG);
//target_pan_deg=deg2rad(target_pan_deg);
//target_tilt_deg=deg2rad(target_tilt_deg);
srv.request.position_pan=deg2rad(target_pan_deg);
srv.request.position_tilt=deg2rad(target_tilt_deg);
client.call(srv);
sleep(JOYSTICK_CONTROL_DELAY);
}
if(ptu_horizontal_request < 0){
target_pan_deg = target_pan_deg - interp(angle_increments_deg,fabs(ptu_horizontal_request),N_DELTA_DEG);
//target_pan_deg=deg2rad(target_pan_deg);
//target_tilt_deg=deg2rad(target_tilt_deg);
srv.request.position_pan=deg2rad(target_pan_deg);
srv.request.position_tilt=deg2rad(target_tilt_deg);
client.call(srv);
sleep(JOYSTICK_CONTROL_DELAY);
}
if (ptu_vertical_request > 0){
target_tilt_deg = target_tilt_deg - interp(angle_increments_deg,fabs(ptu_vertical_request),N_DELTA_DEG);
//target_pan_deg=deg2rad(target_pan_deg);
//target_tilt_deg=deg2rad(target_tilt_deg);
srv.request.position_pan=deg2rad(target_pan_deg);
srv.request.position_tilt=deg2rad(target_tilt_deg);
client.call(srv);
sleep(JOYSTICK_CONTROL_DELAY);
}
if(ptu_vertical_request < 0){
target_tilt_deg = target_tilt_deg + interp(angle_increments_deg,fabs(ptu_vertical_request),N_DELTA_DEG);
//target_pan_deg=deg2rad(target_pan_deg);
//target_tilt_deg=deg2rad(target_tilt_deg);
srv.request.position_pan=deg2rad(target_pan_deg);
srv.request.position_tilt=deg2rad(target_tilt_deg);
client.call(srv);
sleep(JOYSTICK_CONTROL_DELAY);
}
//ROS_INFO("Requested PTU LOCATION %f,%f",target_pan_deg,target_tilt_deg);
}
}
//Service requestes//
else if(service_running) {
ROS_INFO("Service requested");
ROS_INFO("Pan %f,%f,%d",min_pan_srv,max_pan_srv,n_pan_srv);
ROS_INFO("Tilt %f,%f,%d",min_tilt_srv,max_tilt_srv,n_tilt_srv);
//AZIF: if condition here
if (enable_environment_scan){
performSceneScan(state_pub, min_tilt_srv, max_tilt_srv, client,clientStatus);
}
sleep(0.5);
performGasScan(state_pub, min_tilt_srv, max_tilt_srv, min_pan_srv, max_pan_srv, n_pan_srv, n_tilt_srv, samp_delay_srv,client,clientStatus);
sleep(0.5);
resetPTUPosition(state_pub, client,clientStatus);
service_running=false;
}
std_msgs::Int16 msg_state;
msg_state.data=controller_state;
state_pub.publish(msg_state);
ros::spinOnce();
loop_rate.sleep();
}
}
//-------------------------------------------------------
// Parameter retrieval
//-------------------------------------------------------
void retrieveLaunchParameters(ros::NodeHandle n){
char param_name[100];
std::string param_string;
double param_double;
int param_int;
bool param_bool;
// AZIF: Set a parameter to enable/disable the environment scan /enable_environment_scan
//---- Enable/disable Environment Scan ----//
sprintf(param_name,"%s/enable_environment_scan",DEVICE_NAME);
if(n.getParam(param_name,param_bool)) {
enable_environment_scan=param_double;
}
else {
enable_environment_scan=DEFAULT_ENABLE_ENV_SCAN;
}
//---- min tilt scan ----//
sprintf(param_name,"%s/min_tilt_scan",DEVICE_NAME);
if(n.getParam(param_name,param_double)) {
scan_min_tilt_deg=param_double;
}
else {
scan_min_tilt_deg=DEFAULT_SCAN_MIN_TILT_DEG;
}
//---- max tilt scan ----//
sprintf(param_name,"%s/max_tilt_scan",DEVICE_NAME);
if(n.getParam(param_name,param_double)) {
scan_max_tilt_deg=param_double;
}
else {
scan_max_tilt_deg=DEFAULT_SCAN_MAX_TILT_DEG;
}
//---- min pan scan ----//
sprintf(param_name,"%s/min_pan_scan",DEVICE_NAME);
if(n.getParam(param_name,param_double)) {
scan_min_pan_deg=param_double;
}
else {
scan_min_pan_deg=DEFAULT_SCAN_MIN_PAN_DEG;
}
//---- max pan scan ----//
sprintf(param_name,"%s/max_pan_scan",DEVICE_NAME);
if(n.getParam(param_name,param_double)) {
scan_max_pan_deg=param_double;
}
else {
scan_max_pan_deg=DEFAULT_SCAN_MAX_PAN_DEG;
}
//---- scan button ----//
sprintf(param_name,"%s/scan_button",DEVICE_NAME);
if(n.getParam(param_name,param_int)) {
scan_button=param_int;
}
else {
scan_button=DEFAULT_SCAN_BUTTON;
}
//---- reset button ----//
sprintf(param_name,"%s/reset_button",DEVICE_NAME);
if(n.getParam(param_name,param_int)) {
reset_button=param_int;
}
else {
reset_button=DEFAULT_RESET_BUTTON;
}
//---- gas scan button ----//
sprintf(param_name,"%s/gas_button",DEVICE_NAME);
if(n.getParam(param_name,param_int)) {
gas_scan_button=param_int;
}
else {
gas_scan_button=DEFAULT_GAS_SCAN_BUTTON;
}
//---- lock button ----//
sprintf(param_name,"%s/lock_button",DEVICE_NAME);
if(n.getParam(param_name,param_int)) {
lock_button=param_int;
}
else {
lock_button=DEFAULT_LOCK_BUTTON;
}
//---- lock trigger ----//
sprintf(param_name,"%s/lock_trigger",DEVICE_NAME);
if(n.getParam(param_name,param_bool)) {
lock_trigger=param_bool;
}
else {
lock_trigger=DEFAULT_LOCK_TRIGGER;
}
//---- joystick topic ----//
sprintf(param_name,"%s/joystick_topic",DEVICE_NAME);
if(n.getParam(param_name,param_string)) {
joystick_topic=param_string;
}
else {
joystick_topic=DEFAULT_JOYSTICK_TOPIC;
}
//---- Joystick enabled ----//
sprintf(param_name,"%s/joystick_control",DEVICE_NAME);
if(n.getParam(param_name,param_bool)) {
joystick_control_enabled=param_bool;
}
else {
joystick_control_enabled=DEFAULT_JOYSTICK_ENABLED;
}
//---- pan points ----//
sprintf(param_name,"%s/n_pan_points",DEVICE_NAME);
if(n.getParam(param_name,param_int)) {
n_pan_joy=param_int;
}
else {
n_pan_joy=DEFAULT_N_PAN;
}
//---- tilt points ----//
sprintf(param_name,"%s/n_tilt_points",DEVICE_NAME);
if(n.getParam(param_name,param_int)) {
n_tilt_joy=param_int;
}
else {
n_tilt_joy=DEFAULT_N_TILT;
}
//---- sample delay ----//
sprintf(param_name,"%s/samp_delay",DEVICE_NAME);
if(n.getParam(param_name,param_double)) {
samp_delay_joy=param_double;
}
else {
samp_delay_joy=GAS_SWEEP_DELAY;
}
}
//-------------------------------------------------------
// Scene Scan
//-------------------------------------------------------
void performSceneScan(ros::Publisher state_pub,double min_tilt_deg, double max_tilt_deg, ros::ServiceClient client,ros::ServiceClient clientStatus)
{
amtec::SetPosition srv;
amtec::GetStatus srvState;
ROS_INFO("Scan sweep requested");
int tilt_i=0;
int retry_count=0;
bool pos_reached=false;
//Just for the demo ocasion
min_tilt_deg=-5;
max_tilt_deg=10;
///////////////////////////
int increments_tilt=20;
double delta_tilt_deg=(max_tilt_deg-min_tilt_deg+10)/increments_tilt;
//ROS_INFO("%f,%f",max_tilt_deg,min_tilt_deg);
srv.request.position_pan=0;
srv.request.position_tilt=deg2rad(max_tilt_deg+5);
client.call(srv);
do{
sleep(0.5);
if(clientStatus.call(srvState)) {
retry_count++;
ROS_INFO("Moving");
if(fabs(rad2deg(srvState.response.position_tilt)-max_tilt_deg) <= 0.8 && fabs(rad2deg(srvState.response.position_pan)) <= 0.8) {
pos_reached=true;
}
else if (retry_count>20) {
ROS_INFO("Warning: PTU not responding. Retrying");
srv.request.position_pan=0;
srv.request.position_tilt=deg2rad(max_tilt_deg);
client.call(srv);
sleep(1);
retry_count=0;
}
}
else {
ROS_INFO("Warning: PTU not responding. Retrying");
srv.request.position_pan=0;
srv.request.position_tilt=deg2rad(max_tilt_deg);
client.call(srv);
sleep(1);
}
}while(!pos_reached);
double target_tilt_deg=0;//max_tilt_deg;
do{
target_tilt_deg=target_tilt_deg-delta_tilt_deg;
srv.request.position_pan=0;
srv.request.position_tilt=deg2rad(target_tilt_deg);
client.call(srv);
tilt_i=tilt_i+1;
std_msgs::Int16 msg_state;
msg_state.data=SCANNING_MODEL;
state_pub.publish(msg_state);
//ROS_INFO("Requested tilt %f",target_tilt_deg);
sleep(0.1);
}while (tilt_i<=increments_tilt);
do{
clientStatus.call(srvState);
sleep(0.5);
}while(fabs(srvState.response.velocity_tilt) > 0.01);
std_msgs::Int16 msg_state;
msg_state.data=IDLE;
state_pub.publish(msg_state);
}
//-------------------------------------------------------
// Gas Scan
//-------------------------------------------------------
void performGasScan(ros::Publisher state_pub, double min_tilt_deg, double max_tilt_deg, double min_pan_deg, double max_pan_deg, int n_pan, int n_tilt, double samp_delay,ros::ServiceClient client,ros::ServiceClient clientStatus)
{
bool pos_reached=false;
int retry_count=0;
amtec::SetPosition srv;
amtec::GetStatus srvState;
srv.request.position_pan=deg2rad(min_pan_deg);
srv.request.position_tilt=deg2rad(min_tilt_deg);
client.call(srv);
do{
sleep(0.5);
if(clientStatus.call(srvState)) {
retry_count++;
//ROS_INFO("Moving");
if(fabs(rad2deg(srvState.response.position_tilt)-min_tilt_deg) <= 0.8 && fabs(rad2deg(srvState.response.position_pan)-min_pan_deg) <= 0.8) {
pos_reached=true;
}
else if (retry_count>20) {
ROS_INFO("Warning: PTU not responding 1st. Retrying");
srv.request.position_pan=deg2rad(min_pan_deg);
srv.request.position_tilt=deg2rad(min_tilt_deg);
client.call(srv);
sleep(1);
retry_count=0;
}
}
else {
ROS_INFO("Warning: PTU not responding 2nd. Retrying");
srv.request.position_pan=deg2rad(min_pan_deg);
srv.request.position_tilt=deg2rad(min_tilt_deg);
client.call(srv);
sleep(1);
}
}while(!pos_reached);
int tilt_i=0;
int pan_i=0;
int current_movement=TO_RIGHT;
double requested_pan_deg;
double requested_tilt_deg;
requested_pan_deg=min_pan_deg;
requested_tilt_deg=min_tilt_deg;
float delta_pan_deg=fabs(max_pan_deg-min_pan_deg)/n_pan;
float delta_tilt_deg=fabs(max_tilt_deg-min_tilt_deg)/n_tilt;
//AZIF: Changes might go here if(n_tilt=1 && n_pan==1)
do{
if(current_movement==TO_RIGHT){
srv.request.position_pan=deg2rad(requested_pan_deg);
srv.request.position_tilt=deg2rad(requested_tilt_deg);
client.call(srv);
do{
clientStatus.call(srvState);
sleep(0.1);
}while(fabs(srvState.response.velocity_tilt) > 0.0 || fabs(srvState.response.velocity_pan) > 0.0);
//ROS_INFO("Scanning at %f,%f",requested_pan_deg,requested_tilt_deg);
requested_pan_deg=requested_pan_deg+delta_pan_deg;
pan_i=pan_i+1;
if (pan_i > n_pan) {
current_movement=TO_LEFT;
requested_pan_deg=requested_pan_deg-delta_pan_deg;
requested_tilt_deg=requested_tilt_deg+delta_tilt_deg;
tilt_i=tilt_i+1;
}
std_msgs::Int16 msg_state;
msg_state.data=SCANNING_GAS;
state_pub.publish(msg_state);
sleep(samp_delay);
}
else{
srv.request.position_pan=deg2rad(requested_pan_deg);
srv.request.position_tilt=deg2rad(requested_tilt_deg);
client.call(srv);
do{
clientStatus.call(srvState);
sleep(0.1);
}while(fabs(srvState.response.velocity_tilt) > 0.0 || fabs(srvState.response.velocity_pan) > 0.0);
//ROS_INFO("Scanning at %f,%f",requested_pan_deg,requested_tilt_deg);
requested_pan_deg=requested_pan_deg-delta_pan_deg;
pan_i=pan_i-1;
if (pan_i <= 0) {
current_movement=TO_RIGHT;
requested_pan_deg=requested_pan_deg+delta_pan_deg;
requested_tilt_deg=requested_tilt_deg+delta_tilt_deg;
tilt_i=tilt_i+1;
}
std_msgs::Int16 msg_state;
msg_state.data=SCANNING_GAS;
state_pub.publish(msg_state);
sleep(samp_delay);
}
}while (tilt_i<=n_tilt);
do{
clientStatus.call(srvState);
sleep(0.5);
}while(fabs(srvState.response.velocity_tilt) > 0.01);
std_msgs::Int16 msg_state;
msg_state.data=SCANNING_GAS;
state_pub.publish(msg_state);
}
//-------------------------------------------------------
// PTU reset position
//-------------------------------------------------------
void resetPTUPosition(ros::Publisher state_pub, ros::ServiceClient client,ros::ServiceClient clientStatus)
{
amtec::SetPosition srv;
amtec::GetStatus srvState;
srv.request.position_pan=0;
srv.request.position_tilt=0;
client.call(srv);
int retry_count=0;
bool pos_reached=false;
do{
sleep(0.5);
if (clientStatus.call(srvState)){
//ROS_INFO("Gotcha %f,%f",rad2deg(srvState.response.position_tilt),rad2deg(srvState.response.position_pan));
retry_count++;
if(fabs(rad2deg(srvState.response.position_tilt)) <= 0.8 && fabs(rad2deg(srvState.response.position_pan)) <= 0.8){
pos_reached=true;
}
else if (retry_count>20) {
ROS_INFO("Warning: PTU not responding Marco thinks we are here. Retrying");
srv.request.position_pan=0;
srv.request.position_tilt=0;
client.call(srv);
sleep(1);
retry_count=0;
}
}
else{
ROS_INFO("Warning: PTU not responding Ricarrdo thinks we are here. Retrying");
srv.request.position_pan=0;
srv.request.position_tilt=0;
client.call(srv);
sleep(1);
}
std_msgs::Int16 msg_state;
msg_state.data=RESET;
state_pub.publish(msg_state);
ROS_INFO("To reset position");
} while(!pos_reached);
}
/****************************************************
* Interpolation function
****************************************************/
double interp( lookup_table* c, double x, int n )
{
int i;
for( i = 0; i < n-1; i++ )
{
if ( c[i].x <= x && c[i+1].x >= x )
{
double diffx = x - c[i].x;
double diffn = c[i+1].x - c[i].x;
return c[i].y + ( c[i+1].y - c[i].y ) * diffx / diffn;
}
}
return 0; // Not in Range
}
|
[
"asif.arain@oru.se"
] |
asif.arain@oru.se
|
9b622f383e2b65dc005286e0afbc0fce92f8c58d
|
473b54b77a402c261ee44fe3ea1878ea66d4a34a
|
/src/CSix.cpp
|
68e00703603dbffde52a9531cccf171f1cc6ee76
|
[] |
no_license
|
baoleibai/CppExecises
|
7c62a350f674f16e4059bfa2a55a7c3946f68ec6
|
4bfa7baf902106e9bdccd763c1a2a9a4d7bf0d52
|
refs/heads/master
| 2021-01-15T14:29:14.770754
| 2014-03-10T09:59:15
| 2014-03-10T09:59:15
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 11,077
|
cpp
|
/*
* CSix.cpp
*
* Created on: Dec 25, 2013
* Author: b576
*/
#include "include/CSix.h"
CSix::CSix() {
}
CSix::~CSix() {
}
void CSix::show() {
program9();
program8();
program6();
program5();
program4();
program3();
program2();
program1();
exes();
readFromFileIO();
writeToFileIO();
practise();
}
/*
*Read contributors from a given file. first line is number of contributors.
*/
void CSix::program9() {
char filename[50] = "contributors.txt";
ifstream readFile;
readFile.open(filename);
if (!readFile.is_open()) {
cout << "Failed to open " << filename << ". quit the program." << endl;
return;
}
int i = 0;
char chars[50];
readFile.getline(chars, STRSIZE);
cout << chars << endl;
int number = atoi(chars); //stdlib.h is C-style method.
Contributors *cons = new Contributors[number];
while (readFile.good()) {
readFile.getline(cons[i].contributor, STRSIZE);
readFile.getline(chars, STRSIZE);
cons[i].amount = atoi(chars);
i++;
}
if (readFile.fail()) {
cout << "Reach EOF" << endl;
} else if (readFile.bad()) {
cout << "Something Unexpected" << endl;
} else {
cout << "Stopped for un-known reasons" << endl;
}
for (int x = 0; x < number; x++) {
cout << " Countributor: " << cons[x].contributor << " "
<< cons[x].amount << endl;
}
readFile.close();
}
/*
* Enter a filename, read contents of the file and output
* number of characters and empty spaces.
*/
void CSix::program8() {
char filename[50];
cout<<"Please enter the filename that you wants to read: ";
cin>>filename;
ifstream fin;
fin.open(filename);
if(!fin.is_open()) {
cout << "Could not open file " << filename << endl;
cout << "Program terminating.\n";
return;
}
int charCount = 0, spaceCount = 0;
char ch;
ch = fin.get();
while(fin.good()){
if(isspace(ch))
spaceCount++;
else
charCount++;
ch = fin.get();
}
if(fin.fail()){
cout<<"Reached EOF."<<endl;
} else if(fin.bad()) {
cout<<"Something unexpected."<<endl;
} else {
cout << "Input terminated for unknown reason" << endl;
}
cout<<"Number of Character count is "<<charCount<<endl;
cout<<"Number of Space count is "<<spaceCount<<endl;
fin.close();
}
/*
* Enter the number of contributors and their name, amount,.
* if donate >=10000, output as Grand donation.
* else output as Headed patrons.
*/
void CSix::program6() {
int contributorsNo = 0;
do {
cout << "Please enter the number of contributors: ";
if (!(cin >> contributorsNo)) {
cin.clear();
cin.get();
cout << "Invalid Input, Try Again." << endl;
continue;
} else {
break;
}
} while (true);
Contributors *lContributors = new Contributors[contributorsNo];
int NoGrand = 0, NoHeaded = 0;
for (int i = 0; i < contributorsNo; i++) {
cout << "The " << i << " contributor's name:";
cin >> lContributors[i].contributor;
cout << "The contribution amount: ";
cin >> lContributors[i].amount;
if (lContributors[i].amount >= 10000)
NoGrand++;
else
NoHeaded++;
}
cout << "The Grand donations:" << endl;
if (NoGrand == 0) {
cout << "none." << endl;
} else {
for (int i = 0; i < contributorsNo; i++) {
if (lContributors[i].amount >= 10000) {
cout << lContributors[i].contributor << " "
<< lContributors[i].amount << endl;
}
}
}
cout << "The Headed donations:" << endl;
if (NoHeaded == 0) {
cout << "none." << endl;
} else {
for (int i = 0; i < contributorsNo; i++) {
if (lContributors[i].amount < 10000) {
cout << lContributors[i].contributor << " "
<< lContributors[i].amount << endl;
}
}
}
}
/*
* Calculate the tax amount of annual income.
*/
void CSix::program5() {
bool quit = false;
const int salaryLevels = 4;
double tax;
double taxLevel[salaryLevels] = { 5000, 10000, 20000, 35000 };
double taxRate[salaryLevels] = { 0, 0.1, 0.15, 0.2 };
cout << "First 5,000 tvarps: 0% tax" << endl;
cout << "Next 10,000 tvarps: 10% tax" << endl;
cout << "Next 20,000 tvarps: 15% tax" << endl;
cout << "Tvarps after 35,000: 20% tax" << endl;
do {
cout<< "Please enter your anual incout(enter 'q'/Negative numbers to quit): ";
double income;
if (!(cin >> income)) {
cin.clear();
cin.get();
cout << "Quit! Bye" << endl;
quit = true;
}
if (income < 0.0) {
cin.get();
cout << "Quit! Bye" << endl;
quit = true;
}
double temp = income;
for (int i = 0 ; i < salaryLevels; i++) {
if(temp - taxLevel[i] > 0) {
tax+= taxLevel[i] * taxRate[i];
temp -= taxLevel[i];
} else {
tax+= temp*taxRate[i];
break;
}
}
cout << "The tax for annual income " << income << " is " << tax << endl;
} while (!quit);
}
/*
* Display a menu and select options to display info from an struct array.
*/
void CSix::program4() {
Bop bops[3] = { { "Baolei Bai", "Engineer", "Tim White", 2 }, {
"Xiying Cao", "A Engineer", "XYC", 1 }, { "Mu Li", "B Engineer",
"Gary Li", 0 }, };
bool quite = false;
do {
cout << "Please enter one of the following choices(enter q to quite): "
<< endl;
cout << "a) Display by Name b) Display by Title" << endl;
cout << "c) Display by BOP Name d) Display by Preference"
<< endl;
cout << " q) quit" << endl;
cout << "Please enter your choice: ";
char ch;
if (!(ch = cin.get())) {
cout << "Invalid input, try again." << endl;
cin.clear();
cin.get(); //get the remaining "return" char left in the input queue.
continue;
}
cout << endl;
switch (ch) {
case 'a':
for (int i = 0; i < 3; i++) {
cout << " " << bops[i].fullname << endl;
}
break;
case 'b':
for (int i = 0; i < 3; i++) {
cout << " " << bops[i].title << endl;
}
break;
case 'c':
for (int i = 0; i < 3; i++) {
cout << " " << bops[i].bopname << endl;
}
break;
case 'd':
for (int i = 0; i < 3; i++) {
if (bops[i].preference == 0) //display full name
cout << " " << bops[i].fullname << endl;
else if (bops[i].preference == 1)
cout << " " << bops[i].title << endl;
else if (bops[i].preference == 2)
cout << " " << bops[i].bopname << endl;
}
break;
case 'q':
cout << "quite the menu" << endl;
quite = true;
break;
default:
cout << ch << " is not an option." << endl;
break;
}
} while (!quite);
}
/*
* Create an menu and select option to output info with the help
* of switch
*/
void CSix::program3() {
bool quite = false;
do {
cout << "Please enter one of the following choices(enter q to quite): "
<< endl;
cout << "c) carnivore p) pianist" << endl;
cout << "t) tree g) game" << endl;
cout << "Please enter a c, p, t, or g: ";
char ch;
if (!(ch = cin.get())) {
cout << "Invalid input, try again." << endl;
cin.clear();
cin.get(); //get the remaining "return" char left in the input queue.
continue;
}
cout << endl;
switch (ch) {
case 'c':
cout << "carnivore" << endl;
break;
case 'p':
cout << "pianist" << endl;
break;
case 't':
cout << "tree" << endl;
break;
case 'g':
cout << "game" << endl;
break;
case 'q':
cout << "quite the menu" << endl;
quite = true;
break;
default:
cout << ch << " is not an option." << endl;
break;
}
} while (!quite);
}
/*
* Enter donation and output its average and how many donations
* are higher than the average.
*/
void CSix::program2() {
int max = 10;
double *donationvalue = new double[max];
double average, total;
int i = 0;
for (int x = 0; x < max; x++) {
cout << "Please enter your donation value: ";
if (!(cin >> donationvalue[x])) { //The point of this exercise is here
cin.clear(); //reset the error flag.
cin.get(); //get what is left in input queue.
cout << "Input terminated. Entered an invalid value." << endl;
break;
}
total += donationvalue[x];
i++;
}
if (i > 0) {
average = total / i;
cout << "The average value of " << i << " input is " << average << endl;
int larger;
for (int y = 0; y < i; y++) {
if (donationvalue[y] > average)
larger++;
}
cout << "There are " << larger
<< " values in donation are larger than average value "
<< average << endl;
}
}
/*
* Read input char,
* if lower case alphabet -> upper case alphabet.
* if upper case alphabet -> lower case alphabet.
* if @ -> quit
* ignore digits.
* output the rest of the chars.
*/
void CSix::program1() {
char ch;
while ((ch = cin.get())) {
if (ch <= 122 && ch >= 97) {
ch = ch - 32;
cout << ch;
} else if (ch <= 90 && ch >= 65) {
ch = ch + 32;
cout << ch;
} else if (ch == '@')
break;
else if (ch <= 57 && ch >= 48) {
continue;
} else {
cout << ch;
}
}
}
void CSix::exes() {
char ch;
int ct1, ct2;
ct1 = ct2 = 0;
while ((ch = cin.get()) != '$') {
cout << ch;
ct1++;
if (ch = '$')
ct2++;
cout << ch;
}
cout << "ct1 = " << ct1 << ", ct2 = " << ct2 << "\n";
int weight = 0;
if (weight >= 115 && weight < 125) {
}
if (ch == 'q' || ch == 'Q') {
}
int x;
if ((x % 2) == 0 && x != 26) {
}
if ((x % 2) == 0 && (x % 26) != 0) {
}
}
bool CSix::readFromFileIO() {
char filename[50];
ifstream readFile;
cin.clear();
cin.get();
cout << "Enter the name of the data file: ";
cin.getline(filename, 50);
readFile.open(filename);
if (!readFile.is_open()) {
cout << "Could not open file " << filename << endl;
cout << "Program terminating.\n";
return false;
}
char content[100];
readFile >> content;
while (readFile.good()) {
cout << content <<endl;
readFile >> content;
}
if (readFile.eof()) {
cout << " Reached at the end of file." << endl;
} else if (readFile.fail()) {
cout << "Input terminated by data mismatch" << endl;
} else {
cout << "Input terminated for unknown reason" << endl;
}
}
void CSix::writeToFileIO() {
char automobile[50];
int year;
double a_price, d_price;
ofstream outFile;
outFile.open("carinfo.txt");
cout << "Enter the make and model of the car: ";
cin.getline(automobile, 50);
cout << "Enter the model year: ";
cin >> year;
cout << "Enter the original asking price: ";
cin >> a_price;
d_price = 0.913 * a_price;
cout << fixed;
cout.precision(2);
cout.setf(ios_base::showpoint);
cout << "make and model: " << automobile << endl;
cout << "year: " << year << endl;
cout << "price: " << d_price << endl;
outFile << fixed;
outFile.precision(2);
outFile.setf(ios_base::showpoint);
outFile << "make and model: " << automobile << endl;
outFile << "year: " << year << endl;
outFile << "price: " << d_price << endl;
outFile.close();
}
/*
* Enter a given number of scores and output its average
*/
void CSix::practise() {
int golf[Max];
cout << "Please enter your golf score:" << endl;
int i;
for (int i = 0; i < Max; i++) {
cout << "round *" << i + 1 << ": ";
while (!(cin >> golf[i])) {
cin.clear();
while (cin.get() != '\n')
continue;
cout << "Please enter a number: ";
}
}
double total = 0.0;
for (int i = 0; i < Max; i++) {
total += golf[i];
}
cout << total / Max << " = average score " << Max << " rounds\n";
}
|
[
"b576@borqs.com"
] |
b576@borqs.com
|
ade552fc4f75e904705d2c7e838d65350d176c1a
|
62384c6d54c1d92d5ea22df5e101c0ee5aadcfb0
|
/dsprojects/dsproj1/arr_queue.cpp
|
747ca700cad838947edb58e99bb53d7ed8c39827
|
[] |
no_license
|
brianobri/Data_Structures
|
804bd098480636cc463c85da7b7db47ea0a76a82
|
e901e738169bfc38ef20e4f671250ba97bb93c7f
|
refs/heads/master
| 2021-01-01T17:25:23.828093
| 2017-07-23T02:07:29
| 2017-07-23T02:07:29
| 98,068,837
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,181
|
cpp
|
#include "arr_queue.h"
#include <iostream>
using namespace std;
arr_queue::arr_queue()
{
// create the array
list = new char[max_size];
}
arr_queue::~arr_queue()
{
// delete the array from memory
delete [] list;
}
void arr_queue::enqueue(char& in)
{
// make sure we aren't full
assert(count < max_size);
// set the element at the correct position (with wrapping) and update count
list[(front + count++) % max_size] = in;
}
char arr_queue::dequeue()
{
// make sure we aren't empty
if (count > 0)
{
// store the element at the front
char ret = list[front];
// adjust front
// also adjusts count
// set front to 0 if there are no more elements the in queue
front = (--count == 0 ? 0 : ++front % max_size);
// return the element
return ret;
}
else
{
return NULL;
}
}
char& arr_queue::peek()
{
// make sure the array isnt empty
if (count > 0)
{
return list[front];
}
// return the front elements data
return emptychar; // if nothing in array return NULL
}
|
[
"noreply@github.com"
] |
brianobri.noreply@github.com
|
9488a905c7f3d47e460056bdcecc885227c84981
|
af88798163d01a149de2ae04f8354311e734da08
|
/BitSet/parser.h
|
d014a07b45ad71af9cc453bc7f26843b4ca1ccef
|
[
"MIT"
] |
permissive
|
vlad-shevchenko/BitSet
|
abe3121826662e8f250e155ec1e7639aa49ab542
|
e9b24e8e0c432d7eeda3bb460693d1006bbd63cb
|
refs/heads/master
| 2020-12-24T21:27:23.999498
| 2016-06-01T06:36:59
| 2016-06-01T06:36:59
| 56,754,837
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 508
|
h
|
#ifndef PARSER_H
#define PARSER_H
#include <symbols.h>
#include <bitset.h>
#include <QString>
class Parser
{
private:
QList<symbols::Symbol> tokens;
symbols::Symbol cur;
symbols::Symbol next;
void goNext();
BitSet parseConcat();
BitSet parseShift();
BitSet parseXor();
BitSet parseAnd();
BitSet parseOr();
BitSet parseNegate();
BitSet parseTerm();
public:
Parser();
Parser(QList<symbols::Symbol>& tokens);
BitSet parse();
};
#endif // PARSER_H
|
[
"vlad.shevchenko.ua@gmail.com"
] |
vlad.shevchenko.ua@gmail.com
|
8b7cd369226b90a3e39d20060a03ed95ebd0ecfb
|
5bc07dbbdcda1a772de18a36432086a4c09299a9
|
/TXCloudPortal/UI/CreateRoom.h
|
dc6ba15d9cd123dd007070d2390e88faa8e05951
|
[] |
no_license
|
shengang1978/webexe_exe_source
|
f37715405b0e822c779cd00496765f34285981bb
|
716e85310449db720558eea7e2d6dbf803824e56
|
refs/heads/master
| 2020-04-06T17:00:01.144573
| 2018-09-29T10:52:45
| 2018-09-29T10:52:45
| 157,642,349
| 0
| 1
| null | 2018-11-15T02:46:19
| 2018-11-15T02:46:18
| null |
UTF-8
|
C++
| false
| false
| 804
|
h
|
#pragma once
#include <QDialog>
#include "ui_CreateRoom.h"
typedef std::function<void(bool, const std::string&)> handlefunction;
class CreateRoom : public QDialog
{
Q_OBJECT
public:
CreateRoom(QWidget *parent = Q_NULLPTR);
~CreateRoom();
void setLogo(QString styleSheet);
void setHanleFunction(handlefunction func);
protected:
virtual void mousePressEvent(QMouseEvent *event);
virtual void mouseMoveEvent(QMouseEvent *event);
virtual void mouseReleaseEvent(QMouseEvent *event);
virtual void keyPressEvent(QKeyEvent *event);
protected slots:
void onCloseBtnClicked();
void onOperateBtnClicked();
void onCancelBtnClicked();
private:
Ui::CreateRoom ui;
bool m_pressed;
QPoint m_point;
handlefunction m_func;
QString m_roomName;
};
|
[
"xuanyiyan@tencent.com"
] |
xuanyiyan@tencent.com
|
15e98d16b9d317e6b47cbaae56d35e249e1b3447
|
050c8a810d34fe125aecae582f9adfd0625356c6
|
/cf1540/B.cpp
|
cfbb3c60bdcf0125a72cd34a79fa6582cf8fb874
|
[] |
no_license
|
georgerapeanu/c-sources
|
adff7a268121ae8c314e846726267109ba1c62e6
|
af95d3ce726325dcd18b3d94fe99969006b8e138
|
refs/heads/master
| 2022-12-24T22:57:39.526205
| 2022-12-21T16:05:01
| 2022-12-21T16:05:01
| 144,864,608
| 11
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,344
|
cpp
|
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int NMAX = 200;
int fact[NMAX + 5];
int ifact[NMAX + 5];
int pw2[NMAX + 5];
int ipw2[NMAX + 5];
int dp[NMAX + 5][NMAX + 5];
int add(int a,int b){
a += b;
if(a >= MOD){
a -= MOD;
}
return a;
}
int mult(int a,int b){
return 1LL * a * b % MOD;
}
int comb(int n,int k){
return mult(fact[n],mult(ifact[n - k],ifact[k]));
}
int lgpow(int base,int exp){
int answer = 1;
while(exp){
if(exp & 1){
answer = mult(answer,base);
}
base = mult(base,base);
exp >>= 1;
}
return answer;
}
int n;
int weight[NMAX + 5];
vector<int> graph[NMAX + 5];
vector<int> dfs_stack;
void predfs(int nod,int tata){
weight[nod] = 1;
for(auto it:graph[nod]){
if(it == tata){
continue;
}
predfs(it,nod);
weight[nod] += weight[it];
}
}
int invN;
int global_answer = 0;
void dfs(int nod,int tata){
dfs_stack.push_back(nod);
if(nod != dfs_stack[0]){
int ans = mult(weight[dfs_stack[0]] - weight[dfs_stack[1]],invN);
for(int i = 1;i < (int)dfs_stack.size() - 1;i++){
int coef = mult(weight[dfs_stack[i]] - weight[dfs_stack[i + 1]],invN);
ans = add(ans,mult(coef,dp[i][(int)dfs_stack.size() - 1 - i]));
}
if(dfs_stack[0] > nod){
global_answer = add(global_answer,ans);
}
}
for(auto it:graph[nod]){
if(it != tata){
dfs(it,nod);
}
}
dfs_stack.pop_back();
}
int main(){
fact[0] = 1;
pw2[0] = 1;
for(int i = 1;i <= NMAX;i++){
fact[i] = mult(i,fact[i - 1]);
pw2[i] = add(pw2[i - 1],pw2[i - 1]);
}
ifact[NMAX] = lgpow(fact[NMAX],MOD - 2);
ipw2[NMAX] = lgpow(pw2[NMAX],MOD - 2);
for(int i = NMAX - 1;i >= 0;i--){
ifact[i] = mult(ifact[i + 1],i + 1);
ipw2[i] = mult(2,ipw2[i + 1]);
}
scanf("%d",&n);
invN = lgpow(n,MOD - 2);
for(int i = 1;i < n;i++){
int x,y;
scanf("%d %d",&x,&y);
graph[x].push_back(y);
graph[y].push_back(x);
}
for(int i = 1;i <= n;i++){
dp[0][i] = 1;
}
for(int i = 1;i <= n;i++){
for(int j = 1;j <= n;j++){
dp[i][j] = mult(add(dp[i][j - 1],dp[i - 1][j]),ipw2[1]);
}
}
for(int i = 1;i <= n;i++){
predfs(i,0);
dfs(i,0);
}
printf("%d\n",global_answer);
return 0;
}
|
[
"alexandrurapeanu@yahoo.com"
] |
alexandrurapeanu@yahoo.com
|
c5a199aca76e8092977a016cd814325578ead538
|
a366d89b4e41bde44d471f163c49f76abb3da8fc
|
/homing.cpp
|
b242f7e997a6174f31c3fa54674fbf3d7520f3fa
|
[] |
no_license
|
pigranya1218/WinAPI-worms
|
6bc3ff2a3ac6e4216fc973a6b6c7c0031605283c
|
7f864994aa26afc00bfcc3d405b513f9665a627e
|
refs/heads/master
| 2022-11-25T18:05:30.278987
| 2020-07-29T02:17:49
| 2020-07-29T02:17:49
| 276,584,039
| 0
| 1
| null | null | null | null |
UHC
|
C++
| false
| false
| 1,651
|
cpp
|
#include "stdafx.h"
#include "homing.h"
#include "stageManager.h"
#include "wormManager.h"
#include "objectManager.h"
void homing::update()
{
if (!_isFinish)
{
if (_homingCount++ >= 50) // 바추카와 같다
{
if (!_isHoming)
{
_angle = TTYONE_UTIL::getAngle(_x, _y, _pointX, _pointY);
float degree = _angle * (180 / PI);
_isHoming = true;
_power = 20;
SOUND_MANAGER->stop("WEAPON_HOMING_ON");
SOUND_MANAGER->play("WEAPON_HOMING_ON", 1);
}
}
else
{
_ani->frameUpdate(TIME_MANAGER->getElapsedTime());
}
EFFECT_MANAGER->play("EFFECT_HEXHAUST", _x, _y, 40, 40);
bool isBomb = gravityMove(0);
if (isBomb) // 폭파시키기
{
SOUND_MANAGER->stop("WEAPON_HOMING_ON");
EFFECT_MANAGER->play("EFFECT_CIRCLE", _x, _y, _bombWidth, _bombWidth);
EFFECT_MANAGER->play("EFFECT_ELIPSE", _x, _y, _bombWidth + 30, _bombWidth + 30);
EFFECT_MANAGER->play("EFFECT_EX_POW", _x, _y - 50, 50, 50);
_stageManager->pixelBomb(_x, _y, _damage, _bombWidth); // 픽셀 폭파시키기
_wormManager->wormBomb(_x, _y, _damage, _bombWidth); // 맞은 웜즈 날라가게 하기
_objectManager->objectBomb(_x, _y, _damage, _bombWidth);
_objectManager->makeBombEffect(_x, _y, _bombWidth);
_isFinish = true;
}
}
}
void homing::render()
{
if (_isHoming)
{
_img = IMAGE_MANAGER->findImage("PROJECTILE_HOMING_RED");
projectile::render(); // 빨간 유도 미사일 뿅뿅 날라간다
}
else
{
// 파란 유도미사일 빙글빙글 날아간다
CAMERA_MANAGER->aniRender(getMemDC(), _img, _x - (_img->getFrameWidth() / 2), _y - (_img->getFrameHeight() / 2), _ani, false);
}
}
|
[
"ddodd34@gmail.com"
] |
ddodd34@gmail.com
|
df8eaca34063fbe0ef0b9d725745533a3520138a
|
e8193b586e3376e6de82392aac66eb2feee4f7f7
|
/src/GafferSceneBindings/OptionsBinding.cpp
|
10e4c194e6d08138a4d7a49ec6905445a707a6a4
|
[
"BSD-3-Clause"
] |
permissive
|
PaulDoessel/gaffer-play
|
eb31f4917f40b4815c12984f55e3aeba60b8dd8f
|
8b72dabb388e12424c230acfb0bd209049b01bd6
|
refs/heads/master
| 2021-01-12T15:18:35.508661
| 2016-10-22T00:07:02
| 2016-10-22T00:07:02
| 71,752,516
| 0
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,465
|
cpp
|
//////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2013, Image Engine Design Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above
// copyright notice, this list of conditions and the following
// disclaimer.
//
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided with
// the distribution.
//
// * Neither the name of John Haddon nor the names of
// any other contributors to this software may be used to endorse or
// promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////
#include "boost/python.hpp"
#include "GafferBindings/DependencyNodeBinding.h"
#include "GafferScene/StandardOptions.h"
#include "GafferScene/CustomOptions.h"
#include "GafferScene/DeleteOptions.h"
#include "GafferScene/CopyOptions.h"
#include "GafferSceneBindings/OptionsBinding.h"
using namespace GafferScene;
void GafferSceneBindings::bindOptions()
{
GafferBindings::DependencyNodeClass<Options>();
GafferBindings::DependencyNodeClass<StandardOptions>();
GafferBindings::DependencyNodeClass<CustomOptions>();
GafferBindings::DependencyNodeClass<DeleteOptions>();
GafferBindings::DependencyNodeClass<CopyOptions>();
}
|
[
"thehaddonyoof@gmail.com"
] |
thehaddonyoof@gmail.com
|
700f609fb736c3026fd522ee2ce20c4520a64fe2
|
33a92a350d18515613a7c5bac8518556c2c1d799
|
/VC++6.0/数字图像/ljz153/ljz153.h
|
1f02c60d5d8f63c2ed10462d41bdae2e7d167c29
|
[] |
no_license
|
WemtFox/MyLearningCode
|
7b35345524f7cc047e364ab3d9f54892776213fa
|
e7df5692ea57756ae9563a84a5345e0b688c470d
|
refs/heads/master
| 2020-04-12T07:50:30.255469
| 2015-12-05T01:47:40
| 2015-12-05T01:47:40
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,307
|
h
|
// ljz153.h : main header file for the LJZ153 application
//
#if !defined(AFX_LJZ153_H__38C58EDA_692E_41E0_BEB8_CF94E24D2CC0__INCLUDED_)
#define AFX_LJZ153_H__38C58EDA_692E_41E0_BEB8_CF94E24D2CC0__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif
#include "resource.h" // main symbols
/////////////////////////////////////////////////////////////////////////////
// CLjz153App:
// See ljz153.cpp for the implementation of this class
//
class CLjz153App : public CWinApp
{
public:
CLjz153App();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CLjz153App)
public:
virtual BOOL InitInstance();
//}}AFX_VIRTUAL
// Implementation
//{{AFX_MSG(CLjz153App)
afx_msg void OnAppAbout();
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_LJZ153_H__38C58EDA_692E_41E0_BEB8_CF94E24D2CC0__INCLUDED_)
|
[
"sslujuzhi@sina.cn"
] |
sslujuzhi@sina.cn
|
3954dabd846b8f2cbc36366dfda6169fb4d952be
|
2c20040abf2996ba02858ce47a661b7ce280583c
|
/Benchmark/IsaMubuf.h
|
de59f0c2bc805e2956f7f793d61d4899a8028398
|
[] |
no_license
|
carlushuang/auto_gen
|
0157c2bb93f94a1ed446b13f0f3f293b9ad9fa75
|
7e5e0e27cc7e0a7403c0afcca02c69caef07d6cd
|
refs/heads/master
| 2020-04-04T18:54:30.023997
| 2018-11-20T05:13:10
| 2018-11-20T05:13:10
| 156,184,552
| 0
| 0
| null | 2018-11-05T08:30:05
| 2018-11-05T08:30:04
| null |
GB18030
|
C++
| false
| false
| 3,411
|
h
|
#pragma once
#include "SampleConfig.h"
#include "ProblemControl.h"
#include "IsaMubufKernelWriter.h"
/************************************************************************/
/* solution控制 */
/************************************************************************/
class MubufSolution : public SolutionCtrlBase
{
private:
T_KernelArgu d_a, d_b, d_c;
public:
/************************************************************************/
/* 根据problem参数成solution参数空间 */
/************************************************************************/
E_ReturnState GenerateSolutionConfigs();
/************************************************************************/
/* 申请显存 */
/************************************************************************/
E_ReturnState InitDev();
/************************************************************************/
/* 返回结果 */
/************************************************************************/
E_ReturnState GetBackResult();
/************************************************************************/
/* 释放显存 */
/************************************************************************/
void ReleaseDev();
/************************************************************************/
/* 根据solution参数生成source, complier和worksize */
/************************************************************************/
E_ReturnState GenerateSolution();
};
/************************************************************************/
/* 问题控制 */
/************************************************************************/
class MubufProblem : public ProblemCtrlBase
{
public:
MubufProblem(std::string name) :ProblemCtrlBase(name)
{
Solution = new MubufSolution();
}
public:
/************************************************************************/
/* 生成问题空间 */
/************************************************************************/
E_ReturnState GenerateProblemConfigs();
/************************************************************************/
/* 参数初始化 */
/************************************************************************/
E_ReturnState InitHost();
/************************************************************************/
/* HOST端 */
/************************************************************************/
E_ReturnState Host();
/************************************************************************/
/* 校验 */
/************************************************************************/
E_ReturnState Verify();
/************************************************************************/
/* 释放 */
/************************************************************************/
void ReleaseHost();
};
|
[
"Fei.Wang@amd.com"
] |
Fei.Wang@amd.com
|
90bb81b28fdd34f50cf584bcafdb83d1c7e4ce88
|
c43cbfca4056ea30051e46e1917e7946beb1e331
|
/src/qt/editaddressdialog.cpp
|
891eca042a2c3bf7f409b8b29dda130872a3c88e
|
[
"MIT"
] |
permissive
|
Legioncrypto/Legion
|
c9017fce536e9d296f6af9e1d06e5a9b03c9b0c9
|
f7b5a0287e530bec85f3081fd7ac7a8a020cdcf9
|
refs/heads/master
| 2020-03-18T19:55:28.823995
| 2019-03-14T02:29:52
| 2019-03-14T02:29:52
| 135,185,573
| 1
| 4
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 4,480
|
cpp
|
#include "editaddressdialog.h"
#include "ui_editaddressdialog.h"
#include "addresstablemodel.h"
#include "guiutil.h"
#include <QDataWidgetMapper>
#include <QMessageBox>
#include <QClipboard>
EditAddressDialog::EditAddressDialog(Mode mode, QWidget *parent) :
QDialog(parent),
ui(new Ui::EditAddressDialog), mapper(0), mode(mode), model(0)
{
ui->setupUi(this);
GUIUtil::setupAddressWidget(ui->addressEdit, this);
switch(mode)
{
case NewReceivingAddress:
setWindowTitle(tr("New receiving address"));
ui->addressEdit->setEnabled(false);
ui->addressEdit->setVisible(false);
ui->stealthCB->setEnabled(true);
ui->stealthCB->setVisible(true);
break;
case NewSendingAddress:
setWindowTitle(tr("New sending address"));
ui->stealthCB->setVisible(false);
break;
case EditReceivingAddress:
setWindowTitle(tr("Edit receiving address"));
ui->addressEdit->setEnabled(false);
ui->addressEdit->setVisible(true);
ui->stealthCB->setEnabled(false);
ui->stealthCB->setVisible(true);
break;
case EditSendingAddress:
setWindowTitle(tr("Edit sending address"));
ui->stealthCB->setVisible(false);
break;
}
mapper = new QDataWidgetMapper(this);
mapper->setSubmitPolicy(QDataWidgetMapper::ManualSubmit);
}
EditAddressDialog::~EditAddressDialog()
{
delete ui;
}
void EditAddressDialog::setModel(AddressTableModel *model)
{
this->model = model;
if(!model)
return;
mapper->setModel(model);
mapper->addMapping(ui->labelEdit, AddressTableModel::Label);
mapper->addMapping(ui->addressEdit, AddressTableModel::Address);
mapper->addMapping(ui->stealthCB, AddressTableModel::Type);
}
void EditAddressDialog::loadRow(int row)
{
mapper->setCurrentIndex(row);
}
bool EditAddressDialog::saveCurrentRow()
{
if(!model)
return false;
switch(mode)
{
case NewReceivingAddress:
case NewSendingAddress:
{
int typeInd = ui->stealthCB->isChecked() ? AddressTableModel::AT_Stealth : AddressTableModel::AT_Normal;
address = model->addRow(
mode == NewSendingAddress ? AddressTableModel::Send : AddressTableModel::Receive,
ui->labelEdit->text(),
ui->addressEdit->text(),
typeInd);
}
break;
case EditReceivingAddress:
case EditSendingAddress:
if(mapper->submit())
{
address = ui->addressEdit->text();
}
break;
}
return !address.isEmpty();
}
void EditAddressDialog::accept()
{
if(!model)
return;
if(!saveCurrentRow())
{
switch(model->getEditStatus())
{
case AddressTableModel::OK:
// Failed with unknown reason. Just reject.
break;
case AddressTableModel::NO_CHANGES:
// No changes were made during edit operation. Just reject.
break;
case AddressTableModel::INVALID_ADDRESS:
QMessageBox::warning(this, windowTitle(),
tr("The entered address \"%1\" is not a valid Legion address.").arg(ui->addressEdit->text()),
QMessageBox::Ok, QMessageBox::Ok);
break;
case AddressTableModel::DUPLICATE_ADDRESS:
QMessageBox::warning(this, windowTitle(),
tr("The entered address \"%1\" is already in the address book.").arg(ui->addressEdit->text()),
QMessageBox::Ok, QMessageBox::Ok);
break;
case AddressTableModel::WALLET_UNLOCK_FAILURE:
QMessageBox::critical(this, windowTitle(),
tr("Could not unlock wallet."),
QMessageBox::Ok, QMessageBox::Ok);
break;
case AddressTableModel::KEY_GENERATION_FAILURE:
QMessageBox::critical(this, windowTitle(),
tr("New key generation failed."),
QMessageBox::Ok, QMessageBox::Ok);
break;
}
return;
}
QDialog::accept();
}
QString EditAddressDialog::getAddress() const
{
return address;
}
void EditAddressDialog::setAddress(const QString &address)
{
this->address = address;
ui->addressEdit->setText(address);
}
void EditAddressDialog::on_EditAddressPasteButton_clicked()
{
// Paste text from clipboard into recipient field
ui->addressEdit->setText(QApplication::clipboard()->text());
}
|
[
"legioncrypto@users.noreply.github.com"
] |
legioncrypto@users.noreply.github.com
|
a4927524fee30ef2cb25ecec7be414f8c11fb2ae
|
92dbe90d8cf56a38caaefff70b8d1f700f1562aa
|
/ash/system/holding_space/holding_space_tray.cc
|
9004a2414e79efb5945a52cca6d2cf3a0c09e8f3
|
[
"BSD-3-Clause"
] |
permissive
|
jeeeez/chromium
|
4fb134eccfd1d3f469a838ac0b9ee375eb28ad88
|
ed032184fd1bf63ca0e9525f5ccca7d3165e2d63
|
refs/heads/master
| 2023-01-03T08:12:33.054587
| 2020-10-27T09:34:51
| 2020-10-27T09:34:51
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 6,375
|
cc
|
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/system/holding_space/holding_space_tray.h"
#include <memory>
#include "ash/accessibility/accessibility_controller_impl.h"
#include "ash/public/cpp/holding_space/holding_space_constants.h"
#include "ash/public/cpp/holding_space/holding_space_metrics.h"
#include "ash/public/cpp/holding_space/holding_space_prefs.h"
#include "ash/public/cpp/shelf_config.h"
#include "ash/public/cpp/system_tray_client.h"
#include "ash/resources/vector_icons/vector_icons.h"
#include "ash/session/session_controller_impl.h"
#include "ash/shelf/shelf.h"
#include "ash/shell.h"
#include "ash/strings/grit/ash_strings.h"
#include "ash/system/holding_space/holding_space_tray_bubble.h"
#include "ash/system/tray/tray_container.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/views/controls/image_view.h"
#include "ui/views/controls/label.h"
#include "ui/views/layout/fill_layout.h"
#include "ui/views/vector_icons.h"
namespace ash {
HoldingSpaceTray::HoldingSpaceTray(Shelf* shelf) : TrayBackgroundView(shelf) {
controller_observer_.Add(HoldingSpaceController::Get());
SetVisible(false);
SetLayoutManager(std::make_unique<views::FillLayout>());
icon_ = tray_container()->AddChildView(std::make_unique<views::ImageView>());
icon_->SetTooltipText(l10n_util::GetStringUTF16(IDS_ASH_HOLDING_SPACE_TITLE));
icon_->SetImage(CreateVectorIcon(kHoldingSpaceIcon,
ShelfConfig::Get()->shelf_icon_color()));
tray_container()->SetMargin(kHoldingSpaceTrayMainAxisMargin, 0);
}
HoldingSpaceTray::~HoldingSpaceTray() = default;
void HoldingSpaceTray::ClickedOutsideBubble() {
CloseBubble();
}
base::string16 HoldingSpaceTray::GetAccessibleNameForTray() {
return l10n_util::GetStringUTF16(IDS_ASH_HOLDING_SPACE_TITLE);
}
void HoldingSpaceTray::HandleLocaleChange() {
icon_->SetTooltipText(l10n_util::GetStringUTF16(IDS_ASH_HOLDING_SPACE_TITLE));
}
void HoldingSpaceTray::HideBubbleWithView(const TrayBubbleView* bubble_view) {}
void HoldingSpaceTray::AnchorUpdated() {
if (bubble_)
bubble_->AnchorUpdated();
}
void HoldingSpaceTray::UpdateAfterLoginStatusChange() {
UpdateVisibility();
}
bool HoldingSpaceTray::PerformAction(const ui::Event& event) {
holding_space_metrics::RecordPodAction(
holding_space_metrics::PodAction::kClick);
if (bubble_) {
CloseBubble();
return true;
}
ShowBubble(event.IsMouseEvent() || event.IsGestureEvent());
// Activate the bubble for a11y or if it was shown via keypress. Otherwise
// focus will remain on the tray when it should enter the bubble.
if (event.IsKeyEvent() ||
Shell::Get()->accessibility_controller()->spoken_feedback().enabled()) {
DCHECK(bubble_ && bubble_->GetBubbleWidget());
bubble_->GetBubbleWidget()->widget_delegate()->SetCanActivate(true);
bubble_->GetBubbleWidget()->Activate();
}
return true;
}
void HoldingSpaceTray::CloseBubble() {
if (!bubble_)
return;
// If the call to `CloseBubble()` originated from `OnWidgetDestroying()`, as
// would be the case when closing due to ESC key press, the bubble widget will
// have already been destroyed.
if (bubble_->GetBubbleWidget())
bubble_->GetBubbleWidget()->RemoveObserver(this);
bubble_.reset();
SetIsActive(false);
}
void HoldingSpaceTray::ShowBubble(bool show_by_click) {
if (bubble_)
return;
DCHECK(tray_container());
bubble_ = std::make_unique<HoldingSpaceTrayBubble>(this, show_by_click);
// Observe the bubble widget so that we can do proper clean up when it is
// being destroyed. If destruction is due to a call to `CloseBubble()` we will
// have already cleaned up state but there are cases where the bubble widget
// is destroyed independent of a call to `CloseBubble()`, e.g. ESC key press.
bubble_->GetBubbleWidget()->AddObserver(this);
SetIsActive(true);
}
TrayBubbleView* HoldingSpaceTray::GetBubbleView() {
return bubble_ ? bubble_->GetBubbleView() : nullptr;
}
const char* HoldingSpaceTray::GetClassName() const {
return "HoldingSpaceTray";
}
void HoldingSpaceTray::UpdateVisibility() {
HoldingSpaceModel* model = HoldingSpaceController::Get()->model();
bool logged_in =
shelf()->GetStatusAreaWidget()->login_status() == LoginStatus::USER;
if (!model || !logged_in) {
SetVisiblePreferred(false);
return;
}
PrefService* active_pref_service =
Shell::Get()->session_controller()->GetActivePrefService();
bool has_ever_pinned_item =
active_pref_service
? holding_space_prefs::GetTimeOfFirstPin(active_pref_service)
.has_value()
: false;
SetVisiblePreferred(!model->items().empty() || !has_ever_pinned_item);
}
base::string16 HoldingSpaceTray::GetAccessibleNameForBubble() {
return GetAccessibleNameForTray();
}
bool HoldingSpaceTray::ShouldEnableExtraKeyboardAccessibility() {
return Shell::Get()->accessibility_controller()->spoken_feedback().enabled();
}
void HoldingSpaceTray::HideBubble(const TrayBubbleView* bubble_view) {
CloseBubble();
}
void HoldingSpaceTray::OnHoldingSpaceModelAttached(HoldingSpaceModel* model) {
model_observer_.Add(model);
UpdateVisibility();
}
void HoldingSpaceTray::OnHoldingSpaceModelDetached(HoldingSpaceModel* model) {
model_observer_.Remove(model);
UpdateVisibility();
}
void HoldingSpaceTray::OnHoldingSpaceItemAdded(const HoldingSpaceItem* item) {
UpdateVisibility();
}
void HoldingSpaceTray::OnHoldingSpaceItemRemoved(const HoldingSpaceItem* item) {
UpdateVisibility();
}
void HoldingSpaceTray::OnWidgetDragWillStart(views::Widget* widget) {
// The holding space bubble should be closed while dragging holding space
// items so as not to obstruct drop targets. Post the task to close the bubble
// so that we don't attempt to destroy the bubble widget before the associated
// drag event has been fully initialized.
base::SequencedTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(&HoldingSpaceTray::CloseBubble,
weak_factory_.GetWeakPtr()));
}
void HoldingSpaceTray::OnWidgetDestroying(views::Widget* widget) {
widget->RemoveObserver(this);
CloseBubble();
}
} // namespace ash
|
[
"commit-bot@chromium.org"
] |
commit-bot@chromium.org
|
1699ce3c3bf537fcaa3af5dc6c6ba404a666d600
|
aad6b08ee56c2760b207d562f16be0a5bb8e3e2a
|
/tags/Doduo_1.1/BAL/WKAL/Concretizations/Graphics/WK/BCIntRectWK.h
|
184ac411376ea626c23d90f21f62e417b0887abe
|
[] |
no_license
|
Chengjian-Tang/owb-mirror
|
5ffd127685d06f2c8e00832c63cd235bec63f753
|
b48392a07a2f760bfc273d8d8b80e8d3f43b6b55
|
refs/heads/master
| 2021-05-27T02:09:03.654458
| 2010-06-23T11:10:12
| 2010-06-23T11:10:12
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 5,932
|
h
|
/*
* Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef IntRect_h
#define IntRect_h
#include "IntPoint.h"
#include <wtf/Platform.h>
#if PLATFORM(CG)
typedef struct CGRect CGRect;
#endif
#if PLATFORM(MAC)
#ifdef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
typedef struct CGRect NSRect;
#else
typedef struct _NSRect NSRect;
#endif
#endif
#if PLATFORM(WIN)
typedef struct tagRECT RECT;
#elif PLATFORM(QT)
QT_BEGIN_NAMESPACE
class QRect;
QT_END_NAMESPACE
#elif PLATFORM(GTK)
typedef struct _GdkRectangle GdkRectangle;
#endif
#if PLATFORM(SYMBIAN)
class TRect;
#endif
#if PLATFORM(WX)
class wxRect;
#endif
namespace WKAL {
class FloatRect;
class IntRect {
public:
IntRect() { }
IntRect(const IntPoint& location, const IntSize& size)
: m_location(location), m_size(size) { }
IntRect(int x, int y, int width, int height)
: m_location(IntPoint(x, y)), m_size(IntSize(width, height)) { }
explicit IntRect(const FloatRect& rect); // don't do this implicitly since it's lossy
IntPoint location() const { return m_location; }
IntSize size() const { return m_size; }
void setLocation(const IntPoint& location) { m_location = location; }
void setSize(const IntSize& size) { m_size = size; }
int x() const { return m_location.x(); }
int y() const { return m_location.y(); }
int width() const { return m_size.width(); }
int height() const { return m_size.height(); }
void setX(int x) { m_location.setX(x); }
void setY(int y) { m_location.setY(y); }
void setWidth(int width) { m_size.setWidth(width); }
void setHeight(int height) { m_size.setHeight(height); }
// Be careful with these functions. The point is considered to be to the right and below. These are not
// substitutes for right() and bottom().
IntPoint topLeft() const { return m_location; }
IntPoint topRight() const { return IntPoint(right() - 1, y()); }
IntPoint bottomLeft() const { return IntPoint(x(), bottom() - 1); }
IntPoint bottomRight() const { return IntPoint(right() - 1, bottom() - 1); }
bool isEmpty() const { return m_size.isEmpty(); }
int right() const { return x() + width(); }
int bottom() const { return y() + height(); }
void move(const IntSize& s) { m_location += s; }
void move(int dx, int dy) { m_location.move(dx, dy); }
bool intersects(const IntRect&) const;
bool contains(const IntRect&) const;
// This checks to see if the rect contains x,y in the traditional sense.
// Equivalent to checking if the rect contains a 1x1 rect below and to the right of (px,py).
bool contains(int px, int py) const
{ return px >= x() && px < right() && py >= y() && py < bottom(); }
bool contains(const IntPoint& point) const { return contains(point.x(), point.y()); }
void intersect(const IntRect&);
void unite(const IntRect&);
void inflateX(int dx)
{
m_location.setX(m_location.x() - dx);
m_size.setWidth(m_size.width() + dx + dx);
}
void inflateY(int dy)
{
m_location.setY(m_location.y() - dy);
m_size.setHeight(m_size.height() + dy + dy);
}
void inflate(int d) { inflateX(d); inflateY(d); }
void scale(float s);
#if PLATFORM(WX)
IntRect(const wxRect&);
operator wxRect() const;
#endif
#if PLATFORM(WIN)
IntRect(const RECT&);
operator RECT() const;
#elif PLATFORM(QT)
IntRect(const QRect&);
operator QRect() const;
#elif PLATFORM(GTK)
IntRect(const GdkRectangle&);
operator GdkRectangle() const;
#endif
#if PLATFORM(SYMBIAN)
IntRect(const TRect&);
operator TRect() const;
TRect Rect() const;
#endif
#if PLATFORM(CG)
operator CGRect() const;
#endif
#if PLATFORM(MAC) && !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES)
operator NSRect() const;
#endif
private:
IntPoint m_location;
IntSize m_size;
};
inline IntRect intersection(const IntRect& a, const IntRect& b)
{
IntRect c = a;
c.intersect(b);
return c;
}
inline IntRect unionRect(const IntRect& a, const IntRect& b)
{
IntRect c = a;
c.unite(b);
return c;
}
inline bool operator==(const IntRect& a, const IntRect& b)
{
return a.location() == b.location() && a.size() == b.size();
}
inline bool operator!=(const IntRect& a, const IntRect& b)
{
return a.location() != b.location() || a.size() != b.size();
}
#if PLATFORM(CG)
IntRect enclosingIntRect(const CGRect&);
#endif
#if PLATFORM(MAC) && !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES)
IntRect enclosingIntRect(const NSRect&);
#endif
} // namespace WebCore
#endif // IntRect_h
|
[
"sroret@a3cd4a6d-042f-0410-9b26-d8d12826d3fb"
] |
sroret@a3cd4a6d-042f-0410-9b26-d8d12826d3fb
|
089c5270881b5dd21f1fef4645de3d704cc37e27
|
fcdea24e6466d4ec8d7798555358a9af8acf9b35
|
/Engine/mrayEngine/src/MorphAnimator.cpp
|
46e44ecb119f9f0d93b058b68ea3ee17eeb52279
|
[] |
no_license
|
yingzhang536/mrayy-Game-Engine
|
6634afecefcb79c2117cecf3e4e635d3089c9590
|
6b6fcbab8674a6169e26f0f20356d0708620b828
|
refs/heads/master
| 2021-01-17T07:59:30.135446
| 2014-11-30T16:10:54
| 2014-11-30T16:10:54
| 27,630,181
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,802
|
cpp
|
#include "stdafx.h"
#include "MorphAnimator.h"
#include "ILogManager.h"
#include "IMeshBuffer.h"
namespace mray{
namespace scene{
MorphAnimator::MorphAnimator(IMeshBuffer*mesh)
:IMorphAnimator(mesh)
{
m_needUpdate=false;
setMeshBuffer(mesh);
}
MorphAnimator::~MorphAnimator(){
m_targets.clear();
}
void MorphAnimator::setMeshBuffer(IMeshBuffer*mesh)
{
m_needUpdate=false;
m_buffer=mesh;
video::IHardwareStreamBuffer*s=mesh->getStream(0,video::EMST_Position);
m_tempVector.resize(m_vertexCount);
m_baseVector.resize(m_vertexCount);
math::vector3d*mainVert=(math::vector3d*) s->lock(0,0,video::IHardwareBuffer::ELO_ReadOnly);
for (int v=0;v<m_baseVector.size();v++){
m_baseVector[v]=mainVert[v];
}
s->unlock();
}
void MorphAnimator::update(float dt){
m_needUpdate=false;
for (int i=0;i<m_targets.size();++i)
{
if(m_targets[i].target->getPercent()!=m_targets[i].oldVal){
m_needUpdate=true;
break;
}
}
if(!m_needUpdate)return;
m_needUpdate=false;
for (int i=0;i<m_tempVector.size();++i)
{
m_tempVector[i]=0;
}
float total=1;
bool changed=0;
for(int i=0;i<m_targets.size();++i){
MorphTarget*t=m_targets[i].target;
if(t->getPercent()==0)continue;
m_targets[i].oldVal=t->getPercent();
float p=m_targets[i].oldVal*0.01f;
video::IHardwareStreamBuffer*stream=t->getMesh()->getStream(0,video::EMST_Position);
math::vector3d*pV=(math::vector3d*) stream->lock(0,0,video::IHardwareBuffer::ELO_ReadOnly);
int cnt=stream->length();
for (int v=0;v<cnt;v++)
{
m_tempVector[v]+=pV[v]*p;
}
total-=p;
stream->unlock();
changed=true;
}
if(changed){
video::IHardwareStreamBuffer*mainStream=m_buffer->getStream(0,video::EMST_Position);
math::vector3d*mainVert=(math::vector3d*) mainStream->lock(0,0,video::IHardwareBuffer::ELO_Normal);
int len=mainStream->length();
for (int v=0;v<m_tempVector.size();v++){
mainVert[v]=m_tempVector[v]+m_baseVector[v]*total;
}
mainStream->unlock();
}
}
const MorphTargetPtr& MorphAnimator::addTarget(scene::IMeshBuffer*buff,float p){
const MorphTargetPtr& t=IMorphAnimator::addTarget(buff,p);
if(p!=0 && t.pointer()!=0)
m_needUpdate=true;
return t;
}
void MorphAnimator::setTargetPercent(int index,float v){
if(index>=m_targets.size())return;
MorphTarget*t=m_targets[index].target;
v=math::clamp(v,0.0f,1.0f);
if(t->getPercent()!=v){
m_needUpdate=true;
t->setPercent(v);
}
}
IMeshAnimator* MorphAnimator::duplicate()
{
MorphAnimator* c=new MorphAnimator(m_buffer);
for(int i=0;i<m_targets.size();++i)
{
MorphTargetInfo ifo(new MorphTarget(m_targets[i].target->getMesh(),m_targets[i].target->getPercent()));
c->m_targets.push_back(ifo);
}
return c;
}
}
}
|
[
"mrayyamen@gmail.com"
] |
mrayyamen@gmail.com
|
00c0ed7f2f33ed82c0133d78dbd68c1f52aea2fb
|
bbcb83e5d9bababc7d5ad017222f4f2d0127e152
|
/TestThreadLib/TestThreadLib/SharedMemoryThread.h
|
b39da1c0dc10c1f4f1102b21d3c0ae51797d89b3
|
[] |
no_license
|
andrewpaterson/Codaphela.Test
|
d52f3c4d9c5b4ae21f265424cb01a246463f70b5
|
1678a4af46ce363e3d1b01ca931ca8f84330c764
|
refs/heads/master
| 2023-05-25T07:00:38.362742
| 2023-05-14T11:46:51
| 2023-05-14T11:46:51
| 3,249,605
| 0
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 757
|
h
|
#ifndef __SHARED_MEMORY_THREAD_H__
#define __SHARED_MEMORY_THREAD_H__
#include "ThreadLib/Thread.h"
#include "SharedMemoryFill.h"
class CSharedMemoryThread : public CThread
{
CONSTRUCTABLE(CSharedMemoryThread);
private:
CSharedMemoryFill mcFill;
public:
CSharedMemoryThread(void) : CThread() {}
CSharedMemoryThread(CThreadStarter* pcStarter, CThreadStateNotifer* pcNotify) : CThread(pcStarter, pcNotify) {}
CSharedMemoryThread* Init(char* szSharedMemoryName, char* szMutexName, char* szFillChar, int iChunkSize)
{
CThread::Init();
mcFill.Init(szSharedMemoryName, szMutexName, szFillChar, iChunkSize);
return this;
}
virtual void Run(void)
{
mcFill.Run();
}
};
#endif // !__SHARED_MEMORY_THREAD_H__
|
[
"andrew.ian.paterson@gmail.com"
] |
andrew.ian.paterson@gmail.com
|
077988cb4e85122c644aea246d26d91cbf2ad0a1
|
1060214b1efa068d20a756126ad1ffcbfeb0814b
|
/estrutura/PontosdeFeno.cpp
|
aa7ab141b613b2202e44f8b8a12b66db0bb20078
|
[] |
no_license
|
blogdarkspot/MaratonadeProgramacao
|
4b0aecc063033caebad78e34bb090d1822e1fb26
|
41420c2c06b6849f50f9ea99e70d841e15c0f1ea
|
refs/heads/master
| 2021-05-30T01:57:26.007257
| 2015-10-06T14:49:00
| 2015-10-06T14:49:00
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 769
|
cpp
|
//https://www.urionlinejudge.com.br/judge/pt/problems/view/1261
#include<iostream>
#include<string>
#include<cstdio>
#include<map>
using namespace std;
int main ()
{
string buffer;
map<string, int> dic;
int i,j,k, total = 0;
cin>>i>>j;
total = 0;
dic.clear();
while(i--)
{
cin>>buffer>>k;
dic[buffer]=k;
}
while (getline(cin, buffer))
{
for (int a=0, b=0, c=0; a<buffer.size(); a++)
{
while(buffer[a]!=' ' && a<buffer.size() && buffer[a]!='.')
{
a++;
c++;
}
if (a!=b && dic.count(buffer.substr(b,c))>0)
total+=dic.find(buffer.substr(b,c))->second;
if(buffer[a]=='.')
{
cout<<total<<endl;
total=0;
}
b = a+1;
c =0;
}
}
return 0;
}
|
[
"fabio.scienvitarso@gmail.com"
] |
fabio.scienvitarso@gmail.com
|
f78aaae4f665073906caf8fd2ee5f4fce2f7cf84
|
92359e635b722f8c359b6a27133685c1c9b56565
|
/sandbox/FastBlurs/CPUT/CPUT/CPUTRenderTargetOGL.cpp
|
92a3dfb04260a11e0399ed5cc969578ea6f46aee
|
[
"MIT"
] |
permissive
|
oamates/OpenGL
|
547ccb560d76182c70eae3ea6512df81c794f322
|
78c6d1fbdcb0c041b3333ea71c43c8f531e04481
|
refs/heads/master
| 2021-05-11T17:23:36.445056
| 2018-01-16T02:32:04
| 2018-01-16T02:32:04
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,248
|
cpp
|
//--------------------------------------------------------------------------------------
// Copyright 2013 Intel Corporation
// All Rights Reserved
//
// Permission is granted to use, copy, distribute and prepare derivative works of this
// software for any purpose and without fee, provided, that the above copyright notice
// and this statement appear in all copies. Intel makes no representations about the
// suitability of this software for any purpose. THIS SOFTWARE IS PROVIDED "AS IS."
// INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, AND ALL LIABILITY,
// INCLUDING CONSEQUENTIAL AND OTHER INDIRECT DAMAGES, FOR THE USE OF THIS SOFTWARE,
// INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PROPRIETARY RIGHTS, AND INCLUDING THE
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Intel does not
// assume any responsibility for any errors which may appear in this software nor any
// responsibility to update it.
//--------------------------------------------------------------------------------------
#include "CPUTRenderTargetOGL.h"
//#include "CPUTAssetLibrary.h"
#include "CPUTTextureOGL.h"
CPUTFramebufferOGL::CPUTFramebufferOGL()
: mFramebuffer(0), mpColor(NULL), mpDepth(NULL), mpStencil(NULL)
{};
CPUTFramebufferOGL::~CPUTFramebufferOGL()
{
SAFE_RELEASE(mpColor);
SAFE_RELEASE(mpDepth);
SAFE_RELEASE(mpStencil);
if(mFramebuffer == 0)
{
glDeleteFramebuffers(1, &mFramebuffer);
}
}
CPUTFramebufferOGL::CPUTFramebufferOGL(CPUTTextureOGL *pColor,
CPUTTextureOGL *pDepth,
CPUTTextureOGL *pStencil)
{
GLuint framebuffer = 0;
GL_CHECK(glGenFramebuffers(1, &framebuffer));
GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, framebuffer));
if(pDepth)
{
GLuint depthTexture = pDepth->GetTexture();
GL_CHECK(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depthTexture, 0));
}
if(pColor)
{
GL_CHECK(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, pColor->GetTexture(), 0));
GLenum pDrawBuffers[1] = {GL_COLOR_ATTACHMENT0};
GL_CHECK(ES3_COMPAT(glDrawBuffers(1, pDrawBuffers)));
}
else
{
GLenum pDrawBuffers[1] = {GL_NONE};
GL_CHECK(ES3_COMPAT(glDrawBuffers(1, pDrawBuffers)));
}
GLuint status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
ASSERT(status == GL_FRAMEBUFFER_COMPLETE, _L("Failed creating Framebuffer"));
glBindFramebuffer(GL_FRAMEBUFFER, 0);
mFramebuffer = framebuffer;
mpColor = pColor;
if(pColor != NULL)
pColor->AddRef();
if(pDepth != NULL)
pDepth->AddRef();
mpDepth = pDepth;
if(pStencil != NULL)
pStencil->AddRef();
mpStencil = pStencil;
return;
}
void CPUTFramebufferOGL::SetActive()
{
GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, mFramebuffer));
}
void CPUTFramebufferOGL::UnSetActive()
{
GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, 0));
}
GLuint CPUTFramebufferOGL::GetFramebufferName() { return mFramebuffer;}
CPUTTextureOGL* CPUTFramebufferOGL::GetColorTexture() { return mpColor;}
CPUTTextureOGL* CPUTFramebufferOGL::GetDepthTexture() { return mpDepth;}
//void SetColorTexture(CPUTTextureOGL *pTexture)
//void SetDepthTexture(CPUTTextureOGL *pTexture);
|
[
"afoksha@luxoft.com"
] |
afoksha@luxoft.com
|
c207f19caf0c814ea18699171f20932ad31de9b5
|
b22588340d7925b614a735bbbde1b351ad657ffc
|
/athena/Trigger/TrigEvent/TrigParticle/TrigParticle/TrigEFBjetContainer.h
|
eaa39bf15909320a2dd009d109ca42c3e97137b5
|
[] |
no_license
|
rushioda/PIXELVALID_athena
|
90befe12042c1249cbb3655dde1428bb9b9a42ce
|
22df23187ef85e9c3120122c8375ea0e7d8ea440
|
refs/heads/master
| 2020-12-14T22:01:15.365949
| 2020-01-19T03:59:35
| 2020-01-19T03:59:35
| 234,836,993
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 897
|
h
|
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// ************************************************
//
// NAME: TrigEFBjetContainer.h
// PACKAGE: Trigger/TrigEvent/TrigParticle
//
// AUTHOR: Andrea Coccaro
// EMAIL: Andrea.Coccaro@ge.infn.it
//
// ************************************************
#ifndef TRIG_EF_BJET_CONTAINER
#define TRIG_EF_BJET_CONTAINER
#include "DataModel/DataVector.h"
#include "CLIDSvc/CLASS_DEF.h"
#include "TrigParticle/TrigEFBjet.h"
#include "SGTools/BaseInfo.h"
/**
* @brief Container of TrigEFBjet objects to be stored in POOL.
*
* @author Andrea Coccaro <Andrea.Coccaro@ge.infn.it>
*/
class TrigEFBjetContainer: public DataVector<TrigEFBjet> { };
//typedef DataVector<TrigEFBjet> TrigEFBjetContainer;
CLASS_DEF(TrigEFBjetContainer, 1142962358, 1)
SG_BASE(TrigEFBjetContainer, DataVector<TrigEFBjet>);
#endif
|
[
"rushioda@lxplus754.cern.ch"
] |
rushioda@lxplus754.cern.ch
|
a06765545826fc0499576c0069ce91f54a36790c
|
4ceb431679147aedd57c04308f769a2521b1a9e4
|
/Problems and Solutions/10812 - Beat the Spread!.cpp
|
636c1b5b747f9bdef146229df738bc4294d1753b
|
[] |
no_license
|
tushar20008/Competitive-Coding
|
188797383cfa4f3b722543f5a999847c0756388b
|
9ec0891d6023029590cb096417b6477a011f3d61
|
refs/heads/master
| 2021-01-18T18:51:57.586151
| 2018-05-01T10:59:30
| 2018-05-01T10:59:30
| 86,875,720
| 3
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 259
|
cpp
|
#include <iostream>
using namespace std;
int main()
{
int T;
cin>>T;
while(T--)
{
long s,d;
cin>>s>>d;
long a = (s+d)/2;
long b = s-a;
if(b<0 || a+b != s || a-b != d)
cout<<"impossible"<<endl;
else
cout<<a<<" "<<b<<endl;
}
return 0;
}
|
[
"tusharanand20008@gmail.com"
] |
tusharanand20008@gmail.com
|
ced72451d22b4a11f97a3d80f55f95207d5a2bb9
|
c4cfc213646bd5d5dcc637b37e80e35318eb3a40
|
/KOCOM/src/context_elevator.cpp
|
1b7b095a2ca9c7c2335f60675ddacbf44e8fafb2
|
[] |
no_license
|
gandy555/MTM_V3
|
ff90e70b525bd88c6d25756f4de7b21b2b5d0d61
|
abc012b1663b412cca26c5ffb3073bbfd57550c2
|
refs/heads/master
| 2021-01-20T06:59:40.596104
| 2015-10-14T14:30:31
| 2015-10-14T14:30:31
| 42,117,534
| 0
| 0
| null | null | null | null |
UHC
|
C++
| false
| false
| 12,890
|
cpp
|
/*
*/
#include "common.h"
#include "context_elevator.h"
#include "main.h"
#define ELEVATOR_STAT_REQ (1<<0)
#define ELEVATOR_STAT_RES_WAIT (1<<1)
#define ELEVATOR_STAT_RES_TIMEOUT (1<<2)
#define ELEVATOR_CALL_REQ (1<<3)
#define ELEVATOR_CALL_RES_WAIT (1<<4)
#define ELEVATOR_CALL_RES_TIMEOUT (1<<5)
UCHAR g_ElevatorTimerParam = 0;
UCHAR g_ElevatorStatResTimeout = 0;
UCHAR g_ElevatorCallResTimeout = 0;
#if 0
//엘리베이터 타이머 핸들러 : 1초
void elevator_timer_handler(void *pParam)
{
UCHAR* pucParam = (UCHAR *)pParam;
if(g_state.GetState() != STATE_ELEVATOR)
{
g_timer.KillTimer(ELEVATOR_TIMER);
return;
}
if(*pucParam & ELEVATOR_STAT_REQ)
{
if(*pucParam & ELEVATOR_STAT_RES_WAIT)
{
*pucParam |= ELEVATOR_STAT_RES_TIMEOUT;
g_ElevatorStatResTimeout += ELEVATOR_REQ_TIME;
if(g_ElevatorStatResTimeout >= ELEVATOR_RES_TIMEOUT)
{
printf("Elevator Stat Response Timeout!\r\n");
g_timer.KillTimer(ELEVATOR_TIMER);
}
}
else
{
*pucParam |= ELEVATOR_STAT_RES_WAIT;
g_ElevatorStatResTimeout = 0;
// g_wallpad_sns.RequestReserve(SNS_CMD_ELEVATOR_STAT_REQ);
if(g_pWallPad)
{
g_pWallPad->RequestElevatorStatus();
}
}
}
if(*pucParam & ELEVATOR_CALL_RES_WAIT)
{
*pucParam |= ELEVATOR_CALL_RES_TIMEOUT;
}
// g_wallpad_sns.RequestReserve(SNS_CMD_ELEVATOR_STAT_REQ);
if(g_pWallPad)
{
g_pWallPad->RequestElevatorStatus();
}
}
#endif
//
// Construction/Destruction
//
CContextElevator::CContextElevator(GR_WINDOW_ID wid, GR_GC_ID gc)
: CContext(wid, gc)
{
m_isElevatorStatusSuccess = FALSE;
m_isElevatorCalled = FALSE;
m_isElevatorCallSuccess = FALSE;
m_isElevatorArrive = FALSE;
m_nElevatorDir = 0;
m_nElevatorFloor = 0;
m_pObjectIcon = NULL;
}
CContextElevator::~CContextElevator()
{
}
//
// Member Function
//
void CContextElevator::Init()
{
CObject* pObject;
CObjectIcon* pObjectIcon;
UINT id;
CContext::Init();
// Blank 배경 이미지
pObject = new CObjectImage(m_wid_parent, m_gc, 0, 0, g_scr_info.cols, g_scr_info.rows);
if(pObject)
{
pObject->LoadImage(IMG_BACKGROUND, "/app/img/blank_bg.png");
id = m_ObjectList.AddObject(pObject);
}
// 아이콘 이미지
pObject = new CObjectImage(m_wid_parent, m_gc, 58, 50, 158, 158);
if(pObject)
{
pObject->LoadImage(IMG_BACKGROUND, "/app/img/icon_elevator.png");
id = m_ObjectList.AddObject(pObject);
}
// 엘레베이터 이미지
pObject = new CObjectImage(m_wid_parent, m_gc, 510, 175, 207, 258);
if(pObject)
{
pObject->LoadImage(IMG_BACKGROUND, "/app/img/elevator_image.png");
id = m_ObjectList.AddObject(pObject);
}
// 엘레베이터 층표시 박스 이미지
pObject = new CObjectImage(m_wid_parent, m_gc, 339, 240, 143, 127);
if(pObject)
{
pObject->LoadImage(IMG_BACKGROUND, "/app/img/elevator_display.png");
id = m_ObjectList.AddObject(pObject);
}
// 엘레베이터 화살표
// pObject = new CObjectIcon(m_wid_parent, m_gc, 336, 245, 137, 137);
pObject = new CObjectIcon(m_wid_parent, m_gc, 232, 210, 86, 190);
if(pObject)
{
pObjectIcon = (CObjectIcon*)pObject;
pObjectIcon->AllocImageCount(IMG_ENUM_ARROW_COUNT);
pObject->LoadImage(IMG_ENUM_ARROW_BLANK, "/app/img/el_png/arrow_back.png");
pObject->LoadImage(IMG_ENUM_ARROW_UP_1, "/app/img/el_png/arrow_up_1.png");
pObject->LoadImage(IMG_ENUM_ARROW_UP_2, "/app/img/el_png/arrow_up_2.png");
pObject->LoadImage(IMG_ENUM_ARROW_UP_3, "/app/img/el_png/arrow_up_3.png");
pObject->LoadImage(IMG_ENUM_ARROW_DOWN_1, "/app/img/el_png/arrow_down_1.png");
pObject->LoadImage(IMG_ENUM_ARROW_DOWN_2, "/app/img/el_png/arrow_down_2.png");
pObject->LoadImage(IMG_ENUM_ARROW_DOWN_3, "/app/img/el_png/arrow_down_3.png");
id = m_ObjectList.AddObject(pObject);
}
}
void CContextElevator::DeInit()
{
CContext::DeInit();
m_ObjectList.RemoveAll();
}
void CContextElevator::Draw(UINT nContextNum)
{
CObjectIcon* pObjectIcon = NULL;
if(m_gc==0) return;
DBGMSGC(DBG_ELEVATOR, "++ [%d]\r\n", nContextNum);
//배경
m_ObjectList.Draw(ELEVATOR_OBJ_BG);
//아이콘
m_ObjectList.Draw(ELEVATOR_OBJ_ICON);
//텍스트
// DrawText("엘레베이터를 호출하였습니다", m_wid_parent, m_gc, 245, 89, 500, 32, g_font, 24, WHITE, TXT_HALIGN_LEFT|TXT_VALIGN_MIDDLE);
//엘레베이터 이미지
m_ObjectList.Draw(ELEVATOR_OBJ_IMAGE);
//엘레베이터 층표시 박스
m_ObjectList.Draw(ELEVATOR_OBJ_DISPLAY);
switch(nContextNum)
{
case 0:
if(g_setup_data.m_SetupData.wallpad_type == WALLPAD_TYPE_SHN)
{
DrawText("엘레베이터 상태 확인중 입니다", m_wid_parent, m_gc, 245, 89, 500, 32, g_font, 24, WHITE, TXT_HALIGN_LEFT|TXT_VALIGN_MIDDLE);
}
else
{
DrawText("엘레베이터를 호출하였습니다", m_wid_parent, m_gc, 245, 89, 500, 32, g_font, 24, WHITE, TXT_HALIGN_LEFT|TXT_VALIGN_MIDDLE);
}
break;
case 1:
if(g_setup_data.m_SetupData.wallpad_type == WALLPAD_TYPE_KCM)
{
DrawText("엘레베이터 응답이 없습니다", m_wid_parent, m_gc, 245, 89, 500, 32, g_font, 24, WHITE, TXT_HALIGN_LEFT|TXT_VALIGN_MIDDLE);
}
break;
case 2:
if(g_setup_data.m_SetupData.wallpad_type == WALLPAD_TYPE_KCM)
{
switch(m_nElevatorDir)
{
case MTM_DATA_EV_STATUS_STOP:
DrawText("엘레베이터가 정지해 있습니다", m_wid_parent, m_gc, 245, 89, 500, 32, g_font, 24, WHITE, TXT_HALIGN_LEFT|TXT_VALIGN_MIDDLE);
break;
case MTM_DATA_EV_STATUS_UP:
case MTM_DATA_EV_STATUS_DOWN:
DrawText("엘레베이터가 이동중 입니다", m_wid_parent, m_gc, 245, 89, 500, 32, g_font, 24, WHITE, TXT_HALIGN_LEFT|TXT_VALIGN_MIDDLE);
break;
case MTM_DATA_EV_STATUS_ARRIVE:
DrawText("엘레베이터가 도착 하였습니다", m_wid_parent, m_gc, 245, 89, 500, 32, g_font, 24, WHITE, TXT_HALIGN_LEFT|TXT_VALIGN_MIDDLE);
break;
}
}
break;
}
DBGMSGC(DBG_ELEVATOR, "--\r\n");
}
void CContextElevator::Proc(UINT nContextNum)
{
DBGMSGC(DBG_ELEVATOR, "++ [%d]\r\n", nContextNum);
switch(nContextNum)
{
case 0:
m_nElevatorDir = 0;
m_nElevatorFloor = 0;
m_pObjectIcon = (CObjectIcon*)m_ObjectList.FindObjectByID(ELEVATOR_OBJ_ARROW);
m_nThreadStep = 0;
if (g_pWallPad) {
g_pWallPad->RequestElevatorCall();
PlayWavFile("/app/sound/elevator.wav\0");
// g_timer.KillTimer(BACK_LIGHT_TIMER);
// 백라이트 타이머 : 5분
g_timer.SetTimer(BACK_LIGHT_TIMER, ELEVATOR_CALL_WAIT_TIME, NULL, "LCD BackLight Timer");
}
break;
case 1:
// PlayWavFile("/app/sound/elevator.wav\0");
break;
}
DBGMSGC(DBG_ELEVATOR, "--\r\n");
}
void CContextElevator::TimerProc(UINT idTimer)
{
switch(idTimer)
{
case RESPONSE_TIMER:
if(g_pWallPad)
g_pWallPad->RequestElevatorCall();
break;
case RETRY_TIMEOUT:
ChangeContext(1);
break;
}
}
void CContextElevator::RecvProc(UCHAR *pPacket)
{
PMTM_HEADER pHdr = (PMTM_HEADER)pPacket;
PMTM_DATA_ELEVATOR pElevatorInfo;
if(pPacket == NULL) return;
DBGMSGC(DBG_WEATHER, "++\r\n");
switch(pHdr->type)
{
case MTM_DATA_TYPE_WEATHER:
break;
case MTM_DATA_TYPE_PARKING:
break;
case MTM_DATA_TYPE_ELEVATOR:
if(g_isBackLightOn)
{
pElevatorInfo = (PMTM_DATA_ELEVATOR)&pPacket[sizeof(MTM_HEADER)];
switch(pElevatorInfo->status)
{
case MTM_DATA_EV_STATUS_STOP:
case MTM_DATA_EV_STATUS_UP:
case MTM_DATA_EV_STATUS_DOWN:
case MTM_DATA_EV_STATUS_ARRIVE:
m_isElevatorStatusSuccess = (pElevatorInfo->status != MTM_DATA_EV_STATUS_ERROR) ? TRUE : FALSE;
m_nElevatorDir = pElevatorInfo->status;
m_nElevatorFloor = pElevatorInfo->floor;
m_nContextNum = 2; //화면갱신없이 ContextNum만 바꿈. ThreadProc에서 처리목적
// ChangeContext(2);
break;
}
//도착하면 백라이트 타이버 복귀 : 10초
if(pElevatorInfo->status == MTM_DATA_EV_STATUS_ARRIVE)
{
g_timer.SetTimer(BACK_LIGHT_TIMER, BACK_LIGHT_TIME, NULL, "LCD BackLight Timer");
}
}
break;
case MTM_DATA_TYPE_GAS:
break;
case MTM_DATA_TYPE_LIGHT:
break;
case MTM_DATA_TYPE_SECURITY:
break;
}
DBGMSGC(DBG_WEATHER, "--\r\n");
}
void CContextElevator::ThreadProc()
{
static int nArrowStep;
static ULONG ulTickDraw;
char szText[32] = {0,};
//호출이 성공하고 엘리베이터 상태를 모니터링 하는 동안 동작함
// if(m_nContextNum==0) return;
switch(m_nThreadStep)
{
case 0:
nArrowStep = 0;
m_nThreadStep++;
break;
case 1:
if( m_pObjectIcon && (m_nContextNum==2))
{
RedrawImage(m_wid_parent, m_gc, 245, 89, 500, 32, 245, 89, 500, 32, ELEVATOR_OBJ_BG);
switch(m_nElevatorDir)
{
case MTM_DATA_EV_STATUS_STOP:
DrawText("엘레베이터가 정지해 있습니다", m_wid_parent, m_gc, 245, 89, 500, 32, g_font, 24, WHITE, TXT_HALIGN_LEFT|TXT_VALIGN_MIDDLE);
break;
case MTM_DATA_EV_STATUS_UP:
case MTM_DATA_EV_STATUS_DOWN:
DrawText("엘레베이터가 이동중 입니다", m_wid_parent, m_gc, 245, 89, 500, 32, g_font, 24, WHITE, TXT_HALIGN_LEFT|TXT_VALIGN_MIDDLE);
break;
case MTM_DATA_EV_STATUS_ARRIVE:
DrawText("엘레베이터가 도착 하였습니다", m_wid_parent, m_gc, 245, 89, 500, 32, g_font, 24, WHITE, TXT_HALIGN_LEFT|TXT_VALIGN_MIDDLE);
break;
}
//방향표시
if( (m_nElevatorDir == MTM_DATA_EV_STATUS_STOP) || (m_nElevatorDir == MTM_DATA_EV_STATUS_ARRIVE) )
{
m_pObjectIcon->Draw(IMG_ENUM_ARROW_BLANK);
nArrowStep = 0;
}
else if(m_nElevatorDir == MTM_DATA_EV_STATUS_DOWN)
{
switch(nArrowStep)
{
case 0:
m_pObjectIcon->Draw(IMG_ENUM_ARROW_DOWN_1);
break;
case 1:
m_pObjectIcon->Draw(IMG_ENUM_ARROW_DOWN_2);
break;
default:
m_pObjectIcon->Draw(IMG_ENUM_ARROW_DOWN_3);
break;
}
nArrowStep++;
if(nArrowStep==5) nArrowStep=0;
}
else if(m_nElevatorDir == MTM_DATA_EV_STATUS_UP)
{
switch(nArrowStep)
{
case 0:
m_pObjectIcon->Draw(IMG_ENUM_ARROW_UP_1);
break;
case 1:
m_pObjectIcon->Draw(IMG_ENUM_ARROW_UP_2);
break;
default:
m_pObjectIcon->Draw(IMG_ENUM_ARROW_UP_3);
break;
}
nArrowStep++;
if(nArrowStep==5) nArrowStep=0;
}
//층표시
if(m_nElevatorFloor > 0)
{
if(m_nElevatorFloor >= 128)
sprintf(szText, "B%2d\0", 256-m_nElevatorFloor);
else
sprintf(szText, "%3d\0", m_nElevatorFloor);
}
else if(m_nElevatorFloor < 0)
{
sprintf(szText, "B%2d\0", m_nElevatorFloor*(-1));
}
// else
// {
// sprintf(szText, "L\0");
// }
#if 0
DrawText(szText, m_wid_parent, m_gc, 339+13, 240+13, 143-26, 127-26, g_font, 72, WHITE, TXT_HALIGN_CENTER|TXT_VALIGN_MIDDLE);
#else
RedrawImage(m_wid_parent, m_gc, 352, 253, 117, 101, 12, 12, 117, 101, ELEVATOR_OBJ_DISPLAY);
DrawText(szText, m_wid_parent, m_gc, 352, 253, 117, 101, g_font, 72, WHITE, TXT_HALIGN_CENTER|TXT_VALIGN_MIDDLE);
#endif
ulTickDraw = GetTickCount();
m_nThreadStep++;
}
break;
case 2:
if(GetElapsedTick(ulTickDraw) >= 500)
{
m_nThreadStep--;
}
break;
}
}
void CContextElevator::ButtonDown(UINT usGpioFlag, UINT usEventEnum)
{
DBGMSGC(DBG_ELEVATOR, "++\r\n");
if(usEventEnum == MTM_GPIO_BUTTON_DOWN)
{
}
else if(usEventEnum == MTM_GPIO_BUTTON_LONG)
{
#if 0
if( CHK_FLAG(usGpioFlag, BIT_FLAG(GPIO_FRONT_RIGHT_TOP)|BIT_FLAG(GPIO_FRONT_RIGHT_BOTTOM)) ||
CHK_FLAG(usGpioFlag, BIT_FLAG(GPIO_REAR_VOL_UP)|BIT_FLAG(GPIO_REAR_VOL_DOWN)) )
{
g_state.ChangeState(STATE_SETUP);
}
#endif
}
DBGMSGC(DBG_ELEVATOR, "--\r\n");
}
void CContextElevator::ButtonUp(UINT usGpioFlag, UINT usEventEnum)
{
DBGMSGC(DBG_ELEVATOR, "++\r\n");
if(usEventEnum == MTM_GPIO_BUTTON_UP)
{
switch(usGpioFlag)
{
case GPIO_FLAG_FRONT_LEFT_TOP: //Weather
g_state.ChangeState(STATE_WEATHER);
break;
case GPIO_FLAG_FRONT_LEFT_MIDDLE: //Elevator
ChangeContext(0);
break;
case GPIO_FLAG_FRONT_LEFT_BOTTOM: //Parking
g_state.ChangeState(STATE_PARKING);
break;
case GPIO_FLAG_FRONT_RIGHT_TOP: //Gas
g_state.ChangeState(STATE_GAS);
break;
case GPIO_FLAG_FRONT_RIGHT_MIDDLE: //Light
g_state.ChangeState(STATE_LIGHT);
break;
case GPIO_FLAG_FRONT_RIGHT_BOTTOM: //Security
g_state.ChangeState(STATE_SECURITY);
break;
}
//백라이트 타이머 원상복귀 : 10초
if(usGpioFlag != GPIO_FLAG_FRONT_LEFT_MIDDLE)
{
g_timer.SetTimer(BACK_LIGHT_TIMER, BACK_LIGHT_TIME, NULL, "LCD BackLight Timer");
}
}
DBGMSGC(DBG_ELEVATOR, "--\r\n");
}
|
[
"freejack@ubuntu.(none)"
] |
freejack@ubuntu.(none)
|
93fe847067c9bea99f6d82f7592bba9253d7d12c
|
615c7f3cb391f9bb1b8a9b3fe2dcfc238d4956e5
|
/136/136/closest.cpp
|
b3df16a8824810e62ac95448014e5ec8e6be7a48
|
[] |
no_license
|
HelpEverywhere/Phrase1
|
0f07d1d362a63b114cf4eec742d698b872401bb7
|
1120d7a2a546230731e2c7b54812619102795121
|
refs/heads/master
| 2021-01-10T17:46:32.489717
| 2016-02-11T14:53:20
| 2016-02-11T14:53:20
| 50,866,705
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 507
|
cpp
|
#include "stdafx.h"
int abs(int n){
if (n >= 0)
return n;
return -n;
}
void closest()
{
int n;
//n = readnat();
scanf("%d", &n);
if (0 == n)
{
printf("%d", n);
}
else
{
while (true)
{
int m, x = -1, i = 0;
//m = readnat();
scanf("%d", &m);
if (0 == m)
{
break;
}
else
{
while (i < m)
{
int p;
//p = readnat();
scanf("%d", &p);
if (-1 == x || abs(p - n) < abs(x - n))
x = p;
++i;
}
printf("%d\n",x);
}
}
}
}
|
[
"Mike.Zhang@maplesfs.com"
] |
Mike.Zhang@maplesfs.com
|
806927871fe91078c42527e503c28aa857d5ac52
|
961f6147855cb608eefd2ccb7927e65311133efa
|
/util/stream/aligned_ut.cpp
|
0aeb1a4aa422858d6f46961fc5d3a945be8816a2
|
[
"Apache-2.0"
] |
permissive
|
kyper999/catboost_yandex
|
55a79890be28d46748cb4f55dd7a8ad24ab7b354
|
91c41df3d4997dbab57fc1b8a990017270da47c6
|
refs/heads/master
| 2022-10-31T11:21:22.438222
| 2017-07-18T10:25:29
| 2017-07-18T10:25:29
| 97,590,200
| 0
| 1
|
NOASSERTION
| 2022-10-23T09:35:09
| 2017-07-18T11:27:38
|
C
|
UTF-8
|
C++
| false
| false
| 1,296
|
cpp
|
#include "aligned.h"
#include <library/unittest/registar.h>
class TNastyInputStream: public TInputStream {
public:
TNastyInputStream()
: Pos_(0)
{
}
protected:
size_t DoRead(void* buf, size_t len) override {
if (len == 0)
return 0;
*static_cast<unsigned char*>(buf) = static_cast<unsigned char>(Pos_);
++Pos_;
return 1;
}
size_t DoSkip(size_t len) override {
if (len == 0)
return 0;
++Pos_;
return 1;
}
private:
size_t Pos_;
};
SIMPLE_UNIT_TEST_SUITE(TAlignedTest) {
SIMPLE_UNIT_TEST(AlignInput) {
TNastyInputStream input0;
TAlignedInput alignedInput(&input0);
char c = '\1';
alignedInput.Align(2);
alignedInput.ReadChar(c);
UNIT_ASSERT_VALUES_EQUAL(c, '\x0');
alignedInput.Align(2);
alignedInput.ReadChar(c);
UNIT_ASSERT_VALUES_EQUAL(c, '\x2');
alignedInput.Align(4);
alignedInput.ReadChar(c);
UNIT_ASSERT_VALUES_EQUAL(c, '\x4');
alignedInput.Align(16);
alignedInput.ReadChar(c);
UNIT_ASSERT_VALUES_EQUAL(c, '\x10');
alignedInput.Align(128);
alignedInput.ReadChar(c);
UNIT_ASSERT_VALUES_EQUAL(c, '\x80');
}
}
|
[
"exprmntr@pepe.search.yandex.net"
] |
exprmntr@pepe.search.yandex.net
|
dd29684e3e8874a1c605e53236e39a52a5b3fe58
|
d6e3150e58f78ef0c2c08f5ef4493b9951c8bb7d
|
/Chapter12/Practice12_1/Practice12_1.cpp
|
24431c7965910eac2b5a5a820e9d1be93c95a94c
|
[] |
no_license
|
SuperNova911/MFC-Class
|
fdba15bc6c456322bd6b758de397cebd4f305f7c
|
02d53bc34626f6991ea89ce4eb6c341574a5498a
|
refs/heads/master
| 2021-04-15T15:37:15.289858
| 2018-06-15T03:29:58
| 2018-06-15T03:29:58
| 126,199,036
| 0
| 0
| null | null | null | null |
UHC
|
C++
| false
| false
| 5,943
|
cpp
|
// Practice12_1.cpp : 응용 프로그램에 대한 클래스 동작을 정의합니다.
//
#include "stdafx.h"
#include "afxwinappex.h"
#include "afxdialogex.h"
#include "Practice12_1.h"
#include "MainFrm.h"
#include "Practice12_1Doc.h"
#include "Practice12_1View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CPractice12_1App
BEGIN_MESSAGE_MAP(CPractice12_1App, CWinAppEx)
ON_COMMAND(ID_APP_ABOUT, &CPractice12_1App::OnAppAbout)
// 표준 파일을 기초로 하는 문서 명령입니다.
ON_COMMAND(ID_FILE_NEW, &CWinAppEx::OnFileNew)
ON_COMMAND(ID_FILE_OPEN, &CWinAppEx::OnFileOpen)
END_MESSAGE_MAP()
// CPractice12_1App 생성
CPractice12_1App::CPractice12_1App()
{
m_bHiColorIcons = TRUE;
// 다시 시작 관리자 지원
m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_ALL_ASPECTS;
#ifdef _MANAGED
// 응용 프로그램을 공용 언어 런타임 지원을 사용하여 빌드한 경우(/clr):
// 1) 이 추가 설정은 다시 시작 관리자 지원이 제대로 작동하는 데 필요합니다.
// 2) 프로젝트에서 빌드하려면 System.Windows.Forms에 대한 참조를 추가해야 합니다.
System::Windows::Forms::Application::SetUnhandledExceptionMode(System::Windows::Forms::UnhandledExceptionMode::ThrowException);
#endif
// TODO: 아래 응용 프로그램 ID 문자열을 고유 ID 문자열로 바꾸십시오(권장).
// 문자열에 대한 서식: CompanyName.ProductName.SubProduct.VersionInformation
SetAppID(_T("Practice12_1.AppID.NoVersion"));
// TODO: 여기에 생성 코드를 추가합니다.
// InitInstance에 모든 중요한 초기화 작업을 배치합니다.
}
// 유일한 CPractice12_1App 개체입니다.
CPractice12_1App theApp;
// CPractice12_1App 초기화
BOOL CPractice12_1App::InitInstance()
{
// 응용 프로그램 매니페스트가 ComCtl32.dll 버전 6 이상을 사용하여 비주얼 스타일을
// 사용하도록 지정하는 경우, Windows XP 상에서 반드시 InitCommonControlsEx()가 필요합니다.
// InitCommonControlsEx()를 사용하지 않으면 창을 만들 수 없습니다.
INITCOMMONCONTROLSEX InitCtrls;
InitCtrls.dwSize = sizeof(InitCtrls);
// 응용 프로그램에서 사용할 모든 공용 컨트롤 클래스를 포함하도록
// 이 항목을 설정하십시오.
InitCtrls.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&InitCtrls);
CWinAppEx::InitInstance();
// OLE 라이브러리를 초기화합니다.
if (!AfxOleInit())
{
AfxMessageBox(IDP_OLE_INIT_FAILED);
return FALSE;
}
AfxEnableControlContainer();
EnableTaskbarInteraction(FALSE);
// RichEdit 컨트롤을 사용하려면 AfxInitRichEdit2()가 있어야 합니다.
// AfxInitRichEdit2();
// 표준 초기화
// 이들 기능을 사용하지 않고 최종 실행 파일의 크기를 줄이려면
// 아래에서 필요 없는 특정 초기화
// 루틴을 제거해야 합니다.
// 해당 설정이 저장된 레지스트리 키를 변경하십시오.
// TODO: 이 문자열을 회사 또는 조직의 이름과 같은
// 적절한 내용으로 수정해야 합니다.
SetRegistryKey(_T("로컬 응용 프로그램 마법사에서 생성된 응용 프로그램"));
LoadStdProfileSettings(4); // MRU를 포함하여 표준 INI 파일 옵션을 로드합니다.
InitContextMenuManager();
InitKeyboardManager();
InitTooltipManager();
CMFCToolTipInfo ttParams;
ttParams.m_bVislManagerTheme = TRUE;
theApp.GetTooltipManager()->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL,
RUNTIME_CLASS(CMFCToolTipCtrl), &ttParams);
// 응용 프로그램의 문서 템플릿을 등록합니다. 문서 템플릿은
// 문서, 프레임 창 및 뷰 사이의 연결 역할을 합니다.
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CPractice12_1Doc),
RUNTIME_CLASS(CMainFrame), // 주 SDI 프레임 창입니다.
RUNTIME_CLASS(CPractice12_1View));
if (!pDocTemplate)
return FALSE;
AddDocTemplate(pDocTemplate);
// 표준 셸 명령, DDE, 파일 열기에 대한 명령줄을 구문 분석합니다.
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// 명령줄에 지정된 명령을 디스패치합니다.
// 응용 프로그램이 /RegServer, /Register, /Unregserver 또는 /Unregister로 시작된 경우 FALSE를 반환합니다.
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// 창 하나만 초기화되었으므로 이를 표시하고 업데이트합니다.
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
return TRUE;
}
int CPractice12_1App::ExitInstance()
{
//TODO: 추가한 추가 리소스를 처리합니다.
AfxOleTerm(FALSE);
return CWinAppEx::ExitInstance();
}
// CPractice12_1App 메시지 처리기
// 응용 프로그램 정보에 사용되는 CAboutDlg 대화 상자입니다.
class CAboutDlg : public CDialogEx
{
public:
CAboutDlg();
// 대화 상자 데이터입니다.
#ifdef AFX_DESIGN_TIME
enum { IDD = IDD_ABOUTBOX };
#endif
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 지원입니다.
// 구현입니다.
protected:
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialogEx(IDD_ABOUTBOX)
{
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx)
END_MESSAGE_MAP()
// 대화 상자를 실행하기 위한 응용 프로그램 명령입니다.
void CPractice12_1App::OnAppAbout()
{
CAboutDlg aboutDlg;
aboutDlg.DoModal();
}
// CPractice12_1App 사용자 지정 로드/저장 메서드
void CPractice12_1App::PreLoadState()
{
BOOL bNameValid;
CString strName;
bNameValid = strName.LoadString(IDS_EDIT_MENU);
ASSERT(bNameValid);
GetContextMenuManager()->AddMenu(strName, IDR_POPUP_EDIT);
}
void CPractice12_1App::LoadCustomState()
{
}
void CPractice12_1App::SaveCustomState()
{
}
// CPractice12_1App 메시지 처리기
|
[
"suwhan77@naver.com"
] |
suwhan77@naver.com
|
8afb4ddcb87e6dde70b25838afb89860ae1935bb
|
18aeeee08da1ca1ec2f68e73510e39630f662635
|
/src/ConstanzeComponent.hpp
|
460f1d03e681d40904bf89de0058b8097385fea2
|
[] |
no_license
|
openwns/constanze
|
bcac826526c845cd9f844c2c4f019cc234a14bf0
|
1804214f71552744ca2ec719fcb250df289d8725
|
refs/heads/master
| 2016-08-07T18:00:44.409415
| 2014-06-29T23:28:28
| 2014-06-29T23:28:28
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,297
|
hpp
|
/*******************************************************************************
* This file is part of openWNS (open Wireless Network Simulator)
* _____________________________________________________________________________
*
* Copyright (C) 2004-2007
* Chair of Communication Networks (ComNets)
* Kopernikusstr. 16, D-52074 Aachen, Germany
* phone: ++49-241-80-27910,
* fax: ++49-241-80-22242
* email: info@openwns.org
* www: http://www.openwns.org
* _____________________________________________________________________________
*
* openWNS is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License version 2 as published by the
* Free Software Foundation;
*
* openWNS is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
******************************************************************************/
#ifndef CONSTANZE_COMPONENT_HPP
#define CONSTANZE_COMPONENT_HPP
#include <CONSTANZE/Generator.hpp>
#include <WNS/node/component/Component.hpp>
#include <WNS/logger/Logger.hpp>
#include <list>
namespace constanze {
class GeneratorBase;
class Binding;
class Listener;
/**
* @brief Constanze Component (layer above IP,UDP,TCP,SimpleTL,Glue)
*/
class ConstanzeComponent :
virtual public wns::node::component::Component
{
public:
/**
* @brief ConstanzeComponent constructor
*
* @param[in] _node The parent node.
*
* @param[in] _pyco Component configuration of type
* constanze.ConstanzeComponent
*/
ConstanzeComponent(
wns::node::Interface* _node,
const wns::pyconfig::View& _pyco);
/**
* @brief ConstanzeComponent destructor
*/
virtual ~ConstanzeComponent();
/**
* @brief Connect to required components within the same node.
*/
virtual void
onNodeCreated();
/**
* @brief Connect to components in other nodes
*/
virtual void
onWorldCreated();
/**
* @brief Clean up before EventScheduler really stops
*/
virtual void
onShutdown();
private:
/**
* @brief Services are added here
*/
virtual void
doStartup();
/**
* @brief All generators created are put to this list.
*/
std::list<constanze::GeneratorBase*> listOfGenerators;
/**
* @brief Bindings created for the generators.
*/
std::list<constanze::Binding*> listOfGeneratorBindings;
/**
* @brief All listeners created are put to this list.
*/
std::list<constanze::Listener*> listOfListeners;
/**
* @brief Bindings created for the listeners.
*/
std::list<constanze::Binding*> listOfListenerBindings;
/**
* @brief The components configuration.
*/
wns::pyconfig::View pyco;
/**
* @brief The Logger instance.
*/
wns::logger::Logger log;
};
}
#endif // _CONSTANZE_COMPONENT_HPP
/*
Local Variables:
mode: c++
fill-column: 80
c-basic-offset: 8
c-comment-only-line-offset: 0
c-tab-always-indent: t
indent-tabs-mode: t
tab-width: 8
End:
*/
|
[
"mue@comnets.rwth-aachen.de"
] |
mue@comnets.rwth-aachen.de
|
312981ac31fb76117fc883ebf8ff5da9b0afc76e
|
0e5835408690913eb8b30c2cd81bb07f7e0cddc5
|
/Server/database.h
|
49b4dc3392052a41b356b0a23fa63fde5044a7ee
|
[] |
no_license
|
Karaylev96/ChatApp
|
5bae0e2da843c3a6ae0553f0ba470d2ac0d0f978
|
1709685b0fe454fb8222b4bc34c107d19c34208e
|
refs/heads/master
| 2021-09-06T21:58:38.796904
| 2018-02-12T09:04:54
| 2018-02-12T09:04:54
| 115,921,677
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 566
|
h
|
#ifndef DATABASE_H
#define DATABASE_H
#include <stdio.h>
#include <QDebug>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QSqlQueryModel>
#include <QtSql/QSqlDatabase>
#include <QtDebug>
//#include <QtGui/QApplication>
#include <QtSql>
#include <QMessageLogger>
#include <QTcpSocket>
class Database
{
public:
Database();
QSqlDatabase addQry();
bool findUser(const QString& user);
void addToDataBase(const QString & user,const QString& ipAdres);
private:
QSqlDatabase m_db;
int rc;
};
#endif // DATABASE_H
|
[
"karailev96@gmail.com"
] |
karailev96@gmail.com
|
3db1d8ba3cc78ae6f0d286ba74ba205efe29311b
|
e4f9418990bfa3e07357c09922bd713432d4fefe
|
/include/E/Networking/E_NetworkLog.hpp
|
d14c40120cdedead8dc7d74ddacea73350d3f856
|
[
"MIT"
] |
permissive
|
TerrySunty/KENS
|
7bac2ba1e3d75d4d98b618373e748f5f8edf4c7c
|
3fbd998830fbee0e9a6d3a072262034c178ccd16
|
refs/heads/master
| 2020-04-07T16:42:25.885705
| 2017-05-13T13:40:20
| 2017-05-13T13:40:20
| 158,539,716
| 0
| 1
|
MIT
| 2018-11-21T11:46:25
| 2018-11-21T11:46:25
| null |
UTF-8
|
C++
| false
| false
| 2,202
|
hpp
|
/**
* @file E_NetworkLog.hpp
* @Author leeopop (dlrmsghd@gmail.com)
* @date November, 2014
* @brief Header for E::NetworkLog
*/
#ifndef E_NETWORKLOG_HPP_
#define E_NETWORKLOG_HPP_
#include <E/E_Common.hpp>
namespace E
{
/**
* @brief Log provides log-related utilities for network modules.
* We recommend you to inherit this class privately to a network module,
* and it will enable NetworkLog::print_log in your namespace.
*
* @note You cannot use both Log and NetworkLog simultaneously.
* @see E::Log
*/
class NetworkSystem;
class NetworkLog
{
private:
uint64_t level;
NetworkSystem* system;
public:
/**
* @brief Constructs a NetworkLog instance.
*
* @param system NetworkSystem of a NetworkModule
*/
NetworkLog(NetworkSystem* system);
/**
* @brief Constructs a NetworkLog instance with log level.
*
* @param system NetworkSystem of a NetworkModule
* @param level log level
*/
NetworkLog(NetworkSystem* system, uint64_t level);
/**
* @brief Destructs a NetworkLog instance.
*
*/
~NetworkLog();
/**
* @brief Enumerations for log levels.
*
*/
enum LOG_LEVEL
{
PACKET_TO_MODULE = 0UL,
PACKET_FROM_MODULE,
PACKET_TO_HOST,
PACKET_FROM_HOST,
PACKET_ALLOC,
PACKET_CLONE,
PACKET_FREE,
PACKET_QUEUE,
PACKET_DROPPED,
SYSCALL_RAISED,
SYSCALL_FINISHED,
SYSCALL_BLOCKED,
SYSCALL_UNBLOCKED,
SYSCALL_ERROR,
MODULE_ERROR,
PROTOCOL_ERROR,
PROTOCOL_WARNING,
TCP_LOG,
LEVEL_COUNT,
};
protected:
/**
* @brief Prints log with specified log level and format.
* NetworkLog::print_log prints logs specified in log level parameter.
* For example, if log level is set to TCP_LOG, it only prints TCP_LOG logs.
* If you want to print multiple log levels in NetworkLog,
* you can set log level with OR operation (i.e. SYSCALL_ERROR | MODULE_ERROR).
*
* @note Log::print_log
*
* @param level log level
* @param format Format string
* @param ... Print arguments for format string
*
*/
void print_log(uint64_t level, const char* format, ...) __attribute__((format(printf,3,4)));
public:
/**
* @brief Default log level.
*
*/
static uint64_t defaultLevel;
};
}
#endif /* E_NETWORKLOG_HPP_ */
|
[
"wwiiiii@naver.com"
] |
wwiiiii@naver.com
|
8ce53c78d3aea48229b4cfa0000961e3a9290b9d
|
71beff3e20a58fdfeefb5590bba7082fe0bc8292
|
/src/GUI/Screen/ScreenHighscores.cpp
|
7c4776defe0303ac1416417df17dbce52a732b00
|
[] |
no_license
|
milandamen/grimwall
|
351ea51f2018fdb8d4f388c682eca818344f7aec
|
04156b9d5c3bf8f4c31fdb282c6bccbd7e13ea8a
|
refs/heads/master
| 2021-06-15T15:38:33.057796
| 2017-01-17T13:55:23
| 2017-01-17T13:55:23
| 70,218,635
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,151
|
cpp
|
#include "ScreenHighscores.h"
ScreenHighscores::ScreenHighscores(IGame* game,AGUIManager* manager)
: GUI(manager), game(game)
{
this->imgBg = manager->addImage("assets/gui/backgroundMenu.png", 0, 0, 1024, 768);
this->lblSlot1 = manager->addLabel("", 172, 300);
this->lblSlot1->setWidth(200);
this->lblSlot1->setHeight(100);
this->lblSlot1->setAlignment(GUITextAlignment::Center);
this->lblSlot2 = manager->addLabel("", 402, 300);
this->lblSlot2->setWidth(200);
this->lblSlot2->setHeight(100);
this->lblSlot2->setAlignment(GUITextAlignment::Center);
this->lblSlot3 = manager->addLabel("", 632, 300);
this->lblSlot3->setWidth(200);
this->lblSlot3->setHeight(100);
this->lblSlot3->setAlignment(GUITextAlignment::Center);
this->btnReturn = manager->addImageButton("", "assets/gui/settingReturn.png", 172, 650, 680, 100);
this->btnReturn->setForegroundColor(255, 255, 255, 255);
this->btnReturn->setBackgroundColor(0, 0, 0, 0);
this->btnReturn->onClick([&]() {
this->game->setUI("MainMenu");
});
}
ScreenHighscores::~ScreenHighscores()
{
delete this->imgBg;
delete this->btnReturn;
}
void ScreenHighscores::hasBecomeActive()
{
if(!this->loaded) {
this->loaded = true;
try {
SaveGame *s1 = this->game->getSaveGameManager()->load("slot1.sav");
this->lblSlot1->setCaption("Score: " + (s1 != nullptr ? s1->score : 0));
delete s1;
} catch(...) {
this->lblSlot1->setCaption("Score: 0");
}
try {
SaveGame *s2 = this->game->getSaveGameManager()->load("slot2.sav");
this->lblSlot2->setCaption("Score: " + (s2 != nullptr ? s2->score : 0));
delete s2;
} catch (...) {
this->lblSlot2->setCaption("Score: 0");
}
try {
SaveGame *s3 = this->game->getSaveGameManager()->load("slot3.sav");
this->lblSlot3->setCaption("Score: " + (s3 != nullptr ? s3->score : 0));
delete s3;
} catch(...) {
this->lblSlot3->setCaption("Score: 0");
}
}
}
|
[
"sromer@avans.nl"
] |
sromer@avans.nl
|
0c49d36631f18dca9d1ba0f34e5c19440d8bc231
|
d555c767df66a7b3bde1eab92dc5d55c25973762
|
/internal/catch_list.hpp
|
85e19345a4d9fef457a5a417ba299aa0854a5300
|
[
"BSL-1.0"
] |
permissive
|
Tryneus/Catch
|
c32c3ee4387722a897aa73ec74a352b0764b9149
|
52926d8f989cd2401d88c3892bb1ed1a56f1a698
|
refs/heads/master
| 2021-01-16T00:17:11.145192
| 2011-02-09T20:11:13
| 2011-02-09T20:11:13
| 1,343,925
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,351
|
hpp
|
/*
* catch_list.hpp
* Catch
*
* Created by Phil on 5/11/2010.
* Copyright 2010 Two Blue Cubes Ltd. All rights reserved.
*
* Distributed under the Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*
*/
#ifndef TWOBLUECUBES_CATCH_LIST_HPP_INCLUDED
#define TWOBLUECUBES_CATCH_LIST_HPP_INCLUDED
#include "catch_commandline.hpp"
#include <limits>
namespace Catch
{
///////////////////////////////////////////////////////////////////////////
inline int List
(
const Config& config
)
{
if( config.listWhat() & Config::List::Reports )
{
std::cout << "Available reports:\n";
IReporterRegistry::FactoryMap::const_iterator it = Hub::getReporterRegistry().getFactories().begin();
IReporterRegistry::FactoryMap::const_iterator itEnd = Hub::getReporterRegistry().getFactories().end();
for(; it != itEnd; ++it )
{
// !TBD: consider listAs()
std::cout << "\t" << it->first << "\n\t\t'" << it->second->getDescription() << "'\n";
}
std::cout << std::endl;
}
if( config.listWhat() & Config::List::Tests )
{
std::cout << "Available tests:\n";
std::vector<TestCaseInfo>::const_iterator it = Hub::getTestCaseRegistry().getAllTests().begin();
std::vector<TestCaseInfo>::const_iterator itEnd = Hub::getTestCaseRegistry().getAllTests().end();
for(; it != itEnd; ++it )
{
// !TBD: consider listAs()
std::cout << "\t" << it->getName() << "\n\t\t '" << it->getDescription() << "'\n";
}
std::cout << std::endl;
}
if( ( config.listWhat() & Config::List::All ) == 0 )
{
std::cerr << "Unknown list type" << std::endl;
return std::numeric_limits<int>::max();
}
if( config.getReporter() )
{
std::cerr << "Reporters ignored when listing" << std::endl;
}
if( !config.testsSpecified() )
{
std::cerr << "Test specs ignored when listing" << std::endl;
}
return 0;
}
} // end namespace Catch
#endif // TWOBLUECUBES_CATCH_LIST_HPP_INCLUDED
|
[
"phil@twobluecubes.com"
] |
phil@twobluecubes.com
|
5f0a1bad6a9a5ffb585b0e7e03601a43648ba45a
|
6e9304dd32f44ccab2c2348938b170a0dcec4b66
|
/shader_attribute.cpp
|
57dd7bcaf4489103dc277fa0b6755ec49cf017bc
|
[] |
no_license
|
Walter0697/Flying-Undersized-Controlled-Killer
|
347a301e1da1a894789f295c463c275a272b3c96
|
ed1e9b5dd60d1cf52fef36df8cd11e12b7867af4
|
refs/heads/master
| 2022-02-16T09:34:08.547409
| 2019-08-02T03:46:25
| 2019-08-02T03:46:25
| 104,793,474
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,238
|
cpp
|
#include <iostream>
#include "shader_attribute.h"
namespace game {
ShaderAttribute::ShaderAttribute() {}
ShaderAttribute::ShaderAttribute(std::string name, DataType type, int size, GLfloat *data){
name_ = name;
type_ = type;
size_ = size;
data_ = data;
}
ShaderAttribute::~ShaderAttribute(){
}
std::string ShaderAttribute::GetName(void) const {
return name_;
}
DataType ShaderAttribute::GetType(void) const {
return type_;
}
int ShaderAttribute::GetSize(void) const {
return size_;
}
GLfloat *ShaderAttribute::GetData(void) const {
return data_;
}
void ShaderAttribute::SetData(GLfloat *data) {
data_ = data;
}
void ShaderAttribute::SetupShader(GLuint program){
// Set data in the shader
GLint location = glGetUniformLocation(program, name_.c_str());
if (type_ == FloatType){
glUniform3fv(location, size_, data_);
} else if (type_ == Vec2Type){
glUniform2fv(location, size_ / 2, data_);
} else if (type_ == Vec3Type){
glUniform3fv(location, size_ / 3, data_);
} else if (type_ == Vec4Type){
glUniform4fv(location, size_ / 4, data_);
}
}
} // namespace game
|
[
"noreply@github.com"
] |
Walter0697.noreply@github.com
|
f991129b23eca7d31f3244b1cf151accf89e5f48
|
c74e5e9b6cddbe7abbf92b69a813aff38e580b79
|
/src/casecostview.cpp
|
b6554ac970facba8d1564a070df77a9e107df3dd
|
[] |
no_license
|
damaro05/LawFirmPlatform
|
19981236300cbd2adc154e63e0c3f7298aed7ad4
|
f28dbb8a46b3d80314803ff264cd9b65dca06671
|
refs/heads/master
| 2021-03-24T13:57:03.049933
| 2017-05-25T11:42:10
| 2017-05-25T11:42:10
| 80,528,474
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,993
|
cpp
|
#include "casecostview.h"
#include "ui_tableviewtemplate.h"
#include "models/cmodeltableview.h"
#include "models/cases.h"
#include "models/qjsontablemodel.h"
#include "globals.h"
CaseCostView::CaseCostView()
{
std::cout << "Constractor " << typeid(this).name() << std::endl;
model = new CModelTableView(this);
initializeModel( model, "CostTest" );
setupView();
}
CaseCostView::~CaseCostView()
{
std::cout << "Destructor " << typeid(this).name() << std::endl;
delete model;
}
void CaseCostView::setupView()
{
//Define title and column to be calculated
ui->labelTitle->setText( "Listado de costes" );
sumColumn = 2;
sumColumnType = QString(" €");
ui->tableView->setMinimumWidth( 800 );
ui->tableView->setModel( model );
ui->tableView->resizeColumnsToContents();
ui->tableView->setColumnWidth( 0, (ui->tableView->width()/10) * 2.5 );
ui->tableView->setColumnWidth( 1, (ui->tableView->width()/10) * 5.3 );
ui->tableView->setColumnWidth( 2, (ui->tableView->width()/10) * 1 );
ui->tableView->setColumnWidth( 3, (ui->tableView->width()/10) * 0.5 );
ui->tableView->setColumnWidth( 4, (ui->tableView->width()/10) * 0.5 );
ui->tableView->horizontalHeader()->setStretchLastSection( true );
ui->pushBtnRevert->hide();
ui->pushBtnSubmit->hide();
updateTotalLabel();
}
void CaseCostView::setupData( const Cases& currentCase )
{
RestClient* rc = RestClient::getInstance();
QString url = "cases/" + QString::number( currentCase.idcase() ) + "/cost";
rc->getRequest( url );
QJsonTableModel::Header header;
header.push_back( QJsonTableModel::Heading( {{"title", "Fecha de creación"},{"index","entrydate"}} ) );
header.push_back( QJsonTableModel::Heading( {{"title", "Concepto"},{"index","concept"}} ) );
header.push_back( QJsonTableModel::Heading( {{"title", "Importe"},{"index","amount"}} ) );
header.push_back( QJsonTableModel::Heading( {{"title", "Doc"},{"index","doc"}} ) );
header.push_back( QJsonTableModel::Heading( {{"title", "Estado"},{"index","state"}} ) );
QJsonTableModel* hoursModel = new QJsonTableModel( header, this );
ui->tableView->setModel( hoursModel );
bool hourscases = false;
if( rc->isFinished )
if( rc->isCorrect )
hourscases = true;
if( hourscases ){
QJsonDocument jsonDResponse = QJsonDocument::fromJson( rc->response );
hoursModel->setJson( jsonDResponse );
}
}
void CaseCostView::initializeModel( QSqlTableModel *model, const QString &tablename )
{
model->setTable( tablename );
model->setEditStrategy( QSqlTableModel::OnManualSubmit );
model->select();
model->setHeaderData( 0, Qt::Horizontal, "Fecha" );
model->setHeaderData( 1, Qt::Horizontal, "Concepto" );
model->setHeaderData( 2, Qt::Horizontal, "Importe" );
model->setHeaderData( 3, Qt::Horizontal, "Doc" );
model->setHeaderData( 4, Qt::Horizontal, "Estado" );
newDefaultRow( 0, 1 );
}
|
[
"scmh05@gmail.com"
] |
scmh05@gmail.com
|
21165d044c9b53913d573784e471a4217dd29b2f
|
04c203b271bf5532632a356bc8168c5c7c320f40
|
/lecture08/exercise08-A/template.cpp
|
6b1475a52c9558a38136e534302d5a7d538b6a10
|
[
"MIT"
] |
permissive
|
leahhealy/cse-30872-fa21-examples
|
af30878a1594d5a69ee48b9edf25a89c46df7b5f
|
0ec31cdf9df7aefa3a708a95d49b129022495596
|
refs/heads/master
| 2023-08-25T14:13:33.946240
| 2021-11-07T18:43:07
| 2021-11-07T18:43:07
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 561
|
cpp
|
// Exercise 08-A: Largest Number
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
// Functions
bool read_numbers(vector<string> &numbers) {
numbers.clear();
string line;
if (getline(cin, line)) {
stringstream ss(line);
string n;
while (ss >> n) {
numbers.push_back(n);
}
}
return numbers.size();
}
// Main Execution
int main(int argc, char *argv[]) {
vector<string> numbers;
// TODO: Read numbers, sort, and print
return 0;
}
|
[
"pbui@nd.edu"
] |
pbui@nd.edu
|
e50d9cfad9edb01379fd99896c4ffe3c308c3357
|
600df3590cce1fe49b9a96e9ca5b5242884a2a70
|
/chrome/browser/extensions/process_manager_browsertest.cc
|
4027593333f320b8a3dd916c17fc1d5fd848e795
|
[
"BSD-3-Clause"
] |
permissive
|
metux/chromium-suckless
|
efd087ba4f4070a6caac5bfbfb0f7a4e2f3c438a
|
72a05af97787001756bae2511b7985e61498c965
|
refs/heads/orig
| 2022-12-04T23:53:58.681218
| 2017-04-30T10:59:06
| 2017-04-30T23:35:58
| 89,884,931
| 5
| 3
|
BSD-3-Clause
| 2022-11-23T20:52:53
| 2017-05-01T00:09:08
| null |
UTF-8
|
C++
| false
| false
| 53,111
|
cc
|
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <stddef.h>
#include <memory>
#include <utility>
#include "base/callback.h"
#include "base/macros.h"
#include "base/path_service.h"
#include "base/run_loop.h"
#include "base/test/histogram_tester.h"
#include "chrome/browser/extensions/browser_action_test_util.h"
#include "chrome/browser/extensions/extension_browsertest.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/test_extension_dir.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/extensions/extension_process_policy.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/guest_view/browser/test_guest_view_manager.h"
#include "content/public/browser/child_process_security_policy.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/browser_side_navigation_policy.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/test_navigation_observer.h"
#include "content/public/test/test_utils.h"
#include "extensions/browser/app_window/app_window.h"
#include "extensions/browser/app_window/app_window_registry.h"
#include "extensions/browser/process_manager.h"
#include "extensions/common/permissions/permissions_data.h"
#include "extensions/common/value_builder.h"
#include "extensions/test/background_page_watcher.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
namespace extensions {
namespace {
void AddFrameToSet(std::set<content::RenderFrameHost*>* frames,
content::RenderFrameHost* rfh) {
if (rfh->IsRenderFrameLive())
frames->insert(rfh);
}
GURL CreateBlobURL(content::RenderFrameHost* frame,
const std::string& content) {
std::string blob_url_string;
EXPECT_TRUE(ExecuteScriptAndExtractString(
frame,
"var blob = new Blob(['<html><body>" + content + "</body></html>'],\n"
" {type: 'text/html'});\n"
"domAutomationController.send(URL.createObjectURL(blob));\n",
&blob_url_string));
GURL blob_url(blob_url_string);
EXPECT_TRUE(blob_url.is_valid());
EXPECT_TRUE(blob_url.SchemeIsBlob());
return blob_url;
}
GURL CreateFileSystemURL(content::RenderFrameHost* frame,
const std::string& content) {
std::string filesystem_url_string;
EXPECT_TRUE(ExecuteScriptAndExtractString(
frame,
"var blob = new Blob(['<html><body>" + content + "</body></html>'],\n"
" {type: 'text/html'});\n"
"window.webkitRequestFileSystem(TEMPORARY, blob.size, fs => {\n"
" fs.root.getFile('foo.html', {create: true}, file => {\n"
" file.createWriter(writer => {\n"
" writer.write(blob);\n"
" writer.onwriteend = () => {\n"
" domAutomationController.send(file.toURL());\n"
" }\n"
" });\n"
" });\n"
"});\n",
&filesystem_url_string));
GURL filesystem_url(filesystem_url_string);
EXPECT_TRUE(filesystem_url.is_valid());
EXPECT_TRUE(filesystem_url.SchemeIsFileSystem());
return filesystem_url;
}
std::string GetTextContent(content::RenderFrameHost* frame) {
std::string result;
EXPECT_TRUE(ExecuteScriptAndExtractString(
frame, "domAutomationController.send(document.body.innerText)", &result));
return result;
}
// Helper to send a postMessage from |sender| to |opener| via window.opener,
// wait for a reply, and verify the response. Defines its own message event
// handlers.
void VerifyPostMessageToOpener(content::RenderFrameHost* sender,
content::RenderFrameHost* opener) {
EXPECT_TRUE(
ExecuteScript(opener,
"window.addEventListener('message', function(event) {\n"
" event.source.postMessage(event.data, '*');\n"
"});"));
EXPECT_TRUE(
ExecuteScript(sender,
"window.addEventListener('message', function(event) {\n"
" window.domAutomationController.send(event.data);\n"
"});"));
std::string result;
EXPECT_TRUE(ExecuteScriptAndExtractString(
sender, "opener.postMessage('foo', '*');", &result));
EXPECT_EQ("foo", result);
}
} // namespace
// Takes a snapshot of all frames upon construction. When Wait() is called, a
// MessageLoop is created and Quit when all previously recorded frames are
// either present in the tab, or deleted. If a navigation happens between the
// construction and the Wait() call, then this logic ensures that all obsolete
// RenderFrameHosts have been destructed when Wait() returns.
// See also the comment at ProcessManagerBrowserTest::NavigateToURL.
class NavigationCompletedObserver : public content::WebContentsObserver {
public:
explicit NavigationCompletedObserver(content::WebContents* web_contents)
: content::WebContentsObserver(web_contents),
message_loop_runner_(new content::MessageLoopRunner) {
web_contents->ForEachFrame(
base::Bind(&AddFrameToSet, base::Unretained(&frames_)));
}
void Wait() {
if (!AreAllFramesInTab())
message_loop_runner_->Run();
}
void RenderFrameDeleted(content::RenderFrameHost* rfh) override {
if (frames_.erase(rfh) != 0 && message_loop_runner_->loop_running() &&
AreAllFramesInTab())
message_loop_runner_->Quit();
}
private:
// Check whether all frames that were recorded at the construction of this
// class are still part of the tab.
bool AreAllFramesInTab() {
std::set<content::RenderFrameHost*> current_frames;
web_contents()->ForEachFrame(
base::Bind(&AddFrameToSet, base::Unretained(¤t_frames)));
for (content::RenderFrameHost* frame : frames_) {
if (current_frames.find(frame) == current_frames.end())
return false;
}
return true;
}
std::set<content::RenderFrameHost*> frames_;
scoped_refptr<content::MessageLoopRunner> message_loop_runner_;
DISALLOW_COPY_AND_ASSIGN(NavigationCompletedObserver);
};
// Exists as a browser test because ExtensionHosts are hard to create without
// a real browser.
class ProcessManagerBrowserTest : public ExtensionBrowserTest {
public:
// Create an extension with web-accessible frames and an optional background
// page.
const Extension* CreateExtension(const std::string& name,
bool has_background_process) {
std::unique_ptr<TestExtensionDir> dir(new TestExtensionDir());
DictionaryBuilder manifest;
manifest.Set("name", name)
.Set("version", "1")
.Set("manifest_version", 2)
// To allow ExecuteScript* to work.
.Set("content_security_policy",
"script-src 'self' 'unsafe-eval'; object-src 'self'")
.Set("sandbox",
DictionaryBuilder()
.Set("pages", ListBuilder().Append("sandboxed.html").Build())
.Build())
.Set("web_accessible_resources", ListBuilder().Append("*").Build());
if (has_background_process) {
manifest.Set("background",
DictionaryBuilder().Set("page", "bg.html").Build());
dir->WriteFile(FILE_PATH_LITERAL("bg.html"),
"<iframe id='bgframe' src='empty.html'></iframe>");
}
dir->WriteFile(FILE_PATH_LITERAL("blank_iframe.html"),
"<iframe id='frame0' src='about:blank'></iframe>");
dir->WriteFile(FILE_PATH_LITERAL("srcdoc_iframe.html"),
"<iframe id='frame0' srcdoc='Hello world'></iframe>");
dir->WriteFile(FILE_PATH_LITERAL("two_iframes.html"),
"<iframe id='frame1' src='empty.html'></iframe>"
"<iframe id='frame2' src='empty.html'></iframe>");
dir->WriteFile(FILE_PATH_LITERAL("sandboxed.html"), "Some sandboxed page");
dir->WriteFile(FILE_PATH_LITERAL("empty.html"), "");
dir->WriteManifest(manifest.ToJSON());
const Extension* extension = LoadExtension(dir->UnpackedPath());
EXPECT_TRUE(extension);
temp_dirs_.push_back(std::move(dir));
return extension;
}
// ui_test_utils::NavigateToURL sometimes returns too early: It returns as
// soon as the StopLoading notification has been triggered. This does not
// imply that RenderFrameDeleted was called, so the test may continue too
// early and fail when ProcessManager::GetAllFrames() returns too many frames
// (namely frames that are in the process of being deleted). To work around
// this problem, we also wait until all previous frames have been deleted.
void NavigateToURL(const GURL& url) {
NavigationCompletedObserver observer(
browser()->tab_strip_model()->GetActiveWebContents());
ui_test_utils::NavigateToURL(browser(), url);
// Wait until the last RenderFrameHosts are deleted. This wait doesn't take
// long.
observer.Wait();
}
size_t IfExtensionsIsolated(size_t if_enabled, size_t if_disabled) {
return content::AreAllSitesIsolatedForTesting() ||
IsIsolateExtensionsEnabled()
? if_enabled
: if_disabled;
}
content::WebContents* OpenPopup(content::RenderFrameHost* opener,
const GURL& url) {
content::WindowedNotificationObserver popup_observer(
chrome::NOTIFICATION_TAB_ADDED,
content::NotificationService::AllSources());
EXPECT_TRUE(ExecuteScript(
opener, "window.popup = window.open('" + url.spec() + "')"));
popup_observer.Wait();
content::WebContents* popup =
browser()->tab_strip_model()->GetActiveWebContents();
WaitForLoadStop(popup);
EXPECT_EQ(url, popup->GetMainFrame()->GetLastCommittedURL());
return popup;
}
private:
std::vector<std::unique_ptr<TestExtensionDir>> temp_dirs_;
};
// Test that basic extension loading creates the appropriate ExtensionHosts
// and background pages.
IN_PROC_BROWSER_TEST_F(ProcessManagerBrowserTest,
ExtensionHostCreation) {
ProcessManager* pm = ProcessManager::Get(profile());
// We start with no background hosts.
ASSERT_EQ(0u, pm->background_hosts().size());
ASSERT_EQ(0u, pm->GetAllFrames().size());
// Load an extension with a background page.
scoped_refptr<const Extension> extension =
LoadExtension(test_data_dir_.AppendASCII("api_test")
.AppendASCII("browser_action")
.AppendASCII("none"));
ASSERT_TRUE(extension.get());
// Process manager gains a background host.
EXPECT_EQ(1u, pm->background_hosts().size());
EXPECT_EQ(1u, pm->GetAllFrames().size());
EXPECT_TRUE(pm->GetBackgroundHostForExtension(extension->id()));
EXPECT_TRUE(pm->GetSiteInstanceForURL(extension->url()));
EXPECT_EQ(1u, pm->GetRenderFrameHostsForExtension(extension->id()).size());
EXPECT_FALSE(pm->IsBackgroundHostClosing(extension->id()));
EXPECT_EQ(0, pm->GetLazyKeepaliveCount(extension.get()));
// Unload the extension.
UnloadExtension(extension->id());
// Background host disappears.
EXPECT_EQ(0u, pm->background_hosts().size());
EXPECT_EQ(0u, pm->GetAllFrames().size());
EXPECT_FALSE(pm->GetBackgroundHostForExtension(extension->id()));
EXPECT_TRUE(pm->GetSiteInstanceForURL(extension->url()));
EXPECT_EQ(0u, pm->GetRenderFrameHostsForExtension(extension->id()).size());
EXPECT_FALSE(pm->IsBackgroundHostClosing(extension->id()));
EXPECT_EQ(0, pm->GetLazyKeepaliveCount(extension.get()));
}
// Test that loading an extension with a browser action does not create a
// background page and that clicking on the action creates the appropriate
// ExtensionHost.
// Disabled due to flake, see http://crbug.com/315242
IN_PROC_BROWSER_TEST_F(ProcessManagerBrowserTest,
DISABLED_PopupHostCreation) {
ProcessManager* pm = ProcessManager::Get(profile());
// Load an extension with the ability to open a popup but no background
// page.
scoped_refptr<const Extension> popup =
LoadExtension(test_data_dir_.AppendASCII("api_test")
.AppendASCII("browser_action")
.AppendASCII("popup"));
ASSERT_TRUE(popup.get());
// No background host was added.
EXPECT_EQ(0u, pm->background_hosts().size());
EXPECT_EQ(0u, pm->GetAllFrames().size());
EXPECT_FALSE(pm->GetBackgroundHostForExtension(popup->id()));
EXPECT_EQ(0u, pm->GetRenderFrameHostsForExtension(popup->id()).size());
EXPECT_TRUE(pm->GetSiteInstanceForURL(popup->url()));
EXPECT_FALSE(pm->IsBackgroundHostClosing(popup->id()));
EXPECT_EQ(0, pm->GetLazyKeepaliveCount(popup.get()));
// Simulate clicking on the action to open a popup.
BrowserActionTestUtil test_util(browser());
content::WindowedNotificationObserver frame_observer(
content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME,
content::NotificationService::AllSources());
// Open popup in the first extension.
test_util.Press(0);
frame_observer.Wait();
ASSERT_TRUE(test_util.HasPopup());
// We now have a view, but still no background hosts.
EXPECT_EQ(0u, pm->background_hosts().size());
EXPECT_EQ(1u, pm->GetAllFrames().size());
EXPECT_FALSE(pm->GetBackgroundHostForExtension(popup->id()));
EXPECT_EQ(1u, pm->GetRenderFrameHostsForExtension(popup->id()).size());
EXPECT_TRUE(pm->GetSiteInstanceForURL(popup->url()));
EXPECT_FALSE(pm->IsBackgroundHostClosing(popup->id()));
EXPECT_EQ(0, pm->GetLazyKeepaliveCount(popup.get()));
}
// Content loaded from http://hlogonemlfkgpejgnedahbkiabcdhnnn should not
// interact with an installed extension with that ID. Regression test
// for bug 357382.
IN_PROC_BROWSER_TEST_F(ProcessManagerBrowserTest, HttpHostMatchingExtensionId) {
ProcessManager* pm = ProcessManager::Get(profile());
// We start with no background hosts.
ASSERT_EQ(0u, pm->background_hosts().size());
ASSERT_EQ(0u, pm->GetAllFrames().size());
// Load an extension with a background page.
scoped_refptr<const Extension> extension =
LoadExtension(test_data_dir_.AppendASCII("api_test")
.AppendASCII("browser_action")
.AppendASCII("none"));
// Set up a test server running at http://[extension-id]
ASSERT_TRUE(extension.get());
const std::string& aliased_host = extension->id();
host_resolver()->AddRule(aliased_host, "127.0.0.1");
ASSERT_TRUE(embedded_test_server()->Start());
GURL url =
embedded_test_server()->GetURL("/extensions/test_file_with_body.html");
GURL::Replacements replace_host;
replace_host.SetHostStr(aliased_host);
url = url.ReplaceComponents(replace_host);
// Load a page from the test host in a new tab.
ui_test_utils::NavigateToURLWithDisposition(
browser(), url, WindowOpenDisposition::NEW_FOREGROUND_TAB,
ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
// Sanity check that there's no bleeding between the extension and the tab.
content::WebContents* tab_web_contents =
browser()->tab_strip_model()->GetActiveWebContents();
EXPECT_EQ(url, tab_web_contents->GetVisibleURL());
EXPECT_FALSE(pm->GetExtensionForWebContents(tab_web_contents))
<< "Non-extension content must not have an associated extension";
ASSERT_EQ(1u, pm->GetRenderFrameHostsForExtension(extension->id()).size());
content::WebContents* extension_web_contents =
content::WebContents::FromRenderFrameHost(
*pm->GetRenderFrameHostsForExtension(extension->id()).begin());
EXPECT_TRUE(extension_web_contents->GetSiteInstance() !=
tab_web_contents->GetSiteInstance());
EXPECT_TRUE(pm->GetSiteInstanceForURL(extension->url()) !=
tab_web_contents->GetSiteInstance());
EXPECT_TRUE(pm->GetBackgroundHostForExtension(extension->id()));
}
IN_PROC_BROWSER_TEST_F(ProcessManagerBrowserTest, NoBackgroundPage) {
ASSERT_TRUE(embedded_test_server()->Start());
ProcessManager* pm = ProcessManager::Get(profile());
const Extension* extension =
LoadExtension(test_data_dir_.AppendASCII("api_test")
.AppendASCII("messaging")
.AppendASCII("connect_nobackground"));
ASSERT_TRUE(extension);
// The extension has no background page.
EXPECT_EQ(0u, pm->GetRenderFrameHostsForExtension(extension->id()).size());
// Start in a non-extension process, then navigate to an extension process.
NavigateToURL(embedded_test_server()->GetURL("/empty.html"));
EXPECT_EQ(0u, pm->GetRenderFrameHostsForExtension(extension->id()).size());
const GURL extension_url = extension->url().Resolve("manifest.json");
NavigateToURL(extension_url);
EXPECT_EQ(1u, pm->GetRenderFrameHostsForExtension(extension->id()).size());
NavigateToURL(GURL("about:blank"));
EXPECT_EQ(0u, pm->GetRenderFrameHostsForExtension(extension->id()).size());
ui_test_utils::NavigateToURLWithDisposition(
browser(), extension_url, WindowOpenDisposition::NEW_FOREGROUND_TAB,
ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
EXPECT_EQ(1u, pm->GetRenderFrameHostsForExtension(extension->id()).size());
}
// Tests whether frames are correctly classified. Non-extension frames should
// never appear in the list. Top-level extension frames should always appear.
// Child extension frames should only appear if it is hosted in an extension
// process (i.e. if the top-level frame is an extension page, or if OOP frames
// are enabled for extensions).
IN_PROC_BROWSER_TEST_F(ProcessManagerBrowserTest, FrameClassification) {
const Extension* extension1 = CreateExtension("Extension 1", false);
const Extension* extension2 = CreateExtension("Extension 2", true);
embedded_test_server()->ServeFilesFromDirectory(extension1->path());
ASSERT_TRUE(embedded_test_server()->Start());
const GURL kExt1TwoFramesUrl(extension1->url().Resolve("two_iframes.html"));
const GURL kExt1EmptyUrl(extension1->url().Resolve("empty.html"));
const GURL kExt2TwoFramesUrl(extension2->url().Resolve("two_iframes.html"));
const GURL kExt2EmptyUrl(extension2->url().Resolve("empty.html"));
ProcessManager* pm = ProcessManager::Get(profile());
// 1 background page + 1 frame in background page from Extension 2.
BackgroundPageWatcher(pm, extension2).WaitForOpen();
EXPECT_EQ(2u, pm->GetAllFrames().size());
EXPECT_EQ(0u, pm->GetRenderFrameHostsForExtension(extension1->id()).size());
EXPECT_EQ(2u, pm->GetRenderFrameHostsForExtension(extension2->id()).size());
ExecuteScriptInBackgroundPageNoWait(extension2->id(),
"setTimeout(window.close, 0)");
BackgroundPageWatcher(pm, extension2).WaitForClose();
EXPECT_EQ(0u, pm->GetAllFrames().size());
EXPECT_EQ(0u, pm->GetRenderFrameHostsForExtension(extension2->id()).size());
NavigateToURL(embedded_test_server()->GetURL("/two_iframes.html"));
EXPECT_EQ(0u, pm->GetAllFrames().size());
content::WebContents* tab =
browser()->tab_strip_model()->GetActiveWebContents();
// Tests extension frames in non-extension page.
EXPECT_TRUE(content::NavigateIframeToURL(tab, "frame1", kExt1EmptyUrl));
EXPECT_EQ(IfExtensionsIsolated(1, 0),
pm->GetRenderFrameHostsForExtension(extension1->id()).size());
EXPECT_EQ(IfExtensionsIsolated(1, 0), pm->GetAllFrames().size());
EXPECT_TRUE(content::NavigateIframeToURL(tab, "frame2", kExt2EmptyUrl));
EXPECT_EQ(IfExtensionsIsolated(1, 0),
pm->GetRenderFrameHostsForExtension(extension2->id()).size());
EXPECT_EQ(IfExtensionsIsolated(2, 0), pm->GetAllFrames().size());
// Tests non-extension page in extension frame.
NavigateToURL(kExt1TwoFramesUrl);
// 1 top-level + 2 child frames from Extension 1.
EXPECT_EQ(3u, pm->GetAllFrames().size());
EXPECT_EQ(3u, pm->GetRenderFrameHostsForExtension(extension1->id()).size());
EXPECT_EQ(0u, pm->GetRenderFrameHostsForExtension(extension2->id()).size());
EXPECT_TRUE(content::NavigateIframeToURL(tab, "frame1",
embedded_test_server()
->GetURL("/empty.html")));
// 1 top-level + 1 child frame from Extension 1.
EXPECT_EQ(2u, pm->GetRenderFrameHostsForExtension(extension1->id()).size());
EXPECT_EQ(2u, pm->GetAllFrames().size());
EXPECT_TRUE(content::NavigateIframeToURL(tab, "frame1", kExt1EmptyUrl));
// 1 top-level + 2 child frames from Extension 1.
EXPECT_EQ(3u, pm->GetAllFrames().size());
EXPECT_EQ(3u, pm->GetRenderFrameHostsForExtension(extension1->id()).size());
// Load a frame from another extension.
EXPECT_TRUE(content::NavigateIframeToURL(tab, "frame1", kExt2EmptyUrl));
// 1 top-level + 1 child frame from Extension 1,
// 1 child frame from Extension 2.
EXPECT_EQ(IfExtensionsIsolated(3, 2), pm->GetAllFrames().size());
EXPECT_EQ(2u, pm->GetRenderFrameHostsForExtension(extension1->id()).size());
EXPECT_EQ(IfExtensionsIsolated(1, 0),
pm->GetRenderFrameHostsForExtension(extension2->id()).size());
// Destroy all existing frames by navigating to another extension.
NavigateToURL(extension2->url().Resolve("empty.html"));
EXPECT_EQ(1u, pm->GetAllFrames().size());
EXPECT_EQ(0u, pm->GetRenderFrameHostsForExtension(extension1->id()).size());
EXPECT_EQ(1u, pm->GetRenderFrameHostsForExtension(extension2->id()).size());
// Test about:blank and about:srcdoc child frames.
NavigateToURL(extension2->url().Resolve("srcdoc_iframe.html"));
// 1 top-level frame + 1 child frame from Extension 2.
EXPECT_EQ(2u, pm->GetAllFrames().size());
EXPECT_EQ(2u, pm->GetRenderFrameHostsForExtension(extension2->id()).size());
NavigateToURL(extension2->url().Resolve("blank_iframe.html"));
// 1 top-level frame + 1 child frame from Extension 2.
EXPECT_EQ(2u, pm->GetAllFrames().size());
EXPECT_EQ(2u, pm->GetRenderFrameHostsForExtension(extension2->id()).size());
// Sandboxed frames are not viewed as extension frames.
EXPECT_TRUE(content::NavigateIframeToURL(tab, "frame0",
extension2->url()
.Resolve("sandboxed.html")));
// 1 top-level frame from Extension 2.
EXPECT_EQ(1u, pm->GetAllFrames().size());
EXPECT_EQ(1u, pm->GetRenderFrameHostsForExtension(extension2->id()).size());
NavigateToURL(extension2->url().Resolve("sandboxed.html"));
EXPECT_EQ(0u, pm->GetAllFrames().size());
EXPECT_EQ(0u, pm->GetRenderFrameHostsForExtension(extension2->id()).size());
// Test nested frames (same extension).
NavigateToURL(kExt2TwoFramesUrl);
// 1 top-level + 2 child frames from Extension 2.
EXPECT_EQ(3u, pm->GetAllFrames().size());
EXPECT_EQ(3u, pm->GetRenderFrameHostsForExtension(extension2->id()).size());
EXPECT_TRUE(content::NavigateIframeToURL(tab, "frame1", kExt2TwoFramesUrl));
// 1 top-level + 2 child frames from Extension 1,
// 2 child frames in frame1 from Extension 2.
EXPECT_EQ(5u, pm->GetAllFrames().size());
EXPECT_EQ(5u, pm->GetRenderFrameHostsForExtension(extension2->id()).size());
// The extension frame from the other extension should not be classified as an
// extension (unless out-of-process frames are enabled).
EXPECT_TRUE(content::NavigateIframeToURL(tab, "frame1", kExt1EmptyUrl));
// 1 top-level + 1 child frames from Extension 2,
// 1 child frame from Extension 1.
EXPECT_EQ(IfExtensionsIsolated(3, 2), pm->GetAllFrames().size());
EXPECT_EQ(IfExtensionsIsolated(1, 0),
pm->GetRenderFrameHostsForExtension(extension1->id()).size());
EXPECT_EQ(2u, pm->GetRenderFrameHostsForExtension(extension2->id()).size());
EXPECT_TRUE(content::NavigateIframeToURL(tab, "frame2", kExt1TwoFramesUrl));
// 1 top-level + 1 child frames from Extension 2,
// 1 child frame + 2 child frames in frame2 from Extension 1.
EXPECT_EQ(IfExtensionsIsolated(5, 1), pm->GetAllFrames().size());
EXPECT_EQ(IfExtensionsIsolated(4, 0),
pm->GetRenderFrameHostsForExtension(extension1->id()).size());
EXPECT_EQ(1u, pm->GetRenderFrameHostsForExtension(extension2->id()).size());
// Crash tab where the top-level frame is an extension frame.
content::CrashTab(tab);
EXPECT_EQ(0u, pm->GetAllFrames().size());
EXPECT_EQ(0u, pm->GetRenderFrameHostsForExtension(extension1->id()).size());
EXPECT_EQ(0u, pm->GetRenderFrameHostsForExtension(extension2->id()).size());
// Now load an extension page and a non-extension page...
ui_test_utils::NavigateToURLWithDisposition(
browser(), kExt1EmptyUrl, WindowOpenDisposition::NEW_BACKGROUND_TAB,
ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
NavigateToURL(embedded_test_server()->GetURL("/two_iframes.html"));
EXPECT_EQ(1u, pm->GetAllFrames().size());
// ... load an extension frame in the non-extension process
EXPECT_TRUE(content::NavigateIframeToURL(tab, "frame1", kExt1EmptyUrl));
EXPECT_EQ(IfExtensionsIsolated(2, 1),
pm->GetRenderFrameHostsForExtension(extension1->id()).size());
// ... and take down the tab. The extension process is not part of the tab,
// so it should be kept alive (minus the frames that died).
content::CrashTab(tab);
EXPECT_EQ(1u, pm->GetAllFrames().size());
EXPECT_EQ(1u, pm->GetRenderFrameHostsForExtension(extension1->id()).size());
}
// Verify correct keepalive count behavior on network request events.
// Regression test for http://crbug.com/535716.
IN_PROC_BROWSER_TEST_F(ProcessManagerBrowserTest, KeepaliveOnNetworkRequest) {
// Load an extension with a lazy background page.
scoped_refptr<const Extension> extension =
LoadExtension(test_data_dir_.AppendASCII("api_test")
.AppendASCII("lazy_background_page")
.AppendASCII("broadcast_event"));
ASSERT_TRUE(extension.get());
ProcessManager* pm = ProcessManager::Get(profile());
ProcessManager::FrameSet frames =
pm->GetRenderFrameHostsForExtension(extension->id());
ASSERT_EQ(1u, frames.size());
// Keepalive count at this point is unpredictable as there may be an
// outstanding event dispatch. We use the current keepalive count as a
// reliable baseline for future expectations.
int baseline_keepalive = pm->GetLazyKeepaliveCount(extension.get());
// Simulate some network events. This test assumes no other network requests
// are pending, i.e., that there are no conflicts with the fake request IDs
// we're using. This should be a safe assumption because LoadExtension should
// wait for loads to complete, and we don't run the message loop otherwise.
content::RenderFrameHost* frame_host = *frames.begin();
pm->OnNetworkRequestStarted(frame_host, 1);
EXPECT_EQ(baseline_keepalive + 1, pm->GetLazyKeepaliveCount(extension.get()));
pm->OnNetworkRequestDone(frame_host, 1);
EXPECT_EQ(baseline_keepalive, pm->GetLazyKeepaliveCount(extension.get()));
// Simulate only a request completion for this ID and ensure it doesn't result
// in keepalive decrement.
pm->OnNetworkRequestDone(frame_host, 2);
EXPECT_EQ(baseline_keepalive, pm->GetLazyKeepaliveCount(extension.get()));
}
IN_PROC_BROWSER_TEST_F(ProcessManagerBrowserTest, ExtensionProcessReuse) {
const size_t kNumExtensions = 3;
content::RenderProcessHost::SetMaxRendererProcessCount(kNumExtensions - 1);
ProcessManager* pm = ProcessManager::Get(profile());
std::set<int> processes;
std::set<const Extension*> installed_extensions;
// Create 3 extensions, which is more than the process limit.
for (int i = 1; i <= static_cast<int>(kNumExtensions); ++i) {
const Extension* extension =
CreateExtension(base::StringPrintf("Extension %d", i), true);
installed_extensions.insert(extension);
ExtensionHost* extension_host =
pm->GetBackgroundHostForExtension(extension->id());
EXPECT_EQ(extension->url(),
extension_host->host_contents()->GetSiteInstance()->GetSiteURL());
processes.insert(extension_host->render_process_host()->GetID());
}
EXPECT_EQ(kNumExtensions, installed_extensions.size());
if (content::AreAllSitesIsolatedForTesting()) {
EXPECT_EQ(kNumExtensions, processes.size()) << "Extension process reuse is "
"expected to be disabled in "
"--site-per-process.";
} else {
EXPECT_LT(processes.size(), kNumExtensions)
<< "Expected extension process reuse, but none happened.";
}
// Interact with each extension background page by setting and reading back
// the cookie. This would fail for one of the two extensions in a shared
// process, if that process is locked to a single origin. This is a regression
// test for http://crbug.com/600441.
for (const Extension* extension : installed_extensions) {
content::DOMMessageQueue queue;
ExecuteScriptInBackgroundPageNoWait(
extension->id(),
"document.cookie = 'extension_cookie';"
"window.domAutomationController.send(document.cookie);");
std::string message;
ASSERT_TRUE(queue.WaitForMessage(&message));
EXPECT_EQ(message, "\"extension_cookie\"");
}
}
// Test that navigations to blob: and filesystem: URLs with extension origins
// are disallowed when initiated from non-extension processes. See
// https://crbug.com/645028 and https://crbug.com/644426.
IN_PROC_BROWSER_TEST_F(ProcessManagerBrowserTest,
NestedURLNavigationsToExtensionBlocked) {
// Disabling web security is necessary to test the browser enforcement;
// without it, the loads in this test would be blocked by
// SecurityOrigin::canDisplay() as invalid local resource loads.
PrefService* prefs = browser()->profile()->GetPrefs();
prefs->SetBoolean(prefs::kWebKitWebSecurityEnabled, false);
// Create a simple extension without a background page.
const Extension* extension = CreateExtension("Extension", false);
embedded_test_server()->ServeFilesFromDirectory(extension->path());
ASSERT_TRUE(embedded_test_server()->Start());
// Navigate main tab to a web page with two web iframes. There should be no
// extension frames yet.
NavigateToURL(embedded_test_server()->GetURL("/two_iframes.html"));
ProcessManager* pm = ProcessManager::Get(profile());
EXPECT_EQ(0u, pm->GetAllFrames().size());
EXPECT_EQ(0u, pm->GetRenderFrameHostsForExtension(extension->id()).size());
content::WebContents* tab =
browser()->tab_strip_model()->GetActiveWebContents();
// Navigate first subframe to an extension URL. With --isolate-extensions,
// this will go into a new extension process.
const GURL extension_url(extension->url().Resolve("empty.html"));
EXPECT_TRUE(content::NavigateIframeToURL(tab, "frame1", extension_url));
EXPECT_EQ(IfExtensionsIsolated(1, 0),
pm->GetRenderFrameHostsForExtension(extension->id()).size());
EXPECT_EQ(IfExtensionsIsolated(1, 0), pm->GetAllFrames().size());
content::RenderFrameHost* main_frame = tab->GetMainFrame();
content::RenderFrameHost* extension_frame = ChildFrameAt(main_frame, 0);
// Validate that permissions have been granted for the extension scheme
// to the process of the extension iframe.
content::ChildProcessSecurityPolicy* policy =
content::ChildProcessSecurityPolicy::GetInstance();
EXPECT_TRUE(policy->CanRequestURL(
extension_frame->GetProcess()->GetID(),
GURL("blob:chrome-extension://some-extension-id/some-guid")));
EXPECT_TRUE(policy->CanRequestURL(
main_frame->GetProcess()->GetID(),
GURL("blob:chrome-extension://some-extension-id/some-guid")));
EXPECT_TRUE(policy->CanRequestURL(
extension_frame->GetProcess()->GetID(),
GURL("filesystem:chrome-extension://some-extension-id/some-path")));
EXPECT_TRUE(policy->CanRequestURL(
main_frame->GetProcess()->GetID(),
GURL("filesystem:chrome-extension://some-extension-id/some-path")));
EXPECT_TRUE(policy->CanRequestURL(
extension_frame->GetProcess()->GetID(),
GURL("chrome-extension://some-extension-id/resource.html")));
EXPECT_TRUE(policy->CanRequestURL(
main_frame->GetProcess()->GetID(),
GURL("chrome-extension://some-extension-id/resource.html")));
if (IsIsolateExtensionsEnabled()) {
EXPECT_TRUE(policy->CanCommitURL(
extension_frame->GetProcess()->GetID(),
GURL("blob:chrome-extension://some-extension-id/some-guid")));
EXPECT_FALSE(policy->CanCommitURL(
main_frame->GetProcess()->GetID(),
GURL("blob:chrome-extension://some-extension-id/some-guid")));
EXPECT_TRUE(policy->CanCommitURL(
extension_frame->GetProcess()->GetID(),
GURL("chrome-extension://some-extension-id/resource.html")));
EXPECT_FALSE(policy->CanCommitURL(
main_frame->GetProcess()->GetID(),
GURL("chrome-extension://some-extension-id/resource.html")));
EXPECT_TRUE(policy->CanCommitURL(
extension_frame->GetProcess()->GetID(),
GURL("filesystem:chrome-extension://some-extension-id/some-path")));
EXPECT_FALSE(policy->CanCommitURL(
main_frame->GetProcess()->GetID(),
GURL("filesystem:chrome-extension://some-extension-id/some-path")));
}
// Open a new about:blank popup from main frame. This should stay in the web
// process.
content::WebContents* popup =
OpenPopup(main_frame, GURL(url::kAboutBlankURL));
EXPECT_NE(popup, tab);
ASSERT_EQ(2, browser()->tab_strip_model()->count());
EXPECT_EQ(IfExtensionsIsolated(1, 0),
pm->GetRenderFrameHostsForExtension(extension->id()).size());
EXPECT_EQ(IfExtensionsIsolated(1, 0), pm->GetAllFrames().size());
// Create valid blob and filesystem URLs in the extension's origin.
url::Origin extension_origin(extension_frame->GetLastCommittedOrigin());
GURL blob_url(CreateBlobURL(extension_frame, "foo"));
EXPECT_EQ(extension_origin, url::Origin(blob_url));
GURL filesystem_url(CreateFileSystemURL(extension_frame, "foo"));
EXPECT_EQ(extension_origin, url::Origin(filesystem_url));
// Navigate the popup to each nested URL with extension origin.
GURL nested_urls[] = {blob_url, filesystem_url};
for (size_t i = 0; i < arraysize(nested_urls); i++) {
content::TestNavigationObserver observer(popup);
EXPECT_TRUE(ExecuteScript(
popup, "location.href = '" + nested_urls[i].spec() + "';"));
observer.Wait();
// This is a top-level navigation that should be blocked since it
// originates from a non-extension process. Ensure that the error page
// doesn't commit an extension URL or origin.
EXPECT_NE(nested_urls[i], popup->GetLastCommittedURL());
EXPECT_FALSE(extension_origin.IsSameOriginWith(
popup->GetMainFrame()->GetLastCommittedOrigin()));
EXPECT_NE("foo", GetTextContent(popup->GetMainFrame()));
EXPECT_EQ(IfExtensionsIsolated(1, 0),
pm->GetRenderFrameHostsForExtension(extension->id()).size());
EXPECT_EQ(IfExtensionsIsolated(1, 0), pm->GetAllFrames().size());
}
// Navigate second subframe to each nested URL from the main frame (i.e.,
// from non-extension process). This should be blocked in
// --isolate-extensions, but allowed without --isolate-extensions due to
// unblessed extension frames.
//
// TODO(alexmos): This is also temporarily allowed under PlzNavigate, because
// currently this particular blocking happens in
// ChromeContentBrowserClientExtensionsPart::ShouldAllowOpenURL, which isn't
// triggered below under PlzNavigate (since there'll be no transfer). Once
// the blob/filesystem URL checks in ExtensionNavigationThrottle are updated
// to apply to all frames and not just main frames, the PlzNavigate exception
// below can be removed. See https://crbug.com/661324.
for (size_t i = 0; i < arraysize(nested_urls); i++) {
EXPECT_TRUE(content::NavigateIframeToURL(tab, "frame2", nested_urls[i]));
content::RenderFrameHost* second_frame = ChildFrameAt(main_frame, 1);
if (IsIsolateExtensionsEnabled() &&
!content::IsBrowserSideNavigationEnabled()) {
EXPECT_NE(nested_urls[i], second_frame->GetLastCommittedURL());
EXPECT_FALSE(extension_origin.IsSameOriginWith(
second_frame->GetLastCommittedOrigin()));
EXPECT_NE("foo", GetTextContent(second_frame));
EXPECT_EQ(IfExtensionsIsolated(1, 0),
pm->GetRenderFrameHostsForExtension(extension->id()).size());
EXPECT_EQ(IfExtensionsIsolated(1, 0), pm->GetAllFrames().size());
} else {
EXPECT_EQ(nested_urls[i], second_frame->GetLastCommittedURL());
EXPECT_EQ(extension_origin, second_frame->GetLastCommittedOrigin());
EXPECT_EQ("foo", GetTextContent(second_frame));
EXPECT_EQ(IfExtensionsIsolated(2, 0),
pm->GetRenderFrameHostsForExtension(extension->id()).size());
EXPECT_EQ(IfExtensionsIsolated(2, 0), pm->GetAllFrames().size());
}
EXPECT_TRUE(
content::NavigateIframeToURL(tab, "frame2", GURL(url::kAboutBlankURL)));
}
}
// Test that navigations to blob: and filesystem: URLs with extension origins
// are allowed when initiated from extension processes. See
// https://crbug.com/645028 and https://crbug.com/644426.
IN_PROC_BROWSER_TEST_F(ProcessManagerBrowserTest,
NestedURLNavigationsToExtensionAllowed) {
// Create a simple extension without a background page.
const Extension* extension = CreateExtension("Extension", false);
embedded_test_server()->ServeFilesFromDirectory(extension->path());
ASSERT_TRUE(embedded_test_server()->Start());
// Navigate main tab to an extension URL with a blank subframe.
const GURL extension_url(extension->url().Resolve("blank_iframe.html"));
NavigateToURL(extension_url);
ProcessManager* pm = ProcessManager::Get(profile());
EXPECT_EQ(2u, pm->GetAllFrames().size());
EXPECT_EQ(2u, pm->GetRenderFrameHostsForExtension(extension->id()).size());
content::WebContents* tab =
browser()->tab_strip_model()->GetActiveWebContents();
content::RenderFrameHost* main_frame = tab->GetMainFrame();
// Create blob and filesystem URLs in the extension's origin.
url::Origin extension_origin(main_frame->GetLastCommittedOrigin());
GURL blob_url(CreateBlobURL(main_frame, "foo"));
EXPECT_EQ(extension_origin, url::Origin(blob_url));
GURL filesystem_url(CreateFileSystemURL(main_frame, "foo"));
EXPECT_EQ(extension_origin, url::Origin(filesystem_url));
// From the main frame, navigate its subframe to each nested URL. This
// should be allowed and should stay in the extension process.
GURL nested_urls[] = {blob_url, filesystem_url};
for (size_t i = 0; i < arraysize(nested_urls); i++) {
EXPECT_TRUE(content::NavigateIframeToURL(tab, "frame0", nested_urls[i]));
content::RenderFrameHost* child = ChildFrameAt(main_frame, 0);
EXPECT_EQ(nested_urls[i], child->GetLastCommittedURL());
EXPECT_EQ(extension_origin, child->GetLastCommittedOrigin());
EXPECT_EQ("foo", GetTextContent(child));
EXPECT_EQ(2u, pm->GetRenderFrameHostsForExtension(extension->id()).size());
EXPECT_EQ(2u, pm->GetAllFrames().size());
}
// From the main frame, create a blank popup and navigate it to each nested
// URL. This should also be allowed, since the navigation originated from an
// extension process.
for (size_t i = 0; i < arraysize(nested_urls); i++) {
content::WebContents* popup =
OpenPopup(main_frame, GURL(url::kAboutBlankURL));
EXPECT_NE(popup, tab);
content::TestNavigationObserver observer(popup);
EXPECT_TRUE(ExecuteScript(
popup, "location.href = '" + nested_urls[i].spec() + "';"));
observer.Wait();
EXPECT_EQ(nested_urls[i], popup->GetLastCommittedURL());
EXPECT_EQ(extension_origin,
popup->GetMainFrame()->GetLastCommittedOrigin());
EXPECT_EQ("foo", GetTextContent(popup->GetMainFrame()));
EXPECT_EQ(3 + i,
pm->GetRenderFrameHostsForExtension(extension->id()).size());
EXPECT_EQ(3 + i, pm->GetAllFrames().size());
}
}
// Test that navigations to blob: and filesystem: URLs with extension origins
// are disallowed in an unprivileged, non-guest web process when the extension
// origin corresponds to a Chrome app with the "webview" permission. See
// https://crbug.com/656752. These requests should still be allowed inside
// actual <webview> guest processes created by a Chrome app; this is checked in
// WebViewTest.Shim_TestBlobURL.
IN_PROC_BROWSER_TEST_F(ProcessManagerBrowserTest,
NestedURLNavigationsToAppBlocked) {
// TODO(alexmos): Re-enable this test for PlzNavigate after tightening
// nested URL blocking for apps with the "webview" permission in
// ExtensionNavigationThrottle and removing the corresponding check from
// ChromeExtensionsNetworkDelegate. The latter is incompatible with
// PlzNavigate.
if (content::IsBrowserSideNavigationEnabled())
return;
// Disabling web security is necessary to test the browser enforcement;
// without it, the loads in this test would be blocked by
// SecurityOrigin::canDisplay() as invalid local resource loads.
PrefService* prefs = browser()->profile()->GetPrefs();
prefs->SetBoolean(prefs::kWebKitWebSecurityEnabled, false);
// Load a simple app that has the "webview" permission. The app will also
// open a <webview> when it's loaded.
ASSERT_TRUE(embedded_test_server()->Start());
base::FilePath dir;
PathService::Get(chrome::DIR_TEST_DATA, &dir);
dir = dir.AppendASCII("extensions")
.AppendASCII("platform_apps")
.AppendASCII("web_view")
.AppendASCII("simple");
const Extension* app = LoadAndLaunchApp(dir);
EXPECT_TRUE(app->permissions_data()->HasAPIPermission(
extensions::APIPermission::kWebView));
auto app_windows = AppWindowRegistry::Get(browser()->profile())
->GetAppWindowsForApp(app->id());
EXPECT_EQ(1u, app_windows.size());
content::WebContents* app_tab = (*app_windows.begin())->web_contents();
content::RenderFrameHost* app_rfh = app_tab->GetMainFrame();
url::Origin app_origin(app_rfh->GetLastCommittedOrigin());
EXPECT_EQ(url::Origin(app->url()), app_rfh->GetLastCommittedOrigin());
// Wait for the app's guest WebContents to load.
guest_view::TestGuestViewManager* guest_manager =
static_cast<guest_view::TestGuestViewManager*>(
guest_view::TestGuestViewManager::FromBrowserContext(
browser()->profile()));
content::WebContents* guest = guest_manager->WaitForSingleGuestCreated();
// There should be two extension frames in ProcessManager: the app's main
// page and the background page.
ProcessManager* pm = ProcessManager::Get(profile());
EXPECT_EQ(2u, pm->GetAllFrames().size());
EXPECT_EQ(2u, pm->GetRenderFrameHostsForExtension(app->id()).size());
// Create valid blob and filesystem URLs in the app's origin.
GURL blob_url(CreateBlobURL(app_rfh, "foo"));
EXPECT_EQ(app_origin, url::Origin(blob_url));
GURL filesystem_url(CreateFileSystemURL(app_rfh, "foo"));
EXPECT_EQ(app_origin, url::Origin(filesystem_url));
// Create a new tab, unrelated to the app, and navigate it to a web URL.
chrome::NewTab(browser());
content::WebContents* web_tab =
browser()->tab_strip_model()->GetActiveWebContents();
GURL web_url(embedded_test_server()->GetURL("/title1.html"));
ui_test_utils::NavigateToURL(browser(), web_url);
EXPECT_NE(web_tab, app_tab);
EXPECT_NE(web_tab->GetMainFrame()->GetProcess(), app_rfh->GetProcess());
// The web process shouldn't have permission to request URLs in the app's
// origin, but the guest process should.
content::ChildProcessSecurityPolicy* policy =
content::ChildProcessSecurityPolicy::GetInstance();
EXPECT_FALSE(policy->HasSpecificPermissionForOrigin(
web_tab->GetRenderProcessHost()->GetID(), app_origin));
EXPECT_TRUE(policy->HasSpecificPermissionForOrigin(
guest->GetRenderProcessHost()->GetID(), app_origin));
// Try navigating the web tab to each nested URL with the app's origin. This
// should be blocked.
GURL nested_urls[] = {blob_url, filesystem_url};
for (size_t i = 0; i < arraysize(nested_urls); i++) {
content::TestNavigationObserver observer(web_tab);
EXPECT_TRUE(ExecuteScript(
web_tab, "location.href = '" + nested_urls[i].spec() + "';"));
observer.Wait();
EXPECT_NE(nested_urls[i], web_tab->GetLastCommittedURL());
EXPECT_FALSE(app_origin.IsSameOriginWith(
web_tab->GetMainFrame()->GetLastCommittedOrigin()));
EXPECT_NE("foo", GetTextContent(web_tab->GetMainFrame()));
EXPECT_NE(web_tab->GetMainFrame()->GetProcess(), app_rfh->GetProcess());
EXPECT_EQ(2u, pm->GetAllFrames().size());
EXPECT_EQ(2u, pm->GetRenderFrameHostsForExtension(app->id()).size());
}
}
// Test that a web frame can't navigate a proxy for an extension frame to a
// blob/filesystem extension URL. See https://crbug.com/656752.
IN_PROC_BROWSER_TEST_F(ProcessManagerBrowserTest,
NestedURLNavigationsViaProxyBlocked) {
base::HistogramTester uma;
// Create a simple extension without a background page.
const Extension* extension = CreateExtension("Extension", false);
embedded_test_server()->ServeFilesFromDirectory(extension->path());
ASSERT_TRUE(embedded_test_server()->Start());
// Navigate main tab to an empty web page. There should be no extension
// frames yet.
NavigateToURL(embedded_test_server()->GetURL("/empty.html"));
ProcessManager* pm = ProcessManager::Get(profile());
EXPECT_EQ(0u, pm->GetAllFrames().size());
EXPECT_EQ(0u, pm->GetRenderFrameHostsForExtension(extension->id()).size());
content::WebContents* tab =
browser()->tab_strip_model()->GetActiveWebContents();
content::RenderFrameHost* main_frame = tab->GetMainFrame();
// Open a new about:blank popup from main frame. This should stay in the web
// process.
content::WebContents* popup =
OpenPopup(main_frame, GURL(url::kAboutBlankURL));
EXPECT_NE(popup, tab);
ASSERT_EQ(2, browser()->tab_strip_model()->count());
EXPECT_EQ(0u, pm->GetRenderFrameHostsForExtension(extension->id()).size());
EXPECT_EQ(0u, pm->GetAllFrames().size());
// Navigate popup to an extension page.
const GURL extension_url(extension->url().Resolve("empty.html"));
content::TestNavigationObserver observer(popup);
EXPECT_TRUE(
ExecuteScript(popup, "location.href = '" + extension_url.spec() + "';"));
observer.Wait();
EXPECT_EQ(1u, pm->GetAllFrames().size());
EXPECT_EQ(1u, pm->GetRenderFrameHostsForExtension(extension->id()).size());
content::RenderFrameHost* extension_frame = popup->GetMainFrame();
// Create valid blob and filesystem URLs in the extension's origin.
url::Origin extension_origin(extension_frame->GetLastCommittedOrigin());
GURL blob_url(CreateBlobURL(extension_frame, "foo"));
EXPECT_EQ(extension_origin, url::Origin(blob_url));
GURL filesystem_url(CreateFileSystemURL(extension_frame, "foo"));
EXPECT_EQ(extension_origin, url::Origin(filesystem_url));
// Have the web page navigate the popup to each nested URL with extension
// origin via the window reference it obtained earlier from window.open.
GURL nested_urls[] = {blob_url, filesystem_url};
for (size_t i = 0; i < arraysize(nested_urls); i++) {
EXPECT_TRUE(ExecuteScript(
tab, "window.popup.location.href = '" + nested_urls[i].spec() + "';"));
WaitForLoadStop(popup);
// This is a top-level navigation that should be blocked since it
// originates from a non-extension process. Ensure that the popup stays at
// the original page and doesn't navigate to the nested URL.
EXPECT_NE(nested_urls[i], popup->GetLastCommittedURL());
EXPECT_NE("foo", GetTextContent(popup->GetMainFrame()));
EXPECT_EQ(1u, pm->GetRenderFrameHostsForExtension(extension->id()).size());
EXPECT_EQ(1u, pm->GetAllFrames().size());
}
// Verify that the blocking was recorded correctly in UMA.
uma.ExpectTotalCount("Extensions.ShouldAllowOpenURL.Failure", 2);
uma.ExpectBucketCount("Extensions.ShouldAllowOpenURL.Failure",
0 /* FAILURE_FILE_SYSTEM_URL */, 1);
uma.ExpectBucketCount("Extensions.ShouldAllowOpenURL.Failure",
1 /* FAILURE_BLOB_URL */, 1);
}
// Verify that a web popup created via window.open from an extension page can
// communicate with the extension page via window.opener. See
// https://crbug.com/590068.
IN_PROC_BROWSER_TEST_F(ProcessManagerBrowserTest,
WebPopupFromExtensionMainFrameHasValidOpener) {
// Create a simple extension without a background page.
const Extension* extension = CreateExtension("Extension", false);
embedded_test_server()->ServeFilesFromDirectory(extension->path());
ASSERT_TRUE(embedded_test_server()->Start());
// Navigate main tab to an extension page.
NavigateToURL(extension->GetResourceURL("empty.html"));
ProcessManager* pm = ProcessManager::Get(profile());
EXPECT_EQ(1u, pm->GetAllFrames().size());
EXPECT_EQ(1u, pm->GetRenderFrameHostsForExtension(extension->id()).size());
content::WebContents* tab =
browser()->tab_strip_model()->GetActiveWebContents();
content::RenderFrameHost* main_frame = tab->GetMainFrame();
// Open a new web popup from the extension tab. The popup should go into a
// new process.
GURL popup_url(embedded_test_server()->GetURL("/empty.html"));
content::WebContents* popup = OpenPopup(main_frame, popup_url);
EXPECT_NE(popup, tab);
ASSERT_EQ(2, browser()->tab_strip_model()->count());
EXPECT_EQ(1u, pm->GetRenderFrameHostsForExtension(extension->id()).size());
EXPECT_EQ(1u, pm->GetAllFrames().size());
EXPECT_NE(popup->GetRenderProcessHost(), main_frame->GetProcess());
// Ensure the popup's window.opener is defined.
bool is_opener_defined = false;
EXPECT_TRUE(ExecuteScriptAndExtractBool(
popup, "window.domAutomationController.send(!!window.opener)",
&is_opener_defined));
EXPECT_TRUE(is_opener_defined);
// Verify that postMessage to window.opener works.
VerifyPostMessageToOpener(popup->GetMainFrame(), main_frame);
}
// Verify that a web popup created via window.open from an extension subframe
// can communicate with the extension page via window.opener. Similar to the
// test above, but for subframes. See https://crbug.com/590068.
IN_PROC_BROWSER_TEST_F(ProcessManagerBrowserTest,
WebPopupFromExtensionSubframeHasValidOpener) {
// This test only makes sense if OOPIFs are enabled for extension subframes.
if (!IsIsolateExtensionsEnabled())
return;
// Create a simple extension without a background page.
const Extension* extension = CreateExtension("Extension", false);
embedded_test_server()->ServeFilesFromDirectory(extension->path());
ASSERT_TRUE(embedded_test_server()->Start());
// Navigate main tab to a web page with a blank iframe. There should be no
// extension frames yet.
NavigateToURL(embedded_test_server()->GetURL("/blank_iframe.html"));
ProcessManager* pm = ProcessManager::Get(profile());
EXPECT_EQ(0u, pm->GetAllFrames().size());
EXPECT_EQ(0u, pm->GetRenderFrameHostsForExtension(extension->id()).size());
content::WebContents* tab =
browser()->tab_strip_model()->GetActiveWebContents();
// Navigate first subframe to an extension URL.
const GURL extension_url(extension->GetResourceURL("empty.html"));
EXPECT_TRUE(content::NavigateIframeToURL(tab, "frame0", extension_url));
EXPECT_EQ(1u, pm->GetRenderFrameHostsForExtension(extension->id()).size());
EXPECT_EQ(1u, pm->GetAllFrames().size());
content::RenderFrameHost* main_frame = tab->GetMainFrame();
content::RenderFrameHost* extension_frame = ChildFrameAt(main_frame, 0);
// Open a new web popup from extension frame. The popup should go into main
// frame's web process.
GURL popup_url(embedded_test_server()->GetURL("/empty.html"));
content::WebContents* popup = OpenPopup(extension_frame, popup_url);
EXPECT_NE(popup, tab);
ASSERT_EQ(2, browser()->tab_strip_model()->count());
EXPECT_EQ(1u, pm->GetRenderFrameHostsForExtension(extension->id()).size());
EXPECT_EQ(1u, pm->GetAllFrames().size());
EXPECT_NE(popup->GetRenderProcessHost(), extension_frame->GetProcess());
EXPECT_EQ(popup->GetRenderProcessHost(), main_frame->GetProcess());
// Ensure the popup's window.opener is defined.
bool is_opener_defined = false;
EXPECT_TRUE(ExecuteScriptAndExtractBool(
popup, "window.domAutomationController.send(!!window.opener)",
&is_opener_defined));
EXPECT_TRUE(is_opener_defined);
// Verify that postMessage to window.opener works.
VerifyPostMessageToOpener(popup->GetMainFrame(), extension_frame);
}
} // namespace extensions
|
[
"enrico.weigelt@gr13.net"
] |
enrico.weigelt@gr13.net
|
545b0594e58252eec1b81ba91f6ba1b7ca7b00b3
|
b65acdd4e28bac5b0b0cc088bded08cc80437ad8
|
/MVSProg/Task18/Project4/Project4/Source.cpp
|
392ac0723636cdcdd4d6ca1efd01d18bac93b562
|
[] |
no_license
|
YulianStrus/Examples-of-academic-homeworks
|
44794bb234626319810f444a3115557b4e59d54f
|
f2fb2b5e02f069ff8f0cbc1a95c472ad2becad4c
|
refs/heads/master
| 2023-05-27T16:09:41.220326
| 2021-06-02T10:04:07
| 2021-06-02T10:04:07
| 313,245,187
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 859
|
cpp
|
#include "iostream"
#include "stdlib.h"
#include "time.h"
using namespace std;
void main()
{
const int size = 20;
int arr[size];
int Sum = 0;
int x = 15, y = -15, srand(time(NULL));
for (int i = 0; i < size; i++) {
arr[i] = rand() % (x - y) + y;
cout << arr[i] << " ";
}
cout << endl;
int tmp;
bool change = true;
while (change)
{
change = false;
for (int i = 0; i < size - 1; ++i)
{
if (arr[i] > arr[i + 1])
{
tmp = arr[i];
arr[i] = arr[i + 1];
arr[i + 1] = tmp;
change = true;
}
}
}
change = true;
while (change)
{
change = false;
for (int i = 1; i < size - 1; i+=2)
{
if (arr[i] < arr[i + 2])
{
tmp = arr[i];
arr[i] = arr[i + 2];
arr[i + 2] = tmp;
change = true;
}
}
}
for (int i = 0; i < size; i++)
cout << arr[i] << " ";
cout << endl << endl;
system("pause");
}
|
[
"stryulvas@ukr.net"
] |
stryulvas@ukr.net
|
b644f74f8b731de2de169ec034203c340b5d7008
|
b9c1badf27375eacf910dcb87b79e3c69e12a5ef
|
/Orange.cpp
|
72284af1f263f1fd9bc74a5557819e8bc4eb422b
|
[] |
no_license
|
JCoelhoo/Micro-Machines
|
885d8d1d0caa3c54762ad2c918ce981985c4f256
|
dbea30ccb7916c37a2955ab5af6134c88bc57215
|
refs/heads/master
| 2021-01-19T01:11:01.905689
| 2016-06-26T19:14:17
| 2016-06-26T19:14:17
| 61,898,008
| 1
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,183
|
cpp
|
#include <iostream>
#include <string>
#include "Orange.h"
#include <time.h>
using namespace std;
Orange::Orange() : Obstacle() {
init();
}
Orange::Orange(Vector3 pos) : Obstacle(pos) {
init();
}
void Orange::init() {
collisionMax = Vector3(RADIUS, RADIUS, RADIUS);
collisionMin = collisionMax*(-1);
this->respawn();
/*RED_PLASTIC*/
//ambient, diffuse, specular, shine
orange_material = new Material(Vector3(0.25, 0.1, 0), Vector3(1, 0.4, 0), Vector3(0.1, 0.f, 0.f), 50);
caule_material = new Material(Vector3(0, 0, 0), Vector3(0.349, 0.243, 0.102), Vector3(0.03, 0.02, 0.01), 5);
}
void Orange::nextLevel() {
//increase speed
_w += rand() % INCREASEW;
setSpeed(_w * 2 * PI*RADIUS / 360); //increase speed whit random value
}
void Orange::respawn() {
int x = rand() % 6 + 20;
int y = rand() % 16;
if ((rand() % 2) == 0) x = x*(-1);
if ((rand() % 2) == 0) y = y*(-1);
_position = Vector3(x, y, 0); //change orange position
setSpeed(_w * 2 * PI*RADIUS / 360); //set orange speed
setDirection(Vector3(((double)rand() / (RAND_MAX)) - 0.5, ((double)rand() / (RAND_MAX)) - 0.5, 0)); //set orange direction
_degrees = 0;
disabled = false;
}
void Orange::update(double delta_t) {
delta_t = delta_t / 1000; //ms -> s
_degrees = _degrees + _w*delta_t; //calculate angle. angle = angle + w*t
if (_degrees >= 360)
_degrees -= 360;
_position = getSpeed() * delta_t + _position;
}
void Orange::collide(Car* player) {
printf("GAME OVER\n");
player->setPosition(-18, -12, 0);
player->setAcceleration(0);
player->v = 0;
player->_direction = Vector3(1, 0, 0);
}
void Orange::draw() {
if (!disabled) {
orange_material->draw();
glPushMatrix();
glColor3f(1, 0.278, 0.039);
glTranslated(_position.getX(), _position.getY(), _position.getZ());
glTranslated(0, 0, RADIUS); //put range in z=0
glRotated(_degrees, - getSpeed().getY(), getSpeed().getX(), 0);
glutSolidSphere(RADIUS, 25, 50);
glColor3f(.1, 0.278, 0.039);
//CAULE
caule_material->draw();
glTranslated(0, 0, RADIUS);
glutSolidCube(0.25);
glPopMatrix();
}
}
|
[
"noreply@github.com"
] |
JCoelhoo.noreply@github.com
|
13ae85161fadd329013a6759366be23458b9d8d9
|
6058aac649d539ffc4102d64fecc0b397cf014bc
|
/include/Menu.hpp
|
269b3baec6f9d49397eb97bfce2f1652ed9e3b19
|
[
"MIT"
] |
permissive
|
Kirthos/Aerria
|
bb00b1a9fbb32891837d7b9adcb80a53e20539aa
|
ec9eb6c78690838ba5a3509369e2c4d8428b4dc2
|
refs/heads/master
| 2020-04-02T06:33:52.656726
| 2018-10-22T14:37:08
| 2018-10-22T14:37:08
| 154,156,565
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,272
|
hpp
|
#ifndef MENU_HPP_INCLUDED
#define MENU_HPP_INCLUDED
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
#include "Game.hpp"
#include "SingletonWindow.h"
#include <iostream>
using namespace std;
class Menu
{
public:
Menu();
void run();
protected:
void update();
const void render();
int checkBox(float x, float y);
void updateCloud();
void updateSM();
bool cacheActivated;
sf::RectangleShape cache;
//son
sf::Music fond;
//textures
sf::Texture cursorT;
sf::Texture backPlanT;
sf::Sprite backPlan;
sf::Texture bouton1T; //comande normal
sf::Texture bouton2T; //option
sf::Texture bouton3T; //quit
sf::Texture boutonMultiT;
sf::Sprite cursor;
sf::Sprite bouton1;
sf::Sprite bouton3;
sf::Sprite bouton2;
sf::Sprite boutonMulti;
//cloud
sf::Texture cloudT;
sf::Sprite cloud;
sf::Vector2f cloudPos;
sf::Sprite cloud2;
sf::Vector2f cloud2Pos;
//moon / sun
sf::Vector2f sunPos;
sf::Vector2f moonPos;
sf::Texture sunT;
sf::Texture moonT;
sf::Sprite sun;
sf::Sprite moon;
// sf::Mouse mouse;
sf::Vector2i MousePos;
sf::Vector2f MousePosCoo;
sf::View mainView;
//temp
int tempCache;
};
#endif // MENU_HPP_INCLUDED
|
[
"gm.kirthos@gmail.com"
] |
gm.kirthos@gmail.com
|
af24f473cf2766bb59d207fa4296a652398f5e2b
|
1a562c8e43247097582e0089d386eed5b450ed49
|
/Interpreter/DataTypes.h
|
c5b4b66eb5452cf12cb8e09ebca51b0d2d1c6604
|
[] |
no_license
|
baniuk/RadiographySoftware
|
89c202496f4f318005e0459575f29d8928053d99
|
c0efc3b842d56dc19975c213f654299829931e5e
|
refs/heads/master
| 2020-04-29T04:27:32.174950
| 2019-03-15T15:43:17
| 2019-03-15T15:43:17
| 175,847,643
| 0
| 0
| null | null | null | null |
WINDOWS-1250
|
C++
| false
| false
| 829
|
h
|
#pragma once
#define IMAGE 0x00000010
#define STRING 0x00000100
#define MATRIX 0x00001000
#define NUMBER MATRIX
#define DT UINT
#define maxline 256 // maksymalna ilosc znakow w linii
#define CHARNOEXIST 32000
#define maxnameofleftparametr 256
#define maxwindows 256;
#define maxbuffor 50 // ilosc komend
#define maxvar 1024 // ilosc zmiennych w programie (te parmaetry określane w fazie init będą)
#define maxlines 512 // maksymlana ilość linii
#define maxerror 512
#define MAXSIZE 25 // maks nazwa funkcji
#define MAX_GLOBALS 25 // max ilosc zmiennych globalnych
#define maxthreads 8 // maxymalna ilosc watkow
/*
class C_MATRIX
{
public:
C_MATRIX(int rows, int cols);
void SetValue(int row, int col,int value);
int GetValue(int row, int col);
unsigned int rows, cols;
int* data;
public:
~C_MATRIX(void);
};
*/
|
[
"P.Baniukiewicz@warwick.ac.uk"
] |
P.Baniukiewicz@warwick.ac.uk
|
c8e3734adfecfce28189617605e1de41c9588907
|
214355db2ebb44a0c63a993d96cd759e0061a33b
|
/EmptyProject/GameClear.h
|
a989b7c44cda67d38aa8285ce98eb95ee6006997
|
[] |
no_license
|
JeongTaeLee/Gleise-518D
|
b59e24a2f5722155c732adc346ace087cd66c691
|
b9f69cb33b63f4a4e25e6399d8915e35daf95df9
|
refs/heads/master
| 2020-05-02T21:31:55.350658
| 2019-04-02T05:47:45
| 2019-04-02T05:47:45
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 230
|
h
|
#pragma once
#include "GameObject.h"
class GameClear :
public GameObject
{
public:
bool bCompleteProcess = false;
public:
GameClear();
virtual ~GameClear();
virtual void Init() override;
virtual void Update() override;
};
|
[
"jeongtae8633@gmail.com"
] |
jeongtae8633@gmail.com
|
c4f401c6eaeb7dc454c09a3e0267e4aa30eed420
|
2a9213024770a6c6c6b305bf3cf45f44e6398d47
|
/TestClient/GlobalInstance.cpp
|
f2c419561a9e8e958b9422e286fcfd2c295fcfc2
|
[
"Unlicense"
] |
permissive
|
wissunpower/WeizenbierGame
|
195d36e7a32485dc76f06c2b0d5c11ee6d5b4a60
|
34f027c43055dfa6b05e62ca0b6c31271af013f3
|
refs/heads/main
| 2023-08-06T06:44:36.240176
| 2021-09-29T07:34:29
| 2021-09-29T07:34:29
| 390,057,582
| 0
| 0
|
Unlicense
| 2021-09-26T16:22:57
| 2021-07-27T16:43:06
|
C++
|
UTF-8
|
C++
| false
| false
| 179
|
cpp
|
#include "ResponseIntervalCollector.h"
#include "GlobalInstance.h"
ResponseIntervalCollector* ResponseIntervalCollectorInstance = Singleton<ResponseIntervalCollector>::Get();
|
[
"30381759+wissunpower@users.noreply.github.com"
] |
30381759+wissunpower@users.noreply.github.com
|
b53c9d277d602579eb1577da2575c4600f90b298
|
6b5bddc107b800f7fd658413cf626ed6f801ed36
|
/funcs/debug.cpp
|
911394790a325948e6fdf6e8c8f6abdb04a44e6e
|
[
"CC0-1.0",
"LicenseRef-scancode-public-domain"
] |
permissive
|
ashr/notes
|
6c5cc00c1b0a2e30e87755b6f5ee32d463f28ed5
|
c449d10374b0bded8177e318892fdd58bcce3524
|
refs/heads/master
| 2021-05-11T04:39:22.877171
| 2018-01-17T15:01:05
| 2018-01-17T15:01:05
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 261
|
cpp
|
// address: 0x4086F4
//
// debug_load_graphics loads debugging graphics.
void debug_load_graphics();
// address: 0x40870F
//
// debug_cleanup releases the resources used for debugging.
void debug_cleanup();
// address: 0x408721
//
// TODO: add documentation.
|
[
"rnd0x00@gmail.com"
] |
rnd0x00@gmail.com
|
1de0c1f4544030bdb1b8b0665e7443ee8b195520
|
297497957c531d81ba286bc91253fbbb78b4d8be
|
/media/libyuv/libyuv/source/planar_functions.cc
|
f4463d547deb03eab1965e14dd323ae03e0e18be
|
[
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
marco-c/gecko-dev-comments-removed
|
7a9dd34045b07e6b22f0c636c0a836b9e639f9d3
|
61942784fb157763e65608e5a29b3729b0aa66fa
|
refs/heads/master
| 2023-08-09T18:55:25.895853
| 2023-08-01T00:40:39
| 2023-08-01T00:40:39
| 211,297,481
| 0
| 0
|
NOASSERTION
| 2019-09-29T01:27:49
| 2019-09-27T10:44:24
|
C++
|
UTF-8
|
C++
| false
| false
| 149,944
|
cc
|
#include "libyuv/planar_functions.h"
#include <assert.h>
#include <string.h>
#include "libyuv/cpu_id.h"
#ifdef HAVE_JPEG
#include "libyuv/mjpeg_decoder.h"
#endif
#include "libyuv/row.h"
#include "libyuv/scale_row.h"
#ifdef __cplusplus
namespace libyuv {
extern "C" {
#endif
LIBYUV_API
void CopyPlane(const uint8_t* src_y,
int src_stride_y,
uint8_t* dst_y,
int dst_stride_y,
int width,
int height) {
int y;
void (*CopyRow)(const uint8_t* src, uint8_t* dst, int width) = CopyRow_C;
if (width <= 0 || height == 0) {
return;
}
if (height < 0) {
height = -height;
dst_y = dst_y + (height - 1) * dst_stride_y;
dst_stride_y = -dst_stride_y;
}
if (src_stride_y == width && dst_stride_y == width) {
width *= height;
height = 1;
src_stride_y = dst_stride_y = 0;
}
if (src_y == dst_y && src_stride_y == dst_stride_y) {
return;
}
#if defined(HAS_COPYROW_SSE2)
if (TestCpuFlag(kCpuHasSSE2)) {
CopyRow = IS_ALIGNED(width, 32) ? CopyRow_SSE2 : CopyRow_Any_SSE2;
}
#endif
#if defined(HAS_COPYROW_AVX)
if (TestCpuFlag(kCpuHasAVX)) {
CopyRow = IS_ALIGNED(width, 64) ? CopyRow_AVX : CopyRow_Any_AVX;
}
#endif
#if defined(HAS_COPYROW_ERMS)
if (TestCpuFlag(kCpuHasERMS)) {
CopyRow = CopyRow_ERMS;
}
#endif
#if defined(HAS_COPYROW_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
CopyRow = IS_ALIGNED(width, 32) ? CopyRow_NEON : CopyRow_Any_NEON;
}
#endif
for (y = 0; y < height; ++y) {
CopyRow(src_y, dst_y, width);
src_y += src_stride_y;
dst_y += dst_stride_y;
}
}
LIBYUV_API
void CopyPlane_16(const uint16_t* src_y,
int src_stride_y,
uint16_t* dst_y,
int dst_stride_y,
int width,
int height) {
CopyPlane((const uint8_t*)src_y, src_stride_y * 2, (uint8_t*)dst_y,
dst_stride_y * 2, width * 2, height);
}
LIBYUV_API
void Convert16To8Plane(const uint16_t* src_y,
int src_stride_y,
uint8_t* dst_y,
int dst_stride_y,
int scale,
int width,
int height) {
int y;
void (*Convert16To8Row)(const uint16_t* src_y, uint8_t* dst_y, int scale,
int width) = Convert16To8Row_C;
if (width <= 0 || height == 0) {
return;
}
if (height < 0) {
height = -height;
dst_y = dst_y + (height - 1) * dst_stride_y;
dst_stride_y = -dst_stride_y;
}
if (src_stride_y == width && dst_stride_y == width) {
width *= height;
height = 1;
src_stride_y = dst_stride_y = 0;
}
#if defined(HAS_CONVERT16TO8ROW_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
Convert16To8Row = Convert16To8Row_Any_NEON;
if (IS_ALIGNED(width, 16)) {
Convert16To8Row = Convert16To8Row_NEON;
}
}
#endif
#if defined(HAS_CONVERT16TO8ROW_SSSE3)
if (TestCpuFlag(kCpuHasSSSE3)) {
Convert16To8Row = Convert16To8Row_Any_SSSE3;
if (IS_ALIGNED(width, 16)) {
Convert16To8Row = Convert16To8Row_SSSE3;
}
}
#endif
#if defined(HAS_CONVERT16TO8ROW_AVX2)
if (TestCpuFlag(kCpuHasAVX2)) {
Convert16To8Row = Convert16To8Row_Any_AVX2;
if (IS_ALIGNED(width, 32)) {
Convert16To8Row = Convert16To8Row_AVX2;
}
}
#endif
for (y = 0; y < height; ++y) {
Convert16To8Row(src_y, dst_y, scale, width);
src_y += src_stride_y;
dst_y += dst_stride_y;
}
}
LIBYUV_API
void Convert8To16Plane(const uint8_t* src_y,
int src_stride_y,
uint16_t* dst_y,
int dst_stride_y,
int scale,
int width,
int height) {
int y;
void (*Convert8To16Row)(const uint8_t* src_y, uint16_t* dst_y, int scale,
int width) = Convert8To16Row_C;
if (width <= 0 || height == 0) {
return;
}
if (height < 0) {
height = -height;
dst_y = dst_y + (height - 1) * dst_stride_y;
dst_stride_y = -dst_stride_y;
}
if (src_stride_y == width && dst_stride_y == width) {
width *= height;
height = 1;
src_stride_y = dst_stride_y = 0;
}
#if defined(HAS_CONVERT8TO16ROW_SSE2)
if (TestCpuFlag(kCpuHasSSE2)) {
Convert8To16Row = Convert8To16Row_Any_SSE2;
if (IS_ALIGNED(width, 16)) {
Convert8To16Row = Convert8To16Row_SSE2;
}
}
#endif
#if defined(HAS_CONVERT8TO16ROW_AVX2)
if (TestCpuFlag(kCpuHasAVX2)) {
Convert8To16Row = Convert8To16Row_Any_AVX2;
if (IS_ALIGNED(width, 32)) {
Convert8To16Row = Convert8To16Row_AVX2;
}
}
#endif
for (y = 0; y < height; ++y) {
Convert8To16Row(src_y, dst_y, scale, width);
src_y += src_stride_y;
dst_y += dst_stride_y;
}
}
LIBYUV_API
int I422Copy(const uint8_t* src_y,
int src_stride_y,
const uint8_t* src_u,
int src_stride_u,
const uint8_t* src_v,
int src_stride_v,
uint8_t* dst_y,
int dst_stride_y,
uint8_t* dst_u,
int dst_stride_u,
uint8_t* dst_v,
int dst_stride_v,
int width,
int height) {
int halfwidth = (width + 1) >> 1;
if ((!src_y && dst_y) || !src_u || !src_v || !dst_u || !dst_v || width <= 0 ||
height == 0) {
return -1;
}
if (height < 0) {
height = -height;
src_y = src_y + (height - 1) * src_stride_y;
src_u = src_u + (height - 1) * src_stride_u;
src_v = src_v + (height - 1) * src_stride_v;
src_stride_y = -src_stride_y;
src_stride_u = -src_stride_u;
src_stride_v = -src_stride_v;
}
if (dst_y) {
CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height);
}
CopyPlane(src_u, src_stride_u, dst_u, dst_stride_u, halfwidth, height);
CopyPlane(src_v, src_stride_v, dst_v, dst_stride_v, halfwidth, height);
return 0;
}
LIBYUV_API
int I444Copy(const uint8_t* src_y,
int src_stride_y,
const uint8_t* src_u,
int src_stride_u,
const uint8_t* src_v,
int src_stride_v,
uint8_t* dst_y,
int dst_stride_y,
uint8_t* dst_u,
int dst_stride_u,
uint8_t* dst_v,
int dst_stride_v,
int width,
int height) {
if ((!src_y && dst_y) || !src_u || !src_v || !dst_u || !dst_v || width <= 0 ||
height == 0) {
return -1;
}
if (height < 0) {
height = -height;
src_y = src_y + (height - 1) * src_stride_y;
src_u = src_u + (height - 1) * src_stride_u;
src_v = src_v + (height - 1) * src_stride_v;
src_stride_y = -src_stride_y;
src_stride_u = -src_stride_u;
src_stride_v = -src_stride_v;
}
if (dst_y) {
CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height);
}
CopyPlane(src_u, src_stride_u, dst_u, dst_stride_u, width, height);
CopyPlane(src_v, src_stride_v, dst_v, dst_stride_v, width, height);
return 0;
}
LIBYUV_API
int I210Copy(const uint16_t* src_y,
int src_stride_y,
const uint16_t* src_u,
int src_stride_u,
const uint16_t* src_v,
int src_stride_v,
uint16_t* dst_y,
int dst_stride_y,
uint16_t* dst_u,
int dst_stride_u,
uint16_t* dst_v,
int dst_stride_v,
int width,
int height) {
int halfwidth = (width + 1) >> 1;
if ((!src_y && dst_y) || !src_u || !src_v || !dst_u || !dst_v || width <= 0 ||
height == 0) {
return -1;
}
if (height < 0) {
height = -height;
src_y = src_y + (height - 1) * src_stride_y;
src_u = src_u + (height - 1) * src_stride_u;
src_v = src_v + (height - 1) * src_stride_v;
src_stride_y = -src_stride_y;
src_stride_u = -src_stride_u;
src_stride_v = -src_stride_v;
}
if (dst_y) {
CopyPlane_16(src_y, src_stride_y, dst_y, dst_stride_y, width, height);
}
CopyPlane_16(src_u, src_stride_u, dst_u, dst_stride_u, halfwidth, height);
CopyPlane_16(src_v, src_stride_v, dst_v, dst_stride_v, halfwidth, height);
return 0;
}
LIBYUV_API
int I410Copy(const uint16_t* src_y,
int src_stride_y,
const uint16_t* src_u,
int src_stride_u,
const uint16_t* src_v,
int src_stride_v,
uint16_t* dst_y,
int dst_stride_y,
uint16_t* dst_u,
int dst_stride_u,
uint16_t* dst_v,
int dst_stride_v,
int width,
int height) {
if ((!src_y && dst_y) || !src_u || !src_v || !dst_u || !dst_v || width <= 0 ||
height == 0) {
return -1;
}
if (height < 0) {
height = -height;
src_y = src_y + (height - 1) * src_stride_y;
src_u = src_u + (height - 1) * src_stride_u;
src_v = src_v + (height - 1) * src_stride_v;
src_stride_y = -src_stride_y;
src_stride_u = -src_stride_u;
src_stride_v = -src_stride_v;
}
if (dst_y) {
CopyPlane_16(src_y, src_stride_y, dst_y, dst_stride_y, width, height);
}
CopyPlane_16(src_u, src_stride_u, dst_u, dst_stride_u, width, height);
CopyPlane_16(src_v, src_stride_v, dst_v, dst_stride_v, width, height);
return 0;
}
LIBYUV_API
int I400ToI400(const uint8_t* src_y,
int src_stride_y,
uint8_t* dst_y,
int dst_stride_y,
int width,
int height) {
if (!src_y || !dst_y || width <= 0 || height == 0) {
return -1;
}
if (height < 0) {
height = -height;
src_y = src_y + (height - 1) * src_stride_y;
src_stride_y = -src_stride_y;
}
CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height);
return 0;
}
LIBYUV_API
int I420ToI400(const uint8_t* src_y,
int src_stride_y,
const uint8_t* src_u,
int src_stride_u,
const uint8_t* src_v,
int src_stride_v,
uint8_t* dst_y,
int dst_stride_y,
int width,
int height) {
(void)src_u;
(void)src_stride_u;
(void)src_v;
(void)src_stride_v;
if (!src_y || !dst_y || width <= 0 || height == 0) {
return -1;
}
if (height < 0) {
height = -height;
src_y = src_y + (height - 1) * src_stride_y;
src_stride_y = -src_stride_y;
}
CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height);
return 0;
}
LIBYUV_API
int NV12Copy(const uint8_t* src_y,
int src_stride_y,
const uint8_t* src_uv,
int src_stride_uv,
uint8_t* dst_y,
int dst_stride_y,
uint8_t* dst_uv,
int dst_stride_uv,
int width,
int height) {
int halfwidth = (width + 1) >> 1;
int halfheight = (height + 1) >> 1;
if (!src_y || !dst_y || !src_uv || !dst_uv || width <= 0 || height == 0) {
return -1;
}
if (height < 0) {
height = -height;
halfheight = (height + 1) >> 1;
src_y = src_y + (height - 1) * src_stride_y;
src_uv = src_uv + (halfheight - 1) * src_stride_uv;
src_stride_y = -src_stride_y;
src_stride_uv = -src_stride_uv;
}
CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height);
CopyPlane(src_uv, src_stride_uv, dst_uv, dst_stride_uv, halfwidth * 2,
halfheight);
return 0;
}
LIBYUV_API
int NV21Copy(const uint8_t* src_y,
int src_stride_y,
const uint8_t* src_vu,
int src_stride_vu,
uint8_t* dst_y,
int dst_stride_y,
uint8_t* dst_vu,
int dst_stride_vu,
int width,
int height) {
return NV12Copy(src_y, src_stride_y, src_vu, src_stride_vu, dst_y,
dst_stride_y, dst_vu, dst_stride_vu, width, height);
}
LIBYUV_API
void SplitUVPlane(const uint8_t* src_uv,
int src_stride_uv,
uint8_t* dst_u,
int dst_stride_u,
uint8_t* dst_v,
int dst_stride_v,
int width,
int height) {
int y;
void (*SplitUVRow)(const uint8_t* src_uv, uint8_t* dst_u, uint8_t* dst_v,
int width) = SplitUVRow_C;
if (width <= 0 || height == 0) {
return;
}
if (height < 0) {
height = -height;
dst_u = dst_u + (height - 1) * dst_stride_u;
dst_v = dst_v + (height - 1) * dst_stride_v;
dst_stride_u = -dst_stride_u;
dst_stride_v = -dst_stride_v;
}
if (src_stride_uv == width * 2 && dst_stride_u == width &&
dst_stride_v == width) {
width *= height;
height = 1;
src_stride_uv = dst_stride_u = dst_stride_v = 0;
}
#if defined(HAS_SPLITUVROW_SSE2)
if (TestCpuFlag(kCpuHasSSE2)) {
SplitUVRow = SplitUVRow_Any_SSE2;
if (IS_ALIGNED(width, 16)) {
SplitUVRow = SplitUVRow_SSE2;
}
}
#endif
#if defined(HAS_SPLITUVROW_AVX2)
if (TestCpuFlag(kCpuHasAVX2)) {
SplitUVRow = SplitUVRow_Any_AVX2;
if (IS_ALIGNED(width, 32)) {
SplitUVRow = SplitUVRow_AVX2;
}
}
#endif
#if defined(HAS_SPLITUVROW_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
SplitUVRow = SplitUVRow_Any_NEON;
if (IS_ALIGNED(width, 16)) {
SplitUVRow = SplitUVRow_NEON;
}
}
#endif
#if defined(HAS_SPLITUVROW_MSA)
if (TestCpuFlag(kCpuHasMSA)) {
SplitUVRow = SplitUVRow_Any_MSA;
if (IS_ALIGNED(width, 32)) {
SplitUVRow = SplitUVRow_MSA;
}
}
#endif
#if defined(HAS_SPLITUVROW_LSX)
if (TestCpuFlag(kCpuHasLSX)) {
SplitUVRow = SplitUVRow_Any_LSX;
if (IS_ALIGNED(width, 32)) {
SplitUVRow = SplitUVRow_LSX;
}
}
#endif
for (y = 0; y < height; ++y) {
SplitUVRow(src_uv, dst_u, dst_v, width);
dst_u += dst_stride_u;
dst_v += dst_stride_v;
src_uv += src_stride_uv;
}
}
LIBYUV_API
void MergeUVPlane(const uint8_t* src_u,
int src_stride_u,
const uint8_t* src_v,
int src_stride_v,
uint8_t* dst_uv,
int dst_stride_uv,
int width,
int height) {
int y;
void (*MergeUVRow)(const uint8_t* src_u, const uint8_t* src_v,
uint8_t* dst_uv, int width) = MergeUVRow_C;
if (width <= 0 || height == 0) {
return;
}
if (height < 0) {
height = -height;
dst_uv = dst_uv + (height - 1) * dst_stride_uv;
dst_stride_uv = -dst_stride_uv;
}
if (src_stride_u == width && src_stride_v == width &&
dst_stride_uv == width * 2) {
width *= height;
height = 1;
src_stride_u = src_stride_v = dst_stride_uv = 0;
}
#if defined(HAS_MERGEUVROW_SSE2)
if (TestCpuFlag(kCpuHasSSE2)) {
MergeUVRow = MergeUVRow_Any_SSE2;
if (IS_ALIGNED(width, 16)) {
MergeUVRow = MergeUVRow_SSE2;
}
}
#endif
#if defined(HAS_MERGEUVROW_AVX2)
if (TestCpuFlag(kCpuHasAVX2)) {
MergeUVRow = MergeUVRow_Any_AVX2;
if (IS_ALIGNED(width, 32)) {
MergeUVRow = MergeUVRow_AVX2;
}
}
#endif
#if defined(HAS_MERGEUVROW_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
MergeUVRow = MergeUVRow_Any_NEON;
if (IS_ALIGNED(width, 16)) {
MergeUVRow = MergeUVRow_NEON;
}
}
#endif
#if defined(HAS_MERGEUVROW_MSA)
if (TestCpuFlag(kCpuHasMSA)) {
MergeUVRow = MergeUVRow_Any_MSA;
if (IS_ALIGNED(width, 16)) {
MergeUVRow = MergeUVRow_MSA;
}
}
#endif
#if defined(HAS_MERGEUVROW_LSX)
if (TestCpuFlag(kCpuHasLSX)) {
MergeUVRow = MergeUVRow_Any_LSX;
if (IS_ALIGNED(width, 16)) {
MergeUVRow = MergeUVRow_LSX;
}
}
#endif
for (y = 0; y < height; ++y) {
MergeUVRow(src_u, src_v, dst_uv, width);
src_u += src_stride_u;
src_v += src_stride_v;
dst_uv += dst_stride_uv;
}
}
LIBYUV_API
void SplitUVPlane_16(const uint16_t* src_uv,
int src_stride_uv,
uint16_t* dst_u,
int dst_stride_u,
uint16_t* dst_v,
int dst_stride_v,
int width,
int height,
int depth) {
int y;
void (*SplitUVRow_16)(const uint16_t* src_uv, uint16_t* dst_u,
uint16_t* dst_v, int depth, int width) =
SplitUVRow_16_C;
if (width <= 0 || height == 0) {
return;
}
if (height < 0) {
height = -height;
dst_u = dst_u + (height - 1) * dst_stride_u;
dst_v = dst_v + (height - 1) * dst_stride_v;
dst_stride_u = -dst_stride_u;
dst_stride_v = -dst_stride_v;
}
if (src_stride_uv == width * 2 && dst_stride_u == width &&
dst_stride_v == width) {
width *= height;
height = 1;
src_stride_uv = dst_stride_u = dst_stride_v = 0;
}
#if defined(HAS_SPLITUVROW_16_AVX2)
if (TestCpuFlag(kCpuHasAVX2)) {
SplitUVRow_16 = SplitUVRow_16_Any_AVX2;
if (IS_ALIGNED(width, 16)) {
SplitUVRow_16 = SplitUVRow_16_AVX2;
}
}
#endif
#if defined(HAS_SPLITUVROW_16_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
SplitUVRow_16 = SplitUVRow_16_Any_NEON;
if (IS_ALIGNED(width, 8)) {
SplitUVRow_16 = SplitUVRow_16_NEON;
}
}
#endif
for (y = 0; y < height; ++y) {
SplitUVRow_16(src_uv, dst_u, dst_v, depth, width);
dst_u += dst_stride_u;
dst_v += dst_stride_v;
src_uv += src_stride_uv;
}
}
LIBYUV_API
void MergeUVPlane_16(const uint16_t* src_u,
int src_stride_u,
const uint16_t* src_v,
int src_stride_v,
uint16_t* dst_uv,
int dst_stride_uv,
int width,
int height,
int depth) {
int y;
void (*MergeUVRow_16)(const uint16_t* src_u, const uint16_t* src_v,
uint16_t* dst_uv, int depth, int width) =
MergeUVRow_16_C;
assert(depth >= 8);
assert(depth <= 16);
if (width <= 0 || height == 0) {
return;
}
if (height < 0) {
height = -height;
dst_uv = dst_uv + (height - 1) * dst_stride_uv;
dst_stride_uv = -dst_stride_uv;
}
if (src_stride_u == width && src_stride_v == width &&
dst_stride_uv == width * 2) {
width *= height;
height = 1;
src_stride_u = src_stride_v = dst_stride_uv = 0;
}
#if defined(HAS_MERGEUVROW_16_AVX2)
if (TestCpuFlag(kCpuHasAVX2)) {
MergeUVRow_16 = MergeUVRow_16_Any_AVX2;
if (IS_ALIGNED(width, 16)) {
MergeUVRow_16 = MergeUVRow_16_AVX2;
}
}
#endif
#if defined(HAS_MERGEUVROW_16_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
MergeUVRow_16 = MergeUVRow_16_Any_NEON;
if (IS_ALIGNED(width, 8)) {
MergeUVRow_16 = MergeUVRow_16_NEON;
}
}
#endif
for (y = 0; y < height; ++y) {
MergeUVRow_16(src_u, src_v, dst_uv, depth, width);
src_u += src_stride_u;
src_v += src_stride_v;
dst_uv += dst_stride_uv;
}
}
LIBYUV_API
void ConvertToMSBPlane_16(const uint16_t* src_y,
int src_stride_y,
uint16_t* dst_y,
int dst_stride_y,
int width,
int height,
int depth) {
int y;
int scale = 1 << (16 - depth);
void (*MultiplyRow_16)(const uint16_t* src_y, uint16_t* dst_y, int scale,
int width) = MultiplyRow_16_C;
if (width <= 0 || height == 0) {
return;
}
if (height < 0) {
height = -height;
dst_y = dst_y + (height - 1) * dst_stride_y;
dst_stride_y = -dst_stride_y;
}
if (src_stride_y == width && dst_stride_y == width) {
width *= height;
height = 1;
src_stride_y = dst_stride_y = 0;
}
#if defined(HAS_MULTIPLYROW_16_AVX2)
if (TestCpuFlag(kCpuHasAVX2)) {
MultiplyRow_16 = MultiplyRow_16_Any_AVX2;
if (IS_ALIGNED(width, 32)) {
MultiplyRow_16 = MultiplyRow_16_AVX2;
}
}
#endif
#if defined(HAS_MULTIPLYROW_16_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
MultiplyRow_16 = MultiplyRow_16_Any_NEON;
if (IS_ALIGNED(width, 16)) {
MultiplyRow_16 = MultiplyRow_16_NEON;
}
}
#endif
for (y = 0; y < height; ++y) {
MultiplyRow_16(src_y, dst_y, scale, width);
src_y += src_stride_y;
dst_y += dst_stride_y;
}
}
LIBYUV_API
void ConvertToLSBPlane_16(const uint16_t* src_y,
int src_stride_y,
uint16_t* dst_y,
int dst_stride_y,
int width,
int height,
int depth) {
int y;
int scale = 1 << depth;
void (*DivideRow)(const uint16_t* src_y, uint16_t* dst_y, int scale,
int width) = DivideRow_16_C;
if (width <= 0 || height == 0) {
return;
}
if (height < 0) {
height = -height;
dst_y = dst_y + (height - 1) * dst_stride_y;
dst_stride_y = -dst_stride_y;
}
if (src_stride_y == width && dst_stride_y == width) {
width *= height;
height = 1;
src_stride_y = dst_stride_y = 0;
}
#if defined(HAS_DIVIDEROW_16_AVX2)
if (TestCpuFlag(kCpuHasAVX2)) {
DivideRow = DivideRow_16_Any_AVX2;
if (IS_ALIGNED(width, 32)) {
DivideRow = DivideRow_16_AVX2;
}
}
#endif
#if defined(HAS_DIVIDEROW_16_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
DivideRow = DivideRow_16_Any_NEON;
if (IS_ALIGNED(width, 16)) {
DivideRow = DivideRow_16_NEON;
}
}
#endif
for (y = 0; y < height; ++y) {
DivideRow(src_y, dst_y, scale, width);
src_y += src_stride_y;
dst_y += dst_stride_y;
}
}
LIBYUV_API
void SwapUVPlane(const uint8_t* src_uv,
int src_stride_uv,
uint8_t* dst_vu,
int dst_stride_vu,
int width,
int height) {
int y;
void (*SwapUVRow)(const uint8_t* src_uv, uint8_t* dst_vu, int width) =
SwapUVRow_C;
if (width <= 0 || height == 0) {
return;
}
if (height < 0) {
height = -height;
src_uv = src_uv + (height - 1) * src_stride_uv;
src_stride_uv = -src_stride_uv;
}
if (src_stride_uv == width * 2 && dst_stride_vu == width * 2) {
width *= height;
height = 1;
src_stride_uv = dst_stride_vu = 0;
}
#if defined(HAS_SWAPUVROW_SSSE3)
if (TestCpuFlag(kCpuHasSSSE3)) {
SwapUVRow = SwapUVRow_Any_SSSE3;
if (IS_ALIGNED(width, 16)) {
SwapUVRow = SwapUVRow_SSSE3;
}
}
#endif
#if defined(HAS_SWAPUVROW_AVX2)
if (TestCpuFlag(kCpuHasAVX2)) {
SwapUVRow = SwapUVRow_Any_AVX2;
if (IS_ALIGNED(width, 32)) {
SwapUVRow = SwapUVRow_AVX2;
}
}
#endif
#if defined(HAS_SWAPUVROW_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
SwapUVRow = SwapUVRow_Any_NEON;
if (IS_ALIGNED(width, 16)) {
SwapUVRow = SwapUVRow_NEON;
}
}
#endif
for (y = 0; y < height; ++y) {
SwapUVRow(src_uv, dst_vu, width);
src_uv += src_stride_uv;
dst_vu += dst_stride_vu;
}
}
LIBYUV_API
int NV21ToNV12(const uint8_t* src_y,
int src_stride_y,
const uint8_t* src_vu,
int src_stride_vu,
uint8_t* dst_y,
int dst_stride_y,
uint8_t* dst_uv,
int dst_stride_uv,
int width,
int height) {
int halfwidth = (width + 1) >> 1;
int halfheight = (height + 1) >> 1;
if (!src_vu || !dst_uv || width <= 0 || height == 0) {
return -1;
}
if (dst_y) {
CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height);
}
if (height < 0) {
height = -height;
halfheight = (height + 1) >> 1;
src_vu = src_vu + (halfheight - 1) * src_stride_vu;
src_stride_vu = -src_stride_vu;
}
SwapUVPlane(src_vu, src_stride_vu, dst_uv, dst_stride_uv, halfwidth,
halfheight);
return 0;
}
#define IS_POWEROFTWO(x) (!((x) & ((x)-1)))
LIBYUV_API
int DetilePlane(const uint8_t* src_y,
int src_stride_y,
uint8_t* dst_y,
int dst_stride_y,
int width,
int height,
int tile_height) {
const ptrdiff_t src_tile_stride = 16 * tile_height;
int y;
void (*DetileRow)(const uint8_t* src, ptrdiff_t src_tile_stride, uint8_t* dst,
int width) = DetileRow_C;
if (!src_y || !dst_y || width <= 0 || height == 0 ||
!IS_POWEROFTWO(tile_height)) {
return -1;
}
if (height < 0) {
height = -height;
dst_y = dst_y + (height - 1) * dst_stride_y;
dst_stride_y = -dst_stride_y;
}
#if defined(HAS_DETILEROW_SSE2)
if (TestCpuFlag(kCpuHasSSE2)) {
DetileRow = DetileRow_Any_SSE2;
if (IS_ALIGNED(width, 16)) {
DetileRow = DetileRow_SSE2;
}
}
#endif
#if defined(HAS_DETILEROW_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
DetileRow = DetileRow_Any_NEON;
if (IS_ALIGNED(width, 16)) {
DetileRow = DetileRow_NEON;
}
}
#endif
for (y = 0; y < height; ++y) {
DetileRow(src_y, src_tile_stride, dst_y, width);
dst_y += dst_stride_y;
src_y += 16;
if ((y & (tile_height - 1)) == (tile_height - 1)) {
src_y = src_y - src_tile_stride + src_stride_y * tile_height;
}
}
return 0;
}
LIBYUV_API
int DetilePlane_16(const uint16_t* src_y,
int src_stride_y,
uint16_t* dst_y,
int dst_stride_y,
int width,
int height,
int tile_height) {
const ptrdiff_t src_tile_stride = 16 * tile_height;
int y;
void (*DetileRow_16)(const uint16_t* src, ptrdiff_t src_tile_stride,
uint16_t* dst, int width) = DetileRow_16_C;
if (!src_y || !dst_y || width <= 0 || height == 0 ||
!IS_POWEROFTWO(tile_height)) {
return -1;
}
if (height < 0) {
height = -height;
dst_y = dst_y + (height - 1) * dst_stride_y;
dst_stride_y = -dst_stride_y;
}
#if defined(HAS_DETILEROW_16_SSE2)
if (TestCpuFlag(kCpuHasSSE2)) {
DetileRow_16 = DetileRow_16_Any_SSE2;
if (IS_ALIGNED(width, 16)) {
DetileRow_16 = DetileRow_16_SSE2;
}
}
#endif
#if defined(HAS_DETILEROW_16_AVX)
if (TestCpuFlag(kCpuHasAVX)) {
DetileRow_16 = DetileRow_16_Any_AVX;
if (IS_ALIGNED(width, 16)) {
DetileRow_16 = DetileRow_16_AVX;
}
}
#endif
#if defined(HAS_DETILEROW_16_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
DetileRow_16 = DetileRow_16_Any_NEON;
if (IS_ALIGNED(width, 16)) {
DetileRow_16 = DetileRow_16_NEON;
}
}
#endif
for (y = 0; y < height; ++y) {
DetileRow_16(src_y, src_tile_stride, dst_y, width);
dst_y += dst_stride_y;
src_y += 16;
if ((y & (tile_height - 1)) == (tile_height - 1)) {
src_y = src_y - src_tile_stride + src_stride_y * tile_height;
}
}
return 0;
}
LIBYUV_API
void DetileSplitUVPlane(const uint8_t* src_uv,
int src_stride_uv,
uint8_t* dst_u,
int dst_stride_u,
uint8_t* dst_v,
int dst_stride_v,
int width,
int height,
int tile_height) {
const ptrdiff_t src_tile_stride = 16 * tile_height;
int y;
void (*DetileSplitUVRow)(const uint8_t* src, ptrdiff_t src_tile_stride,
uint8_t* dst_u, uint8_t* dst_v, int width) =
DetileSplitUVRow_C;
assert(src_stride_uv >= 0);
assert(tile_height > 0);
assert(src_stride_uv > 0);
if (width <= 0 || height == 0) {
return;
}
if (height < 0) {
height = -height;
dst_u = dst_u + (height - 1) * dst_stride_u;
dst_stride_u = -dst_stride_u;
dst_v = dst_v + (height - 1) * dst_stride_v;
dst_stride_v = -dst_stride_v;
}
#if defined(HAS_DETILESPLITUVROW_SSSE3)
if (TestCpuFlag(kCpuHasSSSE3)) {
DetileSplitUVRow = DetileSplitUVRow_Any_SSSE3;
if (IS_ALIGNED(width, 16)) {
DetileSplitUVRow = DetileSplitUVRow_SSSE3;
}
}
#endif
#if defined(HAS_DETILESPLITUVROW_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
DetileSplitUVRow = DetileSplitUVRow_Any_NEON;
if (IS_ALIGNED(width, 16)) {
DetileSplitUVRow = DetileSplitUVRow_NEON;
}
}
#endif
for (y = 0; y < height; ++y) {
DetileSplitUVRow(src_uv, src_tile_stride, dst_u, dst_v, width);
dst_u += dst_stride_u;
dst_v += dst_stride_v;
src_uv += 16;
if ((y & (tile_height - 1)) == (tile_height - 1)) {
src_uv = src_uv - src_tile_stride + src_stride_uv * tile_height;
}
}
}
LIBYUV_API
void DetileToYUY2(const uint8_t* src_y,
int src_stride_y,
const uint8_t* src_uv,
int src_stride_uv,
uint8_t* dst_yuy2,
int dst_stride_yuy2,
int width,
int height,
int tile_height) {
const ptrdiff_t src_y_tile_stride = 16 * tile_height;
const ptrdiff_t src_uv_tile_stride = src_y_tile_stride / 2;
int y;
void (*DetileToYUY2)(const uint8_t* src_y, ptrdiff_t src_y_tile_stride,
const uint8_t* src_uv, ptrdiff_t src_uv_tile_stride,
uint8_t* dst_yuy2, int width) = DetileToYUY2_C;
assert(src_stride_y >= 0);
assert(src_stride_y > 0);
assert(src_stride_uv >= 0);
assert(src_stride_uv > 0);
assert(tile_height > 0);
if (width <= 0 || height == 0 || tile_height <= 0) {
return;
}
if (height < 0) {
height = -height;
dst_yuy2 = dst_yuy2 + (height - 1) * dst_stride_yuy2;
dst_stride_yuy2 = -dst_stride_yuy2;
}
#if defined(HAS_DETILETOYUY2_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
DetileToYUY2 = DetileToYUY2_Any_NEON;
if (IS_ALIGNED(width, 16)) {
DetileToYUY2 = DetileToYUY2_NEON;
}
}
#endif
#if defined(HAS_DETILETOYUY2_SSE2)
if (TestCpuFlag(kCpuHasSSE2)) {
DetileToYUY2 = DetileToYUY2_Any_SSE2;
if (IS_ALIGNED(width, 16)) {
DetileToYUY2 = DetileToYUY2_SSE2;
}
}
#endif
for (y = 0; y < height; ++y) {
DetileToYUY2(src_y, src_y_tile_stride, src_uv, src_uv_tile_stride, dst_yuy2,
width);
dst_yuy2 += dst_stride_yuy2;
src_y += 16;
if (y & 0x1)
src_uv += 16;
if ((y & (tile_height - 1)) == (tile_height - 1)) {
src_y = src_y - src_y_tile_stride + src_stride_y * tile_height;
src_uv = src_uv - src_uv_tile_stride + src_stride_uv * (tile_height / 2);
}
}
}
LIBYUV_API
void SplitRGBPlane(const uint8_t* src_rgb,
int src_stride_rgb,
uint8_t* dst_r,
int dst_stride_r,
uint8_t* dst_g,
int dst_stride_g,
uint8_t* dst_b,
int dst_stride_b,
int width,
int height) {
int y;
void (*SplitRGBRow)(const uint8_t* src_rgb, uint8_t* dst_r, uint8_t* dst_g,
uint8_t* dst_b, int width) = SplitRGBRow_C;
if (width <= 0 || height == 0) {
return;
}
if (height < 0) {
height = -height;
dst_r = dst_r + (height - 1) * dst_stride_r;
dst_g = dst_g + (height - 1) * dst_stride_g;
dst_b = dst_b + (height - 1) * dst_stride_b;
dst_stride_r = -dst_stride_r;
dst_stride_g = -dst_stride_g;
dst_stride_b = -dst_stride_b;
}
if (src_stride_rgb == width * 3 && dst_stride_r == width &&
dst_stride_g == width && dst_stride_b == width) {
width *= height;
height = 1;
src_stride_rgb = dst_stride_r = dst_stride_g = dst_stride_b = 0;
}
#if defined(HAS_SPLITRGBROW_SSSE3)
if (TestCpuFlag(kCpuHasSSSE3)) {
SplitRGBRow = SplitRGBRow_Any_SSSE3;
if (IS_ALIGNED(width, 16)) {
SplitRGBRow = SplitRGBRow_SSSE3;
}
}
#endif
#if defined(HAS_SPLITRGBROW_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
SplitRGBRow = SplitRGBRow_Any_NEON;
if (IS_ALIGNED(width, 16)) {
SplitRGBRow = SplitRGBRow_NEON;
}
}
#endif
for (y = 0; y < height; ++y) {
SplitRGBRow(src_rgb, dst_r, dst_g, dst_b, width);
dst_r += dst_stride_r;
dst_g += dst_stride_g;
dst_b += dst_stride_b;
src_rgb += src_stride_rgb;
}
}
LIBYUV_API
void MergeRGBPlane(const uint8_t* src_r,
int src_stride_r,
const uint8_t* src_g,
int src_stride_g,
const uint8_t* src_b,
int src_stride_b,
uint8_t* dst_rgb,
int dst_stride_rgb,
int width,
int height) {
int y;
void (*MergeRGBRow)(const uint8_t* src_r, const uint8_t* src_g,
const uint8_t* src_b, uint8_t* dst_rgb, int width) =
MergeRGBRow_C;
if (width <= 0 || height == 0) {
return;
}
if (height < 0) {
height = -height;
dst_rgb = dst_rgb + (height - 1) * dst_stride_rgb;
dst_stride_rgb = -dst_stride_rgb;
}
if (src_stride_r == width && src_stride_g == width && src_stride_b == width &&
dst_stride_rgb == width * 3) {
width *= height;
height = 1;
src_stride_r = src_stride_g = src_stride_b = dst_stride_rgb = 0;
}
#if defined(HAS_MERGERGBROW_SSSE3)
if (TestCpuFlag(kCpuHasSSSE3)) {
MergeRGBRow = MergeRGBRow_Any_SSSE3;
if (IS_ALIGNED(width, 16)) {
MergeRGBRow = MergeRGBRow_SSSE3;
}
}
#endif
#if defined(HAS_MERGERGBROW_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
MergeRGBRow = MergeRGBRow_Any_NEON;
if (IS_ALIGNED(width, 16)) {
MergeRGBRow = MergeRGBRow_NEON;
}
}
#endif
for (y = 0; y < height; ++y) {
MergeRGBRow(src_r, src_g, src_b, dst_rgb, width);
src_r += src_stride_r;
src_g += src_stride_g;
src_b += src_stride_b;
dst_rgb += dst_stride_rgb;
}
}
LIBYUV_NOINLINE
static void SplitARGBPlaneAlpha(const uint8_t* src_argb,
int src_stride_argb,
uint8_t* dst_r,
int dst_stride_r,
uint8_t* dst_g,
int dst_stride_g,
uint8_t* dst_b,
int dst_stride_b,
uint8_t* dst_a,
int dst_stride_a,
int width,
int height) {
int y;
void (*SplitARGBRow)(const uint8_t* src_rgb, uint8_t* dst_r, uint8_t* dst_g,
uint8_t* dst_b, uint8_t* dst_a, int width) =
SplitARGBRow_C;
assert(height > 0);
if (src_stride_argb == width * 4 && dst_stride_r == width &&
dst_stride_g == width && dst_stride_b == width && dst_stride_a == width) {
width *= height;
height = 1;
src_stride_argb = dst_stride_r = dst_stride_g = dst_stride_b =
dst_stride_a = 0;
}
#if defined(HAS_SPLITARGBROW_SSE2)
if (TestCpuFlag(kCpuHasSSE2)) {
SplitARGBRow = SplitARGBRow_Any_SSE2;
if (IS_ALIGNED(width, 8)) {
SplitARGBRow = SplitARGBRow_SSE2;
}
}
#endif
#if defined(HAS_SPLITARGBROW_SSSE3)
if (TestCpuFlag(kCpuHasSSSE3)) {
SplitARGBRow = SplitARGBRow_Any_SSSE3;
if (IS_ALIGNED(width, 8)) {
SplitARGBRow = SplitARGBRow_SSSE3;
}
}
#endif
#if defined(HAS_SPLITARGBROW_AVX2)
if (TestCpuFlag(kCpuHasAVX2)) {
SplitARGBRow = SplitARGBRow_Any_AVX2;
if (IS_ALIGNED(width, 16)) {
SplitARGBRow = SplitARGBRow_AVX2;
}
}
#endif
#if defined(HAS_SPLITARGBROW_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
SplitARGBRow = SplitARGBRow_Any_NEON;
if (IS_ALIGNED(width, 16)) {
SplitARGBRow = SplitARGBRow_NEON;
}
}
#endif
for (y = 0; y < height; ++y) {
SplitARGBRow(src_argb, dst_r, dst_g, dst_b, dst_a, width);
dst_r += dst_stride_r;
dst_g += dst_stride_g;
dst_b += dst_stride_b;
dst_a += dst_stride_a;
src_argb += src_stride_argb;
}
}
LIBYUV_NOINLINE
static void SplitARGBPlaneOpaque(const uint8_t* src_argb,
int src_stride_argb,
uint8_t* dst_r,
int dst_stride_r,
uint8_t* dst_g,
int dst_stride_g,
uint8_t* dst_b,
int dst_stride_b,
int width,
int height) {
int y;
void (*SplitXRGBRow)(const uint8_t* src_rgb, uint8_t* dst_r, uint8_t* dst_g,
uint8_t* dst_b, int width) = SplitXRGBRow_C;
assert(height > 0);
if (src_stride_argb == width * 4 && dst_stride_r == width &&
dst_stride_g == width && dst_stride_b == width) {
width *= height;
height = 1;
src_stride_argb = dst_stride_r = dst_stride_g = dst_stride_b = 0;
}
#if defined(HAS_SPLITXRGBROW_SSE2)
if (TestCpuFlag(kCpuHasSSE2)) {
SplitXRGBRow = SplitXRGBRow_Any_SSE2;
if (IS_ALIGNED(width, 8)) {
SplitXRGBRow = SplitXRGBRow_SSE2;
}
}
#endif
#if defined(HAS_SPLITXRGBROW_SSSE3)
if (TestCpuFlag(kCpuHasSSSE3)) {
SplitXRGBRow = SplitXRGBRow_Any_SSSE3;
if (IS_ALIGNED(width, 8)) {
SplitXRGBRow = SplitXRGBRow_SSSE3;
}
}
#endif
#if defined(HAS_SPLITXRGBROW_AVX2)
if (TestCpuFlag(kCpuHasAVX2)) {
SplitXRGBRow = SplitXRGBRow_Any_AVX2;
if (IS_ALIGNED(width, 16)) {
SplitXRGBRow = SplitXRGBRow_AVX2;
}
}
#endif
#if defined(HAS_SPLITXRGBROW_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
SplitXRGBRow = SplitXRGBRow_Any_NEON;
if (IS_ALIGNED(width, 16)) {
SplitXRGBRow = SplitXRGBRow_NEON;
}
}
#endif
for (y = 0; y < height; ++y) {
SplitXRGBRow(src_argb, dst_r, dst_g, dst_b, width);
dst_r += dst_stride_r;
dst_g += dst_stride_g;
dst_b += dst_stride_b;
src_argb += src_stride_argb;
}
}
LIBYUV_API
void SplitARGBPlane(const uint8_t* src_argb,
int src_stride_argb,
uint8_t* dst_r,
int dst_stride_r,
uint8_t* dst_g,
int dst_stride_g,
uint8_t* dst_b,
int dst_stride_b,
uint8_t* dst_a,
int dst_stride_a,
int width,
int height) {
if (height < 0) {
height = -height;
dst_r = dst_r + (height - 1) * dst_stride_r;
dst_g = dst_g + (height - 1) * dst_stride_g;
dst_b = dst_b + (height - 1) * dst_stride_b;
dst_a = dst_a + (height - 1) * dst_stride_a;
dst_stride_r = -dst_stride_r;
dst_stride_g = -dst_stride_g;
dst_stride_b = -dst_stride_b;
dst_stride_a = -dst_stride_a;
}
if (dst_a == NULL) {
SplitARGBPlaneOpaque(src_argb, src_stride_argb, dst_r, dst_stride_r, dst_g,
dst_stride_g, dst_b, dst_stride_b, width, height);
} else {
SplitARGBPlaneAlpha(src_argb, src_stride_argb, dst_r, dst_stride_r, dst_g,
dst_stride_g, dst_b, dst_stride_b, dst_a, dst_stride_a,
width, height);
}
}
LIBYUV_NOINLINE
static void MergeARGBPlaneAlpha(const uint8_t* src_r,
int src_stride_r,
const uint8_t* src_g,
int src_stride_g,
const uint8_t* src_b,
int src_stride_b,
const uint8_t* src_a,
int src_stride_a,
uint8_t* dst_argb,
int dst_stride_argb,
int width,
int height) {
int y;
void (*MergeARGBRow)(const uint8_t* src_r, const uint8_t* src_g,
const uint8_t* src_b, const uint8_t* src_a,
uint8_t* dst_argb, int width) = MergeARGBRow_C;
assert(height > 0);
if (src_stride_r == width && src_stride_g == width && src_stride_b == width &&
src_stride_a == width && dst_stride_argb == width * 4) {
width *= height;
height = 1;
src_stride_r = src_stride_g = src_stride_b = src_stride_a =
dst_stride_argb = 0;
}
#if defined(HAS_MERGEARGBROW_SSE2)
if (TestCpuFlag(kCpuHasSSE2)) {
MergeARGBRow = MergeARGBRow_Any_SSE2;
if (IS_ALIGNED(width, 8)) {
MergeARGBRow = MergeARGBRow_SSE2;
}
}
#endif
#if defined(HAS_MERGEARGBROW_AVX2)
if (TestCpuFlag(kCpuHasAVX2)) {
MergeARGBRow = MergeARGBRow_Any_AVX2;
if (IS_ALIGNED(width, 16)) {
MergeARGBRow = MergeARGBRow_AVX2;
}
}
#endif
#if defined(HAS_MERGEARGBROW_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
MergeARGBRow = MergeARGBRow_Any_NEON;
if (IS_ALIGNED(width, 16)) {
MergeARGBRow = MergeARGBRow_NEON;
}
}
#endif
for (y = 0; y < height; ++y) {
MergeARGBRow(src_r, src_g, src_b, src_a, dst_argb, width);
src_r += src_stride_r;
src_g += src_stride_g;
src_b += src_stride_b;
src_a += src_stride_a;
dst_argb += dst_stride_argb;
}
}
LIBYUV_NOINLINE
static void MergeARGBPlaneOpaque(const uint8_t* src_r,
int src_stride_r,
const uint8_t* src_g,
int src_stride_g,
const uint8_t* src_b,
int src_stride_b,
uint8_t* dst_argb,
int dst_stride_argb,
int width,
int height) {
int y;
void (*MergeXRGBRow)(const uint8_t* src_r, const uint8_t* src_g,
const uint8_t* src_b, uint8_t* dst_argb, int width) =
MergeXRGBRow_C;
assert(height > 0);
if (src_stride_r == width && src_stride_g == width && src_stride_b == width &&
dst_stride_argb == width * 4) {
width *= height;
height = 1;
src_stride_r = src_stride_g = src_stride_b = dst_stride_argb = 0;
}
#if defined(HAS_MERGEXRGBROW_SSE2)
if (TestCpuFlag(kCpuHasSSE2)) {
MergeXRGBRow = MergeXRGBRow_Any_SSE2;
if (IS_ALIGNED(width, 8)) {
MergeXRGBRow = MergeXRGBRow_SSE2;
}
}
#endif
#if defined(HAS_MERGEXRGBROW_AVX2)
if (TestCpuFlag(kCpuHasAVX2)) {
MergeXRGBRow = MergeXRGBRow_Any_AVX2;
if (IS_ALIGNED(width, 16)) {
MergeXRGBRow = MergeXRGBRow_AVX2;
}
}
#endif
#if defined(HAS_MERGEXRGBROW_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
MergeXRGBRow = MergeXRGBRow_Any_NEON;
if (IS_ALIGNED(width, 16)) {
MergeXRGBRow = MergeXRGBRow_NEON;
}
}
#endif
for (y = 0; y < height; ++y) {
MergeXRGBRow(src_r, src_g, src_b, dst_argb, width);
src_r += src_stride_r;
src_g += src_stride_g;
src_b += src_stride_b;
dst_argb += dst_stride_argb;
}
}
LIBYUV_API
void MergeARGBPlane(const uint8_t* src_r,
int src_stride_r,
const uint8_t* src_g,
int src_stride_g,
const uint8_t* src_b,
int src_stride_b,
const uint8_t* src_a,
int src_stride_a,
uint8_t* dst_argb,
int dst_stride_argb,
int width,
int height) {
if (height < 0) {
height = -height;
dst_argb = dst_argb + (height - 1) * dst_stride_argb;
dst_stride_argb = -dst_stride_argb;
}
if (src_a == NULL) {
MergeARGBPlaneOpaque(src_r, src_stride_r, src_g, src_stride_g, src_b,
src_stride_b, dst_argb, dst_stride_argb, width,
height);
} else {
MergeARGBPlaneAlpha(src_r, src_stride_r, src_g, src_stride_g, src_b,
src_stride_b, src_a, src_stride_a, dst_argb,
dst_stride_argb, width, height);
}
}
LIBYUV_API
void MergeXR30Plane(const uint16_t* src_r,
int src_stride_r,
const uint16_t* src_g,
int src_stride_g,
const uint16_t* src_b,
int src_stride_b,
uint8_t* dst_ar30,
int dst_stride_ar30,
int width,
int height,
int depth) {
int y;
void (*MergeXR30Row)(const uint16_t* src_r, const uint16_t* src_g,
const uint16_t* src_b, uint8_t* dst_ar30, int depth,
int width) = MergeXR30Row_C;
if (height < 0) {
height = -height;
dst_ar30 = dst_ar30 + (height - 1) * dst_stride_ar30;
dst_stride_ar30 = -dst_stride_ar30;
}
if (src_stride_r == width && src_stride_g == width && src_stride_b == width &&
dst_stride_ar30 == width * 4) {
width *= height;
height = 1;
src_stride_r = src_stride_g = src_stride_b = dst_stride_ar30 = 0;
}
#if defined(HAS_MERGEXR30ROW_AVX2)
if (TestCpuFlag(kCpuHasAVX2)) {
MergeXR30Row = MergeXR30Row_Any_AVX2;
if (IS_ALIGNED(width, 16)) {
MergeXR30Row = MergeXR30Row_AVX2;
}
}
#endif
#if defined(HAS_MERGEXR30ROW_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
if (depth == 10) {
MergeXR30Row = MergeXR30Row_10_Any_NEON;
if (IS_ALIGNED(width, 8)) {
MergeXR30Row = MergeXR30Row_10_NEON;
}
} else {
MergeXR30Row = MergeXR30Row_Any_NEON;
if (IS_ALIGNED(width, 8)) {
MergeXR30Row = MergeXR30Row_NEON;
}
}
}
#endif
for (y = 0; y < height; ++y) {
MergeXR30Row(src_r, src_g, src_b, dst_ar30, depth, width);
src_r += src_stride_r;
src_g += src_stride_g;
src_b += src_stride_b;
dst_ar30 += dst_stride_ar30;
}
}
LIBYUV_NOINLINE
static void MergeAR64PlaneAlpha(const uint16_t* src_r,
int src_stride_r,
const uint16_t* src_g,
int src_stride_g,
const uint16_t* src_b,
int src_stride_b,
const uint16_t* src_a,
int src_stride_a,
uint16_t* dst_ar64,
int dst_stride_ar64,
int width,
int height,
int depth) {
int y;
void (*MergeAR64Row)(const uint16_t* src_r, const uint16_t* src_g,
const uint16_t* src_b, const uint16_t* src_a,
uint16_t* dst_argb, int depth, int width) =
MergeAR64Row_C;
if (src_stride_r == width && src_stride_g == width && src_stride_b == width &&
src_stride_a == width && dst_stride_ar64 == width * 4) {
width *= height;
height = 1;
src_stride_r = src_stride_g = src_stride_b = src_stride_a =
dst_stride_ar64 = 0;
}
#if defined(HAS_MERGEAR64ROW_AVX2)
if (TestCpuFlag(kCpuHasAVX2)) {
MergeAR64Row = MergeAR64Row_Any_AVX2;
if (IS_ALIGNED(width, 16)) {
MergeAR64Row = MergeAR64Row_AVX2;
}
}
#endif
#if defined(HAS_MERGEAR64ROW_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
MergeAR64Row = MergeAR64Row_Any_NEON;
if (IS_ALIGNED(width, 8)) {
MergeAR64Row = MergeAR64Row_NEON;
}
}
#endif
for (y = 0; y < height; ++y) {
MergeAR64Row(src_r, src_g, src_b, src_a, dst_ar64, depth, width);
src_r += src_stride_r;
src_g += src_stride_g;
src_b += src_stride_b;
src_a += src_stride_a;
dst_ar64 += dst_stride_ar64;
}
}
LIBYUV_NOINLINE
static void MergeAR64PlaneOpaque(const uint16_t* src_r,
int src_stride_r,
const uint16_t* src_g,
int src_stride_g,
const uint16_t* src_b,
int src_stride_b,
uint16_t* dst_ar64,
int dst_stride_ar64,
int width,
int height,
int depth) {
int y;
void (*MergeXR64Row)(const uint16_t* src_r, const uint16_t* src_g,
const uint16_t* src_b, uint16_t* dst_argb, int depth,
int width) = MergeXR64Row_C;
if (src_stride_r == width && src_stride_g == width && src_stride_b == width &&
dst_stride_ar64 == width * 4) {
width *= height;
height = 1;
src_stride_r = src_stride_g = src_stride_b = dst_stride_ar64 = 0;
}
#if defined(HAS_MERGEXR64ROW_AVX2)
if (TestCpuFlag(kCpuHasAVX2)) {
MergeXR64Row = MergeXR64Row_Any_AVX2;
if (IS_ALIGNED(width, 16)) {
MergeXR64Row = MergeXR64Row_AVX2;
}
}
#endif
#if defined(HAS_MERGEXR64ROW_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
MergeXR64Row = MergeXR64Row_Any_NEON;
if (IS_ALIGNED(width, 8)) {
MergeXR64Row = MergeXR64Row_NEON;
}
}
#endif
for (y = 0; y < height; ++y) {
MergeXR64Row(src_r, src_g, src_b, dst_ar64, depth, width);
src_r += src_stride_r;
src_g += src_stride_g;
src_b += src_stride_b;
dst_ar64 += dst_stride_ar64;
}
}
LIBYUV_API
void MergeAR64Plane(const uint16_t* src_r,
int src_stride_r,
const uint16_t* src_g,
int src_stride_g,
const uint16_t* src_b,
int src_stride_b,
const uint16_t* src_a,
int src_stride_a,
uint16_t* dst_ar64,
int dst_stride_ar64,
int width,
int height,
int depth) {
if (height < 0) {
height = -height;
dst_ar64 = dst_ar64 + (height - 1) * dst_stride_ar64;
dst_stride_ar64 = -dst_stride_ar64;
}
if (src_a == NULL) {
MergeAR64PlaneOpaque(src_r, src_stride_r, src_g, src_stride_g, src_b,
src_stride_b, dst_ar64, dst_stride_ar64, width, height,
depth);
} else {
MergeAR64PlaneAlpha(src_r, src_stride_r, src_g, src_stride_g, src_b,
src_stride_b, src_a, src_stride_a, dst_ar64,
dst_stride_ar64, width, height, depth);
}
}
LIBYUV_NOINLINE
static void MergeARGB16To8PlaneAlpha(const uint16_t* src_r,
int src_stride_r,
const uint16_t* src_g,
int src_stride_g,
const uint16_t* src_b,
int src_stride_b,
const uint16_t* src_a,
int src_stride_a,
uint8_t* dst_argb,
int dst_stride_argb,
int width,
int height,
int depth) {
int y;
void (*MergeARGB16To8Row)(const uint16_t* src_r, const uint16_t* src_g,
const uint16_t* src_b, const uint16_t* src_a,
uint8_t* dst_argb, int depth, int width) =
MergeARGB16To8Row_C;
if (src_stride_r == width && src_stride_g == width && src_stride_b == width &&
src_stride_a == width && dst_stride_argb == width * 4) {
width *= height;
height = 1;
src_stride_r = src_stride_g = src_stride_b = src_stride_a =
dst_stride_argb = 0;
}
#if defined(HAS_MERGEARGB16TO8ROW_AVX2)
if (TestCpuFlag(kCpuHasAVX2)) {
MergeARGB16To8Row = MergeARGB16To8Row_Any_AVX2;
if (IS_ALIGNED(width, 16)) {
MergeARGB16To8Row = MergeARGB16To8Row_AVX2;
}
}
#endif
#if defined(HAS_MERGEARGB16TO8ROW_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
MergeARGB16To8Row = MergeARGB16To8Row_Any_NEON;
if (IS_ALIGNED(width, 8)) {
MergeARGB16To8Row = MergeARGB16To8Row_NEON;
}
}
#endif
for (y = 0; y < height; ++y) {
MergeARGB16To8Row(src_r, src_g, src_b, src_a, dst_argb, depth, width);
src_r += src_stride_r;
src_g += src_stride_g;
src_b += src_stride_b;
src_a += src_stride_a;
dst_argb += dst_stride_argb;
}
}
LIBYUV_NOINLINE
static void MergeARGB16To8PlaneOpaque(const uint16_t* src_r,
int src_stride_r,
const uint16_t* src_g,
int src_stride_g,
const uint16_t* src_b,
int src_stride_b,
uint8_t* dst_argb,
int dst_stride_argb,
int width,
int height,
int depth) {
int y;
void (*MergeXRGB16To8Row)(const uint16_t* src_r, const uint16_t* src_g,
const uint16_t* src_b, uint8_t* dst_argb, int depth,
int width) = MergeXRGB16To8Row_C;
if (src_stride_r == width && src_stride_g == width && src_stride_b == width &&
dst_stride_argb == width * 4) {
width *= height;
height = 1;
src_stride_r = src_stride_g = src_stride_b = dst_stride_argb = 0;
}
#if defined(HAS_MERGEXRGB16TO8ROW_AVX2)
if (TestCpuFlag(kCpuHasAVX2)) {
MergeXRGB16To8Row = MergeXRGB16To8Row_Any_AVX2;
if (IS_ALIGNED(width, 16)) {
MergeXRGB16To8Row = MergeXRGB16To8Row_AVX2;
}
}
#endif
#if defined(HAS_MERGEXRGB16TO8ROW_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
MergeXRGB16To8Row = MergeXRGB16To8Row_Any_NEON;
if (IS_ALIGNED(width, 8)) {
MergeXRGB16To8Row = MergeXRGB16To8Row_NEON;
}
}
#endif
for (y = 0; y < height; ++y) {
MergeXRGB16To8Row(src_r, src_g, src_b, dst_argb, depth, width);
src_r += src_stride_r;
src_g += src_stride_g;
src_b += src_stride_b;
dst_argb += dst_stride_argb;
}
}
LIBYUV_API
void MergeARGB16To8Plane(const uint16_t* src_r,
int src_stride_r,
const uint16_t* src_g,
int src_stride_g,
const uint16_t* src_b,
int src_stride_b,
const uint16_t* src_a,
int src_stride_a,
uint8_t* dst_argb,
int dst_stride_argb,
int width,
int height,
int depth) {
if (height < 0) {
height = -height;
dst_argb = dst_argb + (height - 1) * dst_stride_argb;
dst_stride_argb = -dst_stride_argb;
}
if (src_a == NULL) {
MergeARGB16To8PlaneOpaque(src_r, src_stride_r, src_g, src_stride_g, src_b,
src_stride_b, dst_argb, dst_stride_argb, width,
height, depth);
} else {
MergeARGB16To8PlaneAlpha(src_r, src_stride_r, src_g, src_stride_g, src_b,
src_stride_b, src_a, src_stride_a, dst_argb,
dst_stride_argb, width, height, depth);
}
}
LIBYUV_API
int YUY2ToI422(const uint8_t* src_yuy2,
int src_stride_yuy2,
uint8_t* dst_y,
int dst_stride_y,
uint8_t* dst_u,
int dst_stride_u,
uint8_t* dst_v,
int dst_stride_v,
int width,
int height) {
int y;
void (*YUY2ToUV422Row)(const uint8_t* src_yuy2, uint8_t* dst_u,
uint8_t* dst_v, int width) = YUY2ToUV422Row_C;
void (*YUY2ToYRow)(const uint8_t* src_yuy2, uint8_t* dst_y, int width) =
YUY2ToYRow_C;
if (!src_yuy2 || !dst_y || !dst_u || !dst_v || width <= 0 || height == 0) {
return -1;
}
if (height < 0) {
height = -height;
src_yuy2 = src_yuy2 + (height - 1) * src_stride_yuy2;
src_stride_yuy2 = -src_stride_yuy2;
}
if (src_stride_yuy2 == width * 2 && dst_stride_y == width &&
dst_stride_u * 2 == width && dst_stride_v * 2 == width &&
width * height <= 32768) {
width *= height;
height = 1;
src_stride_yuy2 = dst_stride_y = dst_stride_u = dst_stride_v = 0;
}
#if defined(HAS_YUY2TOYROW_SSE2)
if (TestCpuFlag(kCpuHasSSE2)) {
YUY2ToUV422Row = YUY2ToUV422Row_Any_SSE2;
YUY2ToYRow = YUY2ToYRow_Any_SSE2;
if (IS_ALIGNED(width, 16)) {
YUY2ToUV422Row = YUY2ToUV422Row_SSE2;
YUY2ToYRow = YUY2ToYRow_SSE2;
}
}
#endif
#if defined(HAS_YUY2TOYROW_AVX2)
if (TestCpuFlag(kCpuHasAVX2)) {
YUY2ToUV422Row = YUY2ToUV422Row_Any_AVX2;
YUY2ToYRow = YUY2ToYRow_Any_AVX2;
if (IS_ALIGNED(width, 32)) {
YUY2ToUV422Row = YUY2ToUV422Row_AVX2;
YUY2ToYRow = YUY2ToYRow_AVX2;
}
}
#endif
#if defined(HAS_YUY2TOYROW_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
YUY2ToYRow = YUY2ToYRow_Any_NEON;
YUY2ToUV422Row = YUY2ToUV422Row_Any_NEON;
if (IS_ALIGNED(width, 16)) {
YUY2ToYRow = YUY2ToYRow_NEON;
YUY2ToUV422Row = YUY2ToUV422Row_NEON;
}
}
#endif
#if defined(HAS_YUY2TOYROW_MSA) && defined(HAS_YUY2TOUV422ROW_MSA)
if (TestCpuFlag(kCpuHasMSA)) {
YUY2ToYRow = YUY2ToYRow_Any_MSA;
YUY2ToUV422Row = YUY2ToUV422Row_Any_MSA;
if (IS_ALIGNED(width, 32)) {
YUY2ToYRow = YUY2ToYRow_MSA;
YUY2ToUV422Row = YUY2ToUV422Row_MSA;
}
}
#endif
#if defined(HAS_YUY2TOYROW_LASX) && defined(HAS_YUY2TOUV422ROW_LASX)
if (TestCpuFlag(kCpuHasLASX)) {
YUY2ToYRow = YUY2ToYRow_Any_LASX;
YUY2ToUV422Row = YUY2ToUV422Row_Any_LASX;
if (IS_ALIGNED(width, 32)) {
YUY2ToYRow = YUY2ToYRow_LASX;
YUY2ToUV422Row = YUY2ToUV422Row_LASX;
}
}
#endif
for (y = 0; y < height; ++y) {
YUY2ToUV422Row(src_yuy2, dst_u, dst_v, width);
YUY2ToYRow(src_yuy2, dst_y, width);
src_yuy2 += src_stride_yuy2;
dst_y += dst_stride_y;
dst_u += dst_stride_u;
dst_v += dst_stride_v;
}
return 0;
}
LIBYUV_API
int UYVYToI422(const uint8_t* src_uyvy,
int src_stride_uyvy,
uint8_t* dst_y,
int dst_stride_y,
uint8_t* dst_u,
int dst_stride_u,
uint8_t* dst_v,
int dst_stride_v,
int width,
int height) {
int y;
void (*UYVYToUV422Row)(const uint8_t* src_uyvy, uint8_t* dst_u,
uint8_t* dst_v, int width) = UYVYToUV422Row_C;
void (*UYVYToYRow)(const uint8_t* src_uyvy, uint8_t* dst_y, int width) =
UYVYToYRow_C;
if (!src_uyvy || !dst_y || !dst_u || !dst_v || width <= 0 || height == 0) {
return -1;
}
if (height < 0) {
height = -height;
src_uyvy = src_uyvy + (height - 1) * src_stride_uyvy;
src_stride_uyvy = -src_stride_uyvy;
}
if (src_stride_uyvy == width * 2 && dst_stride_y == width &&
dst_stride_u * 2 == width && dst_stride_v * 2 == width &&
width * height <= 32768) {
width *= height;
height = 1;
src_stride_uyvy = dst_stride_y = dst_stride_u = dst_stride_v = 0;
}
#if defined(HAS_UYVYTOYROW_SSE2)
if (TestCpuFlag(kCpuHasSSE2)) {
UYVYToUV422Row = UYVYToUV422Row_Any_SSE2;
UYVYToYRow = UYVYToYRow_Any_SSE2;
if (IS_ALIGNED(width, 16)) {
UYVYToUV422Row = UYVYToUV422Row_SSE2;
UYVYToYRow = UYVYToYRow_SSE2;
}
}
#endif
#if defined(HAS_UYVYTOYROW_AVX2)
if (TestCpuFlag(kCpuHasAVX2)) {
UYVYToUV422Row = UYVYToUV422Row_Any_AVX2;
UYVYToYRow = UYVYToYRow_Any_AVX2;
if (IS_ALIGNED(width, 32)) {
UYVYToUV422Row = UYVYToUV422Row_AVX2;
UYVYToYRow = UYVYToYRow_AVX2;
}
}
#endif
#if defined(HAS_UYVYTOYROW_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
UYVYToYRow = UYVYToYRow_Any_NEON;
UYVYToUV422Row = UYVYToUV422Row_Any_NEON;
if (IS_ALIGNED(width, 16)) {
UYVYToYRow = UYVYToYRow_NEON;
UYVYToUV422Row = UYVYToUV422Row_NEON;
}
}
#endif
#if defined(HAS_UYVYTOYROW_MSA) && defined(HAS_UYVYTOUV422ROW_MSA)
if (TestCpuFlag(kCpuHasMSA)) {
UYVYToYRow = UYVYToYRow_Any_MSA;
UYVYToUV422Row = UYVYToUV422Row_Any_MSA;
if (IS_ALIGNED(width, 32)) {
UYVYToYRow = UYVYToYRow_MSA;
UYVYToUV422Row = UYVYToUV422Row_MSA;
}
}
#endif
#if defined(HAS_UYVYTOYROW_LASX) && defined(HAS_UYVYTOUV422ROW_LASX)
if (TestCpuFlag(kCpuHasLASX)) {
UYVYToYRow = UYVYToYRow_Any_LASX;
UYVYToUV422Row = UYVYToUV422Row_Any_LASX;
if (IS_ALIGNED(width, 32)) {
UYVYToYRow = UYVYToYRow_LASX;
UYVYToUV422Row = UYVYToUV422Row_LASX;
}
}
#endif
for (y = 0; y < height; ++y) {
UYVYToUV422Row(src_uyvy, dst_u, dst_v, width);
UYVYToYRow(src_uyvy, dst_y, width);
src_uyvy += src_stride_uyvy;
dst_y += dst_stride_y;
dst_u += dst_stride_u;
dst_v += dst_stride_v;
}
return 0;
}
LIBYUV_API
int YUY2ToY(const uint8_t* src_yuy2,
int src_stride_yuy2,
uint8_t* dst_y,
int dst_stride_y,
int width,
int height) {
int y;
void (*YUY2ToYRow)(const uint8_t* src_yuy2, uint8_t* dst_y, int width) =
YUY2ToYRow_C;
if (!src_yuy2 || !dst_y || width <= 0 || height == 0) {
return -1;
}
if (height < 0) {
height = -height;
src_yuy2 = src_yuy2 + (height - 1) * src_stride_yuy2;
src_stride_yuy2 = -src_stride_yuy2;
}
if (src_stride_yuy2 == width * 2 && dst_stride_y == width) {
width *= height;
height = 1;
src_stride_yuy2 = dst_stride_y = 0;
}
#if defined(HAS_YUY2TOYROW_SSE2)
if (TestCpuFlag(kCpuHasSSE2)) {
YUY2ToYRow = YUY2ToYRow_Any_SSE2;
if (IS_ALIGNED(width, 16)) {
YUY2ToYRow = YUY2ToYRow_SSE2;
}
}
#endif
#if defined(HAS_YUY2TOYROW_AVX2)
if (TestCpuFlag(kCpuHasAVX2)) {
YUY2ToYRow = YUY2ToYRow_Any_AVX2;
if (IS_ALIGNED(width, 32)) {
YUY2ToYRow = YUY2ToYRow_AVX2;
}
}
#endif
#if defined(HAS_YUY2TOYROW_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
YUY2ToYRow = YUY2ToYRow_Any_NEON;
if (IS_ALIGNED(width, 16)) {
YUY2ToYRow = YUY2ToYRow_NEON;
}
}
#endif
#if defined(HAS_YUY2TOYROW_MSA)
if (TestCpuFlag(kCpuHasMSA)) {
YUY2ToYRow = YUY2ToYRow_Any_MSA;
if (IS_ALIGNED(width, 32)) {
YUY2ToYRow = YUY2ToYRow_MSA;
}
}
#endif
for (y = 0; y < height; ++y) {
YUY2ToYRow(src_yuy2, dst_y, width);
src_yuy2 += src_stride_yuy2;
dst_y += dst_stride_y;
}
return 0;
}
LIBYUV_API
int UYVYToY(const uint8_t* src_uyvy,
int src_stride_uyvy,
uint8_t* dst_y,
int dst_stride_y,
int width,
int height) {
int y;
void (*UYVYToYRow)(const uint8_t* src_uyvy, uint8_t* dst_y, int width) =
UYVYToYRow_C;
if (!src_uyvy || !dst_y || width <= 0 || height == 0) {
return -1;
}
if (height < 0) {
height = -height;
src_uyvy = src_uyvy + (height - 1) * src_stride_uyvy;
src_stride_uyvy = -src_stride_uyvy;
}
if (src_stride_uyvy == width * 2 && dst_stride_y == width) {
width *= height;
height = 1;
src_stride_uyvy = dst_stride_y = 0;
}
#if defined(HAS_UYVYTOYROW_SSE2)
if (TestCpuFlag(kCpuHasSSE2)) {
UYVYToYRow = UYVYToYRow_Any_SSE2;
if (IS_ALIGNED(width, 16)) {
UYVYToYRow = UYVYToYRow_SSE2;
}
}
#endif
#if defined(HAS_UYVYTOYROW_AVX2)
if (TestCpuFlag(kCpuHasAVX2)) {
UYVYToYRow = UYVYToYRow_Any_AVX2;
if (IS_ALIGNED(width, 32)) {
UYVYToYRow = UYVYToYRow_AVX2;
}
}
#endif
#if defined(HAS_UYVYTOYROW_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
UYVYToYRow = UYVYToYRow_Any_NEON;
if (IS_ALIGNED(width, 16)) {
UYVYToYRow = UYVYToYRow_NEON;
}
}
#endif
#if defined(HAS_UYVYTOYROW_MSA)
if (TestCpuFlag(kCpuHasMSA)) {
UYVYToYRow = UYVYToYRow_Any_MSA;
if (IS_ALIGNED(width, 32)) {
UYVYToYRow = UYVYToYRow_MSA;
}
}
#endif
for (y = 0; y < height; ++y) {
UYVYToYRow(src_uyvy, dst_y, width);
src_uyvy += src_stride_uyvy;
dst_y += dst_stride_y;
}
return 0;
}
LIBYUV_API
void MirrorPlane(const uint8_t* src_y,
int src_stride_y,
uint8_t* dst_y,
int dst_stride_y,
int width,
int height) {
int y;
void (*MirrorRow)(const uint8_t* src, uint8_t* dst, int width) = MirrorRow_C;
if (height < 0) {
height = -height;
src_y = src_y + (height - 1) * src_stride_y;
src_stride_y = -src_stride_y;
}
#if defined(HAS_MIRRORROW_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
MirrorRow = MirrorRow_Any_NEON;
if (IS_ALIGNED(width, 32)) {
MirrorRow = MirrorRow_NEON;
}
}
#endif
#if defined(HAS_MIRRORROW_SSSE3)
if (TestCpuFlag(kCpuHasSSSE3)) {
MirrorRow = MirrorRow_Any_SSSE3;
if (IS_ALIGNED(width, 16)) {
MirrorRow = MirrorRow_SSSE3;
}
}
#endif
#if defined(HAS_MIRRORROW_AVX2)
if (TestCpuFlag(kCpuHasAVX2)) {
MirrorRow = MirrorRow_Any_AVX2;
if (IS_ALIGNED(width, 32)) {
MirrorRow = MirrorRow_AVX2;
}
}
#endif
#if defined(HAS_MIRRORROW_MSA)
if (TestCpuFlag(kCpuHasMSA)) {
MirrorRow = MirrorRow_Any_MSA;
if (IS_ALIGNED(width, 64)) {
MirrorRow = MirrorRow_MSA;
}
}
#endif
#if defined(HAS_MIRRORROW_LASX)
if (TestCpuFlag(kCpuHasLASX)) {
MirrorRow = MirrorRow_Any_LASX;
if (IS_ALIGNED(width, 64)) {
MirrorRow = MirrorRow_LASX;
}
}
#endif
for (y = 0; y < height; ++y) {
MirrorRow(src_y, dst_y, width);
src_y += src_stride_y;
dst_y += dst_stride_y;
}
}
LIBYUV_API
void MirrorUVPlane(const uint8_t* src_uv,
int src_stride_uv,
uint8_t* dst_uv,
int dst_stride_uv,
int width,
int height) {
int y;
void (*MirrorUVRow)(const uint8_t* src, uint8_t* dst, int width) =
MirrorUVRow_C;
if (height < 0) {
height = -height;
src_uv = src_uv + (height - 1) * src_stride_uv;
src_stride_uv = -src_stride_uv;
}
#if defined(HAS_MIRRORUVROW_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
MirrorUVRow = MirrorUVRow_Any_NEON;
if (IS_ALIGNED(width, 32)) {
MirrorUVRow = MirrorUVRow_NEON;
}
}
#endif
#if defined(HAS_MIRRORUVROW_SSSE3)
if (TestCpuFlag(kCpuHasSSSE3)) {
MirrorUVRow = MirrorUVRow_Any_SSSE3;
if (IS_ALIGNED(width, 8)) {
MirrorUVRow = MirrorUVRow_SSSE3;
}
}
#endif
#if defined(HAS_MIRRORUVROW_AVX2)
if (TestCpuFlag(kCpuHasAVX2)) {
MirrorUVRow = MirrorUVRow_Any_AVX2;
if (IS_ALIGNED(width, 16)) {
MirrorUVRow = MirrorUVRow_AVX2;
}
}
#endif
#if defined(HAS_MIRRORUVROW_MSA)
if (TestCpuFlag(kCpuHasMSA)) {
MirrorUVRow = MirrorUVRow_Any_MSA;
if (IS_ALIGNED(width, 8)) {
MirrorUVRow = MirrorUVRow_MSA;
}
}
#endif
#if defined(HAS_MIRRORUVROW_LASX)
if (TestCpuFlag(kCpuHasLASX)) {
MirrorUVRow = MirrorUVRow_Any_LASX;
if (IS_ALIGNED(width, 16)) {
MirrorUVRow = MirrorUVRow_LASX;
}
}
#endif
for (y = 0; y < height; ++y) {
MirrorUVRow(src_uv, dst_uv, width);
src_uv += src_stride_uv;
dst_uv += dst_stride_uv;
}
}
LIBYUV_API
int I400Mirror(const uint8_t* src_y,
int src_stride_y,
uint8_t* dst_y,
int dst_stride_y,
int width,
int height) {
if (!src_y || !dst_y || width <= 0 || height == 0) {
return -1;
}
if (height < 0) {
height = -height;
src_y = src_y + (height - 1) * src_stride_y;
src_stride_y = -src_stride_y;
}
MirrorPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height);
return 0;
}
LIBYUV_API
int I420Mirror(const uint8_t* src_y,
int src_stride_y,
const uint8_t* src_u,
int src_stride_u,
const uint8_t* src_v,
int src_stride_v,
uint8_t* dst_y,
int dst_stride_y,
uint8_t* dst_u,
int dst_stride_u,
uint8_t* dst_v,
int dst_stride_v,
int width,
int height) {
int halfwidth = (width + 1) >> 1;
int halfheight = (height + 1) >> 1;
if (!src_y || !src_u || !src_v || !dst_u || !dst_v || width <= 0 ||
height == 0) {
return -1;
}
if (height < 0) {
height = -height;
halfheight = (height + 1) >> 1;
src_y = src_y + (height - 1) * src_stride_y;
src_u = src_u + (halfheight - 1) * src_stride_u;
src_v = src_v + (halfheight - 1) * src_stride_v;
src_stride_y = -src_stride_y;
src_stride_u = -src_stride_u;
src_stride_v = -src_stride_v;
}
if (dst_y) {
MirrorPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height);
}
MirrorPlane(src_u, src_stride_u, dst_u, dst_stride_u, halfwidth, halfheight);
MirrorPlane(src_v, src_stride_v, dst_v, dst_stride_v, halfwidth, halfheight);
return 0;
}
LIBYUV_API
int NV12Mirror(const uint8_t* src_y,
int src_stride_y,
const uint8_t* src_uv,
int src_stride_uv,
uint8_t* dst_y,
int dst_stride_y,
uint8_t* dst_uv,
int dst_stride_uv,
int width,
int height) {
int halfwidth = (width + 1) >> 1;
int halfheight = (height + 1) >> 1;
if (!src_y || !src_uv || !dst_uv || width <= 0 || height == 0) {
return -1;
}
if (height < 0) {
height = -height;
halfheight = (height + 1) >> 1;
src_y = src_y + (height - 1) * src_stride_y;
src_uv = src_uv + (halfheight - 1) * src_stride_uv;
src_stride_y = -src_stride_y;
src_stride_uv = -src_stride_uv;
}
if (dst_y) {
MirrorPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height);
}
MirrorUVPlane(src_uv, src_stride_uv, dst_uv, dst_stride_uv, halfwidth,
halfheight);
return 0;
}
LIBYUV_API
int ARGBMirror(const uint8_t* src_argb,
int src_stride_argb,
uint8_t* dst_argb,
int dst_stride_argb,
int width,
int height) {
int y;
void (*ARGBMirrorRow)(const uint8_t* src, uint8_t* dst, int width) =
ARGBMirrorRow_C;
if (!src_argb || !dst_argb || width <= 0 || height == 0) {
return -1;
}
if (height < 0) {
height = -height;
src_argb = src_argb + (height - 1) * src_stride_argb;
src_stride_argb = -src_stride_argb;
}
#if defined(HAS_ARGBMIRRORROW_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
ARGBMirrorRow = ARGBMirrorRow_Any_NEON;
if (IS_ALIGNED(width, 8)) {
ARGBMirrorRow = ARGBMirrorRow_NEON;
}
}
#endif
#if defined(HAS_ARGBMIRRORROW_SSE2)
if (TestCpuFlag(kCpuHasSSE2)) {
ARGBMirrorRow = ARGBMirrorRow_Any_SSE2;
if (IS_ALIGNED(width, 4)) {
ARGBMirrorRow = ARGBMirrorRow_SSE2;
}
}
#endif
#if defined(HAS_ARGBMIRRORROW_AVX2)
if (TestCpuFlag(kCpuHasAVX2)) {
ARGBMirrorRow = ARGBMirrorRow_Any_AVX2;
if (IS_ALIGNED(width, 8)) {
ARGBMirrorRow = ARGBMirrorRow_AVX2;
}
}
#endif
#if defined(HAS_ARGBMIRRORROW_MSA)
if (TestCpuFlag(kCpuHasMSA)) {
ARGBMirrorRow = ARGBMirrorRow_Any_MSA;
if (IS_ALIGNED(width, 16)) {
ARGBMirrorRow = ARGBMirrorRow_MSA;
}
}
#endif
#if defined(HAS_ARGBMIRRORROW_LASX)
if (TestCpuFlag(kCpuHasLASX)) {
ARGBMirrorRow = ARGBMirrorRow_Any_LASX;
if (IS_ALIGNED(width, 16)) {
ARGBMirrorRow = ARGBMirrorRow_LASX;
}
}
#endif
for (y = 0; y < height; ++y) {
ARGBMirrorRow(src_argb, dst_argb, width);
src_argb += src_stride_argb;
dst_argb += dst_stride_argb;
}
return 0;
}
LIBYUV_API
int RGB24Mirror(const uint8_t* src_rgb24,
int src_stride_rgb24,
uint8_t* dst_rgb24,
int dst_stride_rgb24,
int width,
int height) {
int y;
void (*RGB24MirrorRow)(const uint8_t* src, uint8_t* dst, int width) =
RGB24MirrorRow_C;
if (!src_rgb24 || !dst_rgb24 || width <= 0 || height == 0) {
return -1;
}
if (height < 0) {
height = -height;
src_rgb24 = src_rgb24 + (height - 1) * src_stride_rgb24;
src_stride_rgb24 = -src_stride_rgb24;
}
#if defined(HAS_RGB24MIRRORROW_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
RGB24MirrorRow = RGB24MirrorRow_Any_NEON;
if (IS_ALIGNED(width, 16)) {
RGB24MirrorRow = RGB24MirrorRow_NEON;
}
}
#endif
#if defined(HAS_RGB24MIRRORROW_SSSE3)
if (TestCpuFlag(kCpuHasSSSE3)) {
RGB24MirrorRow = RGB24MirrorRow_Any_SSSE3;
if (IS_ALIGNED(width, 16)) {
RGB24MirrorRow = RGB24MirrorRow_SSSE3;
}
}
#endif
for (y = 0; y < height; ++y) {
RGB24MirrorRow(src_rgb24, dst_rgb24, width);
src_rgb24 += src_stride_rgb24;
dst_rgb24 += dst_stride_rgb24;
}
return 0;
}
LIBYUV_API
ARGBBlendRow GetARGBBlend() {
void (*ARGBBlendRow)(const uint8_t* src_argb, const uint8_t* src_argb1,
uint8_t* dst_argb, int width) = ARGBBlendRow_C;
#if defined(HAS_ARGBBLENDROW_SSSE3)
if (TestCpuFlag(kCpuHasSSSE3)) {
ARGBBlendRow = ARGBBlendRow_SSSE3;
return ARGBBlendRow;
}
#endif
#if defined(HAS_ARGBBLENDROW_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
ARGBBlendRow = ARGBBlendRow_NEON;
}
#endif
#if defined(HAS_ARGBBLENDROW_MSA)
if (TestCpuFlag(kCpuHasMSA)) {
ARGBBlendRow = ARGBBlendRow_MSA;
}
#endif
#if defined(HAS_ARGBBLENDROW_LSX)
if (TestCpuFlag(kCpuHasLSX)) {
ARGBBlendRow = ARGBBlendRow_LSX;
}
#endif
return ARGBBlendRow;
}
LIBYUV_API
int ARGBBlend(const uint8_t* src_argb0,
int src_stride_argb0,
const uint8_t* src_argb1,
int src_stride_argb1,
uint8_t* dst_argb,
int dst_stride_argb,
int width,
int height) {
int y;
void (*ARGBBlendRow)(const uint8_t* src_argb, const uint8_t* src_argb1,
uint8_t* dst_argb, int width) = GetARGBBlend();
if (!src_argb0 || !src_argb1 || !dst_argb || width <= 0 || height == 0) {
return -1;
}
if (height < 0) {
height = -height;
dst_argb = dst_argb + (height - 1) * dst_stride_argb;
dst_stride_argb = -dst_stride_argb;
}
if (src_stride_argb0 == width * 4 && src_stride_argb1 == width * 4 &&
dst_stride_argb == width * 4) {
width *= height;
height = 1;
src_stride_argb0 = src_stride_argb1 = dst_stride_argb = 0;
}
for (y = 0; y < height; ++y) {
ARGBBlendRow(src_argb0, src_argb1, dst_argb, width);
src_argb0 += src_stride_argb0;
src_argb1 += src_stride_argb1;
dst_argb += dst_stride_argb;
}
return 0;
}
LIBYUV_API
int BlendPlane(const uint8_t* src_y0,
int src_stride_y0,
const uint8_t* src_y1,
int src_stride_y1,
const uint8_t* alpha,
int alpha_stride,
uint8_t* dst_y,
int dst_stride_y,
int width,
int height) {
int y;
void (*BlendPlaneRow)(const uint8_t* src0, const uint8_t* src1,
const uint8_t* alpha, uint8_t* dst, int width) =
BlendPlaneRow_C;
if (!src_y0 || !src_y1 || !alpha || !dst_y || width <= 0 || height == 0) {
return -1;
}
if (height < 0) {
height = -height;
dst_y = dst_y + (height - 1) * dst_stride_y;
dst_stride_y = -dst_stride_y;
}
if (src_stride_y0 == width && src_stride_y1 == width &&
alpha_stride == width && dst_stride_y == width) {
width *= height;
height = 1;
src_stride_y0 = src_stride_y1 = alpha_stride = dst_stride_y = 0;
}
#if defined(HAS_BLENDPLANEROW_SSSE3)
if (TestCpuFlag(kCpuHasSSSE3)) {
BlendPlaneRow = BlendPlaneRow_Any_SSSE3;
if (IS_ALIGNED(width, 8)) {
BlendPlaneRow = BlendPlaneRow_SSSE3;
}
}
#endif
#if defined(HAS_BLENDPLANEROW_AVX2)
if (TestCpuFlag(kCpuHasAVX2)) {
BlendPlaneRow = BlendPlaneRow_Any_AVX2;
if (IS_ALIGNED(width, 32)) {
BlendPlaneRow = BlendPlaneRow_AVX2;
}
}
#endif
for (y = 0; y < height; ++y) {
BlendPlaneRow(src_y0, src_y1, alpha, dst_y, width);
src_y0 += src_stride_y0;
src_y1 += src_stride_y1;
alpha += alpha_stride;
dst_y += dst_stride_y;
}
return 0;
}
#define MAXTWIDTH 2048
LIBYUV_API
int I420Blend(const uint8_t* src_y0,
int src_stride_y0,
const uint8_t* src_u0,
int src_stride_u0,
const uint8_t* src_v0,
int src_stride_v0,
const uint8_t* src_y1,
int src_stride_y1,
const uint8_t* src_u1,
int src_stride_u1,
const uint8_t* src_v1,
int src_stride_v1,
const uint8_t* alpha,
int alpha_stride,
uint8_t* dst_y,
int dst_stride_y,
uint8_t* dst_u,
int dst_stride_u,
uint8_t* dst_v,
int dst_stride_v,
int width,
int height) {
int y;
int halfwidth = (width + 1) >> 1;
void (*BlendPlaneRow)(const uint8_t* src0, const uint8_t* src1,
const uint8_t* alpha, uint8_t* dst, int width) =
BlendPlaneRow_C;
void (*ScaleRowDown2)(const uint8_t* src_ptr, ptrdiff_t src_stride,
uint8_t* dst_ptr, int dst_width) = ScaleRowDown2Box_C;
if (!src_y0 || !src_u0 || !src_v0 || !src_y1 || !src_u1 || !src_v1 ||
!alpha || !dst_y || !dst_u || !dst_v || width <= 0 || height == 0) {
return -1;
}
if (height < 0) {
height = -height;
dst_y = dst_y + (height - 1) * dst_stride_y;
dst_stride_y = -dst_stride_y;
}
BlendPlane(src_y0, src_stride_y0, src_y1, src_stride_y1, alpha, alpha_stride,
dst_y, dst_stride_y, width, height);
#if defined(HAS_BLENDPLANEROW_SSSE3)
if (TestCpuFlag(kCpuHasSSSE3)) {
BlendPlaneRow = BlendPlaneRow_Any_SSSE3;
if (IS_ALIGNED(halfwidth, 8)) {
BlendPlaneRow = BlendPlaneRow_SSSE3;
}
}
#endif
#if defined(HAS_BLENDPLANEROW_AVX2)
if (TestCpuFlag(kCpuHasAVX2)) {
BlendPlaneRow = BlendPlaneRow_Any_AVX2;
if (IS_ALIGNED(halfwidth, 32)) {
BlendPlaneRow = BlendPlaneRow_AVX2;
}
}
#endif
if (!IS_ALIGNED(width, 2)) {
ScaleRowDown2 = ScaleRowDown2Box_Odd_C;
}
#if defined(HAS_SCALEROWDOWN2_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
ScaleRowDown2 = ScaleRowDown2Box_Odd_NEON;
if (IS_ALIGNED(width, 2)) {
ScaleRowDown2 = ScaleRowDown2Box_Any_NEON;
if (IS_ALIGNED(halfwidth, 16)) {
ScaleRowDown2 = ScaleRowDown2Box_NEON;
}
}
}
#endif
#if defined(HAS_SCALEROWDOWN2_SSSE3)
if (TestCpuFlag(kCpuHasSSSE3)) {
ScaleRowDown2 = ScaleRowDown2Box_Odd_SSSE3;
if (IS_ALIGNED(width, 2)) {
ScaleRowDown2 = ScaleRowDown2Box_Any_SSSE3;
if (IS_ALIGNED(halfwidth, 16)) {
ScaleRowDown2 = ScaleRowDown2Box_SSSE3;
}
}
}
#endif
#if defined(HAS_SCALEROWDOWN2_AVX2)
if (TestCpuFlag(kCpuHasAVX2)) {
ScaleRowDown2 = ScaleRowDown2Box_Odd_AVX2;
if (IS_ALIGNED(width, 2)) {
ScaleRowDown2 = ScaleRowDown2Box_Any_AVX2;
if (IS_ALIGNED(halfwidth, 32)) {
ScaleRowDown2 = ScaleRowDown2Box_AVX2;
}
}
}
#endif
align_buffer_64(halfalpha, halfwidth);
for (y = 0; y < height; y += 2) {
if (y == (height - 1)) {
alpha_stride = 0;
}
ScaleRowDown2(alpha, alpha_stride, halfalpha, halfwidth);
alpha += alpha_stride * 2;
BlendPlaneRow(src_u0, src_u1, halfalpha, dst_u, halfwidth);
BlendPlaneRow(src_v0, src_v1, halfalpha, dst_v, halfwidth);
src_u0 += src_stride_u0;
src_u1 += src_stride_u1;
dst_u += dst_stride_u;
src_v0 += src_stride_v0;
src_v1 += src_stride_v1;
dst_v += dst_stride_v;
}
free_aligned_buffer_64(halfalpha);
return 0;
}
LIBYUV_API
int ARGBMultiply(const uint8_t* src_argb0,
int src_stride_argb0,
const uint8_t* src_argb1,
int src_stride_argb1,
uint8_t* dst_argb,
int dst_stride_argb,
int width,
int height) {
int y;
void (*ARGBMultiplyRow)(const uint8_t* src0, const uint8_t* src1,
uint8_t* dst, int width) = ARGBMultiplyRow_C;
if (!src_argb0 || !src_argb1 || !dst_argb || width <= 0 || height == 0) {
return -1;
}
if (height < 0) {
height = -height;
dst_argb = dst_argb + (height - 1) * dst_stride_argb;
dst_stride_argb = -dst_stride_argb;
}
if (src_stride_argb0 == width * 4 && src_stride_argb1 == width * 4 &&
dst_stride_argb == width * 4) {
width *= height;
height = 1;
src_stride_argb0 = src_stride_argb1 = dst_stride_argb = 0;
}
#if defined(HAS_ARGBMULTIPLYROW_SSE2)
if (TestCpuFlag(kCpuHasSSE2)) {
ARGBMultiplyRow = ARGBMultiplyRow_Any_SSE2;
if (IS_ALIGNED(width, 4)) {
ARGBMultiplyRow = ARGBMultiplyRow_SSE2;
}
}
#endif
#if defined(HAS_ARGBMULTIPLYROW_AVX2)
if (TestCpuFlag(kCpuHasAVX2)) {
ARGBMultiplyRow = ARGBMultiplyRow_Any_AVX2;
if (IS_ALIGNED(width, 8)) {
ARGBMultiplyRow = ARGBMultiplyRow_AVX2;
}
}
#endif
#if defined(HAS_ARGBMULTIPLYROW_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
ARGBMultiplyRow = ARGBMultiplyRow_Any_NEON;
if (IS_ALIGNED(width, 8)) {
ARGBMultiplyRow = ARGBMultiplyRow_NEON;
}
}
#endif
#if defined(HAS_ARGBMULTIPLYROW_MSA)
if (TestCpuFlag(kCpuHasMSA)) {
ARGBMultiplyRow = ARGBMultiplyRow_Any_MSA;
if (IS_ALIGNED(width, 4)) {
ARGBMultiplyRow = ARGBMultiplyRow_MSA;
}
}
#endif
#if defined(HAS_ARGBMULTIPLYROW_LASX)
if (TestCpuFlag(kCpuHasLASX)) {
ARGBMultiplyRow = ARGBMultiplyRow_Any_LASX;
if (IS_ALIGNED(width, 8)) {
ARGBMultiplyRow = ARGBMultiplyRow_LASX;
}
}
#endif
for (y = 0; y < height; ++y) {
ARGBMultiplyRow(src_argb0, src_argb1, dst_argb, width);
src_argb0 += src_stride_argb0;
src_argb1 += src_stride_argb1;
dst_argb += dst_stride_argb;
}
return 0;
}
LIBYUV_API
int ARGBAdd(const uint8_t* src_argb0,
int src_stride_argb0,
const uint8_t* src_argb1,
int src_stride_argb1,
uint8_t* dst_argb,
int dst_stride_argb,
int width,
int height) {
int y;
void (*ARGBAddRow)(const uint8_t* src0, const uint8_t* src1, uint8_t* dst,
int width) = ARGBAddRow_C;
if (!src_argb0 || !src_argb1 || !dst_argb || width <= 0 || height == 0) {
return -1;
}
if (height < 0) {
height = -height;
dst_argb = dst_argb + (height - 1) * dst_stride_argb;
dst_stride_argb = -dst_stride_argb;
}
if (src_stride_argb0 == width * 4 && src_stride_argb1 == width * 4 &&
dst_stride_argb == width * 4) {
width *= height;
height = 1;
src_stride_argb0 = src_stride_argb1 = dst_stride_argb = 0;
}
#if defined(HAS_ARGBADDROW_SSE2)
if (TestCpuFlag(kCpuHasSSE2)) {
ARGBAddRow = ARGBAddRow_SSE2;
}
#endif
#if defined(HAS_ARGBADDROW_SSE2)
if (TestCpuFlag(kCpuHasSSE2)) {
ARGBAddRow = ARGBAddRow_Any_SSE2;
if (IS_ALIGNED(width, 4)) {
ARGBAddRow = ARGBAddRow_SSE2;
}
}
#endif
#if defined(HAS_ARGBADDROW_AVX2)
if (TestCpuFlag(kCpuHasAVX2)) {
ARGBAddRow = ARGBAddRow_Any_AVX2;
if (IS_ALIGNED(width, 8)) {
ARGBAddRow = ARGBAddRow_AVX2;
}
}
#endif
#if defined(HAS_ARGBADDROW_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
ARGBAddRow = ARGBAddRow_Any_NEON;
if (IS_ALIGNED(width, 8)) {
ARGBAddRow = ARGBAddRow_NEON;
}
}
#endif
#if defined(HAS_ARGBADDROW_MSA)
if (TestCpuFlag(kCpuHasMSA)) {
ARGBAddRow = ARGBAddRow_Any_MSA;
if (IS_ALIGNED(width, 8)) {
ARGBAddRow = ARGBAddRow_MSA;
}
}
#endif
#if defined(HAS_ARGBADDROW_LASX)
if (TestCpuFlag(kCpuHasLASX)) {
ARGBAddRow = ARGBAddRow_Any_LASX;
if (IS_ALIGNED(width, 8)) {
ARGBAddRow = ARGBAddRow_LASX;
}
}
#endif
for (y = 0; y < height; ++y) {
ARGBAddRow(src_argb0, src_argb1, dst_argb, width);
src_argb0 += src_stride_argb0;
src_argb1 += src_stride_argb1;
dst_argb += dst_stride_argb;
}
return 0;
}
LIBYUV_API
int ARGBSubtract(const uint8_t* src_argb0,
int src_stride_argb0,
const uint8_t* src_argb1,
int src_stride_argb1,
uint8_t* dst_argb,
int dst_stride_argb,
int width,
int height) {
int y;
void (*ARGBSubtractRow)(const uint8_t* src0, const uint8_t* src1,
uint8_t* dst, int width) = ARGBSubtractRow_C;
if (!src_argb0 || !src_argb1 || !dst_argb || width <= 0 || height == 0) {
return -1;
}
if (height < 0) {
height = -height;
dst_argb = dst_argb + (height - 1) * dst_stride_argb;
dst_stride_argb = -dst_stride_argb;
}
if (src_stride_argb0 == width * 4 && src_stride_argb1 == width * 4 &&
dst_stride_argb == width * 4) {
width *= height;
height = 1;
src_stride_argb0 = src_stride_argb1 = dst_stride_argb = 0;
}
#if defined(HAS_ARGBSUBTRACTROW_SSE2)
if (TestCpuFlag(kCpuHasSSE2)) {
ARGBSubtractRow = ARGBSubtractRow_Any_SSE2;
if (IS_ALIGNED(width, 4)) {
ARGBSubtractRow = ARGBSubtractRow_SSE2;
}
}
#endif
#if defined(HAS_ARGBSUBTRACTROW_AVX2)
if (TestCpuFlag(kCpuHasAVX2)) {
ARGBSubtractRow = ARGBSubtractRow_Any_AVX2;
if (IS_ALIGNED(width, 8)) {
ARGBSubtractRow = ARGBSubtractRow_AVX2;
}
}
#endif
#if defined(HAS_ARGBSUBTRACTROW_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
ARGBSubtractRow = ARGBSubtractRow_Any_NEON;
if (IS_ALIGNED(width, 8)) {
ARGBSubtractRow = ARGBSubtractRow_NEON;
}
}
#endif
#if defined(HAS_ARGBSUBTRACTROW_MSA)
if (TestCpuFlag(kCpuHasMSA)) {
ARGBSubtractRow = ARGBSubtractRow_Any_MSA;
if (IS_ALIGNED(width, 8)) {
ARGBSubtractRow = ARGBSubtractRow_MSA;
}
}
#endif
#if defined(HAS_ARGBSUBTRACTROW_LASX)
if (TestCpuFlag(kCpuHasLASX)) {
ARGBSubtractRow = ARGBSubtractRow_Any_LASX;
if (IS_ALIGNED(width, 8)) {
ARGBSubtractRow = ARGBSubtractRow_LASX;
}
}
#endif
for (y = 0; y < height; ++y) {
ARGBSubtractRow(src_argb0, src_argb1, dst_argb, width);
src_argb0 += src_stride_argb0;
src_argb1 += src_stride_argb1;
dst_argb += dst_stride_argb;
}
return 0;
}
LIBYUV_API
int RAWToRGB24(const uint8_t* src_raw,
int src_stride_raw,
uint8_t* dst_rgb24,
int dst_stride_rgb24,
int width,
int height) {
int y;
void (*RAWToRGB24Row)(const uint8_t* src_rgb, uint8_t* dst_rgb24, int width) =
RAWToRGB24Row_C;
if (!src_raw || !dst_rgb24 || width <= 0 || height == 0) {
return -1;
}
if (height < 0) {
height = -height;
src_raw = src_raw + (height - 1) * src_stride_raw;
src_stride_raw = -src_stride_raw;
}
if (src_stride_raw == width * 3 && dst_stride_rgb24 == width * 3) {
width *= height;
height = 1;
src_stride_raw = dst_stride_rgb24 = 0;
}
#if defined(HAS_RAWTORGB24ROW_SSSE3)
if (TestCpuFlag(kCpuHasSSSE3)) {
RAWToRGB24Row = RAWToRGB24Row_Any_SSSE3;
if (IS_ALIGNED(width, 8)) {
RAWToRGB24Row = RAWToRGB24Row_SSSE3;
}
}
#endif
#if defined(HAS_RAWTORGB24ROW_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
RAWToRGB24Row = RAWToRGB24Row_Any_NEON;
if (IS_ALIGNED(width, 8)) {
RAWToRGB24Row = RAWToRGB24Row_NEON;
}
}
#endif
#if defined(HAS_RAWTORGB24ROW_MSA)
if (TestCpuFlag(kCpuHasMSA)) {
RAWToRGB24Row = RAWToRGB24Row_Any_MSA;
if (IS_ALIGNED(width, 16)) {
RAWToRGB24Row = RAWToRGB24Row_MSA;
}
}
#endif
#if defined(HAS_RAWTORGB24ROW_LSX)
if (TestCpuFlag(kCpuHasLSX)) {
RAWToRGB24Row = RAWToRGB24Row_Any_LSX;
if (IS_ALIGNED(width, 16)) {
RAWToRGB24Row = RAWToRGB24Row_LSX;
}
}
#endif
for (y = 0; y < height; ++y) {
RAWToRGB24Row(src_raw, dst_rgb24, width);
src_raw += src_stride_raw;
dst_rgb24 += dst_stride_rgb24;
}
return 0;
}
LIBYUV_API
void SetPlane(uint8_t* dst_y,
int dst_stride_y,
int width,
int height,
uint32_t value) {
int y;
void (*SetRow)(uint8_t* dst, uint8_t value, int width) = SetRow_C;
if (width <= 0 || height == 0) {
return;
}
if (height < 0) {
height = -height;
dst_y = dst_y + (height - 1) * dst_stride_y;
dst_stride_y = -dst_stride_y;
}
if (dst_stride_y == width) {
width *= height;
height = 1;
dst_stride_y = 0;
}
#if defined(HAS_SETROW_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
SetRow = SetRow_Any_NEON;
if (IS_ALIGNED(width, 16)) {
SetRow = SetRow_NEON;
}
}
#endif
#if defined(HAS_SETROW_X86)
if (TestCpuFlag(kCpuHasX86)) {
SetRow = SetRow_Any_X86;
if (IS_ALIGNED(width, 4)) {
SetRow = SetRow_X86;
}
}
#endif
#if defined(HAS_SETROW_ERMS)
if (TestCpuFlag(kCpuHasERMS)) {
SetRow = SetRow_ERMS;
}
#endif
#if defined(HAS_SETROW_MSA)
if (TestCpuFlag(kCpuHasMSA) && IS_ALIGNED(width, 16)) {
SetRow = SetRow_MSA;
}
#endif
#if defined(HAS_SETROW_LSX)
if (TestCpuFlag(kCpuHasLSX)) {
SetRow = SetRow_Any_LSX;
if (IS_ALIGNED(width, 16)) {
SetRow = SetRow_LSX;
}
}
#endif
for (y = 0; y < height; ++y) {
SetRow(dst_y, (uint8_t)value, width);
dst_y += dst_stride_y;
}
}
LIBYUV_API
int I420Rect(uint8_t* dst_y,
int dst_stride_y,
uint8_t* dst_u,
int dst_stride_u,
uint8_t* dst_v,
int dst_stride_v,
int x,
int y,
int width,
int height,
int value_y,
int value_u,
int value_v) {
int halfwidth = (width + 1) >> 1;
int halfheight = (height + 1) >> 1;
uint8_t* start_y = dst_y + y * dst_stride_y + x;
uint8_t* start_u = dst_u + (y / 2) * dst_stride_u + (x / 2);
uint8_t* start_v = dst_v + (y / 2) * dst_stride_v + (x / 2);
if (!dst_y || !dst_u || !dst_v || width <= 0 || height == 0 || x < 0 ||
y < 0 || value_y < 0 || value_y > 255 || value_u < 0 || value_u > 255 ||
value_v < 0 || value_v > 255) {
return -1;
}
SetPlane(start_y, dst_stride_y, width, height, value_y);
SetPlane(start_u, dst_stride_u, halfwidth, halfheight, value_u);
SetPlane(start_v, dst_stride_v, halfwidth, halfheight, value_v);
return 0;
}
LIBYUV_API
int ARGBRect(uint8_t* dst_argb,
int dst_stride_argb,
int dst_x,
int dst_y,
int width,
int height,
uint32_t value) {
int y;
void (*ARGBSetRow)(uint8_t* dst_argb, uint32_t value, int width) =
ARGBSetRow_C;
if (!dst_argb || width <= 0 || height == 0 || dst_x < 0 || dst_y < 0) {
return -1;
}
if (height < 0) {
height = -height;
dst_argb = dst_argb + (height - 1) * dst_stride_argb;
dst_stride_argb = -dst_stride_argb;
}
dst_argb += dst_y * dst_stride_argb + dst_x * 4;
if (dst_stride_argb == width * 4) {
width *= height;
height = 1;
dst_stride_argb = 0;
}
#if defined(HAS_ARGBSETROW_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
ARGBSetRow = ARGBSetRow_Any_NEON;
if (IS_ALIGNED(width, 4)) {
ARGBSetRow = ARGBSetRow_NEON;
}
}
#endif
#if defined(HAS_ARGBSETROW_X86)
if (TestCpuFlag(kCpuHasX86)) {
ARGBSetRow = ARGBSetRow_X86;
}
#endif
#if defined(HAS_ARGBSETROW_MSA)
if (TestCpuFlag(kCpuHasMSA)) {
ARGBSetRow = ARGBSetRow_Any_MSA;
if (IS_ALIGNED(width, 4)) {
ARGBSetRow = ARGBSetRow_MSA;
}
}
#endif
#if defined(HAS_ARGBSETROW_LSX)
if (TestCpuFlag(kCpuHasLSX)) {
ARGBSetRow = ARGBSetRow_Any_LSX;
if (IS_ALIGNED(width, 4)) {
ARGBSetRow = ARGBSetRow_LSX;
}
}
#endif
for (y = 0; y < height; ++y) {
ARGBSetRow(dst_argb, value, width);
dst_argb += dst_stride_argb;
}
return 0;
}
LIBYUV_API
int ARGBAttenuate(const uint8_t* src_argb,
int src_stride_argb,
uint8_t* dst_argb,
int dst_stride_argb,
int width,
int height) {
int y;
void (*ARGBAttenuateRow)(const uint8_t* src_argb, uint8_t* dst_argb,
int width) = ARGBAttenuateRow_C;
if (!src_argb || !dst_argb || width <= 0 || height == 0) {
return -1;
}
if (height < 0) {
height = -height;
src_argb = src_argb + (height - 1) * src_stride_argb;
src_stride_argb = -src_stride_argb;
}
if (src_stride_argb == width * 4 && dst_stride_argb == width * 4) {
width *= height;
height = 1;
src_stride_argb = dst_stride_argb = 0;
}
#if defined(HAS_ARGBATTENUATEROW_SSSE3)
if (TestCpuFlag(kCpuHasSSSE3)) {
ARGBAttenuateRow = ARGBAttenuateRow_Any_SSSE3;
if (IS_ALIGNED(width, 4)) {
ARGBAttenuateRow = ARGBAttenuateRow_SSSE3;
}
}
#endif
#if defined(HAS_ARGBATTENUATEROW_AVX2)
if (TestCpuFlag(kCpuHasAVX2)) {
ARGBAttenuateRow = ARGBAttenuateRow_Any_AVX2;
if (IS_ALIGNED(width, 8)) {
ARGBAttenuateRow = ARGBAttenuateRow_AVX2;
}
}
#endif
#if defined(HAS_ARGBATTENUATEROW_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
ARGBAttenuateRow = ARGBAttenuateRow_Any_NEON;
if (IS_ALIGNED(width, 8)) {
ARGBAttenuateRow = ARGBAttenuateRow_NEON;
}
}
#endif
#if defined(HAS_ARGBATTENUATEROW_MSA)
if (TestCpuFlag(kCpuHasMSA)) {
ARGBAttenuateRow = ARGBAttenuateRow_Any_MSA;
if (IS_ALIGNED(width, 8)) {
ARGBAttenuateRow = ARGBAttenuateRow_MSA;
}
}
#endif
#if defined(HAS_ARGBATTENUATEROW_LASX)
if (TestCpuFlag(kCpuHasLASX)) {
ARGBAttenuateRow = ARGBAttenuateRow_Any_LASX;
if (IS_ALIGNED(width, 16)) {
ARGBAttenuateRow = ARGBAttenuateRow_LASX;
}
}
#endif
for (y = 0; y < height; ++y) {
ARGBAttenuateRow(src_argb, dst_argb, width);
src_argb += src_stride_argb;
dst_argb += dst_stride_argb;
}
return 0;
}
LIBYUV_API
int ARGBUnattenuate(const uint8_t* src_argb,
int src_stride_argb,
uint8_t* dst_argb,
int dst_stride_argb,
int width,
int height) {
int y;
void (*ARGBUnattenuateRow)(const uint8_t* src_argb, uint8_t* dst_argb,
int width) = ARGBUnattenuateRow_C;
if (!src_argb || !dst_argb || width <= 0 || height == 0) {
return -1;
}
if (height < 0) {
height = -height;
src_argb = src_argb + (height - 1) * src_stride_argb;
src_stride_argb = -src_stride_argb;
}
if (src_stride_argb == width * 4 && dst_stride_argb == width * 4) {
width *= height;
height = 1;
src_stride_argb = dst_stride_argb = 0;
}
#if defined(HAS_ARGBUNATTENUATEROW_SSE2)
if (TestCpuFlag(kCpuHasSSE2)) {
ARGBUnattenuateRow = ARGBUnattenuateRow_Any_SSE2;
if (IS_ALIGNED(width, 4)) {
ARGBUnattenuateRow = ARGBUnattenuateRow_SSE2;
}
}
#endif
#if defined(HAS_ARGBUNATTENUATEROW_AVX2)
if (TestCpuFlag(kCpuHasAVX2)) {
ARGBUnattenuateRow = ARGBUnattenuateRow_Any_AVX2;
if (IS_ALIGNED(width, 8)) {
ARGBUnattenuateRow = ARGBUnattenuateRow_AVX2;
}
}
#endif
for (y = 0; y < height; ++y) {
ARGBUnattenuateRow(src_argb, dst_argb, width);
src_argb += src_stride_argb;
dst_argb += dst_stride_argb;
}
return 0;
}
LIBYUV_API
int ARGBGrayTo(const uint8_t* src_argb,
int src_stride_argb,
uint8_t* dst_argb,
int dst_stride_argb,
int width,
int height) {
int y;
void (*ARGBGrayRow)(const uint8_t* src_argb, uint8_t* dst_argb, int width) =
ARGBGrayRow_C;
if (!src_argb || !dst_argb || width <= 0 || height == 0) {
return -1;
}
if (height < 0) {
height = -height;
src_argb = src_argb + (height - 1) * src_stride_argb;
src_stride_argb = -src_stride_argb;
}
if (src_stride_argb == width * 4 && dst_stride_argb == width * 4) {
width *= height;
height = 1;
src_stride_argb = dst_stride_argb = 0;
}
#if defined(HAS_ARGBGRAYROW_SSSE3)
if (TestCpuFlag(kCpuHasSSSE3) && IS_ALIGNED(width, 8)) {
ARGBGrayRow = ARGBGrayRow_SSSE3;
}
#endif
#if defined(HAS_ARGBGRAYROW_NEON)
if (TestCpuFlag(kCpuHasNEON) && IS_ALIGNED(width, 8)) {
ARGBGrayRow = ARGBGrayRow_NEON;
}
#endif
#if defined(HAS_ARGBGRAYROW_MSA)
if (TestCpuFlag(kCpuHasMSA) && IS_ALIGNED(width, 8)) {
ARGBGrayRow = ARGBGrayRow_MSA;
}
#endif
#if defined(HAS_ARGBGRAYROW_LASX)
if (TestCpuFlag(kCpuHasLASX) && IS_ALIGNED(width, 16)) {
ARGBGrayRow = ARGBGrayRow_LASX;
}
#endif
for (y = 0; y < height; ++y) {
ARGBGrayRow(src_argb, dst_argb, width);
src_argb += src_stride_argb;
dst_argb += dst_stride_argb;
}
return 0;
}
LIBYUV_API
int ARGBGray(uint8_t* dst_argb,
int dst_stride_argb,
int dst_x,
int dst_y,
int width,
int height) {
int y;
void (*ARGBGrayRow)(const uint8_t* src_argb, uint8_t* dst_argb, int width) =
ARGBGrayRow_C;
uint8_t* dst = dst_argb + dst_y * dst_stride_argb + dst_x * 4;
if (!dst_argb || width <= 0 || height <= 0 || dst_x < 0 || dst_y < 0) {
return -1;
}
if (dst_stride_argb == width * 4) {
width *= height;
height = 1;
dst_stride_argb = 0;
}
#if defined(HAS_ARGBGRAYROW_SSSE3)
if (TestCpuFlag(kCpuHasSSSE3) && IS_ALIGNED(width, 8)) {
ARGBGrayRow = ARGBGrayRow_SSSE3;
}
#endif
#if defined(HAS_ARGBGRAYROW_NEON)
if (TestCpuFlag(kCpuHasNEON) && IS_ALIGNED(width, 8)) {
ARGBGrayRow = ARGBGrayRow_NEON;
}
#endif
#if defined(HAS_ARGBGRAYROW_MSA)
if (TestCpuFlag(kCpuHasMSA) && IS_ALIGNED(width, 8)) {
ARGBGrayRow = ARGBGrayRow_MSA;
}
#endif
#if defined(HAS_ARGBGRAYROW_LASX)
if (TestCpuFlag(kCpuHasLASX) && IS_ALIGNED(width, 16)) {
ARGBGrayRow = ARGBGrayRow_LASX;
}
#endif
for (y = 0; y < height; ++y) {
ARGBGrayRow(dst, dst, width);
dst += dst_stride_argb;
}
return 0;
}
LIBYUV_API
int ARGBSepia(uint8_t* dst_argb,
int dst_stride_argb,
int dst_x,
int dst_y,
int width,
int height) {
int y;
void (*ARGBSepiaRow)(uint8_t* dst_argb, int width) = ARGBSepiaRow_C;
uint8_t* dst = dst_argb + dst_y * dst_stride_argb + dst_x * 4;
if (!dst_argb || width <= 0 || height <= 0 || dst_x < 0 || dst_y < 0) {
return -1;
}
if (dst_stride_argb == width * 4) {
width *= height;
height = 1;
dst_stride_argb = 0;
}
#if defined(HAS_ARGBSEPIAROW_SSSE3)
if (TestCpuFlag(kCpuHasSSSE3) && IS_ALIGNED(width, 8)) {
ARGBSepiaRow = ARGBSepiaRow_SSSE3;
}
#endif
#if defined(HAS_ARGBSEPIAROW_NEON)
if (TestCpuFlag(kCpuHasNEON) && IS_ALIGNED(width, 8)) {
ARGBSepiaRow = ARGBSepiaRow_NEON;
}
#endif
#if defined(HAS_ARGBSEPIAROW_MSA)
if (TestCpuFlag(kCpuHasMSA) && IS_ALIGNED(width, 8)) {
ARGBSepiaRow = ARGBSepiaRow_MSA;
}
#endif
#if defined(HAS_ARGBSEPIAROW_LASX)
if (TestCpuFlag(kCpuHasLASX) && IS_ALIGNED(width, 16)) {
ARGBSepiaRow = ARGBSepiaRow_LASX;
}
#endif
for (y = 0; y < height; ++y) {
ARGBSepiaRow(dst, width);
dst += dst_stride_argb;
}
return 0;
}
LIBYUV_API
int ARGBColorMatrix(const uint8_t* src_argb,
int src_stride_argb,
uint8_t* dst_argb,
int dst_stride_argb,
const int8_t* matrix_argb,
int width,
int height) {
int y;
void (*ARGBColorMatrixRow)(const uint8_t* src_argb, uint8_t* dst_argb,
const int8_t* matrix_argb, int width) =
ARGBColorMatrixRow_C;
if (!src_argb || !dst_argb || !matrix_argb || width <= 0 || height == 0) {
return -1;
}
if (height < 0) {
height = -height;
src_argb = src_argb + (height - 1) * src_stride_argb;
src_stride_argb = -src_stride_argb;
}
if (src_stride_argb == width * 4 && dst_stride_argb == width * 4) {
width *= height;
height = 1;
src_stride_argb = dst_stride_argb = 0;
}
#if defined(HAS_ARGBCOLORMATRIXROW_SSSE3)
if (TestCpuFlag(kCpuHasSSSE3) && IS_ALIGNED(width, 8)) {
ARGBColorMatrixRow = ARGBColorMatrixRow_SSSE3;
}
#endif
#if defined(HAS_ARGBCOLORMATRIXROW_NEON)
if (TestCpuFlag(kCpuHasNEON) && IS_ALIGNED(width, 8)) {
ARGBColorMatrixRow = ARGBColorMatrixRow_NEON;
}
#endif
#if defined(HAS_ARGBCOLORMATRIXROW_MSA)
if (TestCpuFlag(kCpuHasMSA) && IS_ALIGNED(width, 8)) {
ARGBColorMatrixRow = ARGBColorMatrixRow_MSA;
}
#endif
#if defined(HAS_ARGBCOLORMATRIXROW_LSX)
if (TestCpuFlag(kCpuHasLSX) && IS_ALIGNED(width, 8)) {
ARGBColorMatrixRow = ARGBColorMatrixRow_LSX;
}
#endif
for (y = 0; y < height; ++y) {
ARGBColorMatrixRow(src_argb, dst_argb, matrix_argb, width);
src_argb += src_stride_argb;
dst_argb += dst_stride_argb;
}
return 0;
}
LIBYUV_API
int RGBColorMatrix(uint8_t* dst_argb,
int dst_stride_argb,
const int8_t* matrix_rgb,
int dst_x,
int dst_y,
int width,
int height) {
SIMD_ALIGNED(int8_t matrix_argb[16]);
uint8_t* dst = dst_argb + dst_y * dst_stride_argb + dst_x * 4;
if (!dst_argb || !matrix_rgb || width <= 0 || height <= 0 || dst_x < 0 ||
dst_y < 0) {
return -1;
}
matrix_argb[0] = matrix_rgb[0] / 2;
matrix_argb[1] = matrix_rgb[1] / 2;
matrix_argb[2] = matrix_rgb[2] / 2;
matrix_argb[3] = matrix_rgb[3] / 2;
matrix_argb[4] = matrix_rgb[4] / 2;
matrix_argb[5] = matrix_rgb[5] / 2;
matrix_argb[6] = matrix_rgb[6] / 2;
matrix_argb[7] = matrix_rgb[7] / 2;
matrix_argb[8] = matrix_rgb[8] / 2;
matrix_argb[9] = matrix_rgb[9] / 2;
matrix_argb[10] = matrix_rgb[10] / 2;
matrix_argb[11] = matrix_rgb[11] / 2;
matrix_argb[14] = matrix_argb[13] = matrix_argb[12] = 0;
matrix_argb[15] = 64;
return ARGBColorMatrix((const uint8_t*)(dst), dst_stride_argb, dst,
dst_stride_argb, &matrix_argb[0], width, height);
}
LIBYUV_API
int ARGBColorTable(uint8_t* dst_argb,
int dst_stride_argb,
const uint8_t* table_argb,
int dst_x,
int dst_y,
int width,
int height) {
int y;
void (*ARGBColorTableRow)(uint8_t* dst_argb, const uint8_t* table_argb,
int width) = ARGBColorTableRow_C;
uint8_t* dst = dst_argb + dst_y * dst_stride_argb + dst_x * 4;
if (!dst_argb || !table_argb || width <= 0 || height <= 0 || dst_x < 0 ||
dst_y < 0) {
return -1;
}
if (dst_stride_argb == width * 4) {
width *= height;
height = 1;
dst_stride_argb = 0;
}
#if defined(HAS_ARGBCOLORTABLEROW_X86)
if (TestCpuFlag(kCpuHasX86)) {
ARGBColorTableRow = ARGBColorTableRow_X86;
}
#endif
for (y = 0; y < height; ++y) {
ARGBColorTableRow(dst, table_argb, width);
dst += dst_stride_argb;
}
return 0;
}
LIBYUV_API
int RGBColorTable(uint8_t* dst_argb,
int dst_stride_argb,
const uint8_t* table_argb,
int dst_x,
int dst_y,
int width,
int height) {
int y;
void (*RGBColorTableRow)(uint8_t* dst_argb, const uint8_t* table_argb,
int width) = RGBColorTableRow_C;
uint8_t* dst = dst_argb + dst_y * dst_stride_argb + dst_x * 4;
if (!dst_argb || !table_argb || width <= 0 || height <= 0 || dst_x < 0 ||
dst_y < 0) {
return -1;
}
if (dst_stride_argb == width * 4) {
width *= height;
height = 1;
dst_stride_argb = 0;
}
#if defined(HAS_RGBCOLORTABLEROW_X86)
if (TestCpuFlag(kCpuHasX86)) {
RGBColorTableRow = RGBColorTableRow_X86;
}
#endif
for (y = 0; y < height; ++y) {
RGBColorTableRow(dst, table_argb, width);
dst += dst_stride_argb;
}
return 0;
}
LIBYUV_API
int ARGBQuantize(uint8_t* dst_argb,
int dst_stride_argb,
int scale,
int interval_size,
int interval_offset,
int dst_x,
int dst_y,
int width,
int height) {
int y;
void (*ARGBQuantizeRow)(uint8_t* dst_argb, int scale, int interval_size,
int interval_offset, int width) = ARGBQuantizeRow_C;
uint8_t* dst = dst_argb + dst_y * dst_stride_argb + dst_x * 4;
if (!dst_argb || width <= 0 || height <= 0 || dst_x < 0 || dst_y < 0 ||
interval_size < 1 || interval_size > 255) {
return -1;
}
if (dst_stride_argb == width * 4) {
width *= height;
height = 1;
dst_stride_argb = 0;
}
#if defined(HAS_ARGBQUANTIZEROW_SSE2)
if (TestCpuFlag(kCpuHasSSE2) && IS_ALIGNED(width, 4)) {
ARGBQuantizeRow = ARGBQuantizeRow_SSE2;
}
#endif
#if defined(HAS_ARGBQUANTIZEROW_NEON)
if (TestCpuFlag(kCpuHasNEON) && IS_ALIGNED(width, 8)) {
ARGBQuantizeRow = ARGBQuantizeRow_NEON;
}
#endif
#if defined(HAS_ARGBQUANTIZEROW_MSA)
if (TestCpuFlag(kCpuHasMSA) && IS_ALIGNED(width, 8)) {
ARGBQuantizeRow = ARGBQuantizeRow_MSA;
}
#endif
#if defined(HAS_ARGBQUANTIZEROW_LSX)
if (TestCpuFlag(kCpuHasLSX) && IS_ALIGNED(width, 8)) {
ARGBQuantizeRow = ARGBQuantizeRow_LSX;
}
#endif
for (y = 0; y < height; ++y) {
ARGBQuantizeRow(dst, scale, interval_size, interval_offset, width);
dst += dst_stride_argb;
}
return 0;
}
LIBYUV_API
int ARGBComputeCumulativeSum(const uint8_t* src_argb,
int src_stride_argb,
int32_t* dst_cumsum,
int dst_stride32_cumsum,
int width,
int height) {
int y;
void (*ComputeCumulativeSumRow)(const uint8_t* row, int32_t* cumsum,
const int32_t* previous_cumsum, int width) =
ComputeCumulativeSumRow_C;
int32_t* previous_cumsum = dst_cumsum;
if (!dst_cumsum || !src_argb || width <= 0 || height <= 0) {
return -1;
}
#if defined(HAS_CUMULATIVESUMTOAVERAGEROW_SSE2)
if (TestCpuFlag(kCpuHasSSE2)) {
ComputeCumulativeSumRow = ComputeCumulativeSumRow_SSE2;
}
#endif
memset(dst_cumsum, 0, width * sizeof(dst_cumsum[0]) * 4);
for (y = 0; y < height; ++y) {
ComputeCumulativeSumRow(src_argb, dst_cumsum, previous_cumsum, width);
previous_cumsum = dst_cumsum;
dst_cumsum += dst_stride32_cumsum;
src_argb += src_stride_argb;
}
return 0;
}
LIBYUV_API
int ARGBBlur(const uint8_t* src_argb,
int src_stride_argb,
uint8_t* dst_argb,
int dst_stride_argb,
int32_t* dst_cumsum,
int dst_stride32_cumsum,
int width,
int height,
int radius) {
int y;
void (*ComputeCumulativeSumRow)(const uint8_t* row, int32_t* cumsum,
const int32_t* previous_cumsum, int width) =
ComputeCumulativeSumRow_C;
void (*CumulativeSumToAverageRow)(
const int32_t* topleft, const int32_t* botleft, int width, int area,
uint8_t* dst, int count) = CumulativeSumToAverageRow_C;
int32_t* cumsum_bot_row;
int32_t* max_cumsum_bot_row;
int32_t* cumsum_top_row;
if (!src_argb || !dst_argb || width <= 0 || height == 0) {
return -1;
}
if (height < 0) {
height = -height;
src_argb = src_argb + (height - 1) * src_stride_argb;
src_stride_argb = -src_stride_argb;
}
if (radius > height) {
radius = height;
}
if (radius > (width / 2 - 1)) {
radius = width / 2 - 1;
}
if (radius <= 0 || height <= 1) {
return -1;
}
#if defined(HAS_CUMULATIVESUMTOAVERAGEROW_SSE2)
if (TestCpuFlag(kCpuHasSSE2)) {
ComputeCumulativeSumRow = ComputeCumulativeSumRow_SSE2;
CumulativeSumToAverageRow = CumulativeSumToAverageRow_SSE2;
}
#endif
ARGBComputeCumulativeSum(src_argb, src_stride_argb, dst_cumsum,
dst_stride32_cumsum, width, radius);
src_argb = src_argb + radius * src_stride_argb;
cumsum_bot_row = &dst_cumsum[(radius - 1) * dst_stride32_cumsum];
max_cumsum_bot_row = &dst_cumsum[(radius * 2 + 2) * dst_stride32_cumsum];
cumsum_top_row = &dst_cumsum[0];
for (y = 0; y < height; ++y) {
int top_y = ((y - radius - 1) >= 0) ? (y - radius - 1) : 0;
int bot_y = ((y + radius) < height) ? (y + radius) : (height - 1);
int area = radius * (bot_y - top_y);
int boxwidth = radius * 4;
int x;
int n;
if (top_y) {
cumsum_top_row += dst_stride32_cumsum;
if (cumsum_top_row >= max_cumsum_bot_row) {
cumsum_top_row = dst_cumsum;
}
}
if ((y + radius) < height) {
const int32_t* prev_cumsum_bot_row = cumsum_bot_row;
cumsum_bot_row += dst_stride32_cumsum;
if (cumsum_bot_row >= max_cumsum_bot_row) {
cumsum_bot_row = dst_cumsum;
}
ComputeCumulativeSumRow(src_argb, cumsum_bot_row, prev_cumsum_bot_row,
width);
src_argb += src_stride_argb;
}
for (x = 0; x < radius + 1; ++x) {
CumulativeSumToAverageRow(cumsum_top_row, cumsum_bot_row, boxwidth, area,
&dst_argb[x * 4], 1);
area += (bot_y - top_y);
boxwidth += 4;
}
n = (width - 1) - radius - x + 1;
CumulativeSumToAverageRow(cumsum_top_row, cumsum_bot_row, boxwidth, area,
&dst_argb[x * 4], n);
for (x += n; x <= width - 1; ++x) {
area -= (bot_y - top_y);
boxwidth -= 4;
CumulativeSumToAverageRow(cumsum_top_row + (x - radius - 1) * 4,
cumsum_bot_row + (x - radius - 1) * 4, boxwidth,
area, &dst_argb[x * 4], 1);
}
dst_argb += dst_stride_argb;
}
return 0;
}
LIBYUV_API
int ARGBShade(const uint8_t* src_argb,
int src_stride_argb,
uint8_t* dst_argb,
int dst_stride_argb,
int width,
int height,
uint32_t value) {
int y;
void (*ARGBShadeRow)(const uint8_t* src_argb, uint8_t* dst_argb, int width,
uint32_t value) = ARGBShadeRow_C;
if (!src_argb || !dst_argb || width <= 0 || height == 0 || value == 0u) {
return -1;
}
if (height < 0) {
height = -height;
src_argb = src_argb + (height - 1) * src_stride_argb;
src_stride_argb = -src_stride_argb;
}
if (src_stride_argb == width * 4 && dst_stride_argb == width * 4) {
width *= height;
height = 1;
src_stride_argb = dst_stride_argb = 0;
}
#if defined(HAS_ARGBSHADEROW_SSE2)
if (TestCpuFlag(kCpuHasSSE2) && IS_ALIGNED(width, 4)) {
ARGBShadeRow = ARGBShadeRow_SSE2;
}
#endif
#if defined(HAS_ARGBSHADEROW_NEON)
if (TestCpuFlag(kCpuHasNEON) && IS_ALIGNED(width, 8)) {
ARGBShadeRow = ARGBShadeRow_NEON;
}
#endif
#if defined(HAS_ARGBSHADEROW_MSA)
if (TestCpuFlag(kCpuHasMSA) && IS_ALIGNED(width, 4)) {
ARGBShadeRow = ARGBShadeRow_MSA;
}
#endif
#if defined(HAS_ARGBSHADEROW_LASX)
if (TestCpuFlag(kCpuHasLASX) && IS_ALIGNED(width, 8)) {
ARGBShadeRow = ARGBShadeRow_LASX;
}
#endif
for (y = 0; y < height; ++y) {
ARGBShadeRow(src_argb, dst_argb, width, value);
src_argb += src_stride_argb;
dst_argb += dst_stride_argb;
}
return 0;
}
LIBYUV_API
int InterpolatePlane(const uint8_t* src0,
int src_stride0,
const uint8_t* src1,
int src_stride1,
uint8_t* dst,
int dst_stride,
int width,
int height,
int interpolation) {
int y;
void (*InterpolateRow)(uint8_t* dst_ptr, const uint8_t* src_ptr,
ptrdiff_t src_stride, int dst_width,
int source_y_fraction) = InterpolateRow_C;
if (!src0 || !src1 || !dst || width <= 0 || height == 0) {
return -1;
}
if (height < 0) {
height = -height;
dst = dst + (height - 1) * dst_stride;
dst_stride = -dst_stride;
}
if (src_stride0 == width && src_stride1 == width && dst_stride == width) {
width *= height;
height = 1;
src_stride0 = src_stride1 = dst_stride = 0;
}
#if defined(HAS_INTERPOLATEROW_SSSE3)
if (TestCpuFlag(kCpuHasSSSE3)) {
InterpolateRow = InterpolateRow_Any_SSSE3;
if (IS_ALIGNED(width, 16)) {
InterpolateRow = InterpolateRow_SSSE3;
}
}
#endif
#if defined(HAS_INTERPOLATEROW_AVX2)
if (TestCpuFlag(kCpuHasAVX2)) {
InterpolateRow = InterpolateRow_Any_AVX2;
if (IS_ALIGNED(width, 32)) {
InterpolateRow = InterpolateRow_AVX2;
}
}
#endif
#if defined(HAS_INTERPOLATEROW_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
InterpolateRow = InterpolateRow_Any_NEON;
if (IS_ALIGNED(width, 16)) {
InterpolateRow = InterpolateRow_NEON;
}
}
#endif
#if defined(HAS_INTERPOLATEROW_MSA)
if (TestCpuFlag(kCpuHasMSA)) {
InterpolateRow = InterpolateRow_Any_MSA;
if (IS_ALIGNED(width, 32)) {
InterpolateRow = InterpolateRow_MSA;
}
}
#endif
#if defined(HAS_INTERPOLATEROW_LSX)
if (TestCpuFlag(kCpuHasLSX)) {
InterpolateRow = InterpolateRow_Any_LSX;
if (IS_ALIGNED(width, 32)) {
InterpolateRow = InterpolateRow_LSX;
}
}
#endif
for (y = 0; y < height; ++y) {
InterpolateRow(dst, src0, src1 - src0, width, interpolation);
src0 += src_stride0;
src1 += src_stride1;
dst += dst_stride;
}
return 0;
}
LIBYUV_API
int InterpolatePlane_16(const uint16_t* src0,
int src_stride0,
const uint16_t* src1,
int src_stride1,
uint16_t* dst,
int dst_stride,
int width,
int height,
int interpolation) {
int y;
void (*InterpolateRow_16)(uint16_t* dst_ptr, const uint16_t* src_ptr,
ptrdiff_t src_stride, int dst_width,
int source_y_fraction) = InterpolateRow_16_C;
if (!src0 || !src1 || !dst || width <= 0 || height == 0) {
return -1;
}
if (height < 0) {
height = -height;
dst = dst + (height - 1) * dst_stride;
dst_stride = -dst_stride;
}
if (src_stride0 == width && src_stride1 == width && dst_stride == width) {
width *= height;
height = 1;
src_stride0 = src_stride1 = dst_stride = 0;
}
#if defined(HAS_INTERPOLATEROW_16_SSSE3)
if (TestCpuFlag(kCpuHasSSSE3)) {
InterpolateRow_16 = InterpolateRow_16_Any_SSSE3;
if (IS_ALIGNED(width, 16)) {
InterpolateRow_16 = InterpolateRow_16_SSSE3;
}
}
#endif
#if defined(HAS_INTERPOLATEROW_16_AVX2)
if (TestCpuFlag(kCpuHasAVX2)) {
InterpolateRow_16 = InterpolateRow_16_Any_AVX2;
if (IS_ALIGNED(width, 32)) {
InterpolateRow_16 = InterpolateRow_16_AVX2;
}
}
#endif
#if defined(HAS_INTERPOLATEROW_16_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
InterpolateRow_16 = InterpolateRow_16_Any_NEON;
if (IS_ALIGNED(width, 8)) {
InterpolateRow_16 = InterpolateRow_16_NEON;
}
}
#endif
#if defined(HAS_INTERPOLATEROW_16_MSA)
if (TestCpuFlag(kCpuHasMSA)) {
InterpolateRow_16 = InterpolateRow_16_Any_MSA;
if (IS_ALIGNED(width, 32)) {
InterpolateRow_16 = InterpolateRow_16_MSA;
}
}
#endif
#if defined(HAS_INTERPOLATEROW_16_LSX)
if (TestCpuFlag(kCpuHasLSX)) {
InterpolateRow_16 = InterpolateRow_16_Any_LSX;
if (IS_ALIGNED(width, 32)) {
InterpolateRow_16 = InterpolateRow_16_LSX;
}
}
#endif
for (y = 0; y < height; ++y) {
InterpolateRow_16(dst, src0, src1 - src0, width, interpolation);
src0 += src_stride0;
src1 += src_stride1;
dst += dst_stride;
}
return 0;
}
LIBYUV_API
int ARGBInterpolate(const uint8_t* src_argb0,
int src_stride_argb0,
const uint8_t* src_argb1,
int src_stride_argb1,
uint8_t* dst_argb,
int dst_stride_argb,
int width,
int height,
int interpolation) {
return InterpolatePlane(src_argb0, src_stride_argb0, src_argb1,
src_stride_argb1, dst_argb, dst_stride_argb,
width * 4, height, interpolation);
}
LIBYUV_API
int I420Interpolate(const uint8_t* src0_y,
int src0_stride_y,
const uint8_t* src0_u,
int src0_stride_u,
const uint8_t* src0_v,
int src0_stride_v,
const uint8_t* src1_y,
int src1_stride_y,
const uint8_t* src1_u,
int src1_stride_u,
const uint8_t* src1_v,
int src1_stride_v,
uint8_t* dst_y,
int dst_stride_y,
uint8_t* dst_u,
int dst_stride_u,
uint8_t* dst_v,
int dst_stride_v,
int width,
int height,
int interpolation) {
int halfwidth = (width + 1) >> 1;
int halfheight = (height + 1) >> 1;
if (!src0_y || !src0_u || !src0_v || !src1_y || !src1_u || !src1_v ||
!dst_y || !dst_u || !dst_v || width <= 0 || height == 0) {
return -1;
}
InterpolatePlane(src0_y, src0_stride_y, src1_y, src1_stride_y, dst_y,
dst_stride_y, width, height, interpolation);
InterpolatePlane(src0_u, src0_stride_u, src1_u, src1_stride_u, dst_u,
dst_stride_u, halfwidth, halfheight, interpolation);
InterpolatePlane(src0_v, src0_stride_v, src1_v, src1_stride_v, dst_v,
dst_stride_v, halfwidth, halfheight, interpolation);
return 0;
}
LIBYUV_API
int ARGBShuffle(const uint8_t* src_bgra,
int src_stride_bgra,
uint8_t* dst_argb,
int dst_stride_argb,
const uint8_t* shuffler,
int width,
int height) {
int y;
void (*ARGBShuffleRow)(const uint8_t* src_bgra, uint8_t* dst_argb,
const uint8_t* shuffler, int width) = ARGBShuffleRow_C;
if (!src_bgra || !dst_argb || width <= 0 || height == 0) {
return -1;
}
if (height < 0) {
height = -height;
src_bgra = src_bgra + (height - 1) * src_stride_bgra;
src_stride_bgra = -src_stride_bgra;
}
if (src_stride_bgra == width * 4 && dst_stride_argb == width * 4) {
width *= height;
height = 1;
src_stride_bgra = dst_stride_argb = 0;
}
#if defined(HAS_ARGBSHUFFLEROW_SSSE3)
if (TestCpuFlag(kCpuHasSSSE3)) {
ARGBShuffleRow = ARGBShuffleRow_Any_SSSE3;
if (IS_ALIGNED(width, 8)) {
ARGBShuffleRow = ARGBShuffleRow_SSSE3;
}
}
#endif
#if defined(HAS_ARGBSHUFFLEROW_AVX2)
if (TestCpuFlag(kCpuHasAVX2)) {
ARGBShuffleRow = ARGBShuffleRow_Any_AVX2;
if (IS_ALIGNED(width, 16)) {
ARGBShuffleRow = ARGBShuffleRow_AVX2;
}
}
#endif
#if defined(HAS_ARGBSHUFFLEROW_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
ARGBShuffleRow = ARGBShuffleRow_Any_NEON;
if (IS_ALIGNED(width, 4)) {
ARGBShuffleRow = ARGBShuffleRow_NEON;
}
}
#endif
#if defined(HAS_ARGBSHUFFLEROW_MSA)
if (TestCpuFlag(kCpuHasMSA)) {
ARGBShuffleRow = ARGBShuffleRow_Any_MSA;
if (IS_ALIGNED(width, 8)) {
ARGBShuffleRow = ARGBShuffleRow_MSA;
}
}
#endif
#if defined(HAS_ARGBSHUFFLEROW_LASX)
if (TestCpuFlag(kCpuHasLASX)) {
ARGBShuffleRow = ARGBShuffleRow_Any_LASX;
if (IS_ALIGNED(width, 16)) {
ARGBShuffleRow = ARGBShuffleRow_LASX;
}
}
#endif
for (y = 0; y < height; ++y) {
ARGBShuffleRow(src_bgra, dst_argb, shuffler, width);
src_bgra += src_stride_bgra;
dst_argb += dst_stride_argb;
}
return 0;
}
LIBYUV_API
int AR64Shuffle(const uint16_t* src_ar64,
int src_stride_ar64,
uint16_t* dst_ar64,
int dst_stride_ar64,
const uint8_t* shuffler,
int width,
int height) {
int y;
void (*AR64ShuffleRow)(const uint8_t* src_ar64, uint8_t* dst_ar64,
const uint8_t* shuffler, int width) = AR64ShuffleRow_C;
if (!src_ar64 || !dst_ar64 || width <= 0 || height == 0) {
return -1;
}
if (height < 0) {
height = -height;
src_ar64 = src_ar64 + (height - 1) * src_stride_ar64;
src_stride_ar64 = -src_stride_ar64;
}
if (src_stride_ar64 == width * 4 && dst_stride_ar64 == width * 4) {
width *= height;
height = 1;
src_stride_ar64 = dst_stride_ar64 = 0;
}
#if defined(HAS_ARGBSHUFFLEROW_SSSE3)
if (TestCpuFlag(kCpuHasSSSE3)) {
AR64ShuffleRow = ARGBShuffleRow_Any_SSSE3;
if (IS_ALIGNED(width, 8)) {
AR64ShuffleRow = ARGBShuffleRow_SSSE3;
}
}
#endif
#if defined(HAS_ARGBSHUFFLEROW_AVX2)
if (TestCpuFlag(kCpuHasAVX2)) {
AR64ShuffleRow = ARGBShuffleRow_Any_AVX2;
if (IS_ALIGNED(width, 16)) {
AR64ShuffleRow = ARGBShuffleRow_AVX2;
}
}
#endif
#if defined(HAS_ARGBSHUFFLEROW_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
AR64ShuffleRow = ARGBShuffleRow_Any_NEON;
if (IS_ALIGNED(width, 4)) {
AR64ShuffleRow = ARGBShuffleRow_NEON;
}
}
#endif
for (y = 0; y < height; ++y) {
AR64ShuffleRow((uint8_t*)(src_ar64), (uint8_t*)(dst_ar64), shuffler,
width * 2);
src_ar64 += src_stride_ar64;
dst_ar64 += dst_stride_ar64;
}
return 0;
}
LIBYUV_API
int GaussPlane_F32(const float* src,
int src_stride,
float* dst,
int dst_stride,
int width,
int height) {
int y;
void (*GaussCol_F32)(const float* src0, const float* src1, const float* src2,
const float* src3, const float* src4, float* dst,
int width) = GaussCol_F32_C;
void (*GaussRow_F32)(const float* src, float* dst, int width) =
GaussRow_F32_C;
if (!src || !dst || width <= 0 || height == 0) {
return -1;
}
if (height < 0) {
height = -height;
src = src + (height - 1) * src_stride;
src_stride = -src_stride;
}
#if defined(HAS_GAUSSCOL_F32_NEON)
if (TestCpuFlag(kCpuHasNEON) && IS_ALIGNED(width, 8)) {
GaussCol_F32 = GaussCol_F32_NEON;
}
#endif
#if defined(HAS_GAUSSROW_F32_NEON)
if (TestCpuFlag(kCpuHasNEON) && IS_ALIGNED(width, 8)) {
GaussRow_F32 = GaussRow_F32_NEON;
}
#endif
{
align_buffer_64(rowbuf, (4 + width + 4) * 4);
memset(rowbuf, 0, 16);
memset(rowbuf + (4 + width) * 4, 0, 16);
float* row = (float*)(rowbuf + 16);
const float* src0 = src;
const float* src1 = src;
const float* src2 = src;
const float* src3 = src2 + ((height > 1) ? src_stride : 0);
const float* src4 = src3 + ((height > 2) ? src_stride : 0);
for (y = 0; y < height; ++y) {
GaussCol_F32(src0, src1, src2, src3, src4, row, width);
row[-2] = row[-1] = row[0];
row[width + 1] = row[width] = row[width - 1];
GaussRow_F32(row - 2, dst, width);
src0 = src1;
src1 = src2;
src2 = src3;
src3 = src4;
if ((y + 2) < (height - 1)) {
src4 += src_stride;
}
dst += dst_stride;
}
free_aligned_buffer_64(rowbuf);
}
return 0;
}
static int ARGBSobelize(const uint8_t* src_argb,
int src_stride_argb,
uint8_t* dst_argb,
int dst_stride_argb,
int width,
int height,
void (*SobelRow)(const uint8_t* src_sobelx,
const uint8_t* src_sobely,
uint8_t* dst,
int width)) {
int y;
void (*ARGBToYJRow)(const uint8_t* src_argb, uint8_t* dst_g, int width) =
ARGBToYJRow_C;
void (*SobelYRow)(const uint8_t* src_y0, const uint8_t* src_y1,
uint8_t* dst_sobely, int width) = SobelYRow_C;
void (*SobelXRow)(const uint8_t* src_y0, const uint8_t* src_y1,
const uint8_t* src_y2, uint8_t* dst_sobely, int width) =
SobelXRow_C;
const int kEdge = 16;
if (!src_argb || !dst_argb || width <= 0 || height == 0) {
return -1;
}
if (height < 0) {
height = -height;
src_argb = src_argb + (height - 1) * src_stride_argb;
src_stride_argb = -src_stride_argb;
}
#if defined(HAS_ARGBTOYJROW_SSSE3)
if (TestCpuFlag(kCpuHasSSSE3)) {
ARGBToYJRow = ARGBToYJRow_Any_SSSE3;
if (IS_ALIGNED(width, 16)) {
ARGBToYJRow = ARGBToYJRow_SSSE3;
}
}
#endif
#if defined(HAS_ARGBTOYJROW_AVX2)
if (TestCpuFlag(kCpuHasAVX2)) {
ARGBToYJRow = ARGBToYJRow_Any_AVX2;
if (IS_ALIGNED(width, 32)) {
ARGBToYJRow = ARGBToYJRow_AVX2;
}
}
#endif
#if defined(HAS_ARGBTOYJROW_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
ARGBToYJRow = ARGBToYJRow_Any_NEON;
if (IS_ALIGNED(width, 16)) {
ARGBToYJRow = ARGBToYJRow_NEON;
}
}
#endif
#if defined(HAS_ARGBTOYJROW_MSA)
if (TestCpuFlag(kCpuHasMSA)) {
ARGBToYJRow = ARGBToYJRow_Any_MSA;
if (IS_ALIGNED(width, 16)) {
ARGBToYJRow = ARGBToYJRow_MSA;
}
}
#endif
#if defined(HAS_ARGBTOYJROW_LSX)
if (TestCpuFlag(kCpuHasLSX)) {
ARGBToYJRow = ARGBToYJRow_Any_LSX;
if (IS_ALIGNED(width, 16)) {
ARGBToYJRow = ARGBToYJRow_LSX;
}
}
#endif
#if defined(HAS_ARGBTOYJROW_LASX)
if (TestCpuFlag(kCpuHasLASX)) {
ARGBToYJRow = ARGBToYJRow_Any_LASX;
if (IS_ALIGNED(width, 32)) {
ARGBToYJRow = ARGBToYJRow_LASX;
}
}
#endif
#if defined(HAS_SOBELYROW_SSE2)
if (TestCpuFlag(kCpuHasSSE2)) {
SobelYRow = SobelYRow_SSE2;
}
#endif
#if defined(HAS_SOBELYROW_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
SobelYRow = SobelYRow_NEON;
}
#endif
#if defined(HAS_SOBELYROW_MSA)
if (TestCpuFlag(kCpuHasMSA)) {
SobelYRow = SobelYRow_MSA;
}
#endif
#if defined(HAS_SOBELXROW_SSE2)
if (TestCpuFlag(kCpuHasSSE2)) {
SobelXRow = SobelXRow_SSE2;
}
#endif
#if defined(HAS_SOBELXROW_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
SobelXRow = SobelXRow_NEON;
}
#endif
#if defined(HAS_SOBELXROW_MSA)
if (TestCpuFlag(kCpuHasMSA)) {
SobelXRow = SobelXRow_MSA;
}
#endif
{
const int row_size = (width + kEdge + 31) & ~31;
align_buffer_64(rows, row_size * 2 + (kEdge + row_size * 3 + kEdge));
uint8_t* row_sobelx = rows;
uint8_t* row_sobely = rows + row_size;
uint8_t* row_y = rows + row_size * 2;
uint8_t* row_y0 = row_y + kEdge;
uint8_t* row_y1 = row_y0 + row_size;
uint8_t* row_y2 = row_y1 + row_size;
ARGBToYJRow(src_argb, row_y0, width);
row_y0[-1] = row_y0[0];
memset(row_y0 + width, row_y0[width - 1], 16);
ARGBToYJRow(src_argb, row_y1, width);
row_y1[-1] = row_y1[0];
memset(row_y1 + width, row_y1[width - 1], 16);
memset(row_y2 + width, 0, 16);
for (y = 0; y < height; ++y) {
if (y < (height - 1)) {
src_argb += src_stride_argb;
}
ARGBToYJRow(src_argb, row_y2, width);
row_y2[-1] = row_y2[0];
row_y2[width] = row_y2[width - 1];
SobelXRow(row_y0 - 1, row_y1 - 1, row_y2 - 1, row_sobelx, width);
SobelYRow(row_y0 - 1, row_y2 - 1, row_sobely, width);
SobelRow(row_sobelx, row_sobely, dst_argb, width);
{
uint8_t* row_yt = row_y0;
row_y0 = row_y1;
row_y1 = row_y2;
row_y2 = row_yt;
}
dst_argb += dst_stride_argb;
}
free_aligned_buffer_64(rows);
}
return 0;
}
LIBYUV_API
int ARGBSobel(const uint8_t* src_argb,
int src_stride_argb,
uint8_t* dst_argb,
int dst_stride_argb,
int width,
int height) {
void (*SobelRow)(const uint8_t* src_sobelx, const uint8_t* src_sobely,
uint8_t* dst_argb, int width) = SobelRow_C;
#if defined(HAS_SOBELROW_SSE2)
if (TestCpuFlag(kCpuHasSSE2)) {
SobelRow = SobelRow_Any_SSE2;
if (IS_ALIGNED(width, 16)) {
SobelRow = SobelRow_SSE2;
}
}
#endif
#if defined(HAS_SOBELROW_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
SobelRow = SobelRow_Any_NEON;
if (IS_ALIGNED(width, 8)) {
SobelRow = SobelRow_NEON;
}
}
#endif
#if defined(HAS_SOBELROW_MSA)
if (TestCpuFlag(kCpuHasMSA)) {
SobelRow = SobelRow_Any_MSA;
if (IS_ALIGNED(width, 16)) {
SobelRow = SobelRow_MSA;
}
}
#endif
#if defined(HAS_SOBELROW_LSX)
if (TestCpuFlag(kCpuHasLSX)) {
SobelRow = SobelRow_Any_LSX;
if (IS_ALIGNED(width, 16)) {
SobelRow = SobelRow_LSX;
}
}
#endif
return ARGBSobelize(src_argb, src_stride_argb, dst_argb, dst_stride_argb,
width, height, SobelRow);
}
LIBYUV_API
int ARGBSobelToPlane(const uint8_t* src_argb,
int src_stride_argb,
uint8_t* dst_y,
int dst_stride_y,
int width,
int height) {
void (*SobelToPlaneRow)(const uint8_t* src_sobelx, const uint8_t* src_sobely,
uint8_t* dst_, int width) = SobelToPlaneRow_C;
#if defined(HAS_SOBELTOPLANEROW_SSE2)
if (TestCpuFlag(kCpuHasSSE2)) {
SobelToPlaneRow = SobelToPlaneRow_Any_SSE2;
if (IS_ALIGNED(width, 16)) {
SobelToPlaneRow = SobelToPlaneRow_SSE2;
}
}
#endif
#if defined(HAS_SOBELTOPLANEROW_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
SobelToPlaneRow = SobelToPlaneRow_Any_NEON;
if (IS_ALIGNED(width, 16)) {
SobelToPlaneRow = SobelToPlaneRow_NEON;
}
}
#endif
#if defined(HAS_SOBELTOPLANEROW_MSA)
if (TestCpuFlag(kCpuHasMSA)) {
SobelToPlaneRow = SobelToPlaneRow_Any_MSA;
if (IS_ALIGNED(width, 32)) {
SobelToPlaneRow = SobelToPlaneRow_MSA;
}
}
#endif
#if defined(HAS_SOBELTOPLANEROW_LSX)
if (TestCpuFlag(kCpuHasLSX)) {
SobelToPlaneRow = SobelToPlaneRow_Any_LSX;
if (IS_ALIGNED(width, 32)) {
SobelToPlaneRow = SobelToPlaneRow_LSX;
}
}
#endif
return ARGBSobelize(src_argb, src_stride_argb, dst_y, dst_stride_y, width,
height, SobelToPlaneRow);
}
LIBYUV_API
int ARGBSobelXY(const uint8_t* src_argb,
int src_stride_argb,
uint8_t* dst_argb,
int dst_stride_argb,
int width,
int height) {
void (*SobelXYRow)(const uint8_t* src_sobelx, const uint8_t* src_sobely,
uint8_t* dst_argb, int width) = SobelXYRow_C;
#if defined(HAS_SOBELXYROW_SSE2)
if (TestCpuFlag(kCpuHasSSE2)) {
SobelXYRow = SobelXYRow_Any_SSE2;
if (IS_ALIGNED(width, 16)) {
SobelXYRow = SobelXYRow_SSE2;
}
}
#endif
#if defined(HAS_SOBELXYROW_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
SobelXYRow = SobelXYRow_Any_NEON;
if (IS_ALIGNED(width, 8)) {
SobelXYRow = SobelXYRow_NEON;
}
}
#endif
#if defined(HAS_SOBELXYROW_MSA)
if (TestCpuFlag(kCpuHasMSA)) {
SobelXYRow = SobelXYRow_Any_MSA;
if (IS_ALIGNED(width, 16)) {
SobelXYRow = SobelXYRow_MSA;
}
}
#endif
#if defined(HAS_SOBELXYROW_LSX)
if (TestCpuFlag(kCpuHasLSX)) {
SobelXYRow = SobelXYRow_Any_LSX;
if (IS_ALIGNED(width, 16)) {
SobelXYRow = SobelXYRow_LSX;
}
}
#endif
return ARGBSobelize(src_argb, src_stride_argb, dst_argb, dst_stride_argb,
width, height, SobelXYRow);
}
LIBYUV_API
int ARGBPolynomial(const uint8_t* src_argb,
int src_stride_argb,
uint8_t* dst_argb,
int dst_stride_argb,
const float* poly,
int width,
int height) {
int y;
void (*ARGBPolynomialRow)(const uint8_t* src_argb, uint8_t* dst_argb,
const float* poly, int width) = ARGBPolynomialRow_C;
if (!src_argb || !dst_argb || !poly || width <= 0 || height == 0) {
return -1;
}
if (height < 0) {
height = -height;
src_argb = src_argb + (height - 1) * src_stride_argb;
src_stride_argb = -src_stride_argb;
}
if (src_stride_argb == width * 4 && dst_stride_argb == width * 4) {
width *= height;
height = 1;
src_stride_argb = dst_stride_argb = 0;
}
#if defined(HAS_ARGBPOLYNOMIALROW_SSE2)
if (TestCpuFlag(kCpuHasSSE2) && IS_ALIGNED(width, 2)) {
ARGBPolynomialRow = ARGBPolynomialRow_SSE2;
}
#endif
#if defined(HAS_ARGBPOLYNOMIALROW_AVX2)
if (TestCpuFlag(kCpuHasAVX2) && TestCpuFlag(kCpuHasFMA3) &&
IS_ALIGNED(width, 2)) {
ARGBPolynomialRow = ARGBPolynomialRow_AVX2;
}
#endif
for (y = 0; y < height; ++y) {
ARGBPolynomialRow(src_argb, dst_argb, poly, width);
src_argb += src_stride_argb;
dst_argb += dst_stride_argb;
}
return 0;
}
LIBYUV_API
int HalfFloatPlane(const uint16_t* src_y,
int src_stride_y,
uint16_t* dst_y,
int dst_stride_y,
float scale,
int width,
int height) {
int y;
void (*HalfFloatRow)(const uint16_t* src, uint16_t* dst, float scale,
int width) = HalfFloatRow_C;
if (!src_y || !dst_y || width <= 0 || height == 0) {
return -1;
}
src_stride_y >>= 1;
dst_stride_y >>= 1;
if (height < 0) {
height = -height;
src_y = src_y + (height - 1) * src_stride_y;
src_stride_y = -src_stride_y;
}
if (src_stride_y == width && dst_stride_y == width) {
width *= height;
height = 1;
src_stride_y = dst_stride_y = 0;
}
#if defined(HAS_HALFFLOATROW_SSE2)
if (TestCpuFlag(kCpuHasSSE2)) {
HalfFloatRow = HalfFloatRow_Any_SSE2;
if (IS_ALIGNED(width, 8)) {
HalfFloatRow = HalfFloatRow_SSE2;
}
}
#endif
#if defined(HAS_HALFFLOATROW_AVX2)
if (TestCpuFlag(kCpuHasAVX2)) {
HalfFloatRow = HalfFloatRow_Any_AVX2;
if (IS_ALIGNED(width, 16)) {
HalfFloatRow = HalfFloatRow_AVX2;
}
}
#endif
#if defined(HAS_HALFFLOATROW_F16C)
if (TestCpuFlag(kCpuHasAVX2) && TestCpuFlag(kCpuHasF16C)) {
HalfFloatRow =
(scale == 1.0f) ? HalfFloat1Row_Any_F16C : HalfFloatRow_Any_F16C;
if (IS_ALIGNED(width, 16)) {
HalfFloatRow = (scale == 1.0f) ? HalfFloat1Row_F16C : HalfFloatRow_F16C;
}
}
#endif
#if defined(HAS_HALFFLOATROW_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
HalfFloatRow =
(scale == 1.0f) ? HalfFloat1Row_Any_NEON : HalfFloatRow_Any_NEON;
if (IS_ALIGNED(width, 8)) {
HalfFloatRow = (scale == 1.0f) ? HalfFloat1Row_NEON : HalfFloatRow_NEON;
}
}
#endif
#if defined(HAS_HALFFLOATROW_MSA)
if (TestCpuFlag(kCpuHasMSA)) {
HalfFloatRow = HalfFloatRow_Any_MSA;
if (IS_ALIGNED(width, 32)) {
HalfFloatRow = HalfFloatRow_MSA;
}
}
#endif
#if defined(HAS_HALFFLOATROW_LSX)
if (TestCpuFlag(kCpuHasLSX)) {
HalfFloatRow = HalfFloatRow_Any_LSX;
if (IS_ALIGNED(width, 32)) {
HalfFloatRow = HalfFloatRow_LSX;
}
}
#endif
for (y = 0; y < height; ++y) {
HalfFloatRow(src_y, dst_y, scale, width);
src_y += src_stride_y;
dst_y += dst_stride_y;
}
return 0;
}
LIBYUV_API
int ByteToFloat(const uint8_t* src_y, float* dst_y, float scale, int width) {
void (*ByteToFloatRow)(const uint8_t* src, float* dst, float scale,
int width) = ByteToFloatRow_C;
if (!src_y || !dst_y || width <= 0) {
return -1;
}
#if defined(HAS_BYTETOFLOATROW_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
ByteToFloatRow = ByteToFloatRow_Any_NEON;
if (IS_ALIGNED(width, 8)) {
ByteToFloatRow = ByteToFloatRow_NEON;
}
}
#endif
ByteToFloatRow(src_y, dst_y, scale, width);
return 0;
}
LIBYUV_API
int ARGBLumaColorTable(const uint8_t* src_argb,
int src_stride_argb,
uint8_t* dst_argb,
int dst_stride_argb,
const uint8_t* luma,
int width,
int height) {
int y;
void (*ARGBLumaColorTableRow)(
const uint8_t* src_argb, uint8_t* dst_argb, int width,
const uint8_t* luma, const uint32_t lumacoeff) = ARGBLumaColorTableRow_C;
if (!src_argb || !dst_argb || !luma || width <= 0 || height == 0) {
return -1;
}
if (height < 0) {
height = -height;
src_argb = src_argb + (height - 1) * src_stride_argb;
src_stride_argb = -src_stride_argb;
}
if (src_stride_argb == width * 4 && dst_stride_argb == width * 4) {
width *= height;
height = 1;
src_stride_argb = dst_stride_argb = 0;
}
#if defined(HAS_ARGBLUMACOLORTABLEROW_SSSE3)
if (TestCpuFlag(kCpuHasSSSE3) && IS_ALIGNED(width, 4)) {
ARGBLumaColorTableRow = ARGBLumaColorTableRow_SSSE3;
}
#endif
for (y = 0; y < height; ++y) {
ARGBLumaColorTableRow(src_argb, dst_argb, width, luma, 0x00264b0f);
src_argb += src_stride_argb;
dst_argb += dst_stride_argb;
}
return 0;
}
LIBYUV_API
int ARGBCopyAlpha(const uint8_t* src_argb,
int src_stride_argb,
uint8_t* dst_argb,
int dst_stride_argb,
int width,
int height) {
int y;
void (*ARGBCopyAlphaRow)(const uint8_t* src_argb, uint8_t* dst_argb,
int width) = ARGBCopyAlphaRow_C;
if (!src_argb || !dst_argb || width <= 0 || height == 0) {
return -1;
}
if (height < 0) {
height = -height;
src_argb = src_argb + (height - 1) * src_stride_argb;
src_stride_argb = -src_stride_argb;
}
if (src_stride_argb == width * 4 && dst_stride_argb == width * 4) {
width *= height;
height = 1;
src_stride_argb = dst_stride_argb = 0;
}
#if defined(HAS_ARGBCOPYALPHAROW_SSE2)
if (TestCpuFlag(kCpuHasSSE2)) {
ARGBCopyAlphaRow = ARGBCopyAlphaRow_Any_SSE2;
if (IS_ALIGNED(width, 8)) {
ARGBCopyAlphaRow = ARGBCopyAlphaRow_SSE2;
}
}
#endif
#if defined(HAS_ARGBCOPYALPHAROW_AVX2)
if (TestCpuFlag(kCpuHasAVX2)) {
ARGBCopyAlphaRow = ARGBCopyAlphaRow_Any_AVX2;
if (IS_ALIGNED(width, 16)) {
ARGBCopyAlphaRow = ARGBCopyAlphaRow_AVX2;
}
}
#endif
for (y = 0; y < height; ++y) {
ARGBCopyAlphaRow(src_argb, dst_argb, width);
src_argb += src_stride_argb;
dst_argb += dst_stride_argb;
}
return 0;
}
LIBYUV_API
int ARGBExtractAlpha(const uint8_t* src_argb,
int src_stride_argb,
uint8_t* dst_a,
int dst_stride_a,
int width,
int height) {
if (!src_argb || !dst_a || width <= 0 || height == 0) {
return -1;
}
if (height < 0) {
height = -height;
src_argb += (height - 1) * src_stride_argb;
src_stride_argb = -src_stride_argb;
}
if (src_stride_argb == width * 4 && dst_stride_a == width) {
width *= height;
height = 1;
src_stride_argb = dst_stride_a = 0;
}
void (*ARGBExtractAlphaRow)(const uint8_t* src_argb, uint8_t* dst_a,
int width) = ARGBExtractAlphaRow_C;
#if defined(HAS_ARGBEXTRACTALPHAROW_SSE2)
if (TestCpuFlag(kCpuHasSSE2)) {
ARGBExtractAlphaRow = IS_ALIGNED(width, 8) ? ARGBExtractAlphaRow_SSE2
: ARGBExtractAlphaRow_Any_SSE2;
}
#endif
#if defined(HAS_ARGBEXTRACTALPHAROW_AVX2)
if (TestCpuFlag(kCpuHasAVX2)) {
ARGBExtractAlphaRow = IS_ALIGNED(width, 32) ? ARGBExtractAlphaRow_AVX2
: ARGBExtractAlphaRow_Any_AVX2;
}
#endif
#if defined(HAS_ARGBEXTRACTALPHAROW_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
ARGBExtractAlphaRow = IS_ALIGNED(width, 16) ? ARGBExtractAlphaRow_NEON
: ARGBExtractAlphaRow_Any_NEON;
}
#endif
#if defined(HAS_ARGBEXTRACTALPHAROW_MSA)
if (TestCpuFlag(kCpuHasMSA)) {
ARGBExtractAlphaRow = IS_ALIGNED(width, 16) ? ARGBExtractAlphaRow_MSA
: ARGBExtractAlphaRow_Any_MSA;
}
#endif
#if defined(HAS_ARGBEXTRACTALPHAROW_LSX)
if (TestCpuFlag(kCpuHasLSX)) {
ARGBExtractAlphaRow = IS_ALIGNED(width, 16) ? ARGBExtractAlphaRow_LSX
: ARGBExtractAlphaRow_Any_LSX;
}
#endif
for (int y = 0; y < height; ++y) {
ARGBExtractAlphaRow(src_argb, dst_a, width);
src_argb += src_stride_argb;
dst_a += dst_stride_a;
}
return 0;
}
LIBYUV_API
int ARGBCopyYToAlpha(const uint8_t* src_y,
int src_stride_y,
uint8_t* dst_argb,
int dst_stride_argb,
int width,
int height) {
int y;
void (*ARGBCopyYToAlphaRow)(const uint8_t* src_y, uint8_t* dst_argb,
int width) = ARGBCopyYToAlphaRow_C;
if (!src_y || !dst_argb || width <= 0 || height == 0) {
return -1;
}
if (height < 0) {
height = -height;
src_y = src_y + (height - 1) * src_stride_y;
src_stride_y = -src_stride_y;
}
if (src_stride_y == width && dst_stride_argb == width * 4) {
width *= height;
height = 1;
src_stride_y = dst_stride_argb = 0;
}
#if defined(HAS_ARGBCOPYYTOALPHAROW_SSE2)
if (TestCpuFlag(kCpuHasSSE2)) {
ARGBCopyYToAlphaRow = ARGBCopyYToAlphaRow_Any_SSE2;
if (IS_ALIGNED(width, 8)) {
ARGBCopyYToAlphaRow = ARGBCopyYToAlphaRow_SSE2;
}
}
#endif
#if defined(HAS_ARGBCOPYYTOALPHAROW_AVX2)
if (TestCpuFlag(kCpuHasAVX2)) {
ARGBCopyYToAlphaRow = ARGBCopyYToAlphaRow_Any_AVX2;
if (IS_ALIGNED(width, 16)) {
ARGBCopyYToAlphaRow = ARGBCopyYToAlphaRow_AVX2;
}
}
#endif
for (y = 0; y < height; ++y) {
ARGBCopyYToAlphaRow(src_y, dst_argb, width);
src_y += src_stride_y;
dst_argb += dst_stride_argb;
}
return 0;
}
LIBYUV_API
int YUY2ToNV12(const uint8_t* src_yuy2,
int src_stride_yuy2,
uint8_t* dst_y,
int dst_stride_y,
uint8_t* dst_uv,
int dst_stride_uv,
int width,
int height) {
int y;
void (*YUY2ToYRow)(const uint8_t* src_yuy2, uint8_t* dst_y, int width) =
YUY2ToYRow_C;
void (*YUY2ToNVUVRow)(const uint8_t* src_yuy2, int stride_yuy2,
uint8_t* dst_uv, int width) = YUY2ToNVUVRow_C;
if (!src_yuy2 || !dst_y || !dst_uv || width <= 0 || height == 0) {
return -1;
}
if (height < 0) {
height = -height;
src_yuy2 = src_yuy2 + (height - 1) * src_stride_yuy2;
src_stride_yuy2 = -src_stride_yuy2;
}
#if defined(HAS_YUY2TOYROW_SSE2)
if (TestCpuFlag(kCpuHasSSE2)) {
YUY2ToYRow = YUY2ToYRow_Any_SSE2;
if (IS_ALIGNED(width, 16)) {
YUY2ToYRow = YUY2ToYRow_SSE2;
}
}
#endif
#if defined(HAS_YUY2TOYROW_AVX2)
if (TestCpuFlag(kCpuHasAVX2)) {
YUY2ToYRow = YUY2ToYRow_Any_AVX2;
if (IS_ALIGNED(width, 32)) {
YUY2ToYRow = YUY2ToYRow_AVX2;
}
}
#endif
#if defined(HAS_YUY2TOYROW_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
YUY2ToYRow = YUY2ToYRow_Any_NEON;
if (IS_ALIGNED(width, 16)) {
YUY2ToYRow = YUY2ToYRow_NEON;
}
}
#endif
#if defined(HAS_YUY2TOYROW_MSA) && defined(HAS_YUY2TOUV422ROW_MSA)
if (TestCpuFlag(kCpuHasMSA)) {
YUY2ToYRow = YUY2ToYRow_Any_MSA;
if (IS_ALIGNED(width, 32)) {
YUY2ToYRow = YUY2ToYRow_MSA;
}
}
#endif
#if defined(HAS_YUY2TOYROW_LASX) && defined(HAS_YUY2TOUV422ROW_LASX)
if (TestCpuFlag(kCpuHasLASX)) {
YUY2ToYRow = YUY2ToYRow_Any_LASX;
if (IS_ALIGNED(width, 32)) {
YUY2ToYRow = YUY2ToYRow_LASX;
}
}
#endif
#if defined(HAS_YUY2TONVUVROW_SSE2)
if (TestCpuFlag(kCpuHasSSE2)) {
YUY2ToNVUVRow = YUY2ToNVUVRow_Any_SSE2;
if (IS_ALIGNED(width, 16)) {
YUY2ToNVUVRow = YUY2ToNVUVRow_SSE2;
}
}
#endif
#if defined(HAS_YUY2TONVUVROW_AVX2)
if (TestCpuFlag(kCpuHasAVX2)) {
YUY2ToNVUVRow = YUY2ToNVUVRow_Any_AVX2;
if (IS_ALIGNED(width, 32)) {
YUY2ToNVUVRow = YUY2ToNVUVRow_AVX2;
}
}
#endif
#if defined(HAS_YUY2TONVUVROW_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
YUY2ToNVUVRow = YUY2ToNVUVRow_Any_NEON;
if (IS_ALIGNED(width, 16)) {
YUY2ToNVUVRow = YUY2ToNVUVRow_NEON;
}
}
#endif
for (y = 0; y < height - 1; y += 2) {
YUY2ToYRow(src_yuy2, dst_y, width);
YUY2ToYRow(src_yuy2 + src_stride_yuy2, dst_y + dst_stride_y, width);
YUY2ToNVUVRow(src_yuy2, src_stride_yuy2, dst_uv, width);
src_yuy2 += src_stride_yuy2 * 2;
dst_y += dst_stride_y * 2;
dst_uv += dst_stride_uv;
}
if (height & 1) {
YUY2ToYRow(src_yuy2, dst_y, width);
YUY2ToNVUVRow(src_yuy2, 0, dst_uv, width);
}
return 0;
}
LIBYUV_API
int UYVYToNV12(const uint8_t* src_uyvy,
int src_stride_uyvy,
uint8_t* dst_y,
int dst_stride_y,
uint8_t* dst_uv,
int dst_stride_uv,
int width,
int height) {
int y;
int halfwidth = (width + 1) >> 1;
void (*SplitUVRow)(const uint8_t* src_uv, uint8_t* dst_u, uint8_t* dst_v,
int width) = SplitUVRow_C;
void (*InterpolateRow)(uint8_t* dst_ptr, const uint8_t* src_ptr,
ptrdiff_t src_stride, int dst_width,
int source_y_fraction) = InterpolateRow_C;
if (!src_uyvy || !dst_y || !dst_uv || width <= 0 || height == 0) {
return -1;
}
if (height < 0) {
height = -height;
src_uyvy = src_uyvy + (height - 1) * src_stride_uyvy;
src_stride_uyvy = -src_stride_uyvy;
}
#if defined(HAS_SPLITUVROW_SSE2)
if (TestCpuFlag(kCpuHasSSE2)) {
SplitUVRow = SplitUVRow_Any_SSE2;
if (IS_ALIGNED(width, 16)) {
SplitUVRow = SplitUVRow_SSE2;
}
}
#endif
#if defined(HAS_SPLITUVROW_AVX2)
if (TestCpuFlag(kCpuHasAVX2)) {
SplitUVRow = SplitUVRow_Any_AVX2;
if (IS_ALIGNED(width, 32)) {
SplitUVRow = SplitUVRow_AVX2;
}
}
#endif
#if defined(HAS_SPLITUVROW_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
SplitUVRow = SplitUVRow_Any_NEON;
if (IS_ALIGNED(width, 16)) {
SplitUVRow = SplitUVRow_NEON;
}
}
#endif
#if defined(HAS_SPLITUVROW_MSA)
if (TestCpuFlag(kCpuHasMSA)) {
SplitUVRow = SplitUVRow_Any_MSA;
if (IS_ALIGNED(width, 32)) {
SplitUVRow = SplitUVRow_MSA;
}
}
#endif
#if defined(HAS_SPLITUVROW_LSX)
if (TestCpuFlag(kCpuHasLSX)) {
SplitUVRow = SplitUVRow_Any_LSX;
if (IS_ALIGNED(width, 32)) {
SplitUVRow = SplitUVRow_LSX;
}
}
#endif
#if defined(HAS_INTERPOLATEROW_SSSE3)
if (TestCpuFlag(kCpuHasSSSE3)) {
InterpolateRow = InterpolateRow_Any_SSSE3;
if (IS_ALIGNED(width, 16)) {
InterpolateRow = InterpolateRow_SSSE3;
}
}
#endif
#if defined(HAS_INTERPOLATEROW_AVX2)
if (TestCpuFlag(kCpuHasAVX2)) {
InterpolateRow = InterpolateRow_Any_AVX2;
if (IS_ALIGNED(width, 32)) {
InterpolateRow = InterpolateRow_AVX2;
}
}
#endif
#if defined(HAS_INTERPOLATEROW_NEON)
if (TestCpuFlag(kCpuHasNEON)) {
InterpolateRow = InterpolateRow_Any_NEON;
if (IS_ALIGNED(width, 16)) {
InterpolateRow = InterpolateRow_NEON;
}
}
#endif
#if defined(HAS_INTERPOLATEROW_MSA)
if (TestCpuFlag(kCpuHasMSA)) {
InterpolateRow = InterpolateRow_Any_MSA;
if (IS_ALIGNED(width, 32)) {
InterpolateRow = InterpolateRow_MSA;
}
}
#endif
#if defined(HAS_INTERPOLATEROW_LSX)
if (TestCpuFlag(kCpuHasLSX)) {
InterpolateRow = InterpolateRow_Any_LSX;
if (IS_ALIGNED(width, 32)) {
InterpolateRow = InterpolateRow_LSX;
}
}
#endif
{
int awidth = halfwidth * 2;
align_buffer_64(rows, awidth * 3);
for (y = 0; y < height - 1; y += 2) {
SplitUVRow(src_uyvy, rows + awidth, rows, awidth);
memcpy(dst_y, rows, width);
SplitUVRow(src_uyvy + src_stride_uyvy, rows + awidth * 2, rows, awidth);
memcpy(dst_y + dst_stride_y, rows, width);
InterpolateRow(dst_uv, rows + awidth, awidth, awidth, 128);
src_uyvy += src_stride_uyvy * 2;
dst_y += dst_stride_y * 2;
dst_uv += dst_stride_uv;
}
if (height & 1) {
SplitUVRow(src_uyvy, dst_uv, rows, awidth);
memcpy(dst_y, rows, width);
}
free_aligned_buffer_64(rows);
}
return 0;
}
LIBYUV_API
void HalfMergeUVPlane(const uint8_t* src_u,
int src_stride_u,
const uint8_t* src_v,
int src_stride_v,
uint8_t* dst_uv,
int dst_stride_uv,
int width,
int height) {
int y;
void (*HalfMergeUVRow)(const uint8_t* src_u, int src_stride_u,
const uint8_t* src_v, int src_stride_v,
uint8_t* dst_uv, int width) = HalfMergeUVRow_C;
if (height < 0) {
height = -height;
src_u = src_u + (height - 1) * src_stride_u;
src_v = src_v + (height - 1) * src_stride_v;
src_stride_u = -src_stride_u;
src_stride_v = -src_stride_v;
}
#if defined(HAS_HALFMERGEUVROW_NEON)
if (TestCpuFlag(kCpuHasNEON) && IS_ALIGNED(width, 16)) {
HalfMergeUVRow = HalfMergeUVRow_NEON;
}
#endif
#if defined(HAS_HALFMERGEUVROW_SSSE3)
if (TestCpuFlag(kCpuHasSSSE3) && IS_ALIGNED(width, 16)) {
HalfMergeUVRow = HalfMergeUVRow_SSSE3;
}
#endif
#if defined(HAS_HALFMERGEUVROW_AVX2)
if (TestCpuFlag(kCpuHasAVX2) && IS_ALIGNED(width, 32)) {
HalfMergeUVRow = HalfMergeUVRow_AVX2;
}
#endif
for (y = 0; y < height - 1; y += 2) {
HalfMergeUVRow(src_u, src_stride_u, src_v, src_stride_v, dst_uv, width);
src_u += src_stride_u * 2;
src_v += src_stride_v * 2;
dst_uv += dst_stride_uv;
}
if (height & 1) {
HalfMergeUVRow(src_u, 0, src_v, 0, dst_uv, width);
}
}
#ifdef __cplusplus
}
}
#endif
|
[
"mcastelluccio@mozilla.com"
] |
mcastelluccio@mozilla.com
|
e3c8f77d14490b4cb4d9d0d627f7a6724776d786
|
d1672f193ac15191b3a0445be7330c0eb2508603
|
/ClickRPG-V1/main.cpp
|
f4b3b74770a77c12cf5deb25bab2e681869ce403
|
[] |
no_license
|
SpencerKwok/DragonSlayer
|
af3f9c12b1272be16ba623dde064b71dd9fc11ae
|
061cd2cc670647675d938beab505ad694e78a228
|
refs/heads/master
| 2020-12-25T23:46:46.555419
| 2016-08-17T21:02:53
| 2016-08-17T21:02:53
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 205
|
cpp
|
#include "mainwindow.h"
#include <QApplication>
using namespace std;
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
|
[
"noreply@github.com"
] |
SpencerKwok.noreply@github.com
|
0ac00b6f5b2fae467c144232dd57a365ad29c740
|
f0983a84dd46f5ea7dd43a08fb11fc7d15912988
|
/Classes/QuadTree.cpp
|
a0431129757b90ea98005fa1286177443ad07384
|
[] |
no_license
|
acmersch/Fighter
|
bff6241a767cd1582e73c35a4a20dd69ae3f7566
|
b2ed033d077ebe9f55bf1f206266ed503fe52560
|
refs/heads/master
| 2020-04-29T14:51:42.753321
| 2014-04-15T15:35:15
| 2014-04-15T15:35:15
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,826
|
cpp
|
//
// QuadTree.cpp
// Card
//
// Created by Roton_Lin on 14-3-20.
//
//
#include "QuadTree.h"
#include "lifeObj.h"
//build the tree
QuadTree::QuadTree(int deep, Rect rect) {
mRect = rect;
mObjArray = CCArray::create();
mObjArray->retain();
initChild(deep, rect);
}
QuadTree::~QuadTree() {
mObjArray->removeAllObjects();
mObjArray->release();
deleteTree();
}
void QuadTree::deleteTree() {
for (int i = 0; i < BRANCH; i++) {
if (mChild[i] != NULL) {
delete mChild[i];
}
}
}
void QuadTree::initChild(int deep, Rect rect) {
for (int i = 0; i < BRANCH; i ++) {
mChild[i] = NULL;
}
if (deep == 1) {
return;
}
float width = rect.size.width / 2;
float height = rect.size.height / 2;
int curdeep = deep - 1;
mChild[0] = new QuadTree(curdeep, Rect(rect.origin.x, rect.origin.y, width, height));
mChild[1] = new QuadTree(curdeep, Rect(rect.origin.x + width, rect.origin.y, width, height));
mChild[2] = new QuadTree(curdeep, Rect(rect.origin.x, rect.origin.y + height, width, height));
mChild[3] = new QuadTree(curdeep, Rect(rect.origin.x + width, rect.origin.y + height, width, height));
}
void QuadTree::clear() {
clearTree(this);
}
void QuadTree::clearTree(QuadTree *tree) {
for (int i = 0; i < BRANCH; i ++) {
if (tree->mChild[i] != NULL) {
clearTree(tree->mChild[i]);
}
}
(tree->mObjArray)->removeAllObjects();
}
bool QuadTree::addObject(Node* node) {
lifeObj* obj = (lifeObj*)node;
Rect rec = obj->getShadowRect();
bool isInsert = false;
if (isRecAContainsRecB(mRect, rec)) {
for (int i = 0 ; i < BRANCH; i++) {
if (mChild[i] == NULL) {
break;
}
isInsert |= (mChild[i]->addObject(node));
}
if (!isInsert) {
mObjArray->addObject(node);
isInsert = true;
}
}
return isInsert;
}
bool QuadTree::isRecAContainsRecB(Rect recA, Rect recB) {
bool withFit = recB.origin.x + recB.size.width <= recA.origin.x + recA.size.width;
bool heightFit = recB.origin.y + recB.size.height <= recA.origin.y + recA.size.height;
if (withFit && heightFit && recA.origin.x <= recB.origin.x && recB.origin.y >= recA.origin.y) {
return true;
}
return false;
}
void QuadTree::getCollisionObjects(Node *node, __Array *result) {
lifeObj* obj = (lifeObj*)node;
Rect rec = obj->getShadowRect();
//CCRect rec = node->boundingBox();
if (isRecAContainsRecB(mRect, rec)) {
result->addObjectsFromArray(mObjArray);
for (int i = 0; i < BRANCH; i++) {
if (mChild[i] == NULL) {
break;
}
mChild[i]->getCollisionObjects(node, result);
}
}
}
|
[
"acmercyj@gmail.com"
] |
acmercyj@gmail.com
|
dc6fc7d52e1327e08dc3d486c97b81134e83df99
|
23e393f8c385a4e0f8f3d4b9e2d80f98657f4e1f
|
/从算法到程序(第2版)/Chapter11/hdu1521.cpp
|
9e77f4ea6add52f8b41c10a993a633d50da3d006
|
[] |
no_license
|
IgorYunusov/Mega-collection-cpp-1
|
c7c09e3c76395bcbf95a304db6462a315db921ba
|
42d07f16a379a8093b6ddc15675bf777eb10d480
|
refs/heads/master
| 2020-03-24T10:20:15.783034
| 2018-06-12T13:19:05
| 2018-06-12T13:19:05
| 142,653,486
| 3
| 1
| null | 2018-07-28T06:36:35
| 2018-07-28T06:36:35
| null |
UTF-8
|
C++
| false
| false
| 877
|
cpp
|
#include<stdio.h>
#include<string.h>
int main()
{
int i;
double a[15];
a[0] = a[1] = 1;
for (i = 2; i <= 10; i++)
a[i] = i * a[i - 1];
int n, m;
while (scanf("%d%d", &n, &m) != EOF) {
int num[15];
double c1[15], c2[15];
for (i = 1; i <= n; i++)
scanf("%d", &num[i]);
memset(c1, 0, sizeof(c1));
memset(c2, 0, sizeof(c2));
for (i = 0; i <= num[1]; i++)
c1[i] = 1.0 / a[i];
int j, k;
for (i = 2; i <= n; i++) {
for (j = 0; j <= m; j++)
for (k = 0; k <= num[i] && j + k <= m; k++)
c2[j + k] += c1[j] / a[k];
memcpy(c1, c2, sizeof(c2));
memset(c2, 0, sizeof(c2));
}
printf("%.0lf\n", c1[m]*a[m]);
}
return 0;
}
|
[
"wyrover@gmail.com"
] |
wyrover@gmail.com
|
1fe170cef447c0f76fba91fe15ec4b6177b34114
|
46e2c94c7b5691432716d618beda6f5075b76754
|
/sln/019RemoveNthNodeFromEndofList_v3.cpp
|
b8bea9d8ce68c0900b7600d3fbfc38f6c7138a4a
|
[] |
no_license
|
Starxyz/leetCodeRecord
|
6fc52205130e94b21739c60e068eba7b0067badb
|
ed41d3db46bb1ef8082867483a85bb73f35ae07d
|
refs/heads/master
| 2021-06-29T00:59:46.018955
| 2020-10-04T10:15:06
| 2020-10-04T10:15:06
| 151,848,728
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,285
|
cpp
|
/*
Given a linked list, remove the n-th node from the end of list and return its head.
Example:
Given linked list: 1->2->3->4->5, and n = 2.
After removing the second node from the end, the linked list becomes 1->2->3->5.
Note:
Given n will always be valid.
Follow up:
Could you do this in one pass?
*/
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
ListNode* removeNthFromEnd(ListNode* head, int n) {
ListNode* dummyHead = new ListNode(0);
dummyHead->next = head;
ListNode* p = dummyHead;
ListNode* q = dummyHead;
for (int i=0; i<n+1; i++) {
p = p->next;
}
while (p != NULL) {
q = q->next;
p = p->next;
}
// delete node
ListNode* delNode = q->next;
q->next = delNode->next;
ListNode* relNode = dummyHead->next;
delete dummyHead;
return relNode;
}
};
|
[
"a136009394@163.com"
] |
a136009394@163.com
|
a592addea95811bc23a8550cb3cd4dadbf43e160
|
41098b8eb7a50a0cbc8ce9973eb7840f5d5fa87e
|
/Implementation/id_002/id_002b.cc
|
3dbfe8a85637b921bf3ed353374630494ace53a2
|
[] |
no_license
|
RexusWolf/IS
|
f119bddc372b25ec3c4dea66e72254097f4a1cb3
|
80e11fde39bfbe72cfae17e77a4af822d582ffd5
|
refs/heads/master
| 2021-08-04T17:10:14.810359
| 2019-01-10T19:54:18
| 2019-01-10T19:54:18
| 149,256,650
| 14
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 391
|
cc
|
// ID_0002a: Remove all Student
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <list>
#include "id_002b.h"
#include "../classes/student.h"
using std::list;
void deleteAll(list<Student> students){
list<Student>::iterator b = students.begin();
list<Student>::iterator e = students.end();
students.erase(b,e);
cout << "All students has been removed." << endl;
}
|
[
"francisjmp99@gmail.com"
] |
francisjmp99@gmail.com
|
d848543165c911d67f18f6fc3dd2334212dc102b
|
ca0f494b45522eab05d0342f25b1f0907ce1d720
|
/sources/services/sysmgr/srv/src/NetRpc.cpp
|
b7e345feb207fa06a82510d93df6159d639466a5
|
[] |
no_license
|
hackboxguy/brbox
|
9f79f21097685464c9c9a429603e586e034f8cae
|
ba3850807067b7f623ead5f65dad9c0bf0b3ec2d
|
refs/heads/master
| 2023-07-21T15:38:07.666015
| 2023-07-10T11:51:00
| 2023-07-10T11:51:00
| 32,072,062
| 26
| 9
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 13,846
|
cpp
|
#include "NetRpc.h"
#include "ADSysInfo.hpp"
//#include "SysmgrJsonDef.h"
/* ------------------------------------------------------------------------- */
NetRpc:: NetRpc(std::string rpcName,int myIndex,bool emu,bool log,SYSMGR_CMN_DATA_CACHE *pData):ADJsonRpcMgrConsumer(rpcName,myIndex,emu,log)
{
pDataCache=pData;
}
/* ------------------------------------------------------------------------- */
NetRpc::~ NetRpc()
{
}
/* ------------------------------------------------------------------------- */
int NetRpc::MapJsonToBinary(JsonDataCommObj* pReq,int index)
{
//printf("NetRpc::MapJsonToBinary called\n");
EJSON_SYSMGR_RPC_TYPES command =(EJSON_SYSMGR_RPC_TYPES)index;
switch(command)
{
case EJSON_SYSMGR_RPC_GET_MAC_ADDR :return json_to_bin_get_mac_addr(pReq);
case EJSON_SYSMGR_RPC_SET_MAC_ADDR :return json_to_bin_set_mac_addr(pReq);
case EJSON_SYSMGR_RPC_GET_ETH_COUNT:return json_to_bin_get_eth_count(pReq);
case EJSON_SYSMGR_RPC_GET_ETH_NAME :return json_to_bin_get_eth_name(pReq);
case EJSON_SYSMGR_RPC_GET_IP_ADDR :return json_to_bin_get_ip_addr(pReq);
case EJSON_SYSMGR_RPC_SET_IP_ADDR :return json_to_bin_set_ip_addr(pReq);
case EJSON_SYSMGR_RPC_GET_NETMASK :return json_to_bin_get_netmask(pReq);
case EJSON_SYSMGR_RPC_SET_NETMASK :return json_to_bin_set_netmask(pReq);
}
return -1;//0;
}
/* ------------------------------------------------------------------------- */
int NetRpc::MapBinaryToJson(JsonDataCommObj* pReq,int index)
{
//printf("NetRpc::MapBinaryToJson called\n");
EJSON_SYSMGR_RPC_TYPES command =(EJSON_SYSMGR_RPC_TYPES)index;
switch(command)
{
case EJSON_SYSMGR_RPC_GET_MAC_ADDR :return bin_to_json_get_mac_addr(pReq);
case EJSON_SYSMGR_RPC_SET_MAC_ADDR :return bin_to_json_set_mac_addr(pReq);
case EJSON_SYSMGR_RPC_GET_ETH_COUNT:return bin_to_json_get_eth_count(pReq);
case EJSON_SYSMGR_RPC_GET_ETH_NAME :return bin_to_json_get_eth_name(pReq);
case EJSON_SYSMGR_RPC_GET_IP_ADDR :return bin_to_json_get_ip_addr(pReq);
case EJSON_SYSMGR_RPC_SET_IP_ADDR :return bin_to_json_set_ip_addr(pReq);
case EJSON_SYSMGR_RPC_GET_NETMASK :return bin_to_json_get_netmask(pReq);
case EJSON_SYSMGR_RPC_SET_NETMASK :return bin_to_json_set_netmask(pReq);
}
return -1;
}
/* ------------------------------------------------------------------------- */
int NetRpc::ProcessWork(JsonDataCommObj* pReq,int index,ADJsonRpcMgrProducer* pObj)
{
//printf("NetRpc::ProcessWork called\n");
EJSON_SYSMGR_RPC_TYPES command =(EJSON_SYSMGR_RPC_TYPES)index;
switch(command)
{
case EJSON_SYSMGR_RPC_GET_MAC_ADDR :return process_get_mac_addr(pReq);
case EJSON_SYSMGR_RPC_SET_MAC_ADDR :return process_set_mac_addr(pReq);
case EJSON_SYSMGR_RPC_GET_ETH_COUNT:return process_get_eth_count(pReq);
case EJSON_SYSMGR_RPC_GET_ETH_NAME :return process_get_eth_name(pReq);
case EJSON_SYSMGR_RPC_GET_IP_ADDR :return process_get_ip_addr(pReq);
case EJSON_SYSMGR_RPC_SET_IP_ADDR :return process_set_ip_addr(pReq);
case EJSON_SYSMGR_RPC_GET_NETMASK :return process_get_netmask(pReq);
case EJSON_SYSMGR_RPC_SET_NETMASK :return process_set_netmask(pReq);
}
return 0;
}
/* ------------------------------------------------------------------------- */
RPC_SRV_RESULT NetRpc::ProcessWorkAsync(int index,unsigned char* pWorkData)
{
RPC_SRV_RESULT ret_val=RPC_SRV_RESULT_FAIL;
return ret_val;
}
/* ------------------------------------------------------------------------- */
int NetRpc::json_to_bin_get_mac_addr(JsonDataCommObj* pReq)
{
SYSMGR_MAC_ADDR_PACKET* pPanelCmdObj=NULL;
PREPARE_JSON_REQUEST(RPC_SRV_REQ,SYSMGR_MAC_ADDR_PACKET,RPC_SRV_ACT_READ,EJSON_SYSMGR_RPC_GET_MAC_ADDR);
//after assigning pointer to pPanelReq->dataRef, modify cmd-req-obj with correct client arguments
//JSON_STRING_TO_ENUM(SYSMGR_RPC_MAC_ADDR_ARG_IFACE,SYSMGR_RPC_MAC_ADDR_ARG_IFACE_TABL,EJSON_SYSMGR_IFACE_TYPE,EJSON_SYSMGR_IFACE_TYPE_UNKNOWN,pPanelCmdObj->eth_type);
JSON_STRING_TO_STRING(SYSMGR_RPC_IP_ADDR_ARG_IFACE,pPanelCmdObj->eth_name);//changed from fixed enum list to string
return 0;
}
int NetRpc::bin_to_json_get_mac_addr(JsonDataCommObj* pReq)
{
PREPARE_JSON_RESP_STRING(RPC_SRV_REQ,SYSMGR_MAC_ADDR_PACKET,SYSMGR_RPC_MAC_ADDR_ARG,mac_addr);
return 0;
}
int NetRpc::process_get_mac_addr(JsonDataCommObj* pReq)
{
ADSysInfo SysInfo;//lib-class for reading cpu-info and system-info
char ip[512];char netmask[512];
RPC_SRV_REQ *pPanelReq=NULL;
pPanelReq=(RPC_SRV_REQ *)pReq->pDataObj;
SYSMGR_MAC_ADDR_PACKET* pPacket;
pPacket=(SYSMGR_MAC_ADDR_PACKET*)pPanelReq->dataRef;
const char *table[] = SYSMGR_RPC_MAC_ADDR_ARG_IFACE_TABL;
//if network is connected,then read details from SysInfo
//if(SysInfo.read_network_info((char*)table[pPacket->eth_type],pPacket->mac_addr,ip,netmask)==0)
if(SysInfo.read_network_info(pPacket->eth_name,pPacket->mac_addr,ip,netmask)==0)
pPanelReq->result=RPC_SRV_RESULT_SUCCESS;
else
{
//if network is not connected, use ifconfig method
//if(SysInfo.read_network_info_ifconfig((char*)table[pPacket->eth_type],pPacket->mac_addr,ip,netmask)==0)
if(SysInfo.read_network_info_ifconfig(pPacket->eth_name,pPacket->mac_addr,ip,netmask)==0)
pPanelReq->result=RPC_SRV_RESULT_SUCCESS;
else
pPanelReq->result=RPC_SRV_RESULT_FAIL;
}
return 0;
}
/* ------------------------------------------------------------------------- */
int NetRpc::json_to_bin_set_mac_addr(JsonDataCommObj* pReq)
{
SYSMGR_MAC_ADDR_PACKET* pPanelCmdObj=NULL;
PREPARE_JSON_REQUEST(RPC_SRV_REQ,SYSMGR_MAC_ADDR_PACKET,RPC_SRV_ACT_WRITE,EJSON_SYSMGR_RPC_SET_MAC_ADDR);
//after assigning pointer to pPanelReq->dataRef, modify cmd-req-obj with correct client arguments
JSON_STRING_TO_ENUM(SYSMGR_RPC_MAC_ADDR_ARG_IFACE,SYSMGR_RPC_MAC_ADDR_ARG_IFACE_TABL,EJSON_SYSMGR_IFACE_TYPE,EJSON_SYSMGR_IFACE_TYPE_UNKNOWN,pPanelCmdObj->eth_type);
return 0;
}
int NetRpc::bin_to_json_set_mac_addr(JsonDataCommObj* pReq)
{
PREPARE_JSON_RESP(RPC_SRV_REQ,SYSMGR_MAC_ADDR_PACKET);
return 0;
}
int NetRpc::process_set_mac_addr(JsonDataCommObj* pReq)
{
//TODO:dont supprt mac writing yet
RPC_SRV_REQ *pPanelReq=NULL;
pPanelReq=(RPC_SRV_REQ *)pReq->pDataObj;
pPanelReq->result=RPC_SRV_RESULT_FEATURE_UNSUPPORTED;
return 0;
}
/* ------------------------------------------------------------------------- */
int NetRpc::json_to_bin_get_eth_count(JsonDataCommObj* pReq)
{
SYSMGR_ETH_COUNT_PACKET* pPanelCmdObj=NULL;
PREPARE_JSON_REQUEST(RPC_SRV_REQ,SYSMGR_ETH_COUNT_PACKET,RPC_SRV_ACT_READ,EJSON_SYSMGR_RPC_GET_ETH_COUNT);
return 0;
}
int NetRpc::bin_to_json_get_eth_count(JsonDataCommObj* pReq)
{
PREPARE_JSON_RESP_INT(RPC_SRV_REQ,SYSMGR_MAC_ADDR_PACKET,SYSMGR_RPC_ETH_COUNT_ARG,EthCountIndx);
return 0;
}
int NetRpc::process_get_eth_count(JsonDataCommObj* pReq)
{
RPC_SRV_REQ *pPanelReq=NULL;
pPanelReq=(RPC_SRV_REQ *)pReq->pDataObj;
SYSMGR_ETH_COUNT_PACKET* pPacket;
pPacket=(SYSMGR_ETH_COUNT_PACKET*)pPanelReq->dataRef;
pPacket->EthCountIndx=0;
ADSysInfo SysInfo;
pPanelReq->result=SysInfo.get_total_eth_count(pPacket->EthCountIndx);
return 0;
}
/* ------------------------------------------------------------------------- */
int NetRpc::json_to_bin_get_eth_name(JsonDataCommObj* pReq)
{
SYSMGR_ETH_NAME_PACKET* pPanelCmdObj=NULL;
PREPARE_JSON_REQUEST(RPC_SRV_REQ,SYSMGR_ETH_NAME_PACKET,RPC_SRV_ACT_READ,EJSON_SYSMGR_RPC_GET_ETH_NAME);
JSON_STRING_TO_INT(SYSMGR_RPC_ETH_NAME_ARG_INDEX,pPanelCmdObj->EthCountIndx);
return 0;
}
int NetRpc::bin_to_json_get_eth_name(JsonDataCommObj* pReq)
{
PREPARE_JSON_RESP_STRING(RPC_SRV_REQ,SYSMGR_ETH_NAME_PACKET,SYSMGR_RPC_ETH_NAME_ARG,eth_name);
return 0;
}
int NetRpc::process_get_eth_name(JsonDataCommObj* pReq)
{
RPC_SRV_REQ *pPanelReq=NULL;
pPanelReq=(RPC_SRV_REQ *)pReq->pDataObj;
SYSMGR_ETH_COUNT_PACKET* pPacket;
pPacket=(SYSMGR_ETH_COUNT_PACKET*)pPanelReq->dataRef;
//pPacket->EthCountIndx=0;
//TODO:
ADSysInfo SysInfo;int tmpCount;
pPanelReq->result=SysInfo.get_total_eth_count(tmpCount);
if(pPanelReq->result!=RPC_SRV_RESULT_SUCCESS)
return 0;
if(tmpCount==0)
{
pPanelReq->result=RPC_SRV_RESULT_FAIL;//no eth interfaces are available
return 0;
}
//zero based index must be passed by the client
if(pPacket->EthCountIndx > (tmpCount-1) )
{
pPanelReq->result=RPC_SRV_RESULT_ARG_ERROR;
return 0;
}
pPanelReq->result=SysInfo.get_nth_eth_name(pPacket->EthCountIndx+1,pPacket->eth_name);
return 0;
}
/* ------------------------------------------------------------------------- */
int NetRpc::json_to_bin_get_ip_addr(JsonDataCommObj* pReq)
{
SYSMGR_NET_INFO_PACKET* pPanelCmdObj=NULL;
PREPARE_JSON_REQUEST(RPC_SRV_REQ,SYSMGR_NET_INFO_PACKET,RPC_SRV_ACT_READ,EJSON_SYSMGR_RPC_GET_IP_ADDR);
//after assigning pointer to pPanelReq->dataRef, modify cmd-req-obj with correct client arguments
//JSON_STRING_TO_ENUM(SYSMGR_RPC_IP_ADDR_ARG_IFACE,SYSMGR_RPC_IP_ADDR_ARG_IFACE_TABL,EJSON_SYSMGR_IFACE_TYPE,EJSON_SYSMGR_IFACE_TYPE_UNKNOWN,pPanelCmdObj->eth_type);
JSON_STRING_TO_STRING(SYSMGR_RPC_IP_ADDR_ARG_IFACE,pPanelCmdObj->eth_name);//changed from fixed enum list to string
return 0;
}
int NetRpc::bin_to_json_get_ip_addr(JsonDataCommObj* pReq)
{
PREPARE_JSON_RESP_STRING(RPC_SRV_REQ,SYSMGR_NET_INFO_PACKET,SYSMGR_RPC_IP_ADDR_ARG,addr);
return 0;
}
int NetRpc::process_get_ip_addr(JsonDataCommObj* pReq)
{
ADSysInfo SysInfo;//lib-class for reading cpu-info and system-info
char netmask[512];char mac[512];
RPC_SRV_REQ *pPanelReq=NULL;
pPanelReq=(RPC_SRV_REQ *)pReq->pDataObj;
SYSMGR_NET_INFO_PACKET* pPacket;
pPacket=(SYSMGR_NET_INFO_PACKET*)pPanelReq->dataRef;
const char *table[] = SYSMGR_RPC_MAC_ADDR_ARG_IFACE_TABL;
//if network is connected,then read details from SysInfo
//if(SysInfo.read_network_info((char*)table[pPacket->eth_type],mac,pPacket->addr,netmask)==0)
if(SysInfo.read_network_info(pPacket->eth_name,mac,pPacket->addr,netmask)==0)
pPanelReq->result=RPC_SRV_RESULT_SUCCESS;
else
{
//if network is not connected, use ifconfig method
//if(SysInfo.read_network_info_ifconfig((char*)table[pPacket->eth_type],mac,pPacket->addr,netmask)==0)
if(SysInfo.read_network_info_ifconfig(pPacket->eth_name,mac,pPacket->addr,netmask)==0)
pPanelReq->result=RPC_SRV_RESULT_SUCCESS;
else
pPanelReq->result=RPC_SRV_RESULT_FAIL;
}
return 0;
}
int NetRpc::json_to_bin_set_ip_addr(JsonDataCommObj* pReq)
{
SYSMGR_NET_INFO_PACKET* pPanelCmdObj=NULL;
PREPARE_JSON_REQUEST(RPC_SRV_REQ,SYSMGR_NET_INFO_PACKET,RPC_SRV_ACT_WRITE,EJSON_SYSMGR_RPC_SET_IP_ADDR);
//after assigning pointer to pPanelReq->dataRef, modify cmd-req-obj with correct client arguments
JSON_STRING_TO_ENUM(SYSMGR_RPC_IP_ADDR_ARG_IFACE,SYSMGR_RPC_IP_ADDR_ARG_IFACE_TABL,EJSON_SYSMGR_IFACE_TYPE,EJSON_SYSMGR_IFACE_TYPE_UNKNOWN,pPanelCmdObj->eth_type);
return 0;
}
int NetRpc::bin_to_json_set_ip_addr(JsonDataCommObj* pReq)
{
PREPARE_JSON_RESP(RPC_SRV_REQ,SYSMGR_NET_INFO_PACKET);
return 0;
}
int NetRpc::process_set_ip_addr(JsonDataCommObj* pReq)
{
//TODO:dont supprt mac writing yet
RPC_SRV_REQ *pPanelReq=NULL;
pPanelReq=(RPC_SRV_REQ *)pReq->pDataObj;
pPanelReq->result=RPC_SRV_RESULT_FEATURE_UNSUPPORTED;
return 0;
}
/* ------------------------------------------------------------------------- */
int NetRpc::json_to_bin_get_netmask(JsonDataCommObj* pReq)
{
SYSMGR_NET_INFO_PACKET* pPanelCmdObj=NULL;
PREPARE_JSON_REQUEST(RPC_SRV_REQ,SYSMGR_NET_INFO_PACKET,RPC_SRV_ACT_READ,EJSON_SYSMGR_RPC_GET_NETMASK);
//after assigning pointer to pPanelReq->dataRef, modify cmd-req-obj with correct client arguments
//JSON_STRING_TO_ENUM(SYSMGR_RPC_NETMASK_ARG_IFACE,SYSMGR_RPC_NETMASK_ARG_IFACE_TABL,EJSON_SYSMGR_IFACE_TYPE,EJSON_SYSMGR_IFACE_TYPE_UNKNOWN,pPanelCmdObj->eth_type);
JSON_STRING_TO_STRING(SYSMGR_RPC_IP_ADDR_ARG_IFACE,pPanelCmdObj->eth_name);//changed from fixed enum list to string
return 0;
}
int NetRpc::bin_to_json_get_netmask(JsonDataCommObj* pReq)
{
PREPARE_JSON_RESP_STRING(RPC_SRV_REQ,SYSMGR_NET_INFO_PACKET,SYSMGR_RPC_NETMASK_ARG,addr);
return 0;
}
int NetRpc::process_get_netmask(JsonDataCommObj* pReq)
{
ADSysInfo SysInfo;//lib-class for reading cpu-info and system-info
char ip[512];char mac[512];
RPC_SRV_REQ *pPanelReq=NULL;
pPanelReq=(RPC_SRV_REQ *)pReq->pDataObj;
SYSMGR_NET_INFO_PACKET* pPacket;
pPacket=(SYSMGR_NET_INFO_PACKET*)pPanelReq->dataRef;
const char *table[] = SYSMGR_RPC_MAC_ADDR_ARG_IFACE_TABL;
//if network is connected,then read details from SysInfo
//if(SysInfo.read_network_info((char*)table[pPacket->eth_type],mac,ip,pPacket->addr)==0)
if(SysInfo.read_network_info(pPacket->eth_name,mac,ip,pPacket->addr)==0)
pPanelReq->result=RPC_SRV_RESULT_SUCCESS;
else
{
//if network is not connected, use ifconfig method
//if(SysInfo.read_network_info_ifconfig((char*)table[pPacket->eth_type],mac,ip,pPacket->addr)==0)
if(SysInfo.read_network_info_ifconfig(pPacket->eth_name,mac,ip,pPacket->addr)==0)
pPanelReq->result=RPC_SRV_RESULT_SUCCESS;
else
pPanelReq->result=RPC_SRV_RESULT_FAIL;
}
return 0;
}
int NetRpc::json_to_bin_set_netmask(JsonDataCommObj* pReq)
{
SYSMGR_NET_INFO_PACKET* pPanelCmdObj=NULL;
PREPARE_JSON_REQUEST(RPC_SRV_REQ,SYSMGR_NET_INFO_PACKET,RPC_SRV_ACT_WRITE,EJSON_SYSMGR_RPC_SET_NETMASK);
//after assigning pointer to pPanelReq->dataRef, modify cmd-req-obj with correct client arguments
JSON_STRING_TO_ENUM(SYSMGR_RPC_NETMASK_ARG_IFACE,SYSMGR_RPC_NETMASK_ARG_IFACE_TABL,EJSON_SYSMGR_IFACE_TYPE,EJSON_SYSMGR_IFACE_TYPE_UNKNOWN,pPanelCmdObj->eth_type);
return 0;
}
int NetRpc::bin_to_json_set_netmask(JsonDataCommObj* pReq)
{
PREPARE_JSON_RESP(RPC_SRV_REQ,SYSMGR_NET_INFO_PACKET);
return 0;
}
int NetRpc::process_set_netmask(JsonDataCommObj* pReq)
{
//TODO:dont supprt mac writing yet
RPC_SRV_REQ *pPanelReq=NULL;
pPanelReq=(RPC_SRV_REQ *)pReq->pDataObj;
pPanelReq->result=RPC_SRV_RESULT_FEATURE_UNSUPPORTED;
return 0;
}
/* ------------------------------------------------------------------------- */
|
[
"albert.david@gmail.com"
] |
albert.david@gmail.com
|
900a9cb40c67529ad6db9a98a38689f2a92d6a18
|
c54a0897be1c62def168009ed931acc2ab178872
|
/ouzel/audio/openal/OALAudioDevice.hpp
|
2c73475439327a2751c7ff3f272078da14e84a34
|
[
"BSD-3-Clause",
"BSD-2-Clause"
] |
permissive
|
yeeway/ouzel
|
af73005af643a1b8b19ee90775d26bf062c38dff
|
ad469531ad5c5d424e140aae31a1084098f36b56
|
refs/heads/master
| 2020-09-03T15:46:14.215978
| 2019-11-03T22:56:52
| 2019-11-03T22:56:52
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,157
|
hpp
|
// Copyright 2015-2019 Elviss Strazdins. All rights reserved.
#ifndef OUZEL_AUDIO_AUDIODEVICEAL_HPP
#define OUZEL_AUDIO_AUDIODEVICEAL_HPP
#include "core/Setup.h"
#if OUZEL_COMPILE_OPENAL
#include <atomic>
#include <thread>
#if defined(__APPLE__)
# include <OpenAl/al.h>
# include <OpenAl/alc.h>
#else
# include <AL/al.h>
# include <AL/alc.h>
#endif
#include "audio/AudioDevice.hpp"
#include "utils/Thread.hpp"
namespace ouzel
{
namespace audio
{
namespace openal
{
class AudioDevice final: public audio::AudioDevice
{
public:
AudioDevice(uint32_t initBufferSize,
uint32_t initSampleRate,
uint16_t initChannels,
const std::function<void(uint32_t frames,
uint16_t channels,
uint32_t sampleRate,
std::vector<float>& samples)>& initDataGetter);
~AudioDevice();
void start() final;
void stop() final;
void process();
inline auto getDevice() const noexcept { return device; }
inline auto getContext() const noexcept { return context; }
private:
void run();
ALCdevice* device = nullptr;
ALCcontext* context = nullptr;
ALenum format40 = 0;
ALenum format51 = 0;
ALenum format61 = 0;
ALenum format71 = 0;
ALuint sourceId = 0;
ALenum format = 0;
uint32_t nextBuffer = 0;
ALuint bufferIds[2] = {0, 0};
uint32_t sampleSize = 0;
std::vector<uint8_t> data;
#if !defined(__EMSCRIPTEN__)
std::atomic_bool running{false};
Thread audioThread;
#endif
};
} // namespace openal
} // namespace audio
} // namespace ouzel
#endif
#endif // OUZEL_AUDIO_AUDIODEVICEAL_HPP
|
[
"elviss@elviss.lv"
] |
elviss@elviss.lv
|
2d53f683632423017ea7687ed56bdb094113e327
|
906429cb55aa76ef0b44f03ac84a1265fb311d54
|
/Lab2_ACM_2020/2.AvgExcludeMinAndMax/ConsoleApplication2/ConsoleApplication2.cpp
|
b7cdd3e1d52892243e90500995cf43861dd203a6
|
[] |
no_license
|
Ranazh/Shakieva_ACM_Labs
|
02bf314337506b6b8d95ffe97780b2e4e798ab50
|
2bb23b500f7ef415738044790ae0bac79695198f
|
refs/heads/main
| 2022-12-31T13:21:08.663315
| 2020-10-19T21:18:48
| 2020-10-19T21:18:48
| 305,397,163
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,015
|
cpp
|
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
class Solution1 {
public:
double average(vector<int>& salary) {
int size = salary.size();
int mx = salary[0];
int mn = salary[0];
double sum = salary[0];
for (int i = 1; i < size; i++) {
sum += salary[i];
mx = max(mx, salary[i]);
mn = min(mn, salary[i]);
}
return (sum - mn - mx) / (size - 2);
}
};
class Solution2 {
public:
double average(vector<int>& salary) {
int size = salary.size();
sort(salary.begin(), salary.end());
double sum = salary[1];
for (int i = 2; i < size - 1; i++) {
sum += salary[i];
}
return sum / (size - 2);
}
};
int main()
{
Solution1 *obj1 = new Solution1();
Solution2 *obj2 = new Solution2();
vector<int> v;
int num;
cout << "Enter Numbers" << '\n';
while (cin >> num)
{
v.push_back(num);
}
cout << "The first solution: " << obj1->average(v) << endl;
cout << "The second solution: " << obj2->average(v) << endl;
return 0;
}
|
[
"62495507+Ranazh@users.noreply.github.com"
] |
62495507+Ranazh@users.noreply.github.com
|
4706be939cc1ffea406f473d6d30f8ddf8fed52b
|
b50e21a9d46169930957fc43ce589b60631e3365
|
/OpenGLTutorial/WindowEx.cpp
|
ccbb587d5a50148dcd82f0a7312ee76242f19733
|
[] |
no_license
|
YMMH/OpenGLTutorial
|
05b3ea4118ca306eb62920a815cb958458ac6b39
|
7338c130b8943a727f52310082dec59c35bdac75
|
refs/heads/master
| 2020-06-20T07:39:30.925647
| 2019-07-15T17:59:54
| 2019-07-15T17:59:54
| 197,045,944
| 0
| 0
| null | null | null | null |
UHC
|
C++
| false
| false
| 1,863
|
cpp
|
#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include <iostream>
#define WIN_HEIGHT 600
#define WIN_WIDTH 800
void framebuffer_size_callback(GLFWwindow *window, int width, int height);
void processInput(GLFWwindow* window);
int main()
{
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
//glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
//윈도우 설정
GLFWwindow* window = glfwCreateWindow(800, 600, "LearnOpenGL", NULL, NULL);
if (window == NULL)
{
std::cout << "Failed to create GLFW window" << std::endl;
glfwTerminate();
return -1;
}
glfwMakeContextCurrent(window);
//OpenGL 함수 호출 전 GLAD 초기화
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
{
std::cout << "Failed to initialize GLAD" << std::endl;
return -1;
}
//OpenGL에 rendering window size noti
glViewport(0, 0, WIN_WIDTH, WIN_HEIGHT);//Screen 좌표를 2D 좌표로 변환
//모든 창의 크기가 변경 될 때마다 작성한 사이즈 변경 함수를 호출하겠다고 GLFW에 noti
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
//프로그램이 계속 실행될 수 있도록 하는 render loop
while (!glfwWindowShouldClose(window)) {
//입력처리
processInput(window);
//렌더링 명령
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
//이벤트 확인, 버퍼 교체
glfwSwapBuffers(window);
glfwPollEvents();
}
glfwTerminate();//모든 자원 정리/삭제
return 0;
}
void framebuffer_size_callback(GLFWwindow* window, int width, int height)
{
glViewport(0, 0, width, height);
}
void processInput(GLFWwindow* window)
{
if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS) {
glfwSetWindowShouldClose(window, true);
}
}
|
[
"sftwrmstr@gmail.com"
] |
sftwrmstr@gmail.com
|
c05247070a7d6efdb85211d709a7bdaa7b5322ed
|
4b055f9c18ad613f10c0e281873b800f3ff515ff
|
/Minigin/Renderer.cpp
|
bbf67f609ae66d97ae9e10e8016be455e0dd1735
|
[] |
no_license
|
minoarno/MidestinyEngine
|
982508e7ac0197fc49649c1bec362ad5ba113469
|
68e88f2f3dc537cf4add9fe474004681a90e8a84
|
refs/heads/main
| 2023-07-16T06:31:24.398267
| 2021-08-23T04:40:14
| 2021-08-23T04:40:14
| 337,725,203
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,959
|
cpp
|
#include "MiniginPCH.h"
#include "Renderer.h"
#include <SDL.h>
#include "SceneManager.h"
#include "Texture2D.h"
bool dae::Renderer::m_ShowDemo = true;
void dae::Renderer::Init(SDL_Window * window)
{
m_Window = window;
m_Renderer = SDL_CreateRenderer(window, GetOpenGLDriverIndex(), SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
if (m_Renderer == nullptr)
{
throw std::runtime_error(std::string("SDL_CreateRenderer Error: ") + SDL_GetError());
}
IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImGui_ImplSDL2_InitForOpenGL(window, SDL_GL_GetCurrentContext());
ImGui_ImplOpenGL2_Init();
}
int dae::Renderer::GetOpenGLDriverIndex()
{
auto openglIndex = -1;
const int driverCount = SDL_GetNumRenderDrivers();
for (int i = 0; i < driverCount; i++)
{
SDL_RendererInfo info;
if (!SDL_GetRenderDriverInfo(i, &info))
{
if (!strcmp(info.name, "opengl"))
{
openglIndex = i;
}
}
}
return openglIndex;
}
void dae::Renderer::Render() const
{
SDL_RenderClear(m_Renderer);
SceneManager::GetInstance().Render();
ImGui_ImplOpenGL2_NewFrame();
ImGui_ImplSDL2_NewFrame(m_Window);
ImGui::NewFrame();
if (m_ShowDemo)
{
ImGui::ShowDemoWindow(&m_ShowDemo);
}
ImGui::Render();
ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
SDL_RenderPresent(m_Renderer);
}
void dae::Renderer::Destroy()
{
ImGui_ImplOpenGL2_Shutdown();
ImGui_ImplSDL2_Shutdown();
ImGui::DestroyContext();
if (m_Renderer != nullptr)
{
SDL_DestroyRenderer(m_Renderer);
m_Renderer = nullptr;
}
}
void dae::Renderer::RenderTexture(const Texture2D* pTexture, const float x, const float y) const
{
SDL_Rect dst{};
dst.x = static_cast<int>(x);
dst.y = static_cast<int>(y);
SDL_QueryTexture(pTexture->GetSDLTexture(), nullptr, nullptr, &dst.w, &dst.h);
SDL_RenderCopy(GetSDLRenderer(), pTexture->GetSDLTexture(), nullptr, &dst);
}
void dae::Renderer::RenderTexture(const Texture2D* pTexture, const float x, const float y, const float width, const float height) const
{
SDL_Rect dst{};
dst.x = static_cast<int>(x);
dst.y = static_cast<int>(y);
dst.w = static_cast<int>(width);
dst.h = static_cast<int>(height);
SDL_RenderCopy(GetSDLRenderer(), pTexture->GetSDLTexture(), nullptr, &dst);
}
void dae::Renderer::RenderTexture(const Texture2D* pTexture, SDL_Rect srcRect,const float x, const float y, const float width, const float height) const
{
SDL_Rect dst{};
dst.x = static_cast<int>(x);
dst.y = static_cast<int>(y);
dst.w = static_cast<int>(width);
dst.h = static_cast<int>(height);
SDL_RenderCopy(GetSDLRenderer(), pTexture->GetSDLTexture(), &srcRect, &dst);
}
void dae::Renderer::RenderTexture(const Texture2D* pTexture, SDL_Rect srcRect, const float x, const float y) const
{
SDL_Rect dst{};
dst.x = static_cast<int>(x);
dst.y = static_cast<int>(y);
SDL_QueryTexture(pTexture->GetSDLTexture(), nullptr, nullptr, &dst.w, &dst.h);
SDL_RenderCopy(GetSDLRenderer(), pTexture->GetSDLTexture(), &srcRect, &dst);
}
|
[
"minoarno@users.noreply.github.com"
] |
minoarno@users.noreply.github.com
|
58bbb6a913c062b39f9d0eaf9ff6eb0effe5717c
|
753ed389484c2bbb5d26c21f3c944471a8d704fd
|
/cv2/streamcypher.cpp
|
27e49f739ba6161a6ed1ab12d0d4b5dd10b7cf70
|
[] |
no_license
|
jhrach/BEZ
|
ee86f0ac1f985dc8830db98834e5e69c5eb8dbbe
|
ff04cb9e5b87854762954ff585115a74c839cb06
|
refs/heads/master
| 2021-01-12T21:17:57.541026
| 2014-03-26T16:58:20
| 2014-03-26T16:58:20
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,779
|
cpp
|
#include <stdlib.h>
#include <openssl/evp.h>
#include <string.h>
#include <fstream>
using namespace std;
int main(void) {
unsigned char known[1024] = "abcdefghijklmnopqrstuvwxyz0123";
unsigned char knownst[1024];
int knownstlen = 0;
unsigned char ot[1024] = "Supertajna zprava z BEZ supert"; // open text
unsigned char st[1024]; // sifrovany text
unsigned char key[EVP_MAX_KEY_LENGTH] = "SuperTajnyKlic"; // klic pro sifrovani
unsigned char iv[EVP_MAX_IV_LENGTH] = "SuperTajneIV"; // inicializacni vektor
unsigned char coleaguest[1024];
ofstream outFile;
int colotLength = 0;
int colstLength = 0;
int colkeylength = 0;
unsigned char coleagueot[1024];
unsigned char coleaguekey[1024];
int otLength = strlen((const char*) ot);
int stLength = 0;
int tmpLength = 0;
EVP_CIPHER_CTX ctx; // struktura pro kontext
printf("OT: %s\n", ot);
/* Sifrovani */
EVP_EncryptInit(&ctx, EVP_rc4(), key, iv); // nastaveni kontextu pro sifrovani
EVP_EncryptUpdate(&ctx, st, &stLength, ot, otLength); // sifrovani ot
EVP_EncryptFinal(&ctx, &st[stLength], &tmpLength); // ziskani sifrovaneho textu z kontextu
printf ("Zasifrovano %d znaku.\nMY_ST:", stLength);
for(int i=0; i < stLength ; i++){
printf ("%02x", st[i]);
}
outFile.open("mycyphed.bin");
outFile.write((char *)st,stLength);
outFile.close();
puts("\n");
EVP_EncryptInit(&ctx, EVP_rc4(), key, iv); // nastaveni kontextu pro sifrovani
EVP_EncryptUpdate(&ctx, knownst, &knownstlen, known, (int)strlen((const char *)known)); // sifrovani ot
EVP_EncryptFinal(&ctx, &knownst[knownstlen], &tmpLength); // ziskani sifrovaneho textu z kontextu
printf("KNOWN:%s\n", known);
printf ("Zasifrovano %d znaku.\nKNOWNST:", knownstlen);
for(int i=0; i < knownstlen ; i++){
printf ("%02x", knownst[i]);
}
outFile.open("known.bin");
outFile.write((char*)knownst,knownstlen);
outFile.close();
outFile.open("known.txt");
outFile << known;
outFile.close();
printf("\n");
for(int i=0 ; i < stLength; i++){
coleagueot[i] = (st[i] ^ knownst[i] ^ known[i]);
}
/*
EVP_EncryptInit(&ctx, EVP_rc4(),knownst,coleaguest); // nastaveni kontextu pro sifrovani
EVP_EncryptUpdate(&ctx, coleagueiv, &colivlength, known, strlen((const char*)known)); // sifrovani ot
EVP_EncryptFinal(&ctx, &coleagueiv[colivlength], &tmpLength); // ziskani sifrovaneho textu z kontextu
puts("\nIV:");
//printf("IV:%s\n", coleagueiv);
for(int i=0; i < colivlength ; i++){
printf ("%02x", coleagueiv[i]);
}
puts("\n");
//
*/
/*
printf("IV:%s\n",coleagueiv);
EVP_EncryptInit(&ctx, EVP_rc4(), coleagueiv,coleagueiv); // nastaveni kontextu pro sifrovani
EVP_EncryptUpdate(&ctx, coleaguekey, &colkeylength, known, strlen((char *)known)); // sifrovani ot
EVP_EncryptFinal(&ctx, &coleaguekey[colkeylength], &tmpLength); // ziskani sifrovaneho textu z kontextu
/*
puts("KEY:");
for(int i=0; i < colkeylength ; i++){
printf ("%02x", coleaguekey[i]);
}
puts("\n");
//
*/
// printf("KEY:%s\n", coleaguekey);
/*
EVP_EncryptInit(&ctx, EVP_rc4(), coleaguekey, 0); // nastaveni kontextu pro sifrovani
EVP_EncryptUpdate(&ctx, coleagueot, &colotLength, st, stLength); // sifrovani ot
EVP_EncryptFinal(&ctx, &coleagueot[colotLength], &tmpLength); // ziskani sifrovaneho textu z kontextu
*/
printf("OT:%s\n", coleagueot);
// /* Desifrovani */
// EVP_DecryptInit(&ctx, EVP_rc4(), key, iv); // nastaveni kontextu pro desifrovani
// EVP_DecryptUpdate(&ctx, ot, &otLength, st, stLength); // desifrovani st
// EVP_DecryptFinal(&ctx, &ot[otLength], &tmpLength); // ziskani desifrovaneho textu z kontextu
// /* Vypsani zasifrovaneho a rozsifrovaneho textu. */
// printf("DT: %s\n", ot);
exit(0);
}
|
[
"shadow.to.root@gmail.com"
] |
shadow.to.root@gmail.com
|
70f2bb9e9c151ef3f2bae749ee42a374000bd92b
|
981925c2d9a19f66e2c57f599439576be7ed98fb
|
/myCirclellist/myCirclellist/源.cpp
|
1f0cd685e3a2f25afbe72ecaa60e0ba9c5cac733
|
[] |
no_license
|
ssexuejinwei/create-datastructure-by-myself
|
eafd529bca892e1c1713e4a8ca7701cb6536ca7b
|
d635c2585f8b39b630ac247e7a8a6fc2a9dc3ea9
|
refs/heads/master
| 2020-03-23T04:26:49.240019
| 2018-07-16T04:56:40
| 2018-07-16T04:56:40
| 141,083,959
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 580
|
cpp
|
#include"CirList.h"
#include<iostream>
int main() {
using namespace std;
Cirlist<int> list;
int x;
int n, s, m, k;
cin >> n >> s >> m >> k;
LinkNode<int>* p;
for (int i = 0; i < n; i++)
list.Insert(i + 1, i + 1);
p = list.locate(s);
while (n > k) {
for (int i = 1; i < m; i++) {
if (p == list.getRear()) {
p = list.getHead()->link;
continue;
}
p = p->link;
}
LinkNode<int>* next;
if (p == list.getRear()) {
next = list.getHead()->link;
}
else
next = p->link;
list.Remove(x, p);
p = next;
cout << x << " ";
n--;
}
return 0;
}
|
[
"839315380@qq.com"
] |
839315380@qq.com
|
1eb35009b4afee6258adf665a23a54d9b3ab2332
|
92b6aaade5a3f323d7f8e7d02fb9fec09f4c2f50
|
/CP-Codes/cf_476b.cpp
|
d94b1bef0d24b081f28f9d0001ae983fba89de1e
|
[] |
no_license
|
suraj1611/Competitive_Programming
|
846dee00396e2f2b6d13e2ea8aaed444a34062af
|
82bd88081ac067ad4170553afedc6c479bb53753
|
refs/heads/master
| 2020-04-22T17:27:18.116585
| 2019-12-16T19:42:29
| 2019-12-16T19:42:29
| 170,541,477
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,522
|
cpp
|
/* Code by : Suraj (@suraj1611) */
#include<bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define mx INT_MAX
#define mn INT_MIN
#define md 1000000007
#define pb push_back
#define mp make_pair
#define maxsize 1100005
#define lb cout<<endl;
#define endl "\n"
#define F first
#define S second
#define label cout<<"hello!"<<endl
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
double fact[20];
ll power(ll x, ll y)
{
ll m=md;
ll ans=1;
while (y > 0)
{
if (y & 1)
ans = (ans * x) % m;
x = (x * x) % m;
y >>= 1;
}
return ans;
}
void fac()
{
fact[0]=1;
fact[1]=1;
for(ll i=2;i<15;i++)
{
fact[i]=i*fact[i-1];
}
}
int main()
{
IOS
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif
string s1,s2;
fac();
cin>>s1>>s2;
ll a=0,b=0,a1=0,b1=0,q=0;
double ans=0;
rep(i,s1.length())
{
if(s1[i]=='+')
a++;
else
b++;
}
rep(i,s2.length())
{
if(s2[i]=='+')
a1++;
else if(s2[i]=='-')
b1++;
else
q++;
}
//cout<<q<<" "<<a1<<" "<<b1<<endl;
if(a1>a or b1>b)
ans=0;
else if(q==0)
ans=1;
else
{
ans = (1/(pow(2,q)))*(fact[q]/(fact[a-a1]*fact[b-b1]));
}
cout<<setprecision(12)<<fixed;
cout<<ans<<endl;
#ifndef ONLINE_JUDGE
cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s\n";
#endif
return 0;
}
|
[
"surajsk1611@gmail.com"
] |
surajsk1611@gmail.com
|
b7fc7bea72bfb0f94f28ccb853e7ddd8a7345818
|
c60fe551e358a9c7b3340c9bc8551817f5c6732e
|
/src/calculate.hpp
|
8a0ebe91d8480df15addbc6eaa50f546f5aac1ce
|
[] |
no_license
|
callumacrae/cpp-calculator
|
45b9cd3e70d3a3d01cc518e75e41a26d477d4b29
|
8b80db9895e31906b9e9ba43b7f84bd1cb2854dc
|
refs/heads/main
| 2023-06-04T06:10:34.752871
| 2021-06-29T18:06:01
| 2021-06-29T18:06:01
| 377,284,658
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 154
|
hpp
|
//
// calculate.hpp
// calculator
//
// Created by Callum Macrae on 15/06/2021.
//
#pragma once
float calculate(const std::string_view &mathString);
|
[
"callum@macr.ae"
] |
callum@macr.ae
|
fb5de8f03fa785d8ffb7c80a659bcb80a5c86210
|
b526330604e6cc42b4604dee855ba3291f2df454
|
/CodeLib/Brute Force/POJ 1077 Eight.cpp
|
e6e7d15d221528f688d54b33da640277fe769650
|
[] |
no_license
|
KamikazeChan/Contest
|
039166160140b1eb424cbcc2e2765e6f04d3cafc
|
dcacfee07e7c7c201205b73dc1d92281e6824c63
|
refs/heads/master
| 2021-01-24T23:11:44.978319
| 2014-12-15T10:38:15
| 2014-12-15T10:38:32
| null | 0
| 0
| null | null | null | null |
GB18030
|
C++
| false
| false
| 3,550
|
cpp
|
/*
** POJ 1077 Eight
** Created by Rayn @@ 2014/05/22
*/
#include <iostream>
#include <cstdio>
#include <cstring>
#include <bitset>
#include <algorithm>
using namespace std;
const int MAX = 400000;
int nGoalStatus;
bitset<387420498> Flag;
char szRes[MAX], szMove[MAX];
char Dir[] = "udrl";
int Pre[MAX], Queue[MAX];
int Head, Tail;
int NineToTen(char *s) //九进制字符串转化为十进制数字
{
int res = 0;
for(int i=0; s[i]; ++i)
{
res = res * 9 + s[i] - '0';
}
//printf("%d\n", res);
return res;
}
int TenToNine(int n, char *s) //十进制数字转化为九进制字符串
{
int ZeroPos, nBase = 1;
while (nBase <= n)
nBase *= 9;
nBase /= 9;
int j = 0;
do {
s[j] = n/nBase + '0';
if (s[j] == '0')
ZeroPos = j;
j++;
n %= nBase;
nBase /= 9;
} while(nBase >= 1);
s[j] = '\0';
if(j < 9)
{
for(int i = j+1; i > 0; --i)
{
s[i] = s[i-1];
}
s[0] = '0';
return 0;
}
return ZeroPos;
}
int NewStatus(int nStatus, char cMove)
{
char tmp[20];
int ZeroPos = TenToNine(nStatus, tmp); //返回空格的位置
switch(cMove)
{
case 'u':
if (ZeroPos - 3 < 0) return -1; //空格在第一行
else {
tmp[ZeroPos] = tmp[ZeroPos-3];
tmp[ZeroPos-3] = '0';
}
break;
case 'd':
if (ZeroPos + 3 > 8) return -1; //空格在第三行
else {
tmp[ZeroPos] = tmp[ZeroPos+3];
tmp[ZeroPos+3] = '0';
}
break;
case 'l':
if (ZeroPos % 3 == 0) return -1; //空格在第一列
else {
tmp[ZeroPos] = tmp[ZeroPos-1];
tmp[ZeroPos-1] = '0';
}
break;
case 'r':
if (ZeroPos % 3 == 2) return -1; //空格在第三列
else {
tmp[ZeroPos] = tmp[ZeroPos+1];
tmp[ZeroPos+1] = '0';
}
break;
}
return NineToTen(tmp);
}
bool BFS(int nStatus)
{
int nNewStatus;
Head = Tail = 0;
Queue[Head] = nStatus;
Tail++;
while (Head < Tail)
{
nStatus = Queue[Head];
if(nStatus == nGoalStatus)
return true;
for(int i=0; i<4; ++i)
{
nNewStatus = NewStatus(nStatus, Dir[i]);
if(nNewStatus == -1)
continue;
if(Flag[nNewStatus])
continue;
Flag.set(nNewStatus, true);
Queue[Tail] = nNewStatus;
Pre[Tail] = Head;
szMove[Tail] = Dir[i];
Tail++;
}
Head++;
}
return false;
}
int main()
{
nGoalStatus = NineToTen("123456780");
Flag.reset();
char Line1[50], Line2[20];
cin.getline(Line1, 40);
int i, j;
for(i=0, j=0; Line1[i]; ++i)
{
if(Line1[i] != ' ')
{
if(Line1[i] == 'x')
Line2[j++] = '0';
else
Line2[j++] = Line1[i];
}
}
Line2[j] = '\0';
if( BFS(NineToTen(Line2)) )
{
int nMove = 0;
int nPos = Head;
do {
szRes[nMove++] = szMove[nPos];
nPos = Pre[nPos];
} while(nPos);
for(int i = nMove-1; i >= 0; --i)
{
cout << szRes[i];
}
}
else
{
cout << "unsolvable" << endl;
}
return 0;
}
|
[
"rayn1027@outlook.com"
] |
rayn1027@outlook.com
|
92a073d897ff44193293ec8a1e41764417254267
|
a9ef859bd36defcc2bcc88ee2d3925e678e670f8
|
/codeforces/1294/B.cpp
|
1eb89c8876d5cbb127131da9695fd6cbb8420a6d
|
[] |
no_license
|
thun-cp/Problem-Solving
|
6655c5452849c1a576cb54cc5b8c135148d2a8e1
|
663c5bdb5b51695ded2a3c8c6b0f334f7c97e8f3
|
refs/heads/master
| 2023-02-22T01:30:10.604479
| 2021-01-04T19:38:40
| 2021-01-04T19:38:40
| 323,599,063
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,808
|
cpp
|
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization("unroll-loops")
#include "bits/stdc++.h"
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define endl '\n'
#define F first
#define S second
#define IO ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define cf ll testcases;cin>>testcases;while(testcases--)
#define prn(x) if(x) cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define minel(x) (*min_element(all(x)))
#define maxel(x) (*max_element(all(x)))
#define cou dbg=1;cout
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pi;
typedef vector<ll> vi;
typedef vector<ld> vd;
typedef vector<pi> vp;
ll dbg=0;
template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p);
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v);
template<typename A, typename B> istream& operator>>(istream& cin, pair<A, B> &p);
template<typename A> istream& operator>>(istream& cin, vector<A> &v);
int dx[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy[] = {-1, 0, 1, -1, 1, -1, 0, 1};
ll t=0;
void solve(){
ll n;
cin>>n;
vp arr(n);
cin>>arr;
sort(all(arr));
// for(auto i:arr){
// cout<<i<<endl;
// }
for(ll i=0;i<n;i++){
for(ll j=i+1;j<n;j++){
if((arr[i].F>arr[j].F&&arr[i].S<=arr[j].S)||(arr[i].F<=arr[j].F&&arr[i].S>arr[j].S)){
cout<<"NO"<<endl;
return;
}
}
}
cout<<"YES"<<endl;
string ans;
ll x=0,y=0;
for(auto i:arr){
for(ll j=x;j<i.F;j++) ans+='R';
for(ll j=y;j<i.S;j++) ans+='U';
x=i.F,y=i.S;
}
cout<<ans<<endl;
}
int main(){
IO;
cf
solve();
return 0;
}
template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p) {
if(dbg){dbg=0;
return cout << "(" << p.F << ", " << p.S << ")";
}else{
return cout<<p.F<<' '<<p.S;
}
}
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) {
if(dbg){dbg=0;
cout << "["; for(ll i = 0; i < v.size(); i++) {if (i) cout << ", "; cout << v[i];} return cout << "]";
}else{
for(ll i=0;i<v.size()-1;i++) cout<<v[i]<<' ';
return cout<<v[v.size()-1];
}
}
template<typename A, typename B> istream& operator>>(istream& cin, pair<A, B> &p) {
cin >> p.first;
return cin >> p.second;
}
template<typename A> istream& operator>>(istream& cin, vector<A> &v) {
for(ll i=0;i<v.size()-1;i++) cin>>v[i];
return cin >> v[v.size()-1];
}
|
[
"tmodpe@gmail.com"
] |
tmodpe@gmail.com
|
a33349a5bf841e95739bd23a0ea0b7b16690b2af
|
24411a9cfe06f4e52ff4f7689ee09ebdadebb863
|
/ToDoList/tdccustomattribdata.h
|
621e55e70c085cde5fa64e2d9d67e80d2fff54c0
|
[] |
no_license
|
JohnnyXiaoYang/ToDoList_7.2
|
6371a2d24f86e6781566ba0a86b43c3a2d57a97f
|
7f0f14a49b55304b71b257c0086fbb179c12dbc7
|
refs/heads/master
| 2022-11-30T23:55:53.309392
| 2020-08-16T01:22:04
| 2020-08-16T01:22:04
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,693
|
h
|
#if !defined(AFX_TDCCDATA_H__5951FDE6_508A_4A9D_A55D_D16EB026AEF7__INCLUDED_)
#define AFX_TDCCDATA_H__5951FDE6_508A_4A9D_A55D_D16EB026AEF7__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
/////////////////////////////////////////////////////////////////////////////////////////////
#include "..\interfaces\ITaskList.h"
#include <afxtempl.h>
/////////////////////////////////////////////////////////////////////////////////////////////
struct TDCCADATA
{
TDCCADATA(const CString& sValue = _T(""), TCHAR cSep = 0);
TDCCADATA(LPCTSTR szValue, TCHAR cSep = 0);
TDCCADATA(double dValue);
TDCCADATA(double dValue, TDC_UNITS nUnits);
TDCCADATA(const CStringArray& aValues);
TDCCADATA(const CStringArray& aValues, const CStringArray& aExtra);
TDCCADATA(int nValue);
TDCCADATA(const COleDateTime& dtValue);
TDCCADATA(bool bValue);
TDCCADATA(const TDCCADATA& data);
TDCCADATA& operator=(const TDCCADATA& data);
BOOL operator==(const TDCCADATA& data) const;
BOOL operator!=(const TDCCADATA& data) const;
BOOL HasExtra() const;
BOOL IsEmpty() const;
void Clear();
const CString& AsString() const;
double AsDouble() const;
int AsInteger() const;
COleDateTime AsDate() const;
bool AsBool() const;
int AsArray(CStringArray& aValues) const;
int AsArrays(CStringArray& aValues, CStringArray& aExtra) const;
double AsTimePeriod(TDC_UNITS& nUnits) const;
TDC_UNITS GetTimeUnits() const;
void Set(double dValue);
void Set(int nValue);
void Set(const COleDateTime& dtValue);
void Set(const CString& sValue, TCHAR cSep = 0);
void Set(double dValue, TDC_UNITS nUnits);
void Set(bool bValue, TCHAR nChar = 0);
void Set(const CStringArray& aValues);
void Set(const CStringArray& aValues, const CStringArray& aExtra);
CString FormatAsArray(TCHAR cSep = 0) const;
CString FormatAsDate(BOOL bISO = FALSE) const;
CString FormatAsTimePeriod(int nDecimalPlaces = 2) const;
protected:
CString sData, sExtra;
protected:
static void Set(const CStringArray& aValues, CString& sValue);
static int AsArray(const CString& sValue, CStringArray& aValues);
};
/////////////////////////////////////////////////////////////////////////////
class CTDCCustomAttributeDataMap : public CMap<CString, LPCTSTR, TDCCADATA, TDCCADATA&>
{
public:
BOOL Lookup(LPCTSTR key, TDCCADATA& rValue) const;
void SetAt(LPCTSTR key, const TDCCADATA& newValue);
void Copy(const CTDCCustomAttributeDataMap& mapData);
BOOL MatchAll(const CTDCCustomAttributeDataMap& mapData) const;
TDCCADATA& operator[](LPCTSTR key);
};
/////////////////////////////////////////////////////////////////////////////
#endif // AFX_TDCCDATA_H__5951FDE6_508A_4A9D_A55D_D16EB026AEF7__INCLUDED_
|
[
"daniel.godson@gmail.com"
] |
daniel.godson@gmail.com
|
d81591d29dce1bc6281bcb4828e3df2c238eaa31
|
3ded37602d6d303e61bff401b2682f5c2b52928c
|
/toy/0503/Classes/Model/MiniGameManager.h
|
4e20e6c102df74b97976b50ff848db9697b3cbbc
|
[] |
no_license
|
CristinaBaby/Demo_CC
|
8ce532dcf016f21b442d8b05173a7d20c03d337e
|
6f6a7ff132e93271b8952b8da6884c3634f5cb59
|
refs/heads/master
| 2021-05-02T14:58:52.900119
| 2018-02-09T11:48:02
| 2018-02-09T11:48:02
| 120,727,659
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 4,500
|
h
|
//
// MiniGameManager.h
// BedtimeStory
//
// Created by maxiang on 8/31/15.
//
//
#ifndef __BedtimeStory__MiniGameManager__
#define __BedtimeStory__MiniGameManager__
#include "cocos2d.h"
#include "AppConfigs.h"
class BaseGameData
{
public:
BaseGameData() :
index(-1),
resPath(""),
logo("")
{};
public:
int index;
std::string resPath;
std::string logo;
};
#pragma mark- Spot Game Data
class SpotGameData : public BaseGameData
{
public:
SpotGameData() :
tmxFileName(""),
textureFileName(""),
textureFilePlist("")
{};
public:
std::string tmxFileName;
std::string textureFileName;
std::string textureFilePlist;
};
#pragma mark- Jigsaw Game Data
class JigsawConfig
{
public:
JigsawConfig():
rows(0),
columns(0),
totalWidth(0.0),
totalHeight(0.0)
{};
struct JigsawTileInfo
{
float offsetx;
float offsety;
float width;
float height;
std::string tilePath;
};
public:
int rows;
int columns;
float totalWidth;
float totalHeight;
void init(const std::string& csvfile);
std::vector<JigsawTileInfo> jigsawTilesVector;
};
class JigsawGameData : public BaseGameData
{
public:
JigsawGameData() :
textureFileName(""),
config(nullptr)
{};
~JigsawGameData()
{
if (config != nullptr)
{
delete config;
}
};
public:
JigsawConfig *config;
std::string textureFileName;
};
#pragma mark- ColorBook Game Data
class ColorBookGameData : public BaseGameData
{
public:
ColorBookGameData() :
pictureFileName(""),
maskFileName("")
{};
public:
std::string pictureFileName;
std::string maskFileName;
};
struct Pen
{
std::string penLogo;
GLuint R;
GLuint G;
GLuint B;
GLuint A;
int index;
};
struct Pattern
{
std::string patternLogo;
std::string pattern;
int index;
};
enum class PensType
{
PensType_None = 0,
PensType_Pen1,
PensType_Pen2,
PensType_Pattern,
};
#pragma mark- Record Game Data
class RecordGameData : public BaseGameData //this data struct used to show logo
{
public:
RecordGameData():
leftStoryImageFile(""),
rightStoryImageFile("")
{};
~RecordGameData()
{
};
public:
std::string leftStoryImageFile;
std::string rightStoryImageFile;
};
struct RecordInfo //this data struct used to store record info
{
int index;
int recordTime;
bool isSelected;
std::string recordFilePath;
std::string recordDate;
};
#pragma mark- Game Manager
enum class GameType
{
None = 0,
Spot,
Jigsaw,
ColorBook,
Story,
Record
};
class MiniGameManager
{
public:
static MiniGameManager* getInstance();
MiniGameManager();
~MiniGameManager();
void initSpotData();
void initJigsawData();
//for color book game
void initColorBookData();
void setupPens(const std::string& path);
void setupPatterns(const std::string& path);
std::vector<Pen> *getPens(){return &_pensVector;};
std::vector<Pattern> *getPatterns(){return &_patternsVector;};
CC_SYNTHESIZE(PensType, _currentPensType, CurrentPensType);
//for record data
void initRecordData();
void saveRecordInfo();
void addRecordInfo(const int storyIndex, RecordInfo *info);
void deleteRecordInfo(const int storyIndex, RecordInfo *info);
std::vector<RecordInfo*>* getRecordInfoVector(const int storyIndex);
void destroySpotGameData();
void destroyJigsawGameData();
void destroyColorBookGameData();
void destroyRecordDataVector();
CC_SYNTHESIZE_READONLY_PASS_BY_REF(std::vector<SpotGameData*>, _spotDataVector, SpotDataVector);
CC_SYNTHESIZE_READONLY_PASS_BY_REF(std::vector<JigsawGameData*>, _jigsawDataVector, JigsawDataVector);
CC_SYNTHESIZE_READONLY_PASS_BY_REF(std::vector<ColorBookGameData*>, _colorBookDataVector, ColorBookDataVector);
CC_SYNTHESIZE_READONLY_PASS_BY_REF(std::vector<RecordGameData*>, _recordDataVector, RecordDataVector);
protected:
std::vector<Pen> _pensVector;
std::vector<Pattern> _patternsVector;
//key->story index, value->RecordInfo sturct, used to store records
std::unordered_map<std::string, std::vector<RecordInfo*>> _recordInfoMap;
cocos2d::ValueVector _recordInfoV;
};
#endif /* defined(__BedtimeStory__MiniGameManager__) */
|
[
"wuguiling@smalltreemedia.com"
] |
wuguiling@smalltreemedia.com
|
3a7ef778fda72ff154a433928e69d9ef8cd0402e
|
3ff1fe3888e34cd3576d91319bf0f08ca955940f
|
/iss/src/v20230517/model/ListRecordBackupPlanDevicesResponse.cpp
|
6d46a2f38f705174039b0c0c7a1be1bb2606e58b
|
[
"Apache-2.0"
] |
permissive
|
TencentCloud/tencentcloud-sdk-cpp
|
9f5df8220eaaf72f7eaee07b2ede94f89313651f
|
42a76b812b81d1b52ec6a217fafc8faa135e06ca
|
refs/heads/master
| 2023-08-30T03:22:45.269556
| 2023-08-30T00:45:39
| 2023-08-30T00:45:39
| 188,991,963
| 55
| 37
|
Apache-2.0
| 2023-08-17T03:13:20
| 2019-05-28T08:56:08
|
C++
|
UTF-8
|
C++
| false
| false
| 4,149
|
cpp
|
/*
* Copyright (c) 2017-2019 THL A29 Limited, a Tencent company. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <tencentcloud/iss/v20230517/model/ListRecordBackupPlanDevicesResponse.h>
#include <tencentcloud/core/utils/rapidjson/document.h>
#include <tencentcloud/core/utils/rapidjson/writer.h>
#include <tencentcloud/core/utils/rapidjson/stringbuffer.h>
using TencentCloud::CoreInternalOutcome;
using namespace TencentCloud::Iss::V20230517::Model;
using namespace std;
ListRecordBackupPlanDevicesResponse::ListRecordBackupPlanDevicesResponse() :
m_dataHasBeenSet(false)
{
}
CoreInternalOutcome ListRecordBackupPlanDevicesResponse::Deserialize(const string &payload)
{
rapidjson::Document d;
d.Parse(payload.c_str());
if (d.HasParseError() || !d.IsObject())
{
return CoreInternalOutcome(Core::Error("response not json format"));
}
if (!d.HasMember("Response") || !d["Response"].IsObject())
{
return CoreInternalOutcome(Core::Error("response `Response` is null or not object"));
}
rapidjson::Value &rsp = d["Response"];
if (!rsp.HasMember("RequestId") || !rsp["RequestId"].IsString())
{
return CoreInternalOutcome(Core::Error("response `Response.RequestId` is null or not string"));
}
string requestId(rsp["RequestId"].GetString());
SetRequestId(requestId);
if (rsp.HasMember("Error"))
{
if (!rsp["Error"].IsObject() ||
!rsp["Error"].HasMember("Code") || !rsp["Error"]["Code"].IsString() ||
!rsp["Error"].HasMember("Message") || !rsp["Error"]["Message"].IsString())
{
return CoreInternalOutcome(Core::Error("response `Response.Error` format error").SetRequestId(requestId));
}
string errorCode(rsp["Error"]["Code"].GetString());
string errorMsg(rsp["Error"]["Message"].GetString());
return CoreInternalOutcome(Core::Error(errorCode, errorMsg).SetRequestId(requestId));
}
if (rsp.HasMember("Data") && !rsp["Data"].IsNull())
{
if (!rsp["Data"].IsObject())
{
return CoreInternalOutcome(Core::Error("response `Data` is not object type").SetRequestId(requestId));
}
CoreInternalOutcome outcome = m_data.Deserialize(rsp["Data"]);
if (!outcome.IsSuccess())
{
outcome.GetError().SetRequestId(requestId);
return outcome;
}
m_dataHasBeenSet = true;
}
return CoreInternalOutcome(true);
}
string ListRecordBackupPlanDevicesResponse::ToJsonString() const
{
rapidjson::Document value;
value.SetObject();
rapidjson::Document::AllocatorType& allocator = value.GetAllocator();
if (m_dataHasBeenSet)
{
rapidjson::Value iKey(rapidjson::kStringType);
string key = "Data";
iKey.SetString(key.c_str(), allocator);
value.AddMember(iKey, rapidjson::Value(rapidjson::kObjectType).Move(), allocator);
m_data.ToJsonObject(value[key.c_str()], allocator);
}
rapidjson::Value iKey(rapidjson::kStringType);
string key = "RequestId";
iKey.SetString(key.c_str(), allocator);
value.AddMember(iKey, rapidjson::Value().SetString(GetRequestId().c_str(), allocator), allocator);
rapidjson::StringBuffer buffer;
rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
value.Accept(writer);
return buffer.GetString();
}
ListRecordBackupPlanDevicesData ListRecordBackupPlanDevicesResponse::GetData() const
{
return m_data;
}
bool ListRecordBackupPlanDevicesResponse::DataHasBeenSet() const
{
return m_dataHasBeenSet;
}
|
[
"tencentcloudapi@tencent.com"
] |
tencentcloudapi@tencent.com
|
63dad212574f3af5756aa197847489d271350ca0
|
ce6fc44470dcb5fca78cdd3349a7be70d75f2e3a
|
/AtCoder/Beginner 134/E.cpp
|
92279d0207e0a3f476b32c278259073843f69a42
|
[] |
no_license
|
cormackikkert/competitive-programming
|
f3fa287fcb74248ba218ecd763f8f6df31d57424
|
3a1200b8ff9b6941c422371961a127d7be8f2e00
|
refs/heads/master
| 2022-12-17T02:02:40.892608
| 2020-09-20T11:47:15
| 2020-09-20T11:47:15
| 266,775,265
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,473
|
cpp
|
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
using ll = long long;
ll INF = LLONG_MAX;
using vc = vector<char>;
using vi = vector<int>;
using pii = pair<int, int>;
vector<pii> tree;
void modify(int i, pii v) {
i += tree.size()/2;
tree[i] = v;
for (i /= 2; i >= 1; i /= 2) tree[i] = min(tree[2*i], tree[2*i+1]);
}
pii query(int a, int b) {
a += tree.size() / 2; b += tree.size() / 2;
pii s = {1e9+1,1e9+1};
while (a <= b) {
if (a % 2 == 1) s = min(s, tree[a++]);
if (b % 2 == 0) s = min(s, tree[b--]);
a /= 2; b /= 2;
}
return s;
}
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int N; cin >> N;
tree.resize(2*N);
F0R(i, N) {
int val; cin >> val;
modify(i, pii {val, i});
}
int operations = 0;
while (true) {
pii res = query(0, N-1);
if (res.first == 1e9+1) break;
++operations;
int pos = res.second + 1;
while (pos && res.first < 1e9+1) {
if (query(pos, pos).first <= res.first) {++pos; continue;}
modify(pos, pii {1e9+1, 1e9+1});
res = query(res.second + 1, N-1);
}
if (res.first < 1e9+1) modify(res.second, pii {1e9+1, 1e9+1});
}
cout << operations << endl;
}
|
[
"u6427001@anu.edu.au"
] |
u6427001@anu.edu.au
|
8273697452a4cd52b5d38eb345d7ba3879e280b6
|
45014139581f1211a43b6415a6ee32d442c29fc0
|
/src/content/renderer/render_thread_impl.h
|
e13f73a1ef631d9e482e2e878bd5c79c8b7f0790
|
[
"BSD-3-Clause"
] |
permissive
|
webosose/chromium91
|
a31b847e64391c3de98ca5b6dac3ac247d393e78
|
b28e2ae83ee2e4907a36a49a4c0f054aa386dbfa
|
refs/heads/master
| 2022-12-12T09:32:30.580155
| 2022-09-01T09:02:15
| 2022-09-18T23:58:11
| 460,692,960
| 1
| 5
| null | 2022-10-05T07:19:39
| 2022-02-18T03:16:04
| null |
UTF-8
|
C++
| false
| false
| 24,434
|
h
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_RENDERER_RENDER_THREAD_IMPL_H_
#define CONTENT_RENDERER_RENDER_THREAD_IMPL_H_
#include <stddef.h>
#include <stdint.h>
#include <map>
#include <memory>
#include <set>
#include <string>
#include <utility>
#include <vector>
#include "base/cancelable_callback.h"
#include "base/clang_profiling_buildflags.h"
#include "base/containers/unique_ptr_adapters.h"
#include "base/macros.h"
#include "base/memory/discardable_memory_allocator.h"
#include "base/memory/memory_pressure_listener.h"
#include "base/memory/ref_counted.h"
#include "base/metrics/user_metrics_action.h"
#include "base/observer_list.h"
#include "base/optional.h"
#include "base/time/time.h"
#include "base/types/pass_key.h"
#include "build/build_config.h"
#include "cc/mojom/render_frame_metadata.mojom.h"
#include "content/child/child_thread_impl.h"
#include "content/common/agent_scheduling_group.mojom.h"
#include "content/common/content_export.h"
#include "content/common/frame.mojom.h"
#include "content/common/render_message_filter.mojom.h"
#include "content/common/renderer.mojom.h"
#include "content/common/renderer_host.mojom.h"
#include "content/public/renderer/render_thread.h"
#include "content/renderer/compositor/compositor_dependencies.h"
#include "content/renderer/discardable_memory_utils.h"
#include "gpu/ipc/client/gpu_channel_host.h"
#include "ipc/ipc_sync_channel.h"
#include "media/media_buildflags.h"
#include "mojo/public/cpp/bindings/associated_receiver.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
#include "mojo/public/cpp/bindings/pending_associated_receiver.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "net/base/network_change_notifier.h"
#include "net/nqe/effective_connection_type.h"
#include "services/network/public/mojom/url_loader_factory.mojom.h"
#include "services/viz/public/mojom/compositing/compositing_mode_watcher.mojom.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_registry.h"
#include "third_party/blink/public/common/user_agent/user_agent_metadata.h"
#include "third_party/blink/public/platform/scheduler/web_rail_mode_observer.h"
#include "third_party/blink/public/platform/scheduler/web_thread_scheduler.h"
#include "third_party/blink/public/platform/url_loader_throttle_provider.h"
#include "third_party/blink/public/platform/web_connection_type.h"
#include "third_party/blink/public/web/web_memory_statistics.h"
#include "ui/gfx/native_widget_types.h"
///@name USE_NEVA_APPRUNTIME
///@{
#include "third_party/blink/public/platform/web_scoped_page_pauser.h"
///@}
#if defined(USE_NEVA_MEDIA) || defined(USE_NEVA_SUSPEND_MEDIA_CAPTURE)
// Mix-in for neva
#include "content/renderer/neva/render_thread_impl.h"
#endif
class SkBitmap;
namespace blink {
class WebResourceRequestSenderDelegate;
class WebVideoCaptureImplManager;
}
namespace base {
class SingleThreadTaskRunner;
class Thread;
}
namespace cc {
class TaskGraphRunner;
}
namespace gfx {
class RenderingPipeline;
}
namespace gpu {
class GpuChannelHost;
}
namespace media {
class DecoderFactory;
class GpuVideoAcceleratorFactories;
}
namespace mojo {
class BinderMap;
}
namespace viz {
class ContextProviderCommandBuffer;
class Gpu;
class RasterContextProvider;
} // namespace viz
namespace content {
class AgentSchedulingGroup;
class CategorizedWorkerPool;
class GpuVideoAcceleratorFactoriesImpl;
class MediaInterfaceFactory;
class RenderFrameImpl;
class RenderThreadObserver;
class RendererBlinkPlatformImpl;
class VariationsRenderThreadObserver;
#if defined(OS_ANDROID)
class StreamTextureFactory;
#endif
// The RenderThreadImpl class represents the main thread, where RenderView
// instances live. The RenderThread supports an API that is used by its
// consumer to talk indirectly to the RenderViews and supporting objects.
// Likewise, it provides an API for the RenderViews to talk back to the main
// process (i.e., their corresponding WebContentsImpl).
//
// Most of the communication occurs in the form of IPC messages. They are
// routed to the RenderThread according to the routing IDs of the messages.
// The routing IDs correspond to RenderView instances.
class CONTENT_EXPORT RenderThreadImpl
: public RenderThread,
public ChildThreadImpl,
public mojom::Renderer,
#if defined(USE_NEVA_MEDIA) || defined(USE_NEVA_SUSPEND_MEDIA_CAPTURE)
public neva::RenderThreadImpl<RenderThreadImpl>,
#endif
public viz::mojom::CompositingModeWatcher,
public CompositorDependencies {
public:
static RenderThreadImpl* current();
static mojom::RenderMessageFilter* current_render_message_filter();
static RendererBlinkPlatformImpl* current_blink_platform_impl();
static void SetRenderMessageFilterForTesting(
mojom::RenderMessageFilter* render_message_filter);
static void SetRendererBlinkPlatformImplForTesting(
RendererBlinkPlatformImpl* blink_platform_impl);
// Returns the task runner for the main thread where the RenderThread lives.
static scoped_refptr<base::SingleThreadTaskRunner>
DeprecatedGetMainTaskRunner();
RenderThreadImpl(
base::RepeatingClosure quit_closure,
std::unique_ptr<blink::scheduler::WebThreadScheduler> scheduler);
RenderThreadImpl(
const InProcessChildThreadParams& params,
int32_t client_id,
std::unique_ptr<blink::scheduler::WebThreadScheduler> scheduler);
~RenderThreadImpl() override;
void Shutdown() override;
bool ShouldBeDestroyed() override;
// When initializing WebKit, ensure that any schemes needed for the content
// module are registered properly. Static to allow sharing with tests.
static void RegisterSchemes();
// RenderThread implementation:
IPC::SyncChannel* GetChannel() override;
std::string GetLocale() override;
IPC::SyncMessageFilter* GetSyncMessageFilter() override;
void AddRoute(int32_t routing_id, IPC::Listener* listener) override;
void AttachTaskRunnerToRoute(
int32_t routing_id,
scoped_refptr<base::SingleThreadTaskRunner> task_runner) override;
void RemoveRoute(int32_t routing_id) override;
int GenerateRoutingID() override;
bool GenerateFrameRoutingID(
int32_t& routing_id,
blink::LocalFrameToken& frame_token,
base::UnguessableToken& devtools_frame_token) override;
void AddFilter(IPC::MessageFilter* filter) override;
void RemoveFilter(IPC::MessageFilter* filter) override;
void AddObserver(RenderThreadObserver* observer) override;
void RemoveObserver(RenderThreadObserver* observer) override;
void SetResourceRequestSenderDelegate(
blink::WebResourceRequestSenderDelegate* delegate) override;
blink::WebResourceRequestSenderDelegate* GetResourceRequestSenderDelegate() {
return resource_request_sender_delegate_;
}
void RegisterExtension(std::unique_ptr<v8::Extension> extension) override;
int PostTaskToAllWebWorkers(base::RepeatingClosure closure) override;
base::WaitableEvent* GetShutdownEvent() override;
int32_t GetClientId() override;
void SetRendererProcessType(
blink::scheduler::WebRendererProcessType type) override;
blink::WebString GetUserAgent() override;
const blink::UserAgentMetadata& GetUserAgentMetadata() override;
bool IsUseZoomForDSF() override;
// IPC::Listener implementation via ChildThreadImpl:
void OnAssociatedInterfaceRequest(
const std::string& name,
mojo::ScopedInterfaceEndpointHandle handle) override;
// ChildThread implementation via ChildThreadImpl:
scoped_refptr<base::SingleThreadTaskRunner> GetIOTaskRunner() override;
// CompositorDependencies implementation.
bool IsUseZoomForDSFEnabled() override;
blink::scheduler::WebThreadScheduler* GetWebMainThreadScheduler() override;
cc::TaskGraphRunner* GetTaskGraphRunner() override;
std::unique_ptr<cc::UkmRecorderFactory> CreateUkmRecorderFactory() override;
gfx::RenderingPipeline* GetMainThreadPipeline() override;
gfx::RenderingPipeline* GetCompositorThreadPipeline() override;
bool IsLcdTextEnabled();
bool IsElasticOverscrollEnabled();
bool IsScrollAnimatorEnabled();
// TODO(crbug.com/1111231): The `enable_scroll_animator` flag is currently
// being passed as part of `CreateViewParams`, despite it looking like a
// global setting. It should probably be moved to some `mojom::Renderer` API
// and this method should be removed.
void SetScrollAnimatorEnabled(bool enable_scroll_animator,
base::PassKey<AgentSchedulingGroup>);
bool IsThreadedAnimationEnabled();
// viz::mojom::CompositingModeWatcher implementation.
void CompositingModeFallbackToSoftware() override;
// Whether gpu compositing is being used or is disabled for software
// compositing. Clients of the compositor should give resources that match
// the appropriate mode.
bool IsGpuCompositingDisabled() { return is_gpu_compositing_disabled_; }
// Synchronously establish a channel to the GPU plugin if not previously
// established or if it has been lost (for example if the GPU plugin crashed).
// If there is a pending asynchronous request, it will be completed by the
// time this routine returns.
scoped_refptr<gpu::GpuChannelHost> EstablishGpuChannelSync();
gpu::GpuMemoryBufferManager* GetGpuMemoryBufferManager();
blink::AssociatedInterfaceRegistry* GetAssociatedInterfaceRegistry();
base::DiscardableMemoryAllocator* GetDiscardableMemoryAllocatorForTest()
const {
return discardable_memory_allocator_.get();
}
RendererBlinkPlatformImpl* blink_platform_impl() const {
DCHECK(blink_platform_impl_);
return blink_platform_impl_.get();
}
// Returns the task runner on the compositor thread.
//
// Will be null if threaded compositing has not been enabled.
scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner() const {
return compositor_task_runner_;
}
const std::vector<std::string> cors_exempt_header_list() const {
return cors_exempt_header_list_;
}
blink::URLLoaderThrottleProvider* url_loader_throttle_provider() const {
return url_loader_throttle_provider_.get();
}
#if defined(OS_ANDROID)
scoped_refptr<StreamTextureFactory> GetStreamTexureFactory();
bool EnableStreamTextureCopy();
#endif
blink::WebVideoCaptureImplManager* video_capture_impl_manager() const {
return vc_manager_.get();
}
mojom::RenderMessageFilter* render_message_filter();
// Get the GPU channel. Returns NULL if the channel is not established or
// has been lost.
gpu::GpuChannelHost* GetGpuChannel();
// Returns a SingleThreadTaskRunner instance corresponding to the message loop
// of the thread on which media operations should be run. Must be called
// on the renderer's main thread.
scoped_refptr<base::SingleThreadTaskRunner> GetMediaThreadTaskRunner();
// A TaskRunner instance that runs tasks on the raster worker pool.
base::TaskRunner* GetWorkerTaskRunner();
// Creates a ContextProvider if yet created, and returns it to be used for
// video frame compositing. The ContextProvider given as an argument is
// one that has been lost, and is a hint to the RenderThreadImpl to clear
// it's |video_frame_compositor_context_provider_| if it matches.
scoped_refptr<viz::RasterContextProvider>
GetVideoFrameCompositorContextProvider(
scoped_refptr<viz::RasterContextProvider>);
// Returns a worker context provider that will be bound on the compositor
// thread.
scoped_refptr<viz::RasterContextProvider>
SharedCompositorWorkerContextProvider(bool try_gpu_rasterization);
media::GpuVideoAcceleratorFactories* GetGpuFactories();
media::DecoderFactory* GetMediaDecoderFactory();
scoped_refptr<viz::ContextProviderCommandBuffer>
SharedMainThreadContextProvider();
// For producing custom V8 histograms. Custom histograms are produced if all
// RenderViews share the same host, and the host is in the pre-specified set
// of hosts we want to produce custom diagrams for. The name for a custom
// diagram is the name of the corresponding generic diagram plus a
// host-specific suffix.
class CONTENT_EXPORT HistogramCustomizer {
public:
HistogramCustomizer();
~HistogramCustomizer();
// Called when a top frame of a RenderView navigates. This function updates
// RenderThreadImpl's information about whether all RenderViews are
// displaying a page from the same host. |host| is the host where a
// RenderView navigated, and |view_count| is the number of RenderViews in
// this process.
void RenderViewNavigatedToHost(const std::string& host, size_t view_count);
// Used for customizing some histograms if all RenderViews share the same
// host. Returns the current custom histogram name to use for
// |histogram_name|, or |histogram_name| if it shouldn't be customized.
std::string ConvertToCustomHistogramName(const char* histogram_name) const;
private:
FRIEND_TEST_ALL_PREFIXES(RenderThreadImplUnittest,
IdentifyAlexaTop10NonGoogleSite);
friend class RenderThreadImplUnittest;
// Converts a host name to a suffix for histograms
std::string HostToCustomHistogramSuffix(const std::string& host);
// Helper function to identify a certain set of top pages
bool IsAlexaTop10NonGoogleSite(const std::string& host);
// Used for updating the information on which is the common host which all
// RenderView's share (if any). If there is no common host, this function is
// called with an empty string.
void SetCommonHost(const std::string& host);
// The current common host of the RenderViews; empty string if there is no
// common host.
std::string common_host_;
// The corresponding suffix.
std::string common_host_histogram_suffix_;
// Set of histograms for which we want to produce a custom histogram if
// possible.
std::set<std::string> custom_histograms_;
DISALLOW_COPY_AND_ASSIGN(HistogramCustomizer);
};
HistogramCustomizer* histogram_customizer() {
return &histogram_customizer_;
}
void RegisterPendingFrameCreate(
int routing_id,
mojo::PendingReceiver<mojom::Frame> frame);
mojom::RendererHost* GetRendererHost();
struct RendererMemoryMetrics {
size_t partition_alloc_kb;
size_t blink_gc_kb;
size_t malloc_mb;
size_t discardable_kb;
size_t v8_main_thread_isolate_mb;
size_t total_allocated_mb;
size_t non_discardable_total_allocated_mb;
size_t total_allocated_per_render_view_mb;
};
bool GetRendererMemoryMetrics(RendererMemoryMetrics* memory_metrics) const;
void RecordMetricsForBackgroundedRendererPurge();
// Sets the current pipeline rendering color space.
void SetRenderingColorSpace(const gfx::ColorSpace& color_space);
gfx::ColorSpace GetRenderingColorSpace();
scoped_refptr<base::SingleThreadTaskRunner>
CreateVideoFrameCompositorTaskRunner();
// In the case of kOnDemand, we wont be using the task_runner created in
// CreateVideoFrameCompositorTaskRunner.
// TODO(https://crbug/901513): Remove once kOnDemand is removed.
void SetVideoFrameCompositorTaskRunner(
scoped_refptr<base::SingleThreadTaskRunner> task_runner) {
video_frame_compositor_task_runner_ = task_runner;
}
private:
friend class RenderThreadImplBrowserTest;
friend class AgentSchedulingGroup;
void OnProcessFinalRelease() override;
// IPC::Listener
void OnChannelError() override;
// ChildThread
bool OnControlMessageReceived(const IPC::Message& msg) override;
void RecordAction(const base::UserMetricsAction& action) override;
void RecordComputedAction(const std::string& action) override;
bool IsMainThread();
void Init();
void InitializeCompositorThread();
void InitializeWebKit(mojo::BinderMap* binders);
void OnTransferBitmap(const SkBitmap& bitmap, int resource_id);
void OnGetAccessibilityTree();
// mojom::Renderer:
void CreateAgentSchedulingGroup(
mojo::PendingReceiver<IPC::mojom::ChannelBootstrap> bootstrap,
mojo::PendingRemote<blink::mojom::BrowserInterfaceBroker> broker_remote)
override;
void CreateAssociatedAgentSchedulingGroup(
mojo::PendingAssociatedReceiver<mojom::AgentSchedulingGroup>
agent_scheduling_group,
mojo::PendingRemote<blink::mojom::BrowserInterfaceBroker> broker_remote)
override;
void OnNetworkConnectionChanged(
net::NetworkChangeNotifier::ConnectionType type,
double max_bandwidth_mbps) override;
void OnNetworkQualityChanged(net::EffectiveConnectionType type,
base::TimeDelta http_rtt,
base::TimeDelta transport_rtt,
double bandwidth_kbps) override;
void SetWebKitSharedTimersSuspended(bool suspend) override;
void SetUserAgent(const std::string& user_agent) override;
void SetUserAgentMetadata(const blink::UserAgentMetadata& metadata) override;
void SetCorsExemptHeaderList(const std::vector<std::string>& list) override;
void UpdateScrollbarTheme(
mojom::UpdateScrollbarThemeParamsPtr params) override;
void OnSystemColorsChanged(int32_t aqua_color_variant,
const std::string& highlight_text_color,
const std::string& highlight_color) override;
void UpdateSystemColorInfo(
mojom::UpdateSystemColorInfoParamsPtr params) override;
void PurgePluginListCache(bool reload_pages) override;
void SetProcessState(mojom::RenderProcessBackgroundState background_state,
mojom::RenderProcessVisibleState visible_state) override;
void SetSchedulerKeepActive(bool keep_active) override;
///@name USE_NEVA_APPRUNTIME
///@{
void ProcessResume() override;
void ProcessSuspend() override;
void OnSystemMemoryPressureLevelChanged(
base::MemoryPressureListener::MemoryPressureLevel level) override;
///@}
void SetIsLockedToSite() override;
#if BUILDFLAG(CLANG_PROFILING_INSIDE_SANDBOX)
void WriteClangProfilingProfile(
WriteClangProfilingProfileCallback callback) override;
#endif
void SetIsCrossOriginIsolated(bool value) override;
void OnMemoryPressure(
base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level);
bool RendererIsHidden() const;
void OnRendererHidden();
void OnRendererVisible();
bool RendererIsBackgrounded() const;
void OnRendererBackgrounded();
void OnRendererForegrounded();
void RecordMemoryUsageAfterBackgrounded(const char* suffix,
int foregrounded_count);
void OnRecordMetricsForBackgroundedRendererPurgeTimerExpired(
const char* suffix,
int foregrounded_count_when_purged);
void ReleaseFreeMemory();
void OnSyncMemoryPressure(
base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level);
void OnRendererInterfaceReceiver(
mojo::PendingAssociatedReceiver<mojom::Renderer> receiver);
scoped_refptr<discardable_memory::ClientDiscardableSharedMemoryManager>
discardable_memory_allocator_;
// These objects live solely on the render thread.
std::unique_ptr<blink::scheduler::WebThreadScheduler> main_thread_scheduler_;
std::unique_ptr<RendererBlinkPlatformImpl> blink_platform_impl_;
std::unique_ptr<blink::URLLoaderThrottleProvider>
url_loader_throttle_provider_;
std::vector<std::string> cors_exempt_header_list_;
// Used on the render thread.
std::unique_ptr<blink::WebVideoCaptureImplManager> vc_manager_;
// Used to keep track of the renderer's backgrounded and visibility state.
// Updated via an IPC from the browser process. If nullopt, the browser
// process has yet to send an update and the state is unknown.
base::Optional<mojom::RenderProcessBackgroundState> background_state_;
base::Optional<mojom::RenderProcessVisibleState> visible_state_;
blink::WebString user_agent_;
blink::UserAgentMetadata user_agent_metadata_;
// Sticky once true, indicates that compositing is done without Gpu, so
// resources given to the compositor or to the viz service should be
// software-based.
bool is_gpu_compositing_disabled_ = false;
// Utility class to provide GPU functionalities to media.
// TODO(dcastagna): This should be just one scoped_ptr once
// http://crbug.com/580386 is fixed.
// NOTE(dcastagna): At worst this accumulates a few bytes per context lost.
std::vector<std::unique_ptr<GpuVideoAcceleratorFactoriesImpl>> gpu_factories_;
// Utility classes to allow WebRTC to create video decoders.
std::unique_ptr<MediaInterfaceFactory> media_interface_factory_;
std::unique_ptr<media::DecoderFactory> media_decoder_factory_;
// Thread for running multimedia operations (e.g., video decoding).
std::unique_ptr<base::Thread> media_thread_;
std::unique_ptr<gfx::RenderingPipeline> main_thread_pipeline_;
std::unique_ptr<gfx::RenderingPipeline> compositor_thread_pipeline_;
// Will point to appropriate task runner after initialization,
// regardless of whether |compositor_thread_| is overriden.
scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_;
// Task to run the VideoFrameCompositor on.
scoped_refptr<base::SingleThreadTaskRunner>
video_frame_compositor_task_runner_;
// Pool of workers used for raster operations (e.g., tile rasterization).
scoped_refptr<CategorizedWorkerPool> categorized_worker_pool_;
#if defined(OS_ANDROID)
scoped_refptr<StreamTextureFactory> stream_texture_factory_;
#endif
scoped_refptr<viz::ContextProviderCommandBuffer> shared_main_thread_contexts_;
base::ObserverList<RenderThreadObserver>::Unchecked observers_;
scoped_refptr<viz::RasterContextProvider>
video_frame_compositor_context_provider_;
scoped_refptr<viz::RasterContextProvider> shared_worker_context_provider_;
HistogramCustomizer histogram_customizer_;
std::unique_ptr<base::MemoryPressureListener> memory_pressure_listener_;
std::unique_ptr<viz::Gpu> gpu_;
std::unique_ptr<VariationsRenderThreadObserver> variations_observer_;
// Compositor settings.
int gpu_rasterization_msaa_sample_count_;
bool is_lcd_text_enabled_;
bool is_zero_copy_enabled_;
bool is_gpu_memory_buffer_compositor_resources_enabled_;
bool is_partial_raster_enabled_;
bool is_elastic_overscroll_enabled_;
bool is_zoom_for_dsf_enabled_;
bool is_threaded_animation_enabled_;
bool is_scroll_animator_enabled_;
// Target rendering ColorSpace.
gfx::ColorSpace rendering_color_space_;
// Used when AddRoute() is called and the RenderFrameImpl hasn't been created
// yet.
std::map<int, mojo::PendingReceiver<mojom::Frame>> pending_frames_;
mojo::AssociatedRemote<mojom::RendererHost> renderer_host_;
blink::AssociatedInterfaceRegistry associated_interfaces_;
mojo::AssociatedReceiver<mojom::Renderer> renderer_receiver_{this};
mojo::AssociatedRemote<mojom::RenderMessageFilter> render_message_filter_;
std::set<std::unique_ptr<AgentSchedulingGroup>, base::UniquePtrComparator>
agent_scheduling_groups_;
RendererMemoryMetrics purge_and_suspend_memory_metrics_;
int process_foregrounded_count_;
int32_t client_id_;
#if defined(USE_NEVA_MEDIA)
template <typename original_t>
friend class neva::RenderThreadImpl;
#endif
#if defined(USE_NEVA_APPRUNTIME)
unsigned suspension_count_ = 0;
#endif
// A mojo connection to the CompositingModeReporter service.
mojo::Remote<viz::mojom::CompositingModeReporter> compositing_mode_reporter_;
// The class is a CompositingModeWatcher, which is bound to mojo through
// this member.
mojo::Receiver<viz::mojom::CompositingModeWatcher>
compositing_mode_watcher_receiver_{this};
///@name USE_NEVA_APPRUNTIME
///@{
std::unique_ptr<blink::WebScopedPagePauser> page_pauser_;
///@}
// Delegate is expected to live as long as requests may be sent.
blink::WebResourceRequestSenderDelegate* resource_request_sender_delegate_ =
nullptr;
base::WeakPtrFactory<RenderThreadImpl> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(RenderThreadImpl);
};
} // namespace content
#endif // CONTENT_RENDERER_RENDER_THREAD_IMPL_H_
|
[
"youngsoo.choi@lge.com"
] |
youngsoo.choi@lge.com
|
fe1e4d7b7dbc225bb7231a7cc2942dba348f76f2
|
5be91d95c7c0e3ecd2f6da2cd1f73018f444e0d1
|
/ProjetoPOO/Virus.cpp
|
ff6720161016b4d1a2e02323012ef59f9adb77bc
|
[
"MIT"
] |
permissive
|
DiogoTojal7/ProjetoPOO-
|
8d336ad5ef642efb87376cf15f1e4ab2a4822564
|
5990806a191cbf6f02c7a6b9119ba8c7bd38226b
|
refs/heads/main
| 2023-01-20T19:13:35.422856
| 2020-11-20T18:32:13
| 2020-11-20T18:32:13
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 111
|
cpp
|
#include "Virus.h"
#include "Pessoa.h"
Virus::Virus(string c1)
{
//ctor
}
Virus::~Virus()
{
//dtor
}
|
[
"63270037+DiogoTojal@users.noreply.github.com"
] |
63270037+DiogoTojal@users.noreply.github.com
|
b4771a67b824c59573db7b52440bca76c5b0b212
|
6ced41da926682548df646099662e79d7a6022c5
|
/aws-cpp-sdk-drs/source/model/DeleteJobResult.cpp
|
60c099c98cc79b83f6be170ce28bb65fce0eb780
|
[
"Apache-2.0",
"MIT",
"JSON"
] |
permissive
|
irods/aws-sdk-cpp
|
139104843de529f615defa4f6b8e20bc95a6be05
|
2c7fb1a048c96713a28b730e1f48096bd231e932
|
refs/heads/main
| 2023-07-25T12:12:04.363757
| 2022-08-26T15:33:31
| 2022-08-26T15:33:31
| 141,315,346
| 0
| 1
|
Apache-2.0
| 2022-08-26T17:45:09
| 2018-07-17T16:24:06
|
C++
|
UTF-8
|
C++
| false
| false
| 787
|
cpp
|
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/drs/model/DeleteJobResult.h>
#include <aws/core/utils/json/JsonSerializer.h>
#include <aws/core/AmazonWebServiceResult.h>
#include <aws/core/utils/StringUtils.h>
#include <aws/core/utils/UnreferencedParam.h>
#include <utility>
using namespace Aws::drs::Model;
using namespace Aws::Utils::Json;
using namespace Aws::Utils;
using namespace Aws;
DeleteJobResult::DeleteJobResult()
{
}
DeleteJobResult::DeleteJobResult(const Aws::AmazonWebServiceResult<JsonValue>& result)
{
*this = result;
}
DeleteJobResult& DeleteJobResult::operator =(const Aws::AmazonWebServiceResult<JsonValue>& result)
{
AWS_UNREFERENCED_PARAM(result);
return *this;
}
|
[
"aws-sdk-cpp-automation@github.com"
] |
aws-sdk-cpp-automation@github.com
|
17193755eff1d1ca8964065139151f426bb1bd9f
|
163782f0b7be7540fc24223a1065335cfd6e15d1
|
/MyForm1.cpp
|
feb2b92ab01a7b6aa7aa49df11f064981156081a
|
[] |
no_license
|
pragati0308/FS-Project-Olympics-Management-System
|
a1f1522976bb6406fb5f1865faa72fd24a679cba
|
ad2e36295d9f3ac4ead49e3273aa46129e6f67af
|
refs/heads/main
| 2023-06-28T01:55:57.059328
| 2021-08-03T09:24:28
| 2021-08-03T09:24:28
| 392,259,640
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 430
|
cpp
|
#include "MyForm1.h"
#include "MyForm2.h"
#include "MyForm3.h"
#include "MyForm4.h"
#include "MyForm5.h"
#include "MyForm6.h"
#include "MyForm7.h"
using namespace System;
using namespace System::Windows::Forms;
[STAThreadAttribute]
void Main(array<String^>^ args) {
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
Project1::MyForm1 form1;
Application::Run(% form1);
}
|
[
"noreply@github.com"
] |
pragati0308.noreply@github.com
|
32a996f23bb99a5d1b454fb92cfa81929c3b20cb
|
2b089f87cb277c5f40eb0b89ca593fd6cd96b725
|
/Graph/bridge_2.cpp
|
c776d6da84a129d60314860261a5b3e0443f7efe
|
[] |
no_license
|
ryuat/algorithm
|
f78d0ab8758bb40a24be4508cf8054d75336ad7c
|
2b8dc909a96cb6cbacc46b421ccde92ae40eeacc
|
refs/heads/master
| 2021-07-02T18:46:31.083472
| 2019-02-22T05:43:55
| 2019-02-22T05:43:55
| 134,426,459
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,686
|
cpp
|
/*
다리 만들기 2번째 방법
*/
#include <iostream>
#include <utility>
#include <queue>
int a[100][100]; // (1:육지 2:바다)
int g[100][100]; // 그룹
int d[100][100]; // 거리
int dx[] = {0, 0, -1, 1};
int dy[] = {-1, 1, 0, 0};
using namespace std;
int main(){
int n;
scanf("%d", &n);
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
scanf("%d", &a[i][j]);
g[i][j] = 0; // 그룹 초기화
d[i][j] = -1; // 거리 초기화
}
}
// 육지의 그룹 번호 저장
int grp = 0; //그룹번호
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
if(a[i][j] == 1 && g[i][j] == 0){ // 육지이고 탐색하지 않았다면
queue<pair<int,int>> q;
q.push(make_pair(i,j));
g[i][j] = ++grp; // 다음 그룹
while(!q.empty()){
int x = q.front().first;
int y = q.front().second;
//printf("%dx%d node 호출\n", x,y);
q.pop();
for(int k=0;k<4;k++){
int nx = x+dx[k];
int ny = y+dy[k];
if(0<=nx && nx < n && 0 <= ny && ny < n){ // 인덱스 존재
if(a[nx][ny] == 1 && g[nx][ny]==0){ // 육지이면서 방문 안했다면
q.push(make_pair(nx,ny));
g[nx][ny] = grp; // 현재 grp
}
}
}
}
}
}
}
// dist 계산 + 그룹 채우기
// start node
queue<pair<int,int>> q;
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
if(a[i][j] == 1 && d[i][j] == -1){ // 육지 노드 & 방문 x 를 모두 start로,
q.push(make_pair(i,j)); // start 노드들 = 육지
d[i][j] = 0;
}
}
}
while(!q.empty()){
int x = q.front().first;
int y = q.front().second;
q.pop();
for(int k=0;k<4;k++){
int nx = x+dx[k];
int ny = y+dy[k];
if(0<=nx && nx < n && 0 <= ny && ny < n){
if(d[nx][ny] == -1){ // 방문 x
d[nx][ny] = d[x][y]+1;
g[nx][ny] = g[x][y];
q.push(make_pair(nx,ny));
}
}
}
}
int ans = n*20*n; // 임의의 큰 수
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
for(int k=0;k<4;k++){ // 인접노드
int nx = i + dx[k];
int ny = j + dy[k];
if(0<=nx && nx < n && 0 <= ny && ny < n){
if(g[nx][ny] != g[i][j]){ //인접노드의 그룹이 다를 경우
if(ans > d[i][j] + d[nx][ny]){ // 인접노드 거리의 합을 구하고
//printf("%dx%d - %dx%d\n",i,j ,nx,ny);
ans = d[i][j] + d[nx][ny]; // 최소값 저장
}
}
}
}
}
}
/*
printf("그룹\n");
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
printf("%2d", g[i][j]);
}
printf("\n");
}
printf("거리\n");
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
printf("%2d", d[i][j]);
}
printf("\n");
}*/
printf("%d\n", ans);
return 0;
}
/*
1. 그룹 저장
2. dist 계산 + 바다 그룹 채우기
3. 서로 다른 그룹이 인접한 바다 중 최소 dist
*/
|
[
"jungohryu@gmail.com"
] |
jungohryu@gmail.com
|
7635f0b820925c78502746b914a9d79081d1655a
|
26ee37a92336ac6268b6d23f965d1b54d5594a7b
|
/src/consistency/traditional_ssp_consistency.cc
|
18a5488af0b656f9fa57bcb03b6484a53d75e523
|
[] |
no_license
|
CaryLorrk/woops
|
9494082f9a90926a63299462075e83e49d9688b9
|
66d10b9f93f275f2d2e4aaa71acfa09a3cefa862
|
refs/heads/master
| 2020-05-23T18:30:05.316492
| 2018-09-18T04:08:45
| 2018-09-18T04:08:45
| 95,071,315
| 0
| 1
| null | 2017-10-13T05:09:41
| 2017-06-22T03:36:56
|
C++
|
UTF-8
|
C++
| false
| false
| 1,609
|
cc
|
#include "traditional_ssp_consistency.h"
#include "lib.h"
namespace woops
{
TraditionalSSPConsistency::TraditionalSSPConsistency(Iteration staleness): SSPConsistency(staleness) {}
void TraditionalSSPConsistency::BeforeClock(Iteration iteration) {
auto&& tables = Lib::Client().GetTables();
for (auto&& kv: tables) {
Tableid id = kv.first;
auto&& table = *kv.second;
Iteration min;
{
std::lock_guard<std::mutex> lock(table.mu);
min = std::min_element(
table.iterations.begin(), table.iterations.end(),
[](ClientTable::Iterations::value_type& l,
ClientTable::Iterations::value_type& r) -> bool {
return l.second < r.second;
})->second;
}
if (min < iteration - staleness_) {
// push to server
auto&& partitions = Lib::Placement().GetPartitions(id);
std::map<Hostid, Bytes> server_to_bytes;
{
std::lock_guard<std::mutex> lock(table.mu);
server_to_bytes = table.transmit_buffer->Encode(partitions);
}
for (auto&& kv: partitions) {
auto&& server = kv.first;
auto&& bytes = server_to_bytes[server];
Lib::Comm().ClientPush(server, id, iteration, std::move(bytes));
}
// pull from server
for (auto&& kv: partitions) {
Lib::Comm().ClientPull(kv.first, id, iteration);
}
}
}
}
} /* woops */
|
[
"carylorrk@gmail.com"
] |
carylorrk@gmail.com
|
268cb90fe62680f45851e8bc3359d815e22dd90e
|
00692ba81551905b594279fc37ee8e3ca3a4f8eb
|
/List.cpp
|
235115b0fad04a08e1ac76a2c1ed46d9d45554fe
|
[] |
no_license
|
zhan81776075/Cplusplus-Primer
|
a52bd0ea62bedf248cc9b72e5915e01930b97460
|
9b4103138c94728a4f9ec541a05ae6835fcf5a41
|
refs/heads/master
| 2020-05-17T09:16:13.259039
| 2019-06-15T14:16:30
| 2019-06-15T14:16:30
| 183,628,642
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,692
|
cpp
|
#include<iostream>
#include<list>
#include <utility> // std::move std::swap
#include <vector> // std::vector
#include <string> // std::string
int main()
{
/*list::assign
std::list<int> first;
std::list<int> second;
//void assign (size_type n, const value_type& val);
first.assign(7, 100);
//void assign(InputIterator first, InputIterator last);
second.assign(first.begin(), first.end());
//assigning from array
int myints[] = { 1776,7,3 };
first.assign(myints, myints + 3);
std::cout << "Size of first: " << int(first.size()) << '\n';
std::cout << "Size of second: " << int(second.size()) << '\n';
return 0;
*/
/*list::back
std::list<int> mylist;
mylist.push_back(10);
while (mylist.back() != 0)
{
mylist.push_back(mylist.back() - 1);
}
std::cout << "mylist contains:";
for (std::list<int>::iterator it = mylist.begin(); it != mylist.end(); ++it) {
std::cout << ' ' << *it;
}
std::cout << '\n';
return 0;
*/
/*list::begin
int myints[] = { 75,23,65,42,13 };
std::list<int> mylist(myints, myints + 5);
std::cout << "mylist contains:";
for (std::list<int>::iterator it = mylist.begin(); it != mylist.end(); ++it)
std::cout << ' ' << *it;
std::cout << '\n';
return 0;
*/
/* std::move
std::string foo = "foo-string";
std::string bar = "bar-string";
std::vector<std::string> myvector;
myvector.push_back(foo); // copies
myvector.push_back(std::move(bar)); // moves
std::cout << "myvector contains:";
for (std::string& x : myvector) std::cout << ' ' << x;
std::cout << '\n';
std::cout <<"foo_value:"<< foo << std::endl;
std::cout <<"bar_value:"<< bar << std::endl;
return 0;
*/
}
|
[
"416810161@qq.com"
] |
416810161@qq.com
|
dcf579f490db38b49bd90c24f58bfa07bf5dc9f5
|
7e79799ffb2b32666ed6bce1c3223f4d4e39c7db
|
/03_C_plusplus/096_Remove_Element/01_Remove_Element.cpp
|
89c136e94e49d8941290bdebf8610f18a58e9274
|
[] |
no_license
|
daegukdo/TIL
|
c24fef4b0c694dd5db0a48cc041960b9cb8ede34
|
f3ad8d802e0bf55896d97d5d70fd08a1f7736a79
|
refs/heads/master
| 2022-05-10T12:26:53.270934
| 2022-05-05T13:30:24
| 2022-05-05T13:30:24
| 200,057,564
| 0
| 3
| null | null | null | null |
UHC
|
C++
| false
| false
| 2,259
|
cpp
|
/*
@ LeetCode
Remove Element
Given an array nums and a value val, remove all instances of that value in-place and return the new length.
Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory.
The order of elements can be changed. It doesn't matter what you leave beyond the new length.
Example 1:
Given nums = [3,2,2,3], val = 3,
Your function should return length = 2, with the first two elements of nums being 2.
It doesn't matter what you leave beyond the returned length.
Example 2:
Given nums = [0,1,2,2,3,0,4,2], val = 2,
Your function should return length = 5, with the first five elements of nums containing 0, 1, 3, 0, and 4.
Note that the order of those five elements can be arbitrary.
It doesn't matter what values are set beyond the returned length.
Clarification:
Confused why the returned value is an integer but your answer is an array?
Note that the input array is passed in by reference, which means modification to the input array will be known to the caller as well.
Internally you can think of this:
// nums is passed in by reference. (i.e., without making a copy)
int len = removeElement(nums, val);
// any modification to nums in your function would be known by the caller.
// using the length returned by your function, it prints the first len elements.
for (int i = 0; i < len; i++) {
print(nums[i]);
}
ref : https://leetcode.com/explore/learn/card/array-and-string/205/array-two-pointer-technique/1151/
*/
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
class Solution {
public:
int removeElement(vector<int>& nums, int val) {
// index 저장소 정의
vector<int> removeIndexVct;
// 오름차순 정렬
sort(nums.begin(), nums.end());
// 찾아서 삭제
for(int i = 0; i < nums.size(); i++){
if(nums[i] == val){
removeIndexVct.push_back(i);
}
}
for(int i = removeIndexVct.size() - 1; i > -1; i--){
nums.erase(nums.begin() + removeIndexVct[i]);
}
return nums.size();
}
};
int main() {
int numsArr[4] = {3,2,2,3};
vector<int> nums(numsArr, *(&numsArr + 1));
int val = 3;
Solution s;
int r = s.removeElement(nums, val);
return 0;
}
|
[
"eornrsayclub@gmail.com"
] |
eornrsayclub@gmail.com
|
ee7c17de38bfae05742667e6de587c9006096b3f
|
a82facec4d7111825c59c67a859825074823e6f7
|
/IGC/VectorCompiler/lib/Utils/GenX/Printf.cpp
|
4a9981337f5708584d19238c73ebf9cea20f1f24
|
[
"MIT"
] |
permissive
|
mfkiwl/intel-graphics-compiler-dp4a
|
f6f85313f1f62ffc86786fc7d3239d5366a015d1
|
9d3ddd2a85278b225930dac964427a0395c39c58
|
refs/heads/master
| 2023-04-02T17:24:52.035704
| 2021-05-21T02:17:42
| 2021-05-21T04:03:30
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 5,791
|
cpp
|
/*========================== begin_copyright_notice ============================
Copyright (C) 2021 Intel Corporation
SPDX-License-Identifier: MIT
============================= end_copyright_notice ===========================*/
#include "vc/Utils/GenX/Printf.h"
#include <llvm/GenXIntrinsics/GenXIntrinsics.h>
#include <llvm/ADT/Optional.h>
#include <llvm/ADT/STLExtras.h>
#include <llvm/ADT/StringRef.h>
#include <llvm/IR/Constants.h>
#include <llvm/IR/GlobalVariable.h>
#include <llvm/IR/Operator.h>
#include <llvm/IR/Value.h>
#include <llvm/Support/Casting.h>
#include <algorithm>
#include <iterator>
#include <regex>
#include <string>
#include "Probe/Assertion.h"
using namespace llvm;
using namespace vc;
// extracts underlying c-string from provided constant
static StringRef extractCStr(const Constant &CStrConst) {
if (isa<ConstantDataArray>(CStrConst))
return cast<ConstantDataArray>(CStrConst).getAsCString();
IGC_ASSERT(isa<ConstantAggregateZero>(CStrConst));
return "";
}
Optional<StringRef> vc::getConstStringFromOperandOptional(const Value &Op) {
IGC_ASSERT_MESSAGE(Op.getType()->isPointerTy(),
"wrong argument: pointer was expected");
IGC_ASSERT_MESSAGE(Op.getType()->getPointerElementType()->isIntegerTy(8),
"wrong argument: i8* value was expected");
if (!isa<GEPOperator>(Op))
return {};
auto *StrConst = cast<GEPOperator>(Op).getPointerOperand();
if (!isa<GlobalVariable>(StrConst))
return {};
return extractCStr(*cast<GlobalVariable>(StrConst)->getInitializer());
}
StringRef vc::getConstStringFromOperand(const Value &Op) {
auto FmtStr = getConstStringFromOperandOptional(Op);
IGC_ASSERT_MESSAGE(FmtStr.hasValue(),
"couldn't reach constexpr string through pointer operand");
return FmtStr.getValue();
}
using SRefMatch = std::match_results<StringRef::iterator>;
using SRefRegExIterator = std::regex_iterator<StringRef::iterator>;
// Given that \p ArgDesc describes integer conversion with signedness equal to
// \p IsSigned, defines which particular integer type is provided.
static PrintfArgInfo parseIntLengthModifier(StringRef ArgDesc, bool IsSigned) {
std::string Suffix{1u, ArgDesc.back()};
if (ArgDesc.endswith("hh" + Suffix))
return {PrintfArgInfo::Char, IsSigned};
if (ArgDesc.endswith("h" + Suffix))
return {PrintfArgInfo::Short, IsSigned};
if (ArgDesc.endswith("ll" + Suffix))
// TOTHINK: maybe we need a separate type ID for long long.
return {PrintfArgInfo::Long, IsSigned};
if (ArgDesc.endswith("l" + Suffix))
return {PrintfArgInfo::Long, IsSigned};
return {PrintfArgInfo::Int, IsSigned};
}
static StringRef toStringRef(SRefMatch Match) {
IGC_ASSERT_MESSAGE(!Match.empty(),
"wrong argument: matched string is expected");
return {Match[0].first, static_cast<std::size_t>(Match[0].length())};
}
// \p ArgDescMatch is a format string conversion specifier matched by a regex
// (some string that starts with % and ends with d,i,f,...).
static PrintfArgInfo parseArgDesc(SRefMatch ArgDescMatch) {
StringRef ArgDesc = toStringRef(ArgDescMatch);
if (ArgDesc.endswith("c"))
// FIXME: support %lc
return {PrintfArgInfo::Int, /* IsSigned */ true};
if (ArgDesc.endswith("s"))
// FIXME: support %ls
return {PrintfArgInfo::String, /* IsSigned */ false};
if (ArgDesc.endswith("d") || ArgDesc.endswith("i"))
return parseIntLengthModifier(ArgDesc, /* IsSigned */ true);
if (ArgDesc.endswith("o") || ArgDesc.endswith("u") ||
ArgDesc.endswith_lower("x"))
return parseIntLengthModifier(ArgDesc, /* IsSigned */ false);
if (ArgDesc.endswith_lower("f") || ArgDesc.endswith_lower("e") ||
ArgDesc.endswith_lower("a") || ArgDesc.endswith_lower("g"))
return {PrintfArgInfo::Double, /* IsSigned */ true};
IGC_ASSERT_MESSAGE(ArgDesc.endswith("p"), "unexpected conversion specifier");
return {PrintfArgInfo::Pointer, /* IsSigned */ false};
}
PrintfArgInfoSeq vc::parseFormatString(StringRef FmtStr) {
PrintfArgInfoSeq Args;
std::regex ArgDescRegEx{"%(?:%|.*?[csdioxXufFeEaAgGp])"};
auto &&ArgDescs = make_filter_range(
make_range(SRefRegExIterator{FmtStr.begin(), FmtStr.end(), ArgDescRegEx},
SRefRegExIterator{}),
[](SRefMatch ArgDesc) { return toStringRef(ArgDesc) != "%%"; });
transform(ArgDescs, std::back_inserter(Args),
[](SRefMatch ArgDesc) { return parseArgDesc(ArgDesc); });
return Args;
}
bool vc::isPrintFormatIndex(const User &Usr) {
return GenXIntrinsic::getGenXIntrinsicID(&Usr) ==
GenXIntrinsic::genx_print_format_index;
}
static bool isLegalPrintFormatIndexGEPImpl(const User &GEP) {
IGC_ASSERT_MESSAGE(
isa<GEPOperator>(GEP),
"wrong argument: gep instruction or gep constexpr are expected");
if (GEP.user_empty())
return false;
return std::all_of(GEP.user_begin(), GEP.user_end(),
[](const User *Usr) { return isPrintFormatIndex(*Usr); });
}
bool vc::isLegalPrintFormatIndexGEP(const GetElementPtrInst &GEP) {
return isLegalPrintFormatIndexGEPImpl(GEP);
}
bool vc::isLegalPrintFormatIndexGEP(const Value &V) {
if (isa<GetElementPtrInst>(V))
return isLegalPrintFormatIndexGEPImpl(cast<User>(V));
if (isa<ConstantExpr>(V) &&
cast<ConstantExpr>(V).getOpcode() == Instruction::GetElementPtr)
return isLegalPrintFormatIndexGEPImpl(cast<User>(V));
return false;
}
bool vc::isPrintFormatIndexGEP(const GEPOperator &GEP) {
return std::any_of(GEP.user_begin(), GEP.user_end(),
[](const User *Usr) { return isPrintFormatIndex(*Usr); });
}
bool vc::isPrintFormatIndexGEP(const User &Usr) {
if (!isa<GEPOperator>(Usr))
return false;
return isPrintFormatIndexGEP(cast<GEPOperator>(Usr));
}
|
[
"sys_igcbot@intel.com"
] |
sys_igcbot@intel.com
|
8a29594b18a3bfd282cf2f54d6f903ed3dfc9d31
|
6d3a70abecb8d5f706673ba7068bcd2b941fc84d
|
/Libraries/Dicom/dcm_value_ul.cpp
|
092320c3804318edf9f29b470ceecdd69521ba0d
|
[] |
no_license
|
MarcoTestDVTk/TestDVTk
|
352ab93c0d1ed154985fbad83ed6982029da66d1
|
c9202041090d6f68f5cdfd23db904592440fb365
|
refs/heads/master
| 2021-01-09T20:30:38.405636
| 2016-06-15T08:52:41
| 2016-06-15T08:52:41
| 61,128,764
| 0
| 1
| null | null | null | null |
WINDOWS-1252
|
C++
| false
| false
| 2,399
|
cpp
|
// ------------------------------------------------------
// DVTk - The Healthcare Validation Toolkit (www.dvtk.org)
// Copyright © 2009 DVTk
// ------------------------------------------------------
// This file is part of DVTk.
//
// DVTk is free software; you can redistribute it and/or modify it under the terms of the GNU
// Lesser General Public License as published by the Free Software Foundation; either version 3.0
// of the License, or (at your option) any later version.
//
// DVTk is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
// General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License along with this
// library; if not, see <http://www.gnu.org/licenses/>
//*****************************************************************************
// EXTERNAL DECLARATIONS
//*****************************************************************************
#include "dcm_value_ul.h"
//>>===========================================================================
DCM_VALUE_UL_CLASS::DCM_VALUE_UL_CLASS()
// DESCRIPTION : Constructor.
// PRECONDITIONS :
// POSTCONDITIONS :
// EXCEPTIONS :
// NOTES :
//<<===========================================================================
{
// constructor activities
identifierM = "";
}
//>>===========================================================================
DCM_VALUE_UL_CLASS::~DCM_VALUE_UL_CLASS()
// DESCRIPTION : Destructor.
// PRECONDITIONS :
// POSTCONDITIONS :
// EXCEPTIONS :
// NOTES :
//<<===========================================================================
{
// destructor activities
}
//>>===========================================================================
bool DCM_VALUE_UL_CLASS::operator = (DCM_VALUE_UL_CLASS& source)
// DESCRIPTION : Equal operator.
// PRECONDITIONS :
// POSTCONDITIONS :
// EXCEPTIONS :
// NOTES :
//<<===========================================================================
{
// copy all members
identifierM = source.identifierM;
UINT32 value;
source.Get(value);
Set(value);
return true;
}
|
[
"marco.kemper@dvtk.org"
] |
marco.kemper@dvtk.org
|
d1e448d44043d2b807c7a0e94bb239e93fad851f
|
a5db05a373f489d05a7f2b8e06d2805ee711de17
|
/android/hardware/aw/marlin/Include/Bento4/Core/Ap4Movie.h
|
99e7232a41818ffda71779be992c1abff19b6b14
|
[] |
no_license
|
BPI-SINOVOIP/BPI-H3-New-Android
|
7c0cdd50a23e62a204d4818954357868b4925945
|
5cbaa7ad4f73f615dcc4fbed07b52ae240743504
|
refs/heads/master
| 2023-02-25T15:43:36.633336
| 2018-07-18T10:56:14
| 2018-07-18T10:56:14
| 69,656,896
| 1
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,849
|
h
|
/*****************************************************************
|
| AP4 - Movie
|
| Copyright 2002-2008 Axiomatic Systems, LLC
|
|
| This file is part of Bento4/AP4 (MP4 Atom Processing Library).
|
| Unless you have obtained Bento4 under a difference license,
| this version of Bento4 is Bento4|GPL.
| Bento4|GPL is free software; you can redistribute it and/or modify
| it under the terms of the GNU General Public License as published by
| the Free Software Foundation; either version 2, or (at your option)
| any later version.
|
| Bento4|GPL is distributed in the hope that it will be useful,
| but WITHOUT ANY WARRANTY; without even the implied warranty of
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
| GNU General Public License for more details.
|
| You should have received a copy of the GNU General Public License
| along with Bento4|GPL; see the file COPYING. If not, write to the
| Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
| 02111-1307, USA.
|
****************************************************************/
#ifndef _AP4_MOVIE_H_
#define _AP4_MOVIE_H_
/*----------------------------------------------------------------------
| includes
+---------------------------------------------------------------------*/
#include "Ap4Types.h"
#include "Ap4MoovAtom.h"
#include "Ap4MvhdAtom.h"
#include "Ap4Track.h"
#include "Ap4List.h"
/*----------------------------------------------------------------------
| class references
+---------------------------------------------------------------------*/
class AP4_ByteStream;
class AP4_AtomInspector;
class AP4_MetaData;
/*----------------------------------------------------------------------
| AP4_Movie
+---------------------------------------------------------------------*/
class AP4_Movie {
public:
// methods
AP4_Movie(AP4_UI32 time_scale = 0);
AP4_Movie(AP4_MoovAtom* moov, AP4_ByteStream& sample_stream, bool transfer_moov_ownership = true);
virtual ~AP4_Movie();
AP4_Result Inspect(AP4_AtomInspector& inspector);
AP4_MoovAtom* GetMoovAtom() { return m_MoovAtom;}
AP4_MvhdAtom* GetMvhdAtom() { return m_MvhdAtom;}
AP4_List<AP4_Track>& GetTracks() { return m_Tracks; }
AP4_Track* GetTrack(AP4_UI32 track_id);
AP4_Track* GetTrack(AP4_Track::Type type, AP4_Ordinal index = 0);
AP4_Result AddTrack(AP4_Track* track);
AP4_UI32 GetTimeScale();
AP4_UI64 GetDuration();
AP4_UI32 GetDurationMs();
bool HasFragments();
private:
// members
AP4_MoovAtom* m_MoovAtom;
bool m_MoovAtomIsOwned;
AP4_MvhdAtom* m_MvhdAtom;
AP4_List<AP4_Track> m_Tracks;
};
#endif // _AP4_MOVIE_H_
|
[
"justin@justin-ThinkPad-T420.(none)"
] |
justin@justin-ThinkPad-T420.(none)
|
bc949847e11d14bab314ca201cacacfc9d95eaee
|
696e35ccdf167c3f6b1a7f5458406d3bb81987c9
|
/media/gpu/command_buffer_helper.h
|
13744e53e8f60d4e35fd712b720d5639bcef30d6
|
[
"BSD-3-Clause"
] |
permissive
|
mgh3326/iridium-browser
|
064e91a5e37f4e8501ea971483bd1c76297261c3
|
e7de6a434d2659f02e94917be364a904a442d2d0
|
refs/heads/master
| 2023-03-30T16:18:27.391772
| 2019-04-24T02:14:32
| 2019-04-24T02:14:32
| 183,128,065
| 0
| 0
|
BSD-3-Clause
| 2019-11-30T06:06:02
| 2019-04-24T02:04:51
| null |
UTF-8
|
C++
| false
| false
| 5,104
|
h
|
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef MEDIA_GPU_COMMAND_BUFFER_HELPER_H_
#define MEDIA_GPU_COMMAND_BUFFER_HELPER_H_
#include "base/callback_forward.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_refptr.h"
#include "gpu/command_buffer/common/mailbox.h"
#include "gpu/command_buffer/common/sync_token.h"
#include "media/gpu/media_gpu_export.h"
#include "ui/gl/gl_bindings.h"
namespace gpu {
class CommandBufferStub;
} // namespace gpu
namespace gl {
class GLContext;
class GLImage;
} // namespace gl
namespace media {
// TODO(sandersd): CommandBufferHelper does not inherently need to be ref
// counted, but some clients want that (VdaVideoDecoder and PictureBufferManager
// both hold a ref to the same CommandBufferHelper). Consider making an owned
// variant.
class MEDIA_GPU_EXPORT CommandBufferHelper
: public base::RefCountedThreadSafe<CommandBufferHelper> {
public:
REQUIRE_ADOPTION_FOR_REFCOUNTED_TYPE();
using WillDestroyStubCB = base::OnceCallback<void(bool have_context)>;
// TODO(sandersd): Consider adding an Initialize(stub) method so that
// CommandBufferHelpers can be created before a stub is available.
static scoped_refptr<CommandBufferHelper> Create(
gpu::CommandBufferStub* stub);
// Gets the associated GLContext.
//
// Used by DXVAVDA to test for D3D11 support, and by V4L2VDA to create
// EGLImages. New clients should use more specialized accessors instead.
virtual gl::GLContext* GetGLContext() = 0;
// Checks whether the stub has been destroyed.
virtual bool HasStub() = 0;
// Makes the GL context current.
virtual bool MakeContextCurrent() = 0;
// Creates a texture and returns its |service_id|.
//
// See glTexImage2D() for argument definitions.
//
// The texture will be configured as a video frame: linear filtering, clamp to
// edge. If |target| is GL_TEXTURE_2D, storage will be allocated but not
// initialized.
//
// It is up to the caller to initialize the texture before providing it to the
// renderer, else the results are undefined.
//
// The context must be current.
//
// TODO(sandersd): Is really necessary to allocate storage? GpuVideoDecoder
// does this, but it's not clear that any clients require it.
virtual GLuint CreateTexture(GLenum target,
GLenum internal_format,
GLsizei width,
GLsizei height,
GLenum format,
GLenum type) = 0;
// Destroys a texture.
//
// The context must be current.
virtual void DestroyTexture(GLuint service_id) = 0;
// Sets the cleared flag on level 0 of the texture.
virtual void SetCleared(GLuint service_id) = 0;
// Binds level 0 of the texture to an image.
//
// If the sampler binding already exists, set |client_managed| to true.
// Otherwise set it to false, and BindTexImage()/CopyTexImage() will be called
// when the texture is used.
virtual bool BindImage(GLuint service_id,
gl::GLImage* image,
bool client_managed) = 0;
// Creates a mailbox for a texture.
//
// TODO(sandersd): Specify the behavior when the stub has been destroyed. The
// current implementation returns an empty (zero) mailbox. One solution would
// be to add a HasStub() method, and not define behavior when it is false.
virtual gpu::Mailbox CreateMailbox(GLuint service_id) = 0;
// Produce a texture into a mailbox. The context does not have to be current.
// However, this will fail if the stub has been destroyed.
virtual void ProduceTexture(const gpu::Mailbox& mailbox,
GLuint service_id) = 0;
// Waits for a SyncToken, then runs |done_cb|.
//
// |done_cb| may be destructed without running if the stub is destroyed.
//
// TODO(sandersd): Currently it is possible to lose the stub while
// PictureBufferManager is waiting for all picture buffers, which results in a
// decoding softlock. Notification of wait failure (or just context/stub lost)
// is probably necessary.
virtual void WaitForSyncToken(gpu::SyncToken sync_token,
base::OnceClosure done_cb) = 0;
// Set the callback to be called when our stub is destroyed. This callback
// may not change the current context.
virtual void SetWillDestroyStubCB(WillDestroyStubCB will_destroy_stub_cb) = 0;
protected:
CommandBufferHelper() = default;
// TODO(sandersd): Deleting remaining textures upon destruction requires
// making the context current, which may be undesireable. Consider adding an
// explicit DestroyWithContext() API.
virtual ~CommandBufferHelper() = default;
private:
friend class base::RefCountedThreadSafe<CommandBufferHelper>;
DISALLOW_COPY_AND_ASSIGN(CommandBufferHelper);
};
} // namespace media
#endif // MEDIA_GPU_COMMAND_BUFFER_HELPER_H_
|
[
"commit-bot@chromium.org"
] |
commit-bot@chromium.org
|
694c62cad032361e5bc6d8f3ca915112cc8794a4
|
1fdbb7e551cf8b52b43359cf406bedd969b5f59f
|
/source/driversdk/driverupdate/MainTask.cpp
|
e16935b052868f2c5aa2acc8bc62981af02f2147
|
[] |
no_license
|
trigrass2/eview-server
|
1292958416ebe772ff4ce0b1f1639c65ca13ce92
|
a5e452016a730af79a1d402a3d918403eb6073aa
|
refs/heads/master
| 2023-06-17T09:38:25.004889
| 2021-07-15T09:45:56
| 2021-07-15T09:45:56
| null | 0
| 0
| null | null | null | null |
GB18030
|
C++
| false
| false
| 3,135
|
cpp
|
/**************************************************************
* Filename: RecvThread.cpp
* Copyright: Shanghai Peak InfoTech Co., Ltd.
*
* Description: 接收消息线程.
*
* @author: liuqifeng
* @version 04/13/2009 liuqifeng Initial Version
**************************************************************/
// RecvThread.cpp: implementation of the CRecvThread class.
//
//////////////////////////////////////////////////////////////////////
#include <ace/INET_Addr.h>
#include <ace/Log_Msg.h>
#include "ClientSockHandler.h"
#include "ace/Select_Reactor.h"
#include "ace/OS_NS_strings.h"
#include "MainTask.h"
#include "SystemConfig.h"
#include "common/pklog.h"
#include "SystemConfig.h"
#include "ace/SOCK_Connector.h"
extern CPKLog PKLog;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
//ACE_DLL g_dllforwardaccessor;
//PFN_ReadAllTagsInfo g_pfnReadAllTagsInfo = NULL;
//PFN_ReadAllTagsData g_pfnReadAllTagsData = NULL;
//PFN_ReleaseAllTagsInfo g_pfnReleaseAllTagsInfo = NULL;
#define DLLNAME_FORWARDACCESSOR "forwardaccessor"
CMainTask::CMainTask():m_cycleReader(this)
{
ACE_Select_Reactor *pSelectReactor = new ACE_Select_Reactor();
m_pReactor = new ACE_Reactor(pSelectReactor, 1);
reactor(m_pReactor);
}
CMainTask::~CMainTask()
{
if (m_pReactor != NULL)
{
delete m_pReactor;
m_pReactor = NULL;
}
}
//线程服务
int CMainTask::svc()
{
//long nErr = g_dllforwardaccessor.open(DLLNAME_FORWARDACCESSOR);
//if (nErr == 0)
//{
// PKLog.LogMessage(PK_LOGLEVEL_NOTICE, " load Module %s 成功", DLLNAME_FORWARDACCESSOR);
//}
//else
// PKLog.LogMessage(PK_LOGLEVEL_ERROR, " load Module %s 失败", DLLNAME_FORWARDACCESSOR);
//// 导入初始化函数
//g_pfnReadAllTagsInfo = (PFN_ReadAllTagsInfo)g_dllforwardaccessor.symbol("ReadAllTagsInfo");
//if(g_pfnReadAllTagsInfo == NULL)
//{
// PKLog.LogMessage(PK_LOGLEVEL_ERROR, " 从%s 获取导出函数%s失败",g_dllforwardaccessor.dll_name_, "ReadAllTagsInfo");
//}
//g_pfnReadAllTagsData = (PFN_ReadAllTagsData)g_dllforwardaccessor.symbol("ReadAllTagsData");
//if(g_pfnReadAllTagsData == NULL)
//{
// PKLog.LogMessage(PK_LOGLEVEL_ERROR, " 从%s 获取导出函数%s失败",g_dllforwardaccessor.dll_name_, "ReadAllTagsData");
//}
//g_pfnReleaseAllTagsInfo = (PFN_ReleaseAllTagsInfo)g_dllforwardaccessor.symbol("ReleaseAllTagsInfo");
//if(g_pfnReleaseAllTagsInfo == NULL)
//{
// PKLog.LogMessage(PK_LOGLEVEL_ERROR, " 从%s 获取导出函数%s失败",g_dllforwardaccessor.dll_name_, "ReleaseAllTagsInfo");
//}
this->reactor()->owner(ACE_OS::thr_self ());
m_cycleReader.m_nPollRate = SYSTEM_CONFIG->m_nCycleMS;
m_cycleReader.StartTimer();
this->reactor()->reset_reactor_event_loop();
this->reactor()->run_reactor_event_loop();
m_cycleReader.StopTimer();
return 0;
}
void CMainTask::Stop()
{
// 发出关闭响应起得请求
this->reactor()->end_reactor_event_loop();
// 等待响应器关闭后退出
this->wait();
}
int CMainTask::Start()
{
return this->activate();
}
|
[
"746257224@qq.com"
] |
746257224@qq.com
|
f3824b4bac7b5187c5b567a08ac775f2bc9b0271
|
286a310a00923d5e2cec35d9630aedb34dafcdb9
|
/swagger/sdrangel/code/qt5/client/SWGBladeRF2InputReport.cpp
|
5f3e7d89eb985f9fc54af21f59ed1bf7f715a35b
|
[] |
no_license
|
agrawalharshit/sdrangel
|
a98b6565db7484324786898d59ca9c6f1bb6f19b
|
13eae0d8fe6119397177871b8c66ab073255a9d7
|
refs/heads/master
| 2020-04-14T22:10:24.515807
| 2019-01-01T17:57:41
| 2019-01-01T17:57:41
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 7,153
|
cpp
|
/**
* SDRangel
* This is the web REST/JSON API of SDRangel SDR software. SDRangel is an Open Source Qt5/OpenGL 3.0+ (4.3+ in Windows) GUI and server Software Defined Radio and signal analyzer in software. It supports Airspy, BladeRF, HackRF, LimeSDR, PlutoSDR, RTL-SDR, SDRplay RSP1 and FunCube --- Limitations and specifcities: * In SDRangel GUI the first Rx device set cannot be deleted. Conversely the server starts with no device sets and its number of device sets can be reduced to zero by as many calls as necessary to /sdrangel/deviceset with DELETE method. * Preset import and export from/to file is a server only feature. * Device set focus is a GUI only feature. * The following channels are not implemented (status 501 is returned): ATV and DATV demodulators, Channel Analyzer NG, LoRa demodulator * The device settings and report structures contains only the sub-structure corresponding to the device type. The DeviceSettings and DeviceReport structures documented here shows all of them but only one will be or should be present at a time * The channel settings and report structures contains only the sub-structure corresponding to the channel type. The ChannelSettings and ChannelReport structures documented here shows all of them but only one will be or should be present at a time ---
*
* OpenAPI spec version: 4.3.0
* Contact: f4exb06@gmail.com
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
#include "SWGBladeRF2InputReport.h"
#include "SWGHelpers.h"
#include <QJsonDocument>
#include <QJsonArray>
#include <QObject>
#include <QDebug>
namespace SWGSDRangel {
SWGBladeRF2InputReport::SWGBladeRF2InputReport(QString* json) {
init();
this->fromJson(*json);
}
SWGBladeRF2InputReport::SWGBladeRF2InputReport() {
frequency_range = nullptr;
m_frequency_range_isSet = false;
sample_rate_range = nullptr;
m_sample_rate_range_isSet = false;
bandwidth_range = nullptr;
m_bandwidth_range_isSet = false;
global_gain_range = nullptr;
m_global_gain_range_isSet = false;
gain_modes = nullptr;
m_gain_modes_isSet = false;
}
SWGBladeRF2InputReport::~SWGBladeRF2InputReport() {
this->cleanup();
}
void
SWGBladeRF2InputReport::init() {
frequency_range = new SWGFrequencyRange();
m_frequency_range_isSet = false;
sample_rate_range = new SWGRange();
m_sample_rate_range_isSet = false;
bandwidth_range = new SWGRange();
m_bandwidth_range_isSet = false;
global_gain_range = new SWGRange();
m_global_gain_range_isSet = false;
gain_modes = new QList<SWGNamedEnum*>();
m_gain_modes_isSet = false;
}
void
SWGBladeRF2InputReport::cleanup() {
if(frequency_range != nullptr) {
delete frequency_range;
}
if(sample_rate_range != nullptr) {
delete sample_rate_range;
}
if(bandwidth_range != nullptr) {
delete bandwidth_range;
}
if(global_gain_range != nullptr) {
delete global_gain_range;
}
if(gain_modes != nullptr) {
auto arr = gain_modes;
for(auto o: *arr) {
delete o;
}
delete gain_modes;
}
}
SWGBladeRF2InputReport*
SWGBladeRF2InputReport::fromJson(QString &json) {
QByteArray array (json.toStdString().c_str());
QJsonDocument doc = QJsonDocument::fromJson(array);
QJsonObject jsonObject = doc.object();
this->fromJsonObject(jsonObject);
return this;
}
void
SWGBladeRF2InputReport::fromJsonObject(QJsonObject &pJson) {
::SWGSDRangel::setValue(&frequency_range, pJson["frequencyRange"], "SWGFrequencyRange", "SWGFrequencyRange");
::SWGSDRangel::setValue(&sample_rate_range, pJson["sampleRateRange"], "SWGRange", "SWGRange");
::SWGSDRangel::setValue(&bandwidth_range, pJson["bandwidthRange"], "SWGRange", "SWGRange");
::SWGSDRangel::setValue(&global_gain_range, pJson["globalGainRange"], "SWGRange", "SWGRange");
::SWGSDRangel::setValue(&gain_modes, pJson["gainModes"], "QList", "SWGNamedEnum");
}
QString
SWGBladeRF2InputReport::asJson ()
{
QJsonObject* obj = this->asJsonObject();
QJsonDocument doc(*obj);
QByteArray bytes = doc.toJson();
delete obj;
return QString(bytes);
}
QJsonObject*
SWGBladeRF2InputReport::asJsonObject() {
QJsonObject* obj = new QJsonObject();
if((frequency_range != nullptr) && (frequency_range->isSet())){
toJsonValue(QString("frequencyRange"), frequency_range, obj, QString("SWGFrequencyRange"));
}
if((sample_rate_range != nullptr) && (sample_rate_range->isSet())){
toJsonValue(QString("sampleRateRange"), sample_rate_range, obj, QString("SWGRange"));
}
if((bandwidth_range != nullptr) && (bandwidth_range->isSet())){
toJsonValue(QString("bandwidthRange"), bandwidth_range, obj, QString("SWGRange"));
}
if((global_gain_range != nullptr) && (global_gain_range->isSet())){
toJsonValue(QString("globalGainRange"), global_gain_range, obj, QString("SWGRange"));
}
if(gain_modes->size() > 0){
toJsonArray((QList<void*>*)gain_modes, obj, "gainModes", "SWGNamedEnum");
}
return obj;
}
SWGFrequencyRange*
SWGBladeRF2InputReport::getFrequencyRange() {
return frequency_range;
}
void
SWGBladeRF2InputReport::setFrequencyRange(SWGFrequencyRange* frequency_range) {
this->frequency_range = frequency_range;
this->m_frequency_range_isSet = true;
}
SWGRange*
SWGBladeRF2InputReport::getSampleRateRange() {
return sample_rate_range;
}
void
SWGBladeRF2InputReport::setSampleRateRange(SWGRange* sample_rate_range) {
this->sample_rate_range = sample_rate_range;
this->m_sample_rate_range_isSet = true;
}
SWGRange*
SWGBladeRF2InputReport::getBandwidthRange() {
return bandwidth_range;
}
void
SWGBladeRF2InputReport::setBandwidthRange(SWGRange* bandwidth_range) {
this->bandwidth_range = bandwidth_range;
this->m_bandwidth_range_isSet = true;
}
SWGRange*
SWGBladeRF2InputReport::getGlobalGainRange() {
return global_gain_range;
}
void
SWGBladeRF2InputReport::setGlobalGainRange(SWGRange* global_gain_range) {
this->global_gain_range = global_gain_range;
this->m_global_gain_range_isSet = true;
}
QList<SWGNamedEnum*>*
SWGBladeRF2InputReport::getGainModes() {
return gain_modes;
}
void
SWGBladeRF2InputReport::setGainModes(QList<SWGNamedEnum*>* gain_modes) {
this->gain_modes = gain_modes;
this->m_gain_modes_isSet = true;
}
bool
SWGBladeRF2InputReport::isSet(){
bool isObjectUpdated = false;
do{
if(frequency_range != nullptr && frequency_range->isSet()){ isObjectUpdated = true; break;}
if(sample_rate_range != nullptr && sample_rate_range->isSet()){ isObjectUpdated = true; break;}
if(bandwidth_range != nullptr && bandwidth_range->isSet()){ isObjectUpdated = true; break;}
if(global_gain_range != nullptr && global_gain_range->isSet()){ isObjectUpdated = true; break;}
if(gain_modes->size() > 0){ isObjectUpdated = true; break;}
}while(false);
return isObjectUpdated;
}
}
|
[
"f4exb06@gmail.com"
] |
f4exb06@gmail.com
|
26f3cabdbf00c6736e2e8b401a5599c6e2390cfb
|
cefd6c17774b5c94240d57adccef57d9bba4a2e9
|
/WebKit/Source/WebCore/platform/graphics/ca/win/CACFLayerTreeHost.cpp
|
5e5411a49d6620f22bfb1f32486953b769aa88c9
|
[
"BSL-1.0",
"BSD-2-Clause",
"LGPL-2.0-only",
"LGPL-2.1-only"
] |
permissive
|
adzhou/oragle
|
9c054c25b24ff0a65cb9639bafd02aac2bcdce8b
|
5442d418b87d0da161429ffa5cb83777e9b38e4d
|
refs/heads/master
| 2022-11-01T05:04:59.368831
| 2014-03-12T15:50:08
| 2014-03-12T15:50:08
| 17,238,063
| 0
| 1
|
BSL-1.0
| 2022-10-18T04:23:53
| 2014-02-27T05:39:44
|
C++
|
UTF-8
|
C++
| false
| false
| 10,237
|
cpp
|
/*
* Copyright (C) 2009, 2013 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "CACFLayerTreeHost.h"
#include "CACFLayerTreeHostClient.h"
#include "DefWndProcWindowClass.h"
#include "LayerChangesFlusher.h"
#include "LegacyCACFLayerTreeHost.h"
#include "PlatformCALayerWin.h"
#include "WKCACFViewLayerTreeHost.h"
#include "WebCoreInstanceHandle.h"
#include <limits.h>
#include <QuartzCore/CABase.h>
#include <wtf/CurrentTime.h>
#include <wtf/StdLibExtras.h>
#include <wtf/win/GDIObject.h>
#ifdef DEBUG_ALL
#pragma comment(lib, "QuartzCore_debug")
#else
#pragma comment(lib, "QuartzCore")
#endif
inline static CGRect winRectToCGRect(RECT rc)
{
return CGRectMake(rc.left, rc.top, (rc.right - rc.left), (rc.bottom - rc.top));
}
inline static CGRect winRectToCGRect(RECT rc, RECT relativeToRect)
{
return CGRectMake(rc.left, (relativeToRect.bottom-rc.bottom), (rc.right - rc.left), (rc.bottom - rc.top));
}
namespace WebCore {
bool CACFLayerTreeHost::acceleratedCompositingAvailable()
{
static bool available;
static bool tested;
if (tested)
return available;
tested = true;
// Initialize available to true since this function will be called from a
// propagation within createRenderer(). We want to be able to return true
// when that happens so that the test can continue.
available = true;
HMODULE library = LoadLibrary(TEXT("d3d9.dll"));
if (!library) {
available = false;
return available;
}
FreeLibrary(library);
#ifdef DEBUG_ALL
library = LoadLibrary(TEXT("QuartzCore_debug.dll"));
#else
library = LoadLibrary(TEXT("QuartzCore.dll"));
#endif
if (!library) {
available = false;
return available;
}
FreeLibrary(library);
// Make a dummy HWND.
HWND testWindow = ::CreateWindow(defWndProcWindowClassName(), L"CoreAnimationTesterWindow", WS_POPUP, -500, -500, 20, 20, 0, 0, 0, 0);
if (!testWindow) {
available = false;
return available;
}
RefPtr<CACFLayerTreeHost> host = CACFLayerTreeHost::create();
host->setWindow(testWindow);
available = host->createRenderer();
host->setWindow(0);
::DestroyWindow(testWindow);
return available;
}
PassRefPtr<CACFLayerTreeHost> CACFLayerTreeHost::create()
{
if (!acceleratedCompositingAvailable())
return 0;
RefPtr<CACFLayerTreeHost> host = WKCACFViewLayerTreeHost::create();
if (!host)
host = LegacyCACFLayerTreeHost::create();
host->initialize();
return host.release();
}
CACFLayerTreeHost::CACFLayerTreeHost()
: m_client(0)
, m_rootLayer(PlatformCALayerWin::create(PlatformCALayer::LayerTypeRootLayer, 0))
, m_window(0)
, m_shouldFlushPendingGraphicsLayerChanges(false)
, m_isFlushingLayerChanges(false)
#if !ASSERT_DISABLED
, m_state(WindowNotSet)
#endif
{
}
void CACFLayerTreeHost::initialize()
{
// Point the CACFContext to this
initializeContext(this, m_rootLayer.get());
// Under the root layer, we have a clipping layer to clip the content,
// that contains a scroll layer that we use for scrolling the content.
// The root layer is the size of the client area of the window.
// The clipping layer is the size of the WebView client area (window less the scrollbars).
// The scroll layer is the size of the root child layer.
// Resizing the window will change the bounds of the rootLayer and the clip layer and will not
// cause any repositioning.
// Scrolling will affect only the position of the scroll layer without affecting the bounds.
m_rootLayer->setName("CACFLayerTreeHost rootLayer");
m_rootLayer->setAnchorPoint(FloatPoint3D(0, 0, 0));
m_rootLayer->setGeometryFlipped(true);
#ifndef NDEBUG
CGColorRef debugColor = CGColorCreateGenericRGB(1, 0, 0, 0.8);
m_rootLayer->setBackgroundColor(debugColor);
CGColorRelease(debugColor);
#endif
}
CACFLayerTreeHost::~CACFLayerTreeHost()
{
ASSERT_WITH_MESSAGE(m_state != WindowSet, "Must call setWindow(0) before destroying CACFLayerTreeHost");
}
void CACFLayerTreeHost::setWindow(HWND window)
{
if (window == m_window)
return;
#if !ASSERT_DISABLED
switch (m_state) {
case WindowNotSet:
ASSERT_ARG(window, window);
ASSERT(!m_window);
m_state = WindowSet;
break;
case WindowSet:
ASSERT_ARG(window, !window);
ASSERT(m_window);
m_state = WindowCleared;
break;
case WindowCleared:
ASSERT_NOT_REACHED();
break;
}
#endif
if (m_window)
destroyRenderer();
m_window = window;
}
PlatformCALayer* CACFLayerTreeHost::rootLayer() const
{
return m_rootLayer.get();
}
void CACFLayerTreeHost::addPendingAnimatedLayer(PassRefPtr<PlatformCALayer> layer)
{
m_pendingAnimatedLayers.add(layer);
}
void CACFLayerTreeHost::setRootChildLayer(PlatformCALayer* layer)
{
m_rootLayer->removeAllSublayers();
m_rootChildLayer = layer;
if (m_rootChildLayer)
m_rootLayer->appendSublayer(m_rootChildLayer.get());
}
void CACFLayerTreeHost::layerTreeDidChange()
{
if (m_isFlushingLayerChanges) {
// The layer tree is changing as a result of flushing GraphicsLayer changes to their
// underlying PlatformCALayers. We'll flush those changes to the context as part of that
// process, so there's no need to schedule another flush here.
return;
}
// The layer tree is changing as a result of someone modifying a PlatformCALayer that doesn't
// have a corresponding GraphicsLayer. Schedule a flush since we won't schedule one through the
// normal GraphicsLayer mechanisms.
LayerChangesFlusher::shared().flushPendingLayerChangesSoon(this);
}
void CACFLayerTreeHost::destroyRenderer()
{
m_rootLayer = 0;
m_rootChildLayer = 0;
LayerChangesFlusher::shared().cancelPendingFlush(this);
}
static void getDirtyRects(HWND window, Vector<CGRect>& outRects)
{
ASSERT_ARG(outRects, outRects.isEmpty());
RECT clientRect;
if (!GetClientRect(window, &clientRect))
return;
auto region = adoptGDIObject(::CreateRectRgn(0, 0, 0, 0));
int regionType = GetUpdateRgn(window, region.get(), false);
if (regionType != COMPLEXREGION) {
RECT dirtyRect;
if (GetUpdateRect(window, &dirtyRect, false))
outRects.append(winRectToCGRect(dirtyRect, clientRect));
return;
}
DWORD dataSize = ::GetRegionData(region.get(), 0, 0);
auto regionDataBuffer = std::make_unique<unsigned char[]>(dataSize);
RGNDATA* regionData = reinterpret_cast<RGNDATA*>(regionDataBuffer.get());
if (!::GetRegionData(region.get(), dataSize, regionData))
return;
outRects.resize(regionData->rdh.nCount);
RECT* rect = reinterpret_cast<RECT*>(regionData->Buffer);
for (size_t i = 0; i < outRects.size(); ++i, ++rect)
outRects[i] = winRectToCGRect(*rect, clientRect);
}
void CACFLayerTreeHost::paint()
{
Vector<CGRect> dirtyRects;
getDirtyRects(m_window, dirtyRects);
render(dirtyRects);
}
void CACFLayerTreeHost::flushPendingGraphicsLayerChangesSoon()
{
m_shouldFlushPendingGraphicsLayerChanges = true;
LayerChangesFlusher::shared().flushPendingLayerChangesSoon(this);
}
void CACFLayerTreeHost::setShouldInvertColors(bool)
{
}
void CACFLayerTreeHost::flushPendingLayerChangesNow()
{
// Calling out to the client could cause our last reference to go away.
RefPtr<CACFLayerTreeHost> protector(this);
m_isFlushingLayerChanges = true;
// Flush changes stored up in GraphicsLayers to their underlying PlatformCALayers, if
// requested.
if (m_client && m_shouldFlushPendingGraphicsLayerChanges) {
m_shouldFlushPendingGraphicsLayerChanges = false;
m_client->flushPendingGraphicsLayerChanges();
}
// Flush changes stored up in PlatformCALayers to the context so they will be rendered.
flushContext();
m_isFlushingLayerChanges = false;
}
void CACFLayerTreeHost::contextDidChange()
{
// All pending animations will have been started with the flush. Fire the animationStarted calls.
notifyAnimationsStarted();
}
void CACFLayerTreeHost::notifyAnimationsStarted()
{
// Send currentTime to the pending animations. This function is called by CACF in a callback
// which occurs after the drawInContext calls. So currentTime is very close to the time
// the animations actually start
double currentTime = monotonicallyIncreasingTime();
HashSet<RefPtr<PlatformCALayer> >::iterator end = m_pendingAnimatedLayers.end();
for (HashSet<RefPtr<PlatformCALayer> >::iterator it = m_pendingAnimatedLayers.begin(); it != end; ++it)
(*it)->animationStarted(currentTime);
m_pendingAnimatedLayers.clear();
}
CGRect CACFLayerTreeHost::bounds() const
{
RECT clientRect;
GetClientRect(m_window, &clientRect);
return winRectToCGRect(clientRect);
}
}
|
[
"adzhou@hp.com"
] |
adzhou@hp.com
|
74fab5f8cb799a4218a67b6a2de342d93740dd2a
|
dd80a584130ef1a0333429ba76c1cee0eb40df73
|
/ndk/sources/cxx-stl/llvm-libc++/libcxx/include/__debug
|
0d631bf043861e545592bab8ec955585b5071ef1
|
[
"MIT",
"NCSA"
] |
permissive
|
karunmatharu/Android-4.4-Pay-by-Data
|
466f4e169ede13c5835424c78e8c30ce58f885c1
|
fcb778e92d4aad525ef7a995660580f948d40bc9
|
refs/heads/master
| 2021-03-24T13:33:01.721868
| 2017-02-18T17:48:49
| 2017-02-18T17:48:49
| 81,847,777
| 0
| 2
|
MIT
| 2020-03-09T00:02:12
| 2017-02-13T16:47:00
| null |
UTF-8
|
C++
| false
| false
| 5,259
|
// -*- C++ -*-
//===--------------------------- __debug ----------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_DEBUG_H
#define _LIBCPP_DEBUG_H
#if _LIBCPP_DEBUG_LEVEL >= 1
# include <cstdlib>
# include <cstdio>
# include <cstddef>
# ifndef _LIBCPP_ASSERT
# define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : (_VSTD::printf("%s\n", m), _VSTD::abort()))
# endif
#endif
#if _LIBCPP_DEBUG_LEVEL >= 2
_LIBCPP_BEGIN_NAMESPACE_STD
struct _LIBCPP_TYPE_VIS __c_node;
struct _LIBCPP_TYPE_VIS __i_node
{
void* __i_;
__i_node* __next_;
__c_node* __c_;
__i_node(const __i_node&) = delete;
__i_node& operator=(const __i_node&) = delete;
_LIBCPP_INLINE_VISIBILITY
__i_node(void* __i, __i_node* __next, __c_node* __c)
: __i_(__i), __next_(__next), __c_(__c) {}
~__i_node();
};
struct _LIBCPP_TYPE_VIS __c_node
{
void* __c_;
__c_node* __next_;
__i_node** beg_;
__i_node** end_;
__i_node** cap_;
__c_node(const __c_node&) = delete;
__c_node& operator=(const __c_node&) = delete;
_LIBCPP_INLINE_VISIBILITY
__c_node(void* __c, __c_node* __next)
: __c_(__c), __next_(__next), beg_(nullptr), end_(nullptr), cap_(nullptr) {}
virtual ~__c_node();
virtual bool __dereferenceable(const void*) const = 0;
virtual bool __decrementable(const void*) const = 0;
virtual bool __addable(const void*, ptrdiff_t) const = 0;
virtual bool __subscriptable(const void*, ptrdiff_t) const = 0;
void __add(__i_node* __i);
_LIBCPP_HIDDEN void __remove(__i_node* __i);
};
template <class _Cont>
struct _C_node
: public __c_node
{
_C_node(void* __c, __c_node* __n)
: __c_node(__c, __n) {}
virtual bool __dereferenceable(const void*) const;
virtual bool __decrementable(const void*) const;
virtual bool __addable(const void*, ptrdiff_t) const;
virtual bool __subscriptable(const void*, ptrdiff_t) const;
};
template <class _Cont>
bool
_C_node<_Cont>::__dereferenceable(const void* __i) const
{
typedef typename _Cont::const_iterator iterator;
const iterator* __j = static_cast<const iterator*>(__i);
_Cont* _Cp = static_cast<_Cont*>(__c_);
return _Cp->__dereferenceable(__j);
}
template <class _Cont>
bool
_C_node<_Cont>::__decrementable(const void* __i) const
{
typedef typename _Cont::const_iterator iterator;
const iterator* __j = static_cast<const iterator*>(__i);
_Cont* _Cp = static_cast<_Cont*>(__c_);
return _Cp->__decrementable(__j);
}
template <class _Cont>
bool
_C_node<_Cont>::__addable(const void* __i, ptrdiff_t __n) const
{
typedef typename _Cont::const_iterator iterator;
const iterator* __j = static_cast<const iterator*>(__i);
_Cont* _Cp = static_cast<_Cont*>(__c_);
return _Cp->__addable(__j, __n);
}
template <class _Cont>
bool
_C_node<_Cont>::__subscriptable(const void* __i, ptrdiff_t __n) const
{
typedef typename _Cont::const_iterator iterator;
const iterator* __j = static_cast<const iterator*>(__i);
_Cont* _Cp = static_cast<_Cont*>(__c_);
return _Cp->__subscriptable(__j, __n);
}
class _LIBCPP_TYPE_VIS __libcpp_db
{
__c_node** __cbeg_;
__c_node** __cend_;
size_t __csz_;
__i_node** __ibeg_;
__i_node** __iend_;
size_t __isz_;
__libcpp_db();
public:
__libcpp_db(const __libcpp_db&) = delete;
__libcpp_db& operator=(const __libcpp_db&) = delete;
~__libcpp_db();
class __db_c_iterator;
class __db_c_const_iterator;
class __db_i_iterator;
class __db_i_const_iterator;
__db_c_const_iterator __c_end() const;
__db_i_const_iterator __i_end() const;
template <class _Cont>
_LIBCPP_INLINE_VISIBILITY
void __insert_c(_Cont* __c)
{
__c_node* __n = __insert_c(static_cast<void*>(__c));
::new(__n) _C_node<_Cont>(__n->__c_, __n->__next_);
}
void __insert_i(void* __i);
__c_node* __insert_c(void* __c);
void __erase_c(void* __c);
void __insert_ic(void* __i, const void* __c);
void __iterator_copy(void* __i, const void* __i0);
void __erase_i(void* __i);
void* __find_c_from_i(void* __i) const;
void __invalidate_all(void* __c);
__c_node* __find_c_and_lock(void* __c) const;
__c_node* __find_c(void* __c) const;
void unlock() const;
void swap(void* __c1, void* __c2);
bool __dereferenceable(const void* __i) const;
bool __decrementable(const void* __i) const;
bool __addable(const void* __i, ptrdiff_t __n) const;
bool __subscriptable(const void* __i, ptrdiff_t __n) const;
bool __comparable(const void* __i, const void* __j) const;
private:
_LIBCPP_HIDDEN
__i_node* __insert_iterator(void* __i);
_LIBCPP_HIDDEN
__i_node* __find_iterator(const void* __i) const;
friend _LIBCPP_FUNC_VIS __libcpp_db* __get_db();
};
_LIBCPP_FUNC_VIS __libcpp_db* __get_db();
_LIBCPP_FUNC_VIS const __libcpp_db* __get_const_db();
_LIBCPP_END_NAMESPACE_STD
#endif
#endif // _LIBCPP_DEBUG_H
|
[
"karun.matharu@gmail.com"
] |
karun.matharu@gmail.com
|
|
5fe58ea5c94898f78cec3ab075f98b3946bd3d09
|
7a2425190626dd2e75dd6cbca9fe47727afbad42
|
/cxxrt-source/testsuite/cxxrt.conformance/loc-22-1-1-1-2.exp
|
6e7811bbb191abfa7c380b7b675f544801d11e31
|
[] |
no_license
|
dietmarkuehl/kuhllib
|
fadd4073c9b09992479e92112ef34c367cb90fad
|
482ddc2b910870398a9a2bcaa0a77a145e081f78
|
refs/heads/main
| 2023-08-31T22:13:02.079530
| 2023-08-21T22:14:14
| 2023-08-21T22:14:14
| 3,148,966
| 71
| 7
| null | 2023-08-21T22:14:15
| 2012-01-10T21:49:09
|
C++
|
UTF-8
|
C++
| false
| false
| 2,304
|
exp
|
#!/usr/local/bin/expect
# -*-C++-*- loc-22-1-1-1-2.exp -- C++ is actually a lie but it helps
# --------------------------------------------------------------------------
# Copyright (c) 2002 Dietmar Kuehl
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject
# to the following conditions:
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# --------------------------------------------------------------------------
# Author: Dietmar Kuehl <http://www.dietmar-kuehl.de/>
# Title: Class locale::facet
# Version: $Id: loc-22-1-1-1-2.exp,v 1.1.1.1 2002/06/05 01:02:57 dietmar_kuehl Exp $
# --------------------------------------------------------------------------
inline_compile {
#include <iostream>
#include <locale>
#include <cstdlib>
#if !defined(_CXXRT_STD_NAME)
# define STD std::
#else
# define STD _CXXRT_STD_NAME::
#endif
class facet: public STD locale::facet
{
public:
static STD locale::id id;
facet(): STD locale::facet(), refs(0) {}
explicit facet(STD size_t r): STD locale::facet(r), refs(r) {}
~facet() { STD cout << "dtor: " << static_cast<int>(refs) << "\n"; }
private:
STD size_t refs;
};
STD locale::id facet::id;
int main(int, char *[])
{
STD locale l;
STD locale l1(l, new facet);
STD locale l2(l, new facet(1));
return 0;
}
}
simple_test "locale::facet refcount" "" {
dtor: 0
}
|
[
"dietmar.kuehl@me.com"
] |
dietmar.kuehl@me.com
|
d33bfa4018a480130c2d6f65c12a4c968874e7ee
|
9c875e2e2a425a62ee0ffb148e701342c142a029
|
/src/Saurobyte/AudioStream.hpp
|
8a10bfebf72696ed124bf8a1847071851aa433ce
|
[
"MIT"
] |
permissive
|
Symphonym/Saurobyte
|
4b80e587517d8108a7ac4d60f17ec7518a693c48
|
c4bc5afd4ac4353ed6cd9a201454fd14aa3aced2
|
refs/heads/master
| 2016-08-05T13:26:18.701701
| 2014-07-13T00:46:06
| 2014-07-13T00:46:06
| 17,995,418
| 19
| 2
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,919
|
hpp
|
/*
The MIT License (MIT)
Copyright (c) 2014 by Jakob Larsson
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef SAUROBYTE_AUDIOSTREAM_HPP
#define SAUROBYTE_AUDIOSTREAM_HPP
#include <Saurobyte/AudioSource.hpp>
#include <array>
#include <thread>
namespace Saurobyte
{
class AudioStream : public AudioSource
{
public:
explicit AudioStream(AudioSource::AudioFilePtr audioPtr, std::uint32_t newSource);
~AudioStream();
virtual void play();
virtual void pause();
virtual void stop();
virtual void setLooping(bool looping);
virtual void setOffset(Time offset);
virtual Time getOffset() const;
virtual bool isLooping() const;
private:
bool m_loop;
bool m_requestStop;
Time m_playingOffset;
std::thread m_thread;
// Array of OpenAL buffer handles
std::array<AudioSource::BufferWrapper, 3> m_buffers;
void processStream();
void prepareStreaming();
};
};
#endif
|
[
"symphonymdev@gmail.com"
] |
symphonymdev@gmail.com
|
0af9d676ad79790b86e906672ea473f80ec9a7af
|
2e26bbbbe3801eccf026fdb44fa16497c51de5fd
|
/bank.h
|
c450f1df3f77f324144666771185a46671a03a86
|
[] |
no_license
|
Mordequess/a6
|
aad3b3e28c81d56f723eda692573260193b13aeb
|
0bc869505fb9b30584d817f584063b9f446ce65e
|
refs/heads/master
| 2021-01-10T15:49:35.695324
| 2015-12-07T02:09:30
| 2015-12-07T02:09:30
| 47,424,905
| 0
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 446
|
h
|
#ifndef BANK_H
#define BANK_H
#include <vector>
_Monitor Bank {
uCondition insufficientFunds; // waiting on deposits
unsigned int waiters; // number of people waiting
std::vector<unsigned int> studentAccounts; // the student accounts
public:
Bank( unsigned int numStudents );
void deposit( unsigned int id, unsigned int amount );
void withdraw( unsigned int id, unsigned int amount );
};
#endif
|
[
"t.babaran@gmail.com"
] |
t.babaran@gmail.com
|
513eede9c8b5ce0e2cb0c3edec392634932be424
|
4a6e20a36f5b6b7fa34fdb2c465969e3425d67c0
|
/VulkanProject/Utilities.h
|
c0f12445ccfee201ee77de1edc8dc2f3880e0224
|
[] |
no_license
|
axsaucedo/VulkanWrapper
|
0aec4b4839357bb3667f8dddb05f3c9a19cdddd1
|
42a244db8fef3fdf99ea7a5b80a5420881194bff
|
refs/heads/master
| 2022-11-23T18:43:14.420896
| 2020-07-28T08:16:34
| 2020-07-28T08:16:34
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 11,747
|
h
|
#pragma once
#include <fstream>
#define GLFW_INCLUDE_VULKAN
#include <GLFW/glfw3.h>
#include <glm/glm.hpp>
const int MAX_FRAME_DRAWS = 2;
const int MAX_OBJECTS = 20;
const std::vector<const char*> deviceExtensions = {
VK_KHR_SWAPCHAIN_EXTENSION_NAME
};
struct Vertex
{
glm::vec3 pos; // Vertex position (x, y, z)
glm::vec3 col; // Vertex colour (r, g, b)
glm::vec2 tex; // Texture coords (u, v)
};
// Indices (locations) of queue families (if they exist at all)
struct QueueFamilyIndices {
int graphicsFamily = -1; // Location of Graphics Queue Family
int presentationFamily = -1; // Location of presentation queue family
// Check if queue families are valid
bool isValid() {
return graphicsFamily >= 0 && presentationFamily >= 0;
}
};
struct SwapchainDetails {
VkSurfaceCapabilitiesKHR surfaceCapabilities; // Surface properties, e.g. image size/extent
std::vector<VkSurfaceFormatKHR> formats; // Surface image formats e.g. RGBA and size of each color
std::vector<VkPresentModeKHR> presentationModes; // How images should be presented to screen
};
struct SwapchainImage {
VkImage image;
VkImageView imageView;
};
static std::vector<char> readFile(const std::string& filename) {
// OPen stream from given file
// std::ios::binary telsl stream to read file as binary
// std::ios::ate tells stream to start reading from end of file
std::ifstream file(filename, std::ios::binary | std::ios::ate);
// Check if file stream successfully opened
if (!file.is_open()) {
throw std::runtime_error("Failed to open a file!");
}
// Get current read position and use to resize file buffer
size_t fileSize = (size_t)file.tellg();
std::vector<char> fileBuffer(fileSize);
// Move read position (seek to) the start of the file
file.seekg(0);
// Read the file data into the buffer (stream "filesize" in total)
file.read(fileBuffer.data(), fileSize);
// Close stream
file.close();
return fileBuffer;
}
static uint32_t findMemoryTypeIndex(VkPhysicalDevice physicalDevice, uint32_t allowedTypes, VkMemoryPropertyFlags properties)
{
// Get properties of physical device memory
VkPhysicalDeviceMemoryProperties memoryProperties;
vkGetPhysicalDeviceMemoryProperties(physicalDevice, &memoryProperties);
for (uint32_t i = 0; i < memoryProperties.memoryTypeCount; i++) {
// Currently we are checking if we are aligned to the current allowed type
// ie 1 would be 0001 and if i is 2, then we'd see the 1 shifted into 0100
// This means that we would be comparing the specific allowed type with the current one
if ((allowedTypes & (1 << i)) // Index of memory type must match corresponding bit in allowed types
&& (memoryProperties.memoryTypes[i].propertyFlags & properties) == properties) // Desired property flags are exactly the same as properties flag
{
// This memory type is valid so return its index
return i;
}
}
throw std::runtime_error("No memory type index found");
}
static void createBuffer(
VkPhysicalDevice physicalDevice,
VkDevice device,
VkDeviceSize bufferSize,
VkBufferUsageFlags bufferUsage,
VkMemoryPropertyFlags bufferProperties,
VkBuffer* buffer,
VkDeviceMemory* bufferMemory) {
// -- Create Vertex buffer
// Information to create a buffer (doesn't include assigning memory)
VkBufferCreateInfo bufferInfo = {};
bufferInfo.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
bufferInfo.size = bufferSize; // Size of buffer (size of 1 vertex * number of vertices)
bufferInfo.usage = bufferUsage; // Multiple types of buffers possible
bufferInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE; // Similar to sawp chain images, can share vertex buffers
VkResult result = vkCreateBuffer(device, &bufferInfo, nullptr, buffer);
if (result != VK_SUCCESS) {
throw std::runtime_error("Failed to create a vertex buffer");
}
// Get buffer memory requirements
VkMemoryRequirements memRequirements;
vkGetBufferMemoryRequirements(device, *buffer, &memRequirements);
// Allocate memory to buffer
VkMemoryAllocateInfo memoryAllocInfo = {};
memoryAllocInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
memoryAllocInfo.allocationSize = memRequirements.size;
memoryAllocInfo.memoryTypeIndex = findMemoryTypeIndex(physicalDevice, memRequirements.memoryTypeBits, // Index of memory type on physical device that has required bit flags
bufferProperties); // VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT: CPU can interact with memory. VK_MEMORY_PROERTY_HOST_COHERENT_BIT: allows placement of data straight into buffer after mapping (otherwise would have to specify manually)
// Allocate memory to vkDeviceMemory
result = vkAllocateMemory(device, &memoryAllocInfo, nullptr, bufferMemory);
if (result != VK_SUCCESS) {
throw std::runtime_error("Failed to allocate vertext buffer memory");
}
// Bind the buffer into the memory to given vertex buffer
vkBindBufferMemory(device, *buffer, *bufferMemory, 0);
}
static VkCommandBuffer beginCommandBuffer(VkDevice device, VkCommandPool commandPool) {
// Command buffer to hold trasnfer commands
VkCommandBuffer commandBuffer;
// Command buffer details
VkCommandBufferAllocateInfo allocInfo = {};
allocInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
allocInfo.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
allocInfo.commandPool = commandPool;
allocInfo.commandBufferCount = 1;
// Allocate command buffer from pool
vkAllocateCommandBuffers(device, &allocInfo, &commandBuffer);
// Info to begin the command buffer recod
VkCommandBufferBeginInfo beginInfo = {};
beginInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
beginInfo.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; // We're only use the comand buffer once, so set i for one time submt
// Begin recording transfer commands
vkBeginCommandBuffer(commandBuffer, &beginInfo);
return commandBuffer;
}
static void endAndSubmitCommandBuffer(VkDevice device, VkCommandPool commandPool, VkQueue queue, VkCommandBuffer commandBuffer) {
// End commands
vkEndCommandBuffer(commandBuffer);
// Queue submission information
VkSubmitInfo submitInfo = {};
submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
submitInfo.commandBufferCount = 1;
submitInfo.pCommandBuffers = &commandBuffer;
// Submit transfer command
// Because we don't have many meshes we can have a simple wait for queue to be done (instead of setting the fences/semaphores)
vkQueueSubmit(queue, 1, &submitInfo, VK_NULL_HANDLE);
vkQueueWaitIdle(queue);
// Free temporary command buffer back to pool
vkFreeCommandBuffers(device, commandPool, 1, &commandBuffer);
}
static void copyBuffer(
VkDevice device,
VkQueue transferQueue,
VkCommandPool transferCommandPool,
VkBuffer srcBuffer,
VkBuffer dstBuffer,
VkDeviceSize bufferSize)
{
// Create buffer
VkCommandBuffer transferCommandBuffer = beginCommandBuffer(device, transferCommandPool);
// Region of data to copy from and to
VkBufferCopy bufferCopyRegion = {};
bufferCopyRegion.srcOffset = 0; // Copy everything from the start of the first buffer
bufferCopyRegion.dstOffset = 0; // Copy everything to the start of the second buffer
bufferCopyRegion.size = bufferSize;
// Command to copy src buffer to dst buffer
vkCmdCopyBuffer(transferCommandBuffer, srcBuffer, dstBuffer, 1, &bufferCopyRegion);
// End and submit buffer to dst buffer
endAndSubmitCommandBuffer(device, transferCommandPool, transferQueue, transferCommandBuffer);
}
static void copyImageBuffer(VkDevice device, VkQueue transferQueue, VkCommandPool transferCommandPool,
VkBuffer srcBuffer, VkImage dstImage, uint32_t width, uint32_t height) {
// Create buffer
VkCommandBuffer transferCommandBuffer = beginCommandBuffer(device, transferCommandPool);
VkBufferImageCopy imageRegion = {};
imageRegion.bufferOffset = 0; // Offset into data
imageRegion.bufferRowLength = 0; // Row length of data to calculate data spacing
imageRegion.bufferImageHeight = 0; // Image height to calculate data spacing
imageRegion.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; // Which aspect of image to copy
imageRegion.imageSubresource.mipLevel = 0; // Mipmap level to copy
imageRegion.imageSubresource.baseArrayLayer = 0; // Starting array layer if there is array
imageRegion.imageSubresource.layerCount = 1; // Number of layers to start copy starting at baseArrayLayer
imageRegion.imageOffset = { 0, 0, 0 }; // Offset into image as opposed to raw data in bufferOffset
imageRegion.imageExtent = { width, height, 1 };
// Copy buffer to given image
vkCmdCopyBufferToImage(transferCommandBuffer, srcBuffer, dstImage,
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &imageRegion);
// End and submit buffer to dst buffer
endAndSubmitCommandBuffer(device, transferCommandPool, transferQueue, transferCommandBuffer);
}
static void transitionImageLayout(VkDevice device, VkQueue queue,
VkCommandPool commandPool, VkImage image, VkImageLayout oldLayout, VkImageLayout newLayout) {
// Create buffer
VkCommandBuffer commandBuffer = beginCommandBuffer(device, commandPool);
VkImageMemoryBarrier imageMemoryBarrier = {};
imageMemoryBarrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
imageMemoryBarrier.oldLayout = oldLayout; // Layout to transition from
imageMemoryBarrier.newLayout = newLayout; // Layout to transition to
imageMemoryBarrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; // Queue family to trans
imageMemoryBarrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
imageMemoryBarrier.image = image;
imageMemoryBarrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; // ASpect of image being altered
imageMemoryBarrier.subresourceRange.baseMipLevel = 0; // Firsst mip level to start alteations on
imageMemoryBarrier.subresourceRange.levelCount = 1; // Number of mip levels to start from base
imageMemoryBarrier.subresourceRange.baseArrayLayer = 0; // First layer to start alterations on
imageMemoryBarrier.subresourceRange.layerCount = 1; // Number of layers to alter starting from baseArrayLayer
VkPipelineStageFlags srcStage;
VkPipelineStageFlags dstStage;
// If transitioning from new image to image ready to receive data do the following if statement
if (oldLayout == VK_IMAGE_LAYOUT_UNDEFINED && newLayout == VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL) {
imageMemoryBarrier.srcAccessMask = 0; // Memory stage transition must happen after this stage (currently set to 0 meaning it doens't matter)
imageMemoryBarrier.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; // THis is the access mask that we want to ensure the transition happens before
srcStage = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT;
dstStage = VK_PIPELINE_STAGE_TRANSFER_BIT;
}
// If transitioning from transfer detination to shader readable
else if (oldLayout == VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL && newLayout == VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL) {
imageMemoryBarrier.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
imageMemoryBarrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT;
srcStage = VK_PIPELINE_STAGE_TRANSFER_BIT;
dstStage = VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT;
}
vkCmdPipelineBarrier(
commandBuffer,
srcStage, dstStage, // pipeline stages (match to src and dst access masks just above)
0, // Dependency flags
0, nullptr, // Memory barrier count + data
0, nullptr, // Buffer memory barrier count + data
1, &imageMemoryBarrier // Image memory barrier count + data
);
// End and submit buffer to dst buffer
endAndSubmitCommandBuffer(device, commandPool, queue, commandBuffer);
}
|
[
"axsauze@gmail.com"
] |
axsauze@gmail.com
|
250e5032beba9460f90c3cc33ec46827b7f3e3de
|
154c3822e32c3fc707e775531d3973834345d270
|
/114_ejercicio.cpp
|
b59e0627b9701b1b01e40ef04761e007357a84d1
|
[] |
no_license
|
MEng-Alejandro-Nieto/Learning-cpp
|
f2da6a4f46eb1f86d472d8a1469bd885eb99287c
|
3d17d451cb534afdf9ea79e2fcb8e5495dc8a6d7
|
refs/heads/master
| 2020-07-30T13:08:22.122242
| 2019-12-05T23:20:48
| 2019-12-05T23:20:48
| 210,244,804
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 867
|
cpp
|
/*
Comprobar si un numero es par o impar, y senalar la posicion de memoria
donde se esta guardando el numero con punteros.
*/
#include <iostream>
using std::cin; using std::cout; using std::endl;
///////////////////////////////////////////////////////////////////
int n{0},*dir_n=&n;
///////////////////////////////////////////////////////////////////
void pregunta();
void par(int);
///////////////////////////////////////////////////////////////////
int main(){
pregunta();
par(n);
return 0;
}
///////////////////////////////////////////////////////////////////
void pregunta(){
cout<<"Ingrese un numero para comprobar si es par: "; cin>>n;
}
void par(int n){
if(*dir_n%2==0){
cout<<"El numero "<<*&n<< " es par y esta ubicado en "<<&n;
}
else{
cout<<"El numero "<<*&n<< " es impar y esta ubicado en "<<&n;
}
}
|
[
"alejandrolive932@hotmail.com"
] |
alejandrolive932@hotmail.com
|
07f865db53e262c036668795ee294b1f38f15157
|
03d01d133062e1ee483b685b834a76a7bfff6cd4
|
/src/ofApp.h
|
904a6251f333097b4be8af32d8536c2cea5a0679
|
[] |
no_license
|
AgnesChavez/XTrees_2020
|
0a99c22836d29dabd466919756e522f4d4413543
|
3722b643aabf9e2d62f5967e4edab0c868565e4c
|
refs/heads/master
| 2023-05-15T08:05:52.785686
| 2021-06-02T19:10:03
| 2021-06-02T19:10:03
| 296,460,159
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,445
|
h
|
#pragma once
#include "ofMain.h"
//#include "ofxControlPanel.h"
#include "TreesManager.h"
#include "InteractiveAudio.h"
//#include "ofxApp.h"
#include "XTreeButton.h"
#include "AlphaRect.h"
#include "TwitterLayer.h"
#include "LeavesLayer.h"
#include "LinesLayer.h"
#include "TwitterStream.h"
class ofApp :
//public ofxApp{
public ofBaseApp{
public:
ofApp();
~ofApp();
void setup();
void update();
void draw();
void exit();
void mousePressed(ofMouseEventArgs& args);
void mouseMoved(ofMouseEventArgs& args);
void mouseDragged(ofMouseEventArgs& args);
void keyPressed(ofKeyEventArgs& args);
void keyReleased(int key);
void windowResized(int w, int h);
#if USE_PDLIB
void audioReceived(float * input, int bufferSize, int nChannels);
void audioRequested(float * output, int bufferSize, int nChannels);
#endif
vector<ofNode> nodes;
// AlphaRect m_fadeRectangle;
ofSoundPlayer soundtrack;
// FlowersLayer* m_flowersLayer;
ofImage background;
bool use_background;
int backgroundOpacity;
void setFromWindowSize();
private:
void start();
void stop();
void goClicked(bool& do_);
void resetClicked(bool& do_);
// void controlChanged(guiCallbackData & data);
void updateSimulationState();
enum GuiState {
STATE_SETUP,
STATE_GUI,
STATE_SIMULATION
};
enum TimelineStates {
TIME_GROWING, // starts growing trees
TIME_LEAVES, // stop trees, start leaves
TIME_LINES_TRANS, // wait some more time after leaves have fallen
TIME_LINES, // starts the lines
TIME_LEAVESFALLING_TRANS, // stops for N seconds with all the leaves in place
TIME_LEAVESFALLING, // leaves fall,
TIME_LINES_FAST, // when no leaves are anymore present, accelerate lines
TIME_STOP_LINES, // stop
TIME_REGENERATE, // regenerate
TIME_GROWING_TRANS, // wait some time before restarting
};
GuiState m_state;
std::shared_ptr<TreesManager> m_treesLayer = nullptr;
std::shared_ptr<TwitterLayer> m_twitterLayer = nullptr;
std::shared_ptr<LinesLayer> m_linesLayer = nullptr;
std::shared_ptr<LeavesLayer> m_leavesLayer = nullptr;
std::unique_ptr<XTreeButton> m_goBtn = nullptr;
std::unique_ptr<XTreeButton> m_resetBtn = nullptr;
ofColor m_layerObfuscationColor;
// simpleFileLister m_backgroundsLister;
// simpleFileLister m_soundtracksLister;
bool m_internetOk;
int m_backgroundFadeTime;
int m_back1, m_back2;
float m_maxThreads;
bool m_screenshot;
TimelineStates m_simulationState;
unsigned int m_simulationTimer;
unsigned int m_numberOfIterations;
bool m_clearFBO;
string toString(GuiState s) {
switch(s){
case STATE_SETUP : return "STATE_SETUP";
case STATE_GUI : return "STATE_GUI";
case STATE_SIMULATION : return "STATE_SIMULATION";
}
return "";
}
string toString(TimelineStates s) {
switch(s)
{
case TIME_GROWING: return "TIME_GROWING";
case TIME_LEAVES: return "TIME_LEAVES";
case TIME_LINES_TRANS: return "TIME_LINES_TRANS";
case TIME_LINES: return "TIME_LINES";
case TIME_LEAVESFALLING_TRANS: return "TIME_LEAVESFALLING_TRANS";
case TIME_LEAVESFALLING: return "TIME_LEAVESFALLING";
case TIME_LINES_FAST: return "TIME_LINES_FAST";
case TIME_STOP_LINES: return "TIME_STOP_LINES";
case TIME_REGENERATE: return "TIME_REGENERATE";
case TIME_GROWING_TRANS: return "TIME_GROWING_TRANS";
}
return "";
}
bool bDrawStatesInfo = false;
bool bDebug = false;
bool bDrawGui = false;
};
|
[
"macdonald.roy@gmail.com"
] |
macdonald.roy@gmail.com
|
7a5b27cc8aeefb3b49e1f3dfee406d6eacd3be5d
|
b4826dd67114c5282b769fc9d658c9c55617a96d
|
/DataStructuresLearningSoftware/DataStructuresLearningSoftware/LinkedList1.h
|
8e8862c2bea61d946a490efe5f799bfe565ad7be
|
[] |
no_license
|
Kethavath9199/Data-Structures-Software-Learning
|
c7d5ed7efaab9baf0ee014311c7727ccbbea0208
|
990512de73234a9f7c348bdca4b38f529ff72a3f
|
refs/heads/master
| 2022-11-26T21:11:32.731210
| 2020-08-06T15:17:04
| 2020-08-06T15:17:04
| 285,603,091
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 24,123
|
h
|
#pragma once
#include "LinkedList_Introduction.h"
#include "LinkedList_Insertion.h"
#include "LinkedList_Deletion.h"
#include "LinkedList_Traversal.h"
#include "Quiz.h"
#include "DiscussionForum.h"
namespace DataStructuresLearningSoftware {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
/// <summary>
/// Summary for LinkedList1
/// </summary>
public ref class LinkedList1 : public System::Windows::Forms::Form
{
public:
LinkedList1(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~LinkedList1()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Panel^ panel1;
protected:
private: System::Windows::Forms::Panel^ panel2;
private: System::Windows::Forms::Panel^ MainPanel;
private: System::Windows::Forms::Button^ btnTraversal;
private: System::Windows::Forms::Button^ btnDeletion;
private: System::Windows::Forms::Button^ btnInsertion;
private: System::Windows::Forms::Button^ btnIntroduction;
private: System::Windows::Forms::Button^ btnQuiz;
private: System::Windows::Forms::Button^ btnHome;
private: System::Windows::Forms::Button^ btnNext;
private: System::Windows::Forms::Button^ btnBack;
private: System::Windows::Forms::Label^ lblWelcome;
private: System::Windows::Forms::Button^ button1;
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(LinkedList1::typeid));
this->panel1 = (gcnew System::Windows::Forms::Panel());
this->btnQuiz = (gcnew System::Windows::Forms::Button());
this->btnTraversal = (gcnew System::Windows::Forms::Button());
this->btnDeletion = (gcnew System::Windows::Forms::Button());
this->btnInsertion = (gcnew System::Windows::Forms::Button());
this->btnIntroduction = (gcnew System::Windows::Forms::Button());
this->panel2 = (gcnew System::Windows::Forms::Panel());
this->button1 = (gcnew System::Windows::Forms::Button());
this->lblWelcome = (gcnew System::Windows::Forms::Label());
this->btnHome = (gcnew System::Windows::Forms::Button());
this->btnNext = (gcnew System::Windows::Forms::Button());
this->btnBack = (gcnew System::Windows::Forms::Button());
this->MainPanel = (gcnew System::Windows::Forms::Panel());
this->panel1->SuspendLayout();
this->panel2->SuspendLayout();
this->SuspendLayout();
//
// panel1
//
this->panel1->BackColor = System::Drawing::Color::AliceBlue;
this->panel1->Controls->Add(this->btnQuiz);
this->panel1->Controls->Add(this->btnTraversal);
this->panel1->Controls->Add(this->btnDeletion);
this->panel1->Controls->Add(this->btnInsertion);
this->panel1->Controls->Add(this->btnIntroduction);
this->panel1->Location = System::Drawing::Point(0, 0);
this->panel1->Name = L"panel1";
this->panel1->Size = System::Drawing::Size(175, 720);
this->panel1->TabIndex = 0;
//
// btnQuiz
//
this->btnQuiz->Cursor = System::Windows::Forms::Cursors::Hand;
this->btnQuiz->FlatAppearance->BorderSize = 0;
this->btnQuiz->FlatStyle = System::Windows::Forms::FlatStyle::Popup;
this->btnQuiz->Font = (gcnew System::Drawing::Font(L"Comic Sans MS", 11.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->btnQuiz->Location = System::Drawing::Point(0, 210);
this->btnQuiz->Name = L"btnQuiz";
this->btnQuiz->Size = System::Drawing::Size(175, 40);
this->btnQuiz->TabIndex = 4;
this->btnQuiz->Text = L"Quiz Time";
this->btnQuiz->UseVisualStyleBackColor = true;
this->btnQuiz->Click += gcnew System::EventHandler(this, &LinkedList1::btnQuiz_Click);
//
// btnTraversal
//
this->btnTraversal->Cursor = System::Windows::Forms::Cursors::Hand;
this->btnTraversal->FlatAppearance->BorderSize = 0;
this->btnTraversal->FlatStyle = System::Windows::Forms::FlatStyle::Popup;
this->btnTraversal->Font = (gcnew System::Drawing::Font(L"Comic Sans MS", 11.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->btnTraversal->Location = System::Drawing::Point(0, 170);
this->btnTraversal->Name = L"btnTraversal";
this->btnTraversal->Size = System::Drawing::Size(175, 40);
this->btnTraversal->TabIndex = 3;
this->btnTraversal->Text = L"Traversal";
this->btnTraversal->UseVisualStyleBackColor = true;
this->btnTraversal->Click += gcnew System::EventHandler(this, &LinkedList1::btnTraversal_Click);
//
// btnDeletion
//
this->btnDeletion->Cursor = System::Windows::Forms::Cursors::Hand;
this->btnDeletion->FlatAppearance->BorderSize = 0;
this->btnDeletion->FlatStyle = System::Windows::Forms::FlatStyle::Popup;
this->btnDeletion->Font = (gcnew System::Drawing::Font(L"Comic Sans MS", 11.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->btnDeletion->Location = System::Drawing::Point(0, 130);
this->btnDeletion->Name = L"btnDeletion";
this->btnDeletion->Size = System::Drawing::Size(175, 40);
this->btnDeletion->TabIndex = 2;
this->btnDeletion->Text = L"Deletion";
this->btnDeletion->UseVisualStyleBackColor = true;
this->btnDeletion->Click += gcnew System::EventHandler(this, &LinkedList1::btnDeletion_Click);
//
// btnInsertion
//
this->btnInsertion->Cursor = System::Windows::Forms::Cursors::Hand;
this->btnInsertion->FlatAppearance->BorderSize = 0;
this->btnInsertion->FlatStyle = System::Windows::Forms::FlatStyle::Popup;
this->btnInsertion->Font = (gcnew System::Drawing::Font(L"Comic Sans MS", 11.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->btnInsertion->Location = System::Drawing::Point(0, 90);
this->btnInsertion->Name = L"btnInsertion";
this->btnInsertion->Size = System::Drawing::Size(175, 40);
this->btnInsertion->TabIndex = 1;
this->btnInsertion->Text = L"Insertion";
this->btnInsertion->UseVisualStyleBackColor = true;
this->btnInsertion->Click += gcnew System::EventHandler(this, &LinkedList1::btnInsertion_Click);
//
// btnIntroduction
//
this->btnIntroduction->Cursor = System::Windows::Forms::Cursors::Hand;
this->btnIntroduction->FlatAppearance->BorderSize = 0;
this->btnIntroduction->FlatStyle = System::Windows::Forms::FlatStyle::Popup;
this->btnIntroduction->Font = (gcnew System::Drawing::Font(L"Comic Sans MS", 11.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->btnIntroduction->Location = System::Drawing::Point(0, 50);
this->btnIntroduction->Name = L"btnIntroduction";
this->btnIntroduction->Size = System::Drawing::Size(175, 40);
this->btnIntroduction->TabIndex = 0;
this->btnIntroduction->Text = L"Introduction";
this->btnIntroduction->UseVisualStyleBackColor = true;
this->btnIntroduction->Click += gcnew System::EventHandler(this, &LinkedList1::btnIntroduction_Click);
//
// panel2
//
this->panel2->BackColor = System::Drawing::Color::AliceBlue;
this->panel2->Controls->Add(this->button1);
this->panel2->Controls->Add(this->lblWelcome);
this->panel2->Controls->Add(this->btnHome);
this->panel2->Controls->Add(this->btnNext);
this->panel2->Controls->Add(this->btnBack);
this->panel2->Location = System::Drawing::Point(175, 0);
this->panel2->Name = L"panel2";
this->panel2->Size = System::Drawing::Size(1105, 50);
this->panel2->TabIndex = 1;
//
// button1
//
this->button1->BackColor = System::Drawing::Color::CornflowerBlue;
this->button1->FlatAppearance->BorderSize = 0;
this->button1->FlatStyle = System::Windows::Forms::FlatStyle::Popup;
this->button1->Font = (gcnew System::Drawing::Font(L"Comic Sans MS", 11.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->button1->Location = System::Drawing::Point(50, 10);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(150, 30);
this->button1->TabIndex = 0;
this->button1->Text = L"Discussion Forum";
this->button1->UseVisualStyleBackColor = false;
this->button1->Click += gcnew System::EventHandler(this, &LinkedList1::button1_Click);
//
// lblWelcome
//
this->lblWelcome->Font = (gcnew System::Drawing::Font(L"Comic Sans MS", 11.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->lblWelcome->ForeColor = System::Drawing::Color::Firebrick;
this->lblWelcome->Location = System::Drawing::Point(206, 15);
this->lblWelcome->Name = L"lblWelcome";
this->lblWelcome->Size = System::Drawing::Size(749, 20);
this->lblWelcome->TabIndex = 4;
this->lblWelcome->Text = L"label1";
this->lblWelcome->TextAlign = System::Drawing::ContentAlignment::MiddleRight;
//
// btnHome
//
this->btnHome->Cursor = System::Windows::Forms::Cursors::Hand;
this->btnHome->FlatAppearance->BorderSize = 0;
this->btnHome->FlatStyle = System::Windows::Forms::FlatStyle::Popup;
this->btnHome->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"btnHome.Image")));
this->btnHome->Location = System::Drawing::Point(1055, 0);
this->btnHome->Name = L"btnHome";
this->btnHome->Size = System::Drawing::Size(50, 50);
this->btnHome->TabIndex = 2;
this->btnHome->UseVisualStyleBackColor = true;
this->btnHome->Click += gcnew System::EventHandler(this, &LinkedList1::btnHome_Click);
//
// btnNext
//
this->btnNext->Cursor = System::Windows::Forms::Cursors::Hand;
this->btnNext->FlatAppearance->BorderSize = 0;
this->btnNext->FlatStyle = System::Windows::Forms::FlatStyle::Popup;
this->btnNext->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"btnNext.Image")));
this->btnNext->Location = System::Drawing::Point(1005, 0);
this->btnNext->Name = L"btnNext";
this->btnNext->Size = System::Drawing::Size(50, 50);
this->btnNext->TabIndex = 1;
this->btnNext->UseVisualStyleBackColor = true;
this->btnNext->Click += gcnew System::EventHandler(this, &LinkedList1::btnNext_Click);
//
// btnBack
//
this->btnBack->Cursor = System::Windows::Forms::Cursors::Hand;
this->btnBack->FlatAppearance->BorderSize = 0;
this->btnBack->FlatStyle = System::Windows::Forms::FlatStyle::Popup;
this->btnBack->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"btnBack.Image")));
this->btnBack->Location = System::Drawing::Point(0, 0);
this->btnBack->Name = L"btnBack";
this->btnBack->Size = System::Drawing::Size(50, 50);
this->btnBack->TabIndex = 0;
this->btnBack->UseVisualStyleBackColor = true;
this->btnBack->Click += gcnew System::EventHandler(this, &LinkedList1::btnBack_Click);
//
// MainPanel
//
this->MainPanel->AutoScroll = true;
this->MainPanel->Location = System::Drawing::Point(175, 50);
this->MainPanel->Name = L"MainPanel";
this->MainPanel->Size = System::Drawing::Size(1105, 670);
this->MainPanel->TabIndex = 2;
//
// LinkedList1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->BackColor = System::Drawing::SystemColors::Control;
this->ClientSize = System::Drawing::Size(1280, 720);
this->Controls->Add(this->MainPanel);
this->Controls->Add(this->panel2);
this->Controls->Add(this->panel1);
this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::None;
this->Name = L"LinkedList1";
this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen;
this->Text = L"LinkedList1";
this->Load += gcnew System::EventHandler(this, &LinkedList1::LinkedList1_Load);
this->panel1->ResumeLayout(false);
this->panel2->ResumeLayout(false);
this->ResumeLayout(false);
}
#pragma endregion
public: String ^username;
int moduleId;
String ^fullname;
int modulesCompleted;
private: System::Void btnIntroduction_Click(System::Object^ sender, System::EventArgs^ e) {
OleDb::OleDbConnection ^ DB_Connection = gcnew OleDb::OleDbConnection();
DB_Connection->ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source="+IO::Path::GetDirectoryName(Application::StartupPath)+"\\Database.accdb";
DB_Connection->Open();
String ^readString = "SELECT * FROM Users WHERE UserName='"+username+"'";
OleDbCommand ^ cmd = gcnew OleDbCommand(readString, DB_Connection);
OleDbDataReader ^ reader = cmd->ExecuteReader();
if(reader->Read()){
modulesCompleted = reader->GetInt32(10);
}
DB_Connection->Close();
if(modulesCompleted < 0){ // 0 is module ID of Introduction
MessageBox::Show("Complete the previous module to unlock this module");
}
else{
moduleId = 0;
display();
}
}
private: System::Void btnInsertion_Click(System::Object^ sender, System::EventArgs^ e) {
OleDb::OleDbConnection ^ DB_Connection = gcnew OleDb::OleDbConnection();
DB_Connection->ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source="+IO::Path::GetDirectoryName(Application::StartupPath)+"\\Database.accdb";
DB_Connection->Open();
String ^readString = "SELECT * FROM Users WHERE UserName='"+username+"'";
OleDbCommand ^ cmd = gcnew OleDbCommand(readString, DB_Connection);
OleDbDataReader ^ reader = cmd->ExecuteReader();
if(reader->Read()){
modulesCompleted = reader->GetInt32(10);
}
DB_Connection->Close();
if(modulesCompleted < 1){ // 1 is module ID of Insertion
MessageBox::Show("Complete the previous module to unlock this module");
}
else{
moduleId = 1;
display();
}
}
private: System::Void btnDeletion_Click(System::Object^ sender, System::EventArgs^ e) {
OleDb::OleDbConnection ^ DB_Connection = gcnew OleDb::OleDbConnection();
DB_Connection->ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source="+IO::Path::GetDirectoryName(Application::StartupPath)+"\\Database.accdb";
DB_Connection->Open();
String ^readString = "SELECT * FROM Users WHERE UserName='"+username+"'";
OleDbCommand ^ cmd = gcnew OleDbCommand(readString, DB_Connection);
OleDbDataReader ^ reader = cmd->ExecuteReader();
if(reader->Read()){
modulesCompleted = reader->GetInt32(10);
}
DB_Connection->Close();
if(modulesCompleted < 2){ // 2 is module ID of Deletion
MessageBox::Show("Complete the previous module to unlock this module");
}
else{
moduleId = 2;
display();
}
}
private: System::Void btnTraversal_Click(System::Object^ sender, System::EventArgs^ e) {
OleDb::OleDbConnection ^ DB_Connection = gcnew OleDb::OleDbConnection();
DB_Connection->ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source="+IO::Path::GetDirectoryName(Application::StartupPath)+"\\Database.accdb";
DB_Connection->Open();
String ^readString = "SELECT * FROM Users WHERE UserName='"+username+"'";
OleDbCommand ^ cmd = gcnew OleDbCommand(readString, DB_Connection);
OleDbDataReader ^ reader = cmd->ExecuteReader();
if(reader->Read()){
modulesCompleted = reader->GetInt32(10);
}
DB_Connection->Close();
if(modulesCompleted < 3){ // 3 is module ID of Traversal
MessageBox::Show("Complete the previous module to unlock this module");
}
else{
moduleId = 3;
display();
}
}
private: System::Void btnQuiz_Click(System::Object^ sender, System::EventArgs^ e) {
OleDb::OleDbConnection ^ DB_Connection = gcnew OleDb::OleDbConnection();
DB_Connection->ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source="+IO::Path::GetDirectoryName(Application::StartupPath)+"\\Database.accdb";
DB_Connection->Open();
String ^readString = "SELECT * FROM Users WHERE UserName='"+username+"'";
OleDbCommand ^ cmd = gcnew OleDbCommand(readString, DB_Connection);
OleDbDataReader ^ reader = cmd->ExecuteReader();
if(reader->Read()){
modulesCompleted = reader->GetInt32(10);
}
DB_Connection->Close();
if(modulesCompleted < 3){ // 4 is module ID of Quiz
MessageBox::Show("Complete the previous module to unlock this module");
}
else{
moduleId = 4;
display();
}
}
private: System::Void LinkedList1_Load(System::Object^ sender, System::EventArgs^ e) {
moduleId = 0;
OleDb::OleDbConnection ^ DB_Connection = gcnew OleDb::OleDbConnection();
DB_Connection->ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source="+IO::Path::GetDirectoryName(Application::StartupPath)+"\\Database.accdb";
DB_Connection->Open();
String ^readString = "SELECT * FROM Users WHERE UserName='"+username+"'";
OleDbCommand ^ cmd = gcnew OleDbCommand(readString, DB_Connection);
OleDbDataReader ^ reader = cmd->ExecuteReader();
if(reader->Read()){
fullname = reader->GetString(2);
modulesCompleted = reader->GetInt32(10);
}
DB_Connection->Close();
lblWelcome->Text = "Welcome, "+fullname;
display();
}
public: void display(){
if(modulesCompleted == 0){
btnIntroduction->BackColor = Color::IndianRed;
btnInsertion->BackColor = Color::IndianRed;
btnDeletion->BackColor = Color::IndianRed;
btnTraversal->BackColor = Color::IndianRed;
btnQuiz->BackColor = Color::IndianRed;
}
else if(modulesCompleted == 1){
btnIntroduction->BackColor = Color::MediumSeaGreen;
btnInsertion->BackColor = Color::IndianRed;
btnDeletion->BackColor = Color::IndianRed;
btnTraversal->BackColor = Color::IndianRed;
btnQuiz->BackColor = Color::IndianRed;
}
else if(modulesCompleted == 2){
btnIntroduction->BackColor = Color::MediumSeaGreen;
btnInsertion->BackColor = Color::MediumSeaGreen;
btnDeletion->BackColor = Color::IndianRed;
btnTraversal->BackColor = Color::IndianRed;
btnQuiz->BackColor = Color::IndianRed;
}
else if(modulesCompleted == 3){
btnIntroduction->BackColor = Color::MediumSeaGreen;
btnInsertion->BackColor = Color::MediumSeaGreen;
btnDeletion->BackColor = Color::MediumSeaGreen;
btnTraversal->BackColor = Color::IndianRed;
btnQuiz->BackColor = Color::IndianRed;
}
else if(modulesCompleted == 4){
btnIntroduction->BackColor = Color::MediumSeaGreen;
btnInsertion->BackColor = Color::MediumSeaGreen;
btnDeletion->BackColor = Color::MediumSeaGreen;
btnTraversal->BackColor = Color::MediumSeaGreen;
btnQuiz->BackColor = Color::IndianRed;
}
else if(modulesCompleted == 5){
btnIntroduction->BackColor = Color::MediumSeaGreen;
btnInsertion->BackColor = Color::MediumSeaGreen;
btnDeletion->BackColor = Color::MediumSeaGreen;
btnTraversal->BackColor = Color::MediumSeaGreen;
btnQuiz->BackColor = Color::MediumSeaGreen;
}
if(moduleId == 0){
btnIntroduction->BackColor = Color::CornflowerBlue;
btnBack->Hide();
btnNext->Show();
MainPanel->Controls->Clear();
LinkedList_Introduction ^newUserControl = gcnew LinkedList_Introduction();
newUserControl->username = username;
MainPanel->Controls->Add(newUserControl);
}
else if(moduleId == 1){
btnInsertion->BackColor = Color::CornflowerBlue;
btnBack->Show();
btnNext->Show();
MainPanel->Controls->Clear();
LinkedList_Insertion ^newUserControl = gcnew LinkedList_Insertion();
newUserControl->username = username;
MainPanel->Controls->Add(newUserControl);
}
else if(moduleId == 2){
btnDeletion->BackColor = Color::CornflowerBlue;
btnBack->Show();
btnNext->Show();
MainPanel->Controls->Clear();
LinkedList_Deletion ^newUserControl = gcnew LinkedList_Deletion();
newUserControl->username = username;
MainPanel->Controls->Add(newUserControl);
}
else if(moduleId == 3){
btnTraversal->BackColor = Color::CornflowerBlue;
btnBack->Show();
btnNext->Show();
MainPanel->Controls->Clear();
LinkedList_Traversal ^newUserControl = gcnew LinkedList_Traversal();
newUserControl->username = username;
MainPanel->Controls->Add(newUserControl);
}
else if(moduleId == 4){
btnQuiz->BackColor = Color::CornflowerBlue;
btnNext->Hide();
btnBack->Show();
MainPanel->Controls->Clear();
Quiz ^newUserControl = gcnew Quiz();
newUserControl->username = username;
newUserControl->ds_id = 1;
MainPanel->Controls->Add(newUserControl);
}
}
private: System::Void btnBack_Click(System::Object^ sender, System::EventArgs^ e) {
OleDb::OleDbConnection ^ DB_Connection = gcnew OleDb::OleDbConnection();
DB_Connection->ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source="+IO::Path::GetDirectoryName(Application::StartupPath)+"\\Database.accdb";
DB_Connection->Open();
String ^readString = "SELECT * FROM Users WHERE UserName='"+username+"'";
OleDbCommand ^ cmd = gcnew OleDbCommand(readString, DB_Connection);
OleDbDataReader ^ reader = cmd->ExecuteReader();
if(reader->Read()){
modulesCompleted = reader->GetInt32(10);
}
DB_Connection->Close();
if(moduleId-1 > modulesCompleted){
MessageBox::Show("Complete the previous module to unlock this module");
}
else{
moduleId--;
display();
}
}
private: System::Void btnNext_Click(System::Object^ sender, System::EventArgs^ e) {
OleDb::OleDbConnection ^ DB_Connection = gcnew OleDb::OleDbConnection();
DB_Connection->ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source="+IO::Path::GetDirectoryName(Application::StartupPath)+"\\Database.accdb";
DB_Connection->Open();
String ^readString = "SELECT * FROM Users WHERE UserName='"+username+"'";
OleDbCommand ^ cmd = gcnew OleDbCommand(readString, DB_Connection);
OleDbDataReader ^ reader = cmd->ExecuteReader();
if(reader->Read()){
modulesCompleted = reader->GetInt32(10);
}
DB_Connection->Close();
if(moduleId+1 > modulesCompleted){
MessageBox::Show("Complete the previous module to unlock this module");
}
else{
moduleId++;
display();
}
}
private: System::Void btnHome_Click(System::Object^ sender, System::EventArgs^ e) {
OleDb::OleDbConnection ^ DB_Connection = gcnew OleDb::OleDbConnection();
DB_Connection->ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source="+IO::Path::GetDirectoryName(Application::StartupPath)+"\\Database.accdb";
DB_Connection->Open();
String ^readString = "SELECT * FROM Users WHERE UserName='"+username+"'";
OleDbCommand ^ cmd = gcnew OleDbCommand(readString, DB_Connection);
OleDbDataReader ^ reader = cmd->ExecuteReader();
if(reader->Read()){
modulesCompleted = reader->GetInt32(10);
}
this->Close();
}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
MainPanel->Controls->Clear();
DiscussionForum ^ discuss = gcnew DiscussionForum;
discuss->username=username;
discuss->module="Linked List";
MainPanel->Controls->Add(discuss);
}
};
}
|
[
"kethavathnaveen@192.168.1.5"
] |
kethavathnaveen@192.168.1.5
|
3142093627ae4033a8b5ff12d61960a38bac28ed
|
26dbe4913ffb77fad2eafb6ba466233e956ef68e
|
/debugformat/debugformat-example.cpp
|
faa0b58f92568a4925f7f58555a1557a89a5c209
|
[] |
no_license
|
retdec-build/retdec-build-system-tests
|
c1fd970b2237c5e3369d35cde46f4c234c4f0dd9
|
dc5882c340d7640e207e63e43723e3304257506b
|
refs/heads/master
| 2023-01-20T18:07:58.232114
| 2020-07-21T09:55:37
| 2020-07-21T09:55:37
| 467,175,156
| 0
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 157
|
cpp
|
#include <iostream>
#include <retdec/debugformat/debugformat.h>
int main(int argc, char* argv[])
{
retdec::debugformat::DebugFormat debug;
return 0;
}
|
[
"peter.matula@avast.com"
] |
peter.matula@avast.com
|
9e48c2d5e1dd5377ade75545a1450f5d49a47873
|
0e1693c18bb5897e2242549b2512d34555a0a266
|
/Libraries/Prim.cpp
|
e189788adc2ea9ff796b9f20d05d0fb773bca2b1
|
[] |
no_license
|
AngelFA04/algoritmos
|
b3c9cef7b37fb500f05cc463677a99564cefe847
|
bbc16d8e492872d6d3cd2f6f0586d3ee9e5590d3
|
refs/heads/master
| 2022-12-02T02:27:06.874755
| 2020-08-19T15:49:21
| 2020-08-19T15:49:21
| 287,777,577
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,567
|
cpp
|
#include <iostream>
#include <limits.h>
#include "Prim.h"
using namespace std;
Prim::Prim(int numeroNodos, int **matrizAdj){
this->numeroNodos = numeroNodos;
this->matrizAdj = matrizAdj;
arbol = new int[numeroNodos];
visitados = new bool[numeroNodos];
}
void Prim::inicializarValores(){
for(int i = 0; i < numeroNodos; i++){
arbol[i] = -1;
visitados[i] = false;
}
arbol[0] = 0;
visitados[0] = true;
}
bool Prim::noVisiteTodos(){
for(int i = 0; i < numeroNodos; i++){
if(!visitados[i]){
return true;
}
}
return false;
}
void Prim::imprimirSolucion(){
cout << "[ ";
for(int i = 0; i < numeroNodos - 1; i++){
cout << arbol[i] << ", ";
}
cout << arbol[numeroNodos - 1] << " ]" << endl;
}
void Prim::calcularAEM(){
inicializarValores();
while(noVisiteTodos()){
int minPeso = INT_MAX;
int minIndex;
int padre;
for(int i = 0; i < numeroNodos; i++){
if(arbol[i] != -1){
for(int j = 0; j < numeroNodos; j++){
if(visitados[j] || matrizAdj[i][j] == 0) continue;
if(matrizAdj[i][j] < minPeso){
minPeso = matrizAdj[i][j];
minIndex = j;
padre = i;
}
}
}
}
arbol[minIndex] = padre + 1;
visitados[minIndex] = true;
}
imprimirSolucion();
}
|
[
"cyberangel1000@gmail.com"
] |
cyberangel1000@gmail.com
|
4139dcc5944bb511e85e4d5887d1305b0588320f
|
51318bac6c32d5d298e277bad94511bcf3de42cf
|
/message.cpp
|
48be0a2767d3b162eb4227e69fc0d8ffd1607fd3
|
[] |
no_license
|
xxmicloxx/GSPlayerQT
|
8d66a5ac6ce6a597aa6347faf4b3692d60bd8030
|
83e5f6ed0ef7f1d66e5503a6e9b94602d842996e
|
refs/heads/master
| 2021-01-17T05:30:07.205693
| 2014-01-01T21:05:35
| 2014-01-01T21:05:35
| 4,930,092
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,204
|
cpp
|
#include "message.h"
#include "ui_message.h"
#include <QTimer>
Message::Message(QWidget *parent) :
QWidget(parent),
ui(new Ui::Message)
{
ui->setupUi(this);
opacity = new QGraphicsOpacityEffect(this);
opacity->setOpacity(0.0);
this->setGraphicsEffect(opacity);
blendIn = new QPropertyAnimation(opacity, "opacity");
blendOut = new QPropertyAnimation(opacity, "opacity");
moveUp = new QPropertyAnimation(this, "geometry");
moveUp->setDuration(1000);
blendIn->setDuration(500);
blendOut->setDuration(500);
blendIn->setStartValue(0.0);
blendOut->setStartValue(0.75);
blendIn->setEndValue(0.75);
blendOut->setEndValue(0.0);
this->setAttribute(Qt::WA_TransparentForMouseEvents);
connect(blendIn, SIGNAL(finished()), this, SLOT(blendedIn()));
}
Message::~Message()
{
delete ui;
delete blendIn;
delete blendOut;
delete moveUp;
}
void Message::blendedIn() {
QTimer* timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), blendOut, SLOT(start()));
timer->setSingleShot(true);
timer->start(1500);
}
void Message::setText(std::string text) {
ui->lblMessage->setText(QString::fromStdString(text));
}
|
[
"xxmicloxx@googlemail.com"
] |
xxmicloxx@googlemail.com
|
453d8030070ac2115102ea4e30bdd990c79f9063
|
1e5c93564f82e6b069504a38c7048c1e9e1e47a6
|
/2017.1/algorithms-review/t235.cpp
|
0e82403c82d77c8a9e29c1b4f5158cb1b47da69b
|
[
"MIT"
] |
permissive
|
Forec/learn
|
d3a28209b73f4ffa9026dd232b4914f2e19f7b8d
|
38ef91d1310f82713e7a04c45c7e99e3929df813
|
refs/heads/master
| 2021-01-17T02:33:31.201367
| 2017-10-18T15:44:17
| 2017-10-18T15:44:17
| 39,928,290
| 4
| 2
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,496
|
cpp
|
#include <iostream>
#include <unordered_map>
#include <vector>
#include <unordered_set>
using namespace std;
struct TreeNode {
int val;
TreeNode *left;
TreeNode *right;
TreeNode(int x) : val(x), left(NULL), right(NULL) {}
};
class Solution1 {
private:
unordered_set<TreeNode*> vis;
unordered_map<TreeNode*, TreeNode*> par;
TreeNode *pn, *qn;
TreeNode *res;
TreeNode * find(TreeNode *u){
return par[u] == u ? u : find(par[u]);
}
void init(TreeNode * root){
if (root == NULL)
return;
par[root] = root;
init(root->left);
init(root->right);
}
void tarjan(TreeNode * root){
if (root == NULL)
return;
vis.insert(root);
if (root == pn || root == qn){
if (root == pn && vis.count(qn) >= 1)
res = find(qn);
if (root == qn && vis.count(pn) >= 1)
res = find(pn);
}
if (root->left != NULL && vis.count(root->left) == 0){
tarjan(root->left);
par[root->left] = root;
}
if (root->right != NULL && vis.count(root->right) == 0){
tarjan(root->right);
par[root->right] = root;
}
}
public:
TreeNode* lowestCommonAncestor(TreeNode* root, TreeNode* p, TreeNode* q) {
res = NULL;
pn = p; qn = q;
vis.clear();
par.clear();
init(root);
tarjan(root);
return res;
}
};
class Solution {
public:
TreeNode* lowestCommonAncestor(TreeNode* root, TreeNode* p, TreeNode* q) {
while ((root->val - p->val) * (root->val - q->val) > 0) {
root = p->val > root->val ? root->right : root->left;
}
return root;
}
};
int main(){
TreeNode * n6 = new TreeNode(6);
TreeNode * n2 = new TreeNode(2);
TreeNode * n8 = new TreeNode(8);
TreeNode * n0 = new TreeNode(0);
TreeNode * n4 = new TreeNode(4);
TreeNode * n7 = new TreeNode(7);
TreeNode * n9 = new TreeNode(9);
TreeNode * n3 = new TreeNode(3);
TreeNode * n5 = new TreeNode(5);
n6->left = n2; n6->right = n8;
n2->left = n0; n2->right = n4;
n4->left = n3; n4->right = n5;
n8->left = n7; n8->right = n9;
Solution sol;
TreeNode * ans1 = sol.lowestCommonAncestor(n6, n2, n8);
cout << (ans1 != NULL && 6 == ans1->val) << endl;
TreeNode * ans2 = sol.lowestCommonAncestor(n6, n2, n4);
cout << (ans2 != NULL && 2 == ans2->val) << endl;
TreeNode * ans3 = sol.lowestCommonAncestor(n6, n0, n5);
cout << (ans3 != NULL && 2 == ans3->val) << endl;
return 0;
}
|
[
"forec@bupt.edu.cn"
] |
forec@bupt.edu.cn
|
c36c9d7e02d6cc3785e5dcb5c7146f18d9599bdc
|
7e72fd8bd7faf8a311439b43fa7574c16daafc92
|
/src/Graph.hpp
|
2d80f6089dbb5b2d6438d5cc32a446d7fa171d5f
|
[] |
no_license
|
stryitg/csp_lab1
|
20d8973c1fa422efecefc76a4f39627a756eeb6f
|
7d75ee5146a60e3026fd07c870d45540564ff907
|
refs/heads/master
| 2023-02-07T07:52:34.326155
| 2020-12-19T17:24:41
| 2020-12-19T17:24:41
| 305,174,489
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 90
|
hpp
|
#pragma once
#include <vector>
using AdjacmentMatrix = std::vector<std::vector<double>>;
|
[
"stryitg@gmail.com"
] |
stryitg@gmail.com
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.