<commit_before>#include<iostream>
#include<math.h>
#include<stdlib.h>

int prime[10000],primes;

void init_primes(){
     static bool isprime[32000];
     int i,j;
     for(i=2;i<32000;i++) isprime[i]=true;
     for(i=2;i*i < 32000;i++)if(isprime[i])
     {
         for(j=2*i;j<32000;j+=i) isprime[j]=false;
     }
     primes=0;
     for(i=2;i<32000;i++)
        if(isprime[i])
            prime[primes++]=i;
}

bool seive[100001];

void find_seive(int lo, int hi){
   int i,j,p,n;
   for(i=0; i<=hi-lo; i++)
       seive[i]=true;
   for(j=0;;j++){
       p=prime[j];
       if(p*p > hi) break;
       n = (lo/p)*p;
       if(n<lo) n+=p;
       if(n==p) n+=p;
       for(;n<=hi; n+=p)
          seive[n-lo]=false;
   }
}

void generatePrimeBetween(int lower, const int upper){
	if(lower<2) lower=2;
	find_seive(lower,upper);
         for(int i=0; i<=upper-lower; i++)
            if(seive[i]){
               cout << lower+i << endl;
            }
}

int main(){
	init_primes();
	int noOfTestCases;
	scanf("%d", &noOfTestCases);
	int num1; //smaller number
	int num2; // larger number
	while (noOfTestCases--) {
		scanf("%d %d",&num1,&num2);
		generatePrimeBetween(num1, num2);
		cout << endl;
	}
	return 0;
}
<commit_msg>Update main.cpp<commit_after>#include<iostream>
#include<math.h>
#include<stdlib.h>

using namespace std;

int prime[10000],primes;

void init_primes(){
     static bool isprime[32000];
     int i,j;
     for(i=2;i<32000;i++) isprime[i]=true;
     for(i=2;i*i < 32000;i++)if(isprime[i])
     {
         for(j=2*i;j<32000;j+=i) isprime[j]=false;
     }
     primes=0;
     for(i=2;i<32000;i++)
        if(isprime[i])
            prime[primes++]=i;
}

bool seive[100001];

void find_seive(int lo, int hi){
   int i,j,p,n;
   for(i=0; i<=hi-lo; i++)
       seive[i]=true;
   for(j=0;;j++){
       p=prime[j];
       if(p*p > hi) break;
       n = (lo/p)*p;
       if(n<lo) n+=p;
       if(n==p) n+=p;
       for(;n<=hi; n+=p)
          seive[n-lo]=false;
   }
}

void generatePrimeBetween(int lower, const int upper){
	if(lower<2) lower=2;
	find_seive(lower,upper);
         for(int i=0; i<=upper-lower; i++)
            if(seive[i]){
               cout << lower+i << endl;
            }
}

int main(){
	init_primes();
	int noOfTestCases;
	scanf("%d", &noOfTestCases);
	int num1; //smaller number
	int num2; // larger number
	while (noOfTestCases--) {
		scanf("%d %d",&num1,&num2);
		generatePrimeBetween(num1, num2);
		cout << endl;
	}
	return 0;
}
<|endoftext|>


<commit_before>/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you 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.
 *
 * Modified by Cloudius Systems.
 * Copyright 2015 Cloudius Systems.
 */

/*
 * This file is part of Scylla.
 *
 * Scylla is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Scylla 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 Scylla.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "gms/failure_detector.hh"
#include "gms/gossiper.hh"
#include "gms/i_failure_detector.hh"
#include "gms/i_failure_detection_event_listener.hh"
#include "gms/endpoint_state.hh"
#include "gms/application_state.hh"
#include "gms/inet_address.hh"
#include <iostream>
#include <chrono>

namespace gms {

extern logging::logger logger;

constexpr std::chrono::milliseconds failure_detector::DEFAULT_MAX_PAUSE;

using clk = arrival_window::clk;

static clk::duration get_initial_value() {
#if 0
    String newvalue = System.getProperty("cassandra.fd_initial_value_ms");
    if (newvalue == null)
    {
        return Gossiper.intervalInMillis * 2;
    }
    else
    {
        logger.info("Overriding FD INITIAL_VALUE to {}ms", newvalue);
        return Integer.parseInt(newvalue);
    }
#endif
    warn(unimplemented::cause::GOSSIP);
    return std::chrono::seconds(2);
}

clk::duration arrival_window::get_max_interval() {
#if 0
    sstring newvalue = System.getProperty("cassandra.fd_max_interval_ms");
    if (newvalue == null)
    {
        return failure_detector.INITIAL_VALUE_NANOS;
    }
    else
    {
        logger.info("Overriding FD MAX_INTERVAL to {}ms", newvalue);
        return TimeUnit.NANOSECONDS.convert(Integer.parseInt(newvalue), TimeUnit.MILLISECONDS);
    }
#endif
    warn(unimplemented::cause::GOSSIP);
    return get_initial_value();
}

void arrival_window::add(clk::time_point value, const gms::inet_address& ep) {
    if (_tlast > clk::time_point::min()) {
        auto inter_arrival_time = value - _tlast;
        if (inter_arrival_time <= get_max_interval()) {
            _arrival_intervals.add(inter_arrival_time.count());
        } else  {
            logger.debug("failure_detector: Ignoring interval time of {} for {}", inter_arrival_time.count(), ep);
        }
    } else {
        // We use a very large initial interval since the "right" average depends on the cluster size
        // and it's better to err high (false negatives, which will be corrected by waiting a bit longer)
        // than low (false positives, which cause "flapping").
        _arrival_intervals.add(get_initial_value().count());
    }
    _tlast = value;
}

double arrival_window::mean() {
    return _arrival_intervals.mean();
}

double arrival_window::phi(clk::time_point tnow) {
    assert(_arrival_intervals.size() > 0 && _tlast > clk::time_point::min()); // should not be called before any samples arrive
    auto t = (tnow - _tlast).count();
    auto m = mean();
    double phi = t / m;
    logger.debug("failure_detector: now={}, tlast={}, t={}, mean={}, phi={}",
        tnow.time_since_epoch().count(), _tlast.time_since_epoch().count(), t, m, phi);
    return phi;
}

std::ostream& operator<<(std::ostream& os, const arrival_window& w) {
    for (auto& x : w._arrival_intervals.deque()) {
        os << x << " ";
    }
    return os;
}

sstring failure_detector::get_all_endpoint_states() {
    std::stringstream ss;
    for (auto& entry : get_local_gossiper().endpoint_state_map) {
        auto& ep = entry.first;
        auto& state = entry.second;
        ss << ep << "\n";
        append_endpoint_state(ss, state);
    }
    return sstring(ss.str());
}

std::map<sstring, sstring> failure_detector::get_simple_states() {
    std::map<sstring, sstring> nodes_status;
    for (auto& entry : get_local_gossiper().endpoint_state_map) {
        auto& ep = entry.first;
        auto& state = entry.second;
        std::stringstream ss;
        ss << ep;
        if (state.is_alive())
            nodes_status.emplace(sstring(ss.str()), "UP");
        else
            nodes_status.emplace(sstring(ss.str()), "DOWN");
    }
    return nodes_status;
}

int failure_detector::get_down_endpoint_count() {
    int count = 0;
    for (auto& entry : get_local_gossiper().endpoint_state_map) {
        auto& state = entry.second;
        if (!state.is_alive()) {
            count++;
        }
    }
    return count;
}

int failure_detector::get_up_endpoint_count() {
    int count = 0;
    for (auto& entry : get_local_gossiper().endpoint_state_map) {
        auto& state = entry.second;
        if (state.is_alive()) {
            count++;
        }
    }
    return count;
}

sstring failure_detector::get_endpoint_state(sstring address) {
    std::stringstream ss;
    auto eps = get_local_gossiper().get_endpoint_state_for_endpoint(inet_address(address));
    if (eps) {
        append_endpoint_state(ss, *eps);
        return sstring(ss.str());
    } else {
        return sstring("unknown endpoint ") + address;
    }
}

void failure_detector::append_endpoint_state(std::stringstream& ss, endpoint_state& state) {
    ss << "  generation:" << state.get_heart_beat_state().get_generation() << "\n";
    ss << "  heartbeat:" << state.get_heart_beat_state().get_heart_beat_version() << "\n";
    for (auto& entry : state.get_application_state_map()) {
        auto& app_state = entry.first;
        auto& value = entry.second;
        if (app_state == application_state::TOKENS) {
            continue;
        }
        ss << "  " << app_state << ":" << value.value << "\n";
    }
}

void failure_detector::set_phi_convict_threshold(double phi) {
    _phi = phi;
}

double failure_detector::get_phi_convict_threshold() {
    return _phi;
}

bool failure_detector::is_alive(inet_address ep) {
    return get_local_gossiper().is_alive(ep);
}

void failure_detector::report(inet_address ep) {
    logger.trace("failure_detector: reporting {}", ep);
    auto now = clk::now();
    auto it = _arrival_samples.find(ep);
    if (it == _arrival_samples.end()) {
        // avoid adding an empty ArrivalWindow to the Map
        auto heartbeat_window = arrival_window(SAMPLE_SIZE);
        heartbeat_window.add(now, ep);
        _arrival_samples.emplace(ep, heartbeat_window);
    } else {
        it->second.add(now, ep);
    }
}

// Runs inside seastar::async context
void failure_detector::interpret(inet_address ep) {
    auto it = _arrival_samples.find(ep);
    if (it == _arrival_samples.end()) {
        return;
    }
    arrival_window& hb_wnd = it->second;
    auto now = clk::now();
    auto diff = std::chrono::duration_cast<std::chrono::milliseconds>(now - _last_interpret);
    _last_interpret = now;
    if (diff > get_max_local_pause()) {
        logger.warn("Not marking nodes down due to local pause of {} > {} (milliseconds)", diff.count(), get_max_local_pause().count());
        _last_paused = now;
        return;
    }
    if (clk::now() - _last_paused < get_max_local_pause()) {
        logger.debug("Still not marking nodes down due to local pause");
        return;
    }
    double phi = hb_wnd.phi(now);
    logger.trace("failure_detector: PHI for {} : {}", ep, phi);
    logger.trace("failure_detector: phi_convict_threshold={}", _phi);

    if (PHI_FACTOR * phi > get_phi_convict_threshold()) {
        logger.trace("failure_detector: notifying listeners that {} is down", ep);
        logger.trace("failure_detector: intervals: {} mean: {}", hb_wnd, hb_wnd.mean());
        for (auto& listener : _fd_evnt_listeners) {
            logger.debug("failure_detector: convict ep={} phi={}", ep, phi);
            listener->convict(ep, phi);
        }
    }
}

// Runs inside seastar::async context
void failure_detector::force_conviction(inet_address ep) {
    logger.debug("failure_detector: Forcing conviction of {}", ep);
    for (auto& listener : _fd_evnt_listeners) {
        listener->convict(ep, get_phi_convict_threshold());
    }
}

void failure_detector::remove(inet_address ep) {
    _arrival_samples.erase(ep);
}

void failure_detector::register_failure_detection_event_listener(i_failure_detection_event_listener* listener) {
    _fd_evnt_listeners.push_back(std::move(listener));
}

void failure_detector::unregister_failure_detection_event_listener(i_failure_detection_event_listener* listener) {
    _fd_evnt_listeners.remove(listener);
}

std::ostream& operator<<(std::ostream& os, const failure_detector& x) {
    for (auto& entry : x._arrival_samples) {
        const inet_address& ep = entry.first;
        const arrival_window& win = entry.second;
        os << ep << " : "  << win << "\n";
    }
    return os;
}

distributed<failure_detector> _the_failure_detector;

} // namespace gms
<commit_msg>failure_detector: Print versions for gossip states in gossipinfo<commit_after>/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you 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.
 *
 * Modified by Cloudius Systems.
 * Copyright 2015 Cloudius Systems.
 */

/*
 * This file is part of Scylla.
 *
 * Scylla is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Scylla 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 Scylla.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "gms/failure_detector.hh"
#include "gms/gossiper.hh"
#include "gms/i_failure_detector.hh"
#include "gms/i_failure_detection_event_listener.hh"
#include "gms/endpoint_state.hh"
#include "gms/application_state.hh"
#include "gms/inet_address.hh"
#include <iostream>
#include <chrono>

namespace gms {

extern logging::logger logger;

constexpr std::chrono::milliseconds failure_detector::DEFAULT_MAX_PAUSE;

using clk = arrival_window::clk;

static clk::duration get_initial_value() {
#if 0
    String newvalue = System.getProperty("cassandra.fd_initial_value_ms");
    if (newvalue == null)
    {
        return Gossiper.intervalInMillis * 2;
    }
    else
    {
        logger.info("Overriding FD INITIAL_VALUE to {}ms", newvalue);
        return Integer.parseInt(newvalue);
    }
#endif
    warn(unimplemented::cause::GOSSIP);
    return std::chrono::seconds(2);
}

clk::duration arrival_window::get_max_interval() {
#if 0
    sstring newvalue = System.getProperty("cassandra.fd_max_interval_ms");
    if (newvalue == null)
    {
        return failure_detector.INITIAL_VALUE_NANOS;
    }
    else
    {
        logger.info("Overriding FD MAX_INTERVAL to {}ms", newvalue);
        return TimeUnit.NANOSECONDS.convert(Integer.parseInt(newvalue), TimeUnit.MILLISECONDS);
    }
#endif
    warn(unimplemented::cause::GOSSIP);
    return get_initial_value();
}

void arrival_window::add(clk::time_point value, const gms::inet_address& ep) {
    if (_tlast > clk::time_point::min()) {
        auto inter_arrival_time = value - _tlast;
        if (inter_arrival_time <= get_max_interval()) {
            _arrival_intervals.add(inter_arrival_time.count());
        } else  {
            logger.debug("failure_detector: Ignoring interval time of {} for {}", inter_arrival_time.count(), ep);
        }
    } else {
        // We use a very large initial interval since the "right" average depends on the cluster size
        // and it's better to err high (false negatives, which will be corrected by waiting a bit longer)
        // than low (false positives, which cause "flapping").
        _arrival_intervals.add(get_initial_value().count());
    }
    _tlast = value;
}

double arrival_window::mean() {
    return _arrival_intervals.mean();
}

double arrival_window::phi(clk::time_point tnow) {
    assert(_arrival_intervals.size() > 0 && _tlast > clk::time_point::min()); // should not be called before any samples arrive
    auto t = (tnow - _tlast).count();
    auto m = mean();
    double phi = t / m;
    logger.debug("failure_detector: now={}, tlast={}, t={}, mean={}, phi={}",
        tnow.time_since_epoch().count(), _tlast.time_since_epoch().count(), t, m, phi);
    return phi;
}

std::ostream& operator<<(std::ostream& os, const arrival_window& w) {
    for (auto& x : w._arrival_intervals.deque()) {
        os << x << " ";
    }
    return os;
}

sstring failure_detector::get_all_endpoint_states() {
    std::stringstream ss;
    for (auto& entry : get_local_gossiper().endpoint_state_map) {
        auto& ep = entry.first;
        auto& state = entry.second;
        ss << ep << "\n";
        append_endpoint_state(ss, state);
    }
    return sstring(ss.str());
}

std::map<sstring, sstring> failure_detector::get_simple_states() {
    std::map<sstring, sstring> nodes_status;
    for (auto& entry : get_local_gossiper().endpoint_state_map) {
        auto& ep = entry.first;
        auto& state = entry.second;
        std::stringstream ss;
        ss << ep;
        if (state.is_alive())
            nodes_status.emplace(sstring(ss.str()), "UP");
        else
            nodes_status.emplace(sstring(ss.str()), "DOWN");
    }
    return nodes_status;
}

int failure_detector::get_down_endpoint_count() {
    int count = 0;
    for (auto& entry : get_local_gossiper().endpoint_state_map) {
        auto& state = entry.second;
        if (!state.is_alive()) {
            count++;
        }
    }
    return count;
}

int failure_detector::get_up_endpoint_count() {
    int count = 0;
    for (auto& entry : get_local_gossiper().endpoint_state_map) {
        auto& state = entry.second;
        if (state.is_alive()) {
            count++;
        }
    }
    return count;
}

sstring failure_detector::get_endpoint_state(sstring address) {
    std::stringstream ss;
    auto eps = get_local_gossiper().get_endpoint_state_for_endpoint(inet_address(address));
    if (eps) {
        append_endpoint_state(ss, *eps);
        return sstring(ss.str());
    } else {
        return sstring("unknown endpoint ") + address;
    }
}

void failure_detector::append_endpoint_state(std::stringstream& ss, endpoint_state& state) {
    ss << "  generation:" << state.get_heart_beat_state().get_generation() << "\n";
    ss << "  heartbeat:" << state.get_heart_beat_state().get_heart_beat_version() << "\n";
    for (const auto& entry : state.get_application_state_map()) {
        auto& app_state = entry.first;
        auto& versioned_val = entry.second;
        if (app_state == application_state::TOKENS) {
            continue;
        }
        ss << "  " << app_state << ":" << versioned_val.version << ":" << versioned_val.value << "\n";
    }
    const auto& app_state_map = state.get_application_state_map();
    if (app_state_map.count(application_state::TOKENS)) {
        ss << "  TOKENS:" << app_state_map.at(application_state::TOKENS).version << ":<hidden>\n";
    } else {
        ss << "  TOKENS: not present" << "\n";
    }
}

void failure_detector::set_phi_convict_threshold(double phi) {
    _phi = phi;
}

double failure_detector::get_phi_convict_threshold() {
    return _phi;
}

bool failure_detector::is_alive(inet_address ep) {
    return get_local_gossiper().is_alive(ep);
}

void failure_detector::report(inet_address ep) {
    logger.trace("failure_detector: reporting {}", ep);
    auto now = clk::now();
    auto it = _arrival_samples.find(ep);
    if (it == _arrival_samples.end()) {
        // avoid adding an empty ArrivalWindow to the Map
        auto heartbeat_window = arrival_window(SAMPLE_SIZE);
        heartbeat_window.add(now, ep);
        _arrival_samples.emplace(ep, heartbeat_window);
    } else {
        it->second.add(now, ep);
    }
}

// Runs inside seastar::async context
void failure_detector::interpret(inet_address ep) {
    auto it = _arrival_samples.find(ep);
    if (it == _arrival_samples.end()) {
        return;
    }
    arrival_window& hb_wnd = it->second;
    auto now = clk::now();
    auto diff = std::chrono::duration_cast<std::chrono::milliseconds>(now - _last_interpret);
    _last_interpret = now;
    if (diff > get_max_local_pause()) {
        logger.warn("Not marking nodes down due to local pause of {} > {} (milliseconds)", diff.count(), get_max_local_pause().count());
        _last_paused = now;
        return;
    }
    if (clk::now() - _last_paused < get_max_local_pause()) {
        logger.debug("Still not marking nodes down due to local pause");
        return;
    }
    double phi = hb_wnd.phi(now);
    logger.trace("failure_detector: PHI for {} : {}", ep, phi);
    logger.trace("failure_detector: phi_convict_threshold={}", _phi);

    if (PHI_FACTOR * phi > get_phi_convict_threshold()) {
        logger.trace("failure_detector: notifying listeners that {} is down", ep);
        logger.trace("failure_detector: intervals: {} mean: {}", hb_wnd, hb_wnd.mean());
        for (auto& listener : _fd_evnt_listeners) {
            logger.debug("failure_detector: convict ep={} phi={}", ep, phi);
            listener->convict(ep, phi);
        }
    }
}

// Runs inside seastar::async context
void failure_detector::force_conviction(inet_address ep) {
    logger.debug("failure_detector: Forcing conviction of {}", ep);
    for (auto& listener : _fd_evnt_listeners) {
        listener->convict(ep, get_phi_convict_threshold());
    }
}

void failure_detector::remove(inet_address ep) {
    _arrival_samples.erase(ep);
}

void failure_detector::register_failure_detection_event_listener(i_failure_detection_event_listener* listener) {
    _fd_evnt_listeners.push_back(std::move(listener));
}

void failure_detector::unregister_failure_detection_event_listener(i_failure_detection_event_listener* listener) {
    _fd_evnt_listeners.remove(listener);
}

std::ostream& operator<<(std::ostream& os, const failure_detector& x) {
    for (auto& entry : x._arrival_samples) {
        const inet_address& ep = entry.first;
        const arrival_window& win = entry.second;
        os << ep << " : "  << win << "\n";
    }
    return os;
}

distributed<failure_detector> _the_failure_detector;

} // namespace gms
<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: vclxaccessibletabpagewindow.cxx,v $
 *
 *  $Revision: 1.2 $
 *
 *  last change: $Author: hr $ $Date: 2007-06-27 15:41:25 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library 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, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/

// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_accessibility.hxx"

#ifndef ACCESSIBILITY_STANDARD_VCLXACCESSIBLETABPAGEWINDOW_HXX
#include <accessibility/standard/vclxaccessibletabpagewindow.hxx>
#endif

#ifndef _TOOLKIT_HELPER_CONVERT_HXX_
#include <toolkit/helper/convert.hxx>
#endif

#ifndef _SV_TABCTRL_HXX
#include <vcl/tabctrl.hxx>
#endif
#ifndef _SV_TABPAGE_HXX
#include <vcl/tabpage.hxx>
#endif

using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::accessibility;
using namespace ::comphelper;

//  ----------------------------------------------------
//  class VCLXAccessibleTabPageWindow
//  ----------------------------------------------------

VCLXAccessibleTabPageWindow::VCLXAccessibleTabPageWindow( VCLXWindow* pVCLXWindow )
    :VCLXAccessibleComponent( pVCLXWindow )
{
    m_pTabPage = static_cast< TabPage* >( GetWindow() );
    if ( m_pTabPage )
    {
        Window* pParent = m_pTabPage->GetAccessibleParentWindow();
        if ( pParent && pParent->GetType() == WINDOW_TABCONTROL )
        {
            m_pTabControl = static_cast< TabControl* >( pParent );
            if ( m_pTabControl )
            {
                for ( sal_uInt16 i = 0, nCount = m_pTabControl->GetPageCount(); i < nCount; ++i )
                {
                    sal_uInt16 nPageId = m_pTabControl->GetPageId( i );
                    if ( m_pTabControl->GetTabPage( nPageId ) == m_pTabPage )
                        m_nPageId = nPageId;
                }
            }
        }
    }
}

// -----------------------------------------------------------------------------

VCLXAccessibleTabPageWindow::~VCLXAccessibleTabPageWindow()
{
}

// -----------------------------------------------------------------------------
// OCommonAccessibleComponent
// -----------------------------------------------------------------------------

awt::Rectangle VCLXAccessibleTabPageWindow::implGetBounds() throw (RuntimeException)
{
    awt::Rectangle aBounds( 0, 0, 0, 0 );

    if ( m_pTabControl )
    {
        Rectangle aPageRect = m_pTabControl->GetTabBounds( m_nPageId );
        if ( m_pTabPage )
        {
            Rectangle aRect = Rectangle( m_pTabPage->GetPosPixel(), m_pTabPage->GetSizePixel() );
            aRect.Move( -aPageRect.Left(), -aPageRect.Top() );
            aBounds = AWTRectangle( aRect );
        }
    }

    return aBounds;
}

// -----------------------------------------------------------------------------
// XComponent
// -----------------------------------------------------------------------------

void VCLXAccessibleTabPageWindow::disposing()
{
    VCLXAccessibleComponent::disposing();

    m_pTabControl = NULL;
    m_pTabPage = NULL;
}

// -----------------------------------------------------------------------------
// XAccessibleContext
// -----------------------------------------------------------------------------

Reference< XAccessible > VCLXAccessibleTabPageWindow::getAccessibleParent(  ) throw (RuntimeException)
{
    OExternalLockGuard aGuard( this );

    Reference< XAccessible > xParent;
    if ( m_pTabControl )
    {
        Reference< XAccessible > xAcc( m_pTabControl->GetAccessible() );
        if ( xAcc.is() )
        {
            Reference< XAccessibleContext > xCont( xAcc->getAccessibleContext() );
            if ( xCont.is() )
                xParent = xCont->getAccessibleChild( m_pTabControl->GetPagePos( m_nPageId ) );
        }
    }

    return xParent;
}

// -----------------------------------------------------------------------------

sal_Int32 VCLXAccessibleTabPageWindow::getAccessibleIndexInParent(  ) throw (RuntimeException)
{
    OExternalLockGuard aGuard( this );

    return 0;
}

// -----------------------------------------------------------------------------
<commit_msg>INTEGRATION: CWS changefileheader (1.2.44); FILE MERGED 2008/04/01 14:59:01 thb 1.2.44.3: #i85898# Stripping all external header guards 2008/04/01 10:46:05 thb 1.2.44.2: #i85898# Stripping all external header guards 2008/03/28 15:57:56 rt 1.2.44.1: #i87441# Change license header to LPGL v3.<commit_after>/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * Copyright 2008 by Sun Microsystems, Inc.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * $RCSfile: vclxaccessibletabpagewindow.cxx,v $
 * $Revision: 1.3 $
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org 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 version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/

// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_accessibility.hxx"
#include <accessibility/standard/vclxaccessibletabpagewindow.hxx>
#include <toolkit/helper/convert.hxx>
#include <vcl/tabctrl.hxx>
#include <vcl/tabpage.hxx>

using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::accessibility;
using namespace ::comphelper;

//  ----------------------------------------------------
//  class VCLXAccessibleTabPageWindow
//  ----------------------------------------------------

VCLXAccessibleTabPageWindow::VCLXAccessibleTabPageWindow( VCLXWindow* pVCLXWindow )
    :VCLXAccessibleComponent( pVCLXWindow )
{
    m_pTabPage = static_cast< TabPage* >( GetWindow() );
    if ( m_pTabPage )
    {
        Window* pParent = m_pTabPage->GetAccessibleParentWindow();
        if ( pParent && pParent->GetType() == WINDOW_TABCONTROL )
        {
            m_pTabControl = static_cast< TabControl* >( pParent );
            if ( m_pTabControl )
            {
                for ( sal_uInt16 i = 0, nCount = m_pTabControl->GetPageCount(); i < nCount; ++i )
                {
                    sal_uInt16 nPageId = m_pTabControl->GetPageId( i );
                    if ( m_pTabControl->GetTabPage( nPageId ) == m_pTabPage )
                        m_nPageId = nPageId;
                }
            }
        }
    }
}

// -----------------------------------------------------------------------------

VCLXAccessibleTabPageWindow::~VCLXAccessibleTabPageWindow()
{
}

// -----------------------------------------------------------------------------
// OCommonAccessibleComponent
// -----------------------------------------------------------------------------

awt::Rectangle VCLXAccessibleTabPageWindow::implGetBounds() throw (RuntimeException)
{
    awt::Rectangle aBounds( 0, 0, 0, 0 );

    if ( m_pTabControl )
    {
        Rectangle aPageRect = m_pTabControl->GetTabBounds( m_nPageId );
        if ( m_pTabPage )
        {
            Rectangle aRect = Rectangle( m_pTabPage->GetPosPixel(), m_pTabPage->GetSizePixel() );
            aRect.Move( -aPageRect.Left(), -aPageRect.Top() );
            aBounds = AWTRectangle( aRect );
        }
    }

    return aBounds;
}

// -----------------------------------------------------------------------------
// XComponent
// -----------------------------------------------------------------------------

void VCLXAccessibleTabPageWindow::disposing()
{
    VCLXAccessibleComponent::disposing();

    m_pTabControl = NULL;
    m_pTabPage = NULL;
}

// -----------------------------------------------------------------------------
// XAccessibleContext
// -----------------------------------------------------------------------------

Reference< XAccessible > VCLXAccessibleTabPageWindow::getAccessibleParent(  ) throw (RuntimeException)
{
    OExternalLockGuard aGuard( this );

    Reference< XAccessible > xParent;
    if ( m_pTabControl )
    {
        Reference< XAccessible > xAcc( m_pTabControl->GetAccessible() );
        if ( xAcc.is() )
        {
            Reference< XAccessibleContext > xCont( xAcc->getAccessibleContext() );
            if ( xCont.is() )
                xParent = xCont->getAccessibleChild( m_pTabControl->GetPagePos( m_nPageId ) );
        }
    }

    return xParent;
}

// -----------------------------------------------------------------------------

sal_Int32 VCLXAccessibleTabPageWindow::getAccessibleIndexInParent(  ) throw (RuntimeException)
{
    OExternalLockGuard aGuard( this );

    return 0;
}

// -----------------------------------------------------------------------------
<|endoftext|>


<commit_before>/*
 * Copyright 2011 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

/* Tests text rendering with LCD and subpixel rendering turned on and off.
 */

#include "gm.h"
#include "SkCanvas.h"

class LcdTextGM : public skiagm::GM {
public:
    LcdTextGM() {
        const int pointSize = 36;
        textHeight = SkIntToScalar(pointSize);
    }

protected:

    SkString onShortName() {
        return SkString("lcdtext");
    }

    SkISize onISize() { return SkISize::Make(640, 480); }

    virtual void onDraw(SkCanvas* canvas) {

        y = textHeight;
        drawText(canvas, SkString("TEXT: SubpixelTrue LCDRenderTrue"),
                 true,  true);
        drawText(canvas, SkString("TEXT: SubpixelTrue LCDRenderFalse"),
                 true,  false);
        drawText(canvas, SkString("TEXT: SubpixelFalse LCDRenderTrue"),
                 false, true);
        drawText(canvas, SkString("TEXT: SubpixelFalse LCDRenderFalse"),
                 false, false);
    }

    void drawText(SkCanvas* canvas, const SkString& string,
                  bool subpixelTextEnabled, bool lcdRenderTextEnabled) {
        SkPaint paint;
        paint.setColor(SK_ColorBLACK);
        paint.setDither(true);
        paint.setAntiAlias(true);
        sk_tool_utils::set_portable_typeface(&paint);
        paint.setSubpixelText(subpixelTextEnabled);
        paint.setLCDRenderText(lcdRenderTextEnabled);
        paint.setTextSize(textHeight);

        canvas->drawText(string.c_str(), string.size(), 0, y, paint);
        y += textHeight;
    }

private:
    typedef skiagm::GM INHERITED;
    SkScalar y, textHeight;
};

/*
 *  Skia will automatically disable LCD requests if the total size exceeds some limit
 *  (hard coded in this test for now, as it is now avaiable as an API)
 *
 *  Test this both by changing "textsize" and by changing the computed size (textsize * CTM)
 */
class LcdTextSizeGM : public skiagm::GM {
    enum {
        kLCDTextSizeLimit = 48
    };

    static void ScaleAbout(SkCanvas* canvas, SkScalar sx, SkScalar sy, SkScalar px, SkScalar py) {
        SkMatrix m;
        m.setScale(sx, sy, px, py);
        canvas->concat(m);
    }

public:
    LcdTextSizeGM() {}

protected:
    SkString onShortName() {
        return SkString("lcdtextsize");
    }

    SkISize onISize() { return SkISize::Make(320, 120); }

    virtual void onDraw(SkCanvas* canvas) {
        const char* lcd_text = "LCD";
        const char* gray_text = "GRAY";

        SkPaint paint;
        paint.setAntiAlias(true);
        paint.setLCDRenderText(true);

        const struct {
            SkPoint     fLoc;
            SkScalar    fTextSize;
            SkScalar    fScale;
            const char* fText;
        } rec[] = {
            { {  10,  50 }, kLCDTextSizeLimit - 1,     1,  lcd_text },
            { { 160,  50 }, kLCDTextSizeLimit + 1,     1,  gray_text },
            { {  10, 100 }, kLCDTextSizeLimit / 2, 1.99f,  lcd_text },
            { { 160, 100 }, kLCDTextSizeLimit / 2, 2.01f,  gray_text },
        };

        for (size_t i = 0; i < SK_ARRAY_COUNT(rec); ++i) {
            const SkPoint loc = rec[i].fLoc;
            SkAutoCanvasRestore acr(canvas, true);

            paint.setTextSize(rec[i].fTextSize);
            ScaleAbout(canvas, rec[i].fScale, rec[i].fScale, loc.x(), loc.y());
            canvas->drawText(rec[i].fText, strlen(rec[i].fText), loc.x(), loc.y(), paint);
        }
    }

private:
    typedef skiagm::GM INHERITED;
};

#include "SkSurface.h"

// ensure that we respect the SkPixelGeometry in SurfaceProps
class LcdTextProps : public skiagm::GM {
    static void DrawText(SkCanvas* canvas) {
        canvas->drawColor(SK_ColorWHITE);
        SkPaint paint;
        paint.setAntiAlias(true);
        paint.setLCDRenderText(true);
        paint.setTextSize(30);
        canvas->drawText("Base", 4, 4, 30, paint);
        canvas->saveLayer(NULL, NULL);
        canvas->drawText("Layer", 5, 4, 70, paint);
        canvas->restore();
    }

protected:
    SkString onShortName() SK_OVERRIDE {
        return SkString("lcdtextprops");
    }

    SkISize onISize() SK_OVERRIDE { return SkISize::Make(230, 120); }

    uint32_t onGetFlags() const SK_OVERRIDE {
        return kSkip565_Flag;
    }

    virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
        const SkPixelGeometry geos[] = {
            kRGB_H_SkPixelGeometry,
            kUnknown_SkPixelGeometry,
        };

        const SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100);
        for (size_t i = 0; i < SK_ARRAY_COUNT(geos); ++i) {
            SkSurfaceProps props = SkSurfaceProps(0, geos[i]);
            SkAutoTUnref<SkSurface> surf(canvas->newSurface(info, &props));
            if (!surf) {
                surf.reset(SkSurface::NewRaster(info, &props));
            }
            DrawText(surf->getCanvas());
            surf->draw(canvas, SkIntToScalar(i * (info.width() + 10)), 0, NULL);
        }
    }
};

///////////////////////////////////////////////////////////////////////////////

DEF_GM( return new LcdTextGM; )
DEF_GM( return new LcdTextSizeGM; )
DEF_GM( return new LcdTextProps; )
<commit_msg>Fully disable lcdtextprops<commit_after>/*
 * Copyright 2011 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

/* Tests text rendering with LCD and subpixel rendering turned on and off.
 */

#include "gm.h"
#include "SkCanvas.h"

class LcdTextGM : public skiagm::GM {
public:
    LcdTextGM() {
        const int pointSize = 36;
        textHeight = SkIntToScalar(pointSize);
    }

protected:

    SkString onShortName() {
        return SkString("lcdtext");
    }

    SkISize onISize() { return SkISize::Make(640, 480); }

    virtual void onDraw(SkCanvas* canvas) {

        y = textHeight;
        drawText(canvas, SkString("TEXT: SubpixelTrue LCDRenderTrue"),
                 true,  true);
        drawText(canvas, SkString("TEXT: SubpixelTrue LCDRenderFalse"),
                 true,  false);
        drawText(canvas, SkString("TEXT: SubpixelFalse LCDRenderTrue"),
                 false, true);
        drawText(canvas, SkString("TEXT: SubpixelFalse LCDRenderFalse"),
                 false, false);
    }

    void drawText(SkCanvas* canvas, const SkString& string,
                  bool subpixelTextEnabled, bool lcdRenderTextEnabled) {
        SkPaint paint;
        paint.setColor(SK_ColorBLACK);
        paint.setDither(true);
        paint.setAntiAlias(true);
        sk_tool_utils::set_portable_typeface(&paint);
        paint.setSubpixelText(subpixelTextEnabled);
        paint.setLCDRenderText(lcdRenderTextEnabled);
        paint.setTextSize(textHeight);

        canvas->drawText(string.c_str(), string.size(), 0, y, paint);
        y += textHeight;
    }

private:
    typedef skiagm::GM INHERITED;
    SkScalar y, textHeight;
};

/*
 *  Skia will automatically disable LCD requests if the total size exceeds some limit
 *  (hard coded in this test for now, as it is now avaiable as an API)
 *
 *  Test this both by changing "textsize" and by changing the computed size (textsize * CTM)
 */
class LcdTextSizeGM : public skiagm::GM {
    enum {
        kLCDTextSizeLimit = 48
    };

    static void ScaleAbout(SkCanvas* canvas, SkScalar sx, SkScalar sy, SkScalar px, SkScalar py) {
        SkMatrix m;
        m.setScale(sx, sy, px, py);
        canvas->concat(m);
    }

public:
    LcdTextSizeGM() {}

protected:
    SkString onShortName() {
        return SkString("lcdtextsize");
    }

    SkISize onISize() { return SkISize::Make(320, 120); }

    virtual void onDraw(SkCanvas* canvas) {
        const char* lcd_text = "LCD";
        const char* gray_text = "GRAY";

        SkPaint paint;
        paint.setAntiAlias(true);
        paint.setLCDRenderText(true);

        const struct {
            SkPoint     fLoc;
            SkScalar    fTextSize;
            SkScalar    fScale;
            const char* fText;
        } rec[] = {
            { {  10,  50 }, kLCDTextSizeLimit - 1,     1,  lcd_text },
            { { 160,  50 }, kLCDTextSizeLimit + 1,     1,  gray_text },
            { {  10, 100 }, kLCDTextSizeLimit / 2, 1.99f,  lcd_text },
            { { 160, 100 }, kLCDTextSizeLimit / 2, 2.01f,  gray_text },
        };

        for (size_t i = 0; i < SK_ARRAY_COUNT(rec); ++i) {
            const SkPoint loc = rec[i].fLoc;
            SkAutoCanvasRestore acr(canvas, true);

            paint.setTextSize(rec[i].fTextSize);
            ScaleAbout(canvas, rec[i].fScale, rec[i].fScale, loc.x(), loc.y());
            canvas->drawText(rec[i].fText, strlen(rec[i].fText), loc.x(), loc.y(), paint);
        }
    }

private:
    typedef skiagm::GM INHERITED;
};

#include "SkSurface.h"

// ensure that we respect the SkPixelGeometry in SurfaceProps
class LcdTextProps : public skiagm::GM {
    static void DrawText(SkCanvas* canvas) {
        canvas->drawColor(SK_ColorWHITE);
        SkPaint paint;
        paint.setAntiAlias(true);
        paint.setLCDRenderText(true);
        paint.setTextSize(30);
        canvas->drawText("Base", 4, 4, 30, paint);
        canvas->saveLayer(NULL, NULL);
        canvas->drawText("Layer", 5, 4, 70, paint);
        canvas->restore();
    }

protected:
    SkString onShortName() SK_OVERRIDE {
        return SkString("lcdtextprops");
    }

    SkISize onISize() SK_OVERRIDE { return SkISize::Make(230, 120); }

    uint32_t onGetFlags() const SK_OVERRIDE {
        return kSkip565_Flag;
    }

    virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
        const SkPixelGeometry geos[] = {
            kRGB_H_SkPixelGeometry,
            kUnknown_SkPixelGeometry,
        };

        const SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100);
        for (size_t i = 0; i < SK_ARRAY_COUNT(geos); ++i) {
            SkSurfaceProps props = SkSurfaceProps(0, geos[i]);
            SkAutoTUnref<SkSurface> surf(canvas->newSurface(info, &props));
            if (!surf) {
                surf.reset(SkSurface::NewRaster(info, &props));
            }
            DrawText(surf->getCanvas());
            surf->draw(canvas, SkIntToScalar(i * (info.width() + 10)), 0, NULL);
        }
    }
};

///////////////////////////////////////////////////////////////////////////////

DEF_GM( return new LcdTextGM; )
DEF_GM( return new LcdTextSizeGM; )
// Temporarily disabled (dftext interference)
// DEF_GM( return new LcdTextProps; )
<|endoftext|>


<commit_before>/*
 * Copyright 2011 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include "gm.h"
#include "SkBlurDrawLooper.h"
#include "SkBlurMask.h"
#include "SkPath.h"

namespace skiagm {

///////////////////////////////////////////////////////////////////////////////

static void setup(SkPaint* paint, SkColor c, SkScalar strokeWidth) {
    paint->setColor(c);
    if (strokeWidth < 0) {
        paint->setStyle(SkPaint::kFill_Style);
    } else {
        paint->setStyle(SkPaint::kStroke_Style);
        paint->setStrokeWidth(strokeWidth);
    }
}

class ShadowsGM : public GM {
public:
    SkPath fCirclePath;
    SkRect fRect;
    SkBitmap fBitmap;

protected:
    void onOnceBeforeDraw() override {
        this->setBGColor(sk_tool_utils::color_to_565(0xFFDDDDDD));
        fCirclePath.addCircle(SkIntToScalar(20), SkIntToScalar(20), SkIntToScalar(10) );
        fRect.set(SkIntToScalar(10), SkIntToScalar(10),
                  SkIntToScalar(30), SkIntToScalar(30));
        fBitmap.allocPixels(SkImageInfo::Make(20, 20, SkColorType::kAlpha_8_SkColorType,
                            kPremul_SkAlphaType));
        SkCanvas canvas(fBitmap);
        canvas.clear(0x0);
        SkPaint p;
        canvas.drawRect(SkRect::MakeXYWH(10, 0, 10, 10), p);
        canvas.drawRect(SkRect::MakeXYWH(0, 10, 10, 10), p);
    }

    SkString onShortName() override {
        return SkString("shadows");
    }

    SkISize onISize() override {
        return SkISize::Make(200, 120);
    }

    void onDraw(SkCanvas* canvas) override {
        SkBlurDrawLooper* shadowLoopers[5];
        shadowLoopers[0] =
            SkBlurDrawLooper::Create(SK_ColorBLUE,
                                     SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(10)),
                                     SkIntToScalar(5), SkIntToScalar(10),
                                     SkBlurDrawLooper::kIgnoreTransform_BlurFlag |
                                     SkBlurDrawLooper::kOverrideColor_BlurFlag |
                                     SkBlurDrawLooper::kHighQuality_BlurFlag);
        SkAutoUnref aurL0(shadowLoopers[0]);
        shadowLoopers[1] =
            SkBlurDrawLooper::Create(SK_ColorBLUE,
                                     SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(10)),
                                     SkIntToScalar(5), SkIntToScalar(10),
                                     SkBlurDrawLooper::kIgnoreTransform_BlurFlag |
                                     SkBlurDrawLooper::kOverrideColor_BlurFlag);
        SkAutoUnref aurL1(shadowLoopers[1]);
        shadowLoopers[2] =
            SkBlurDrawLooper::Create(SK_ColorBLACK,
                                     SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(5)),
                                     SkIntToScalar(5),
                                     SkIntToScalar(10),
                                     SkBlurDrawLooper::kIgnoreTransform_BlurFlag |
                                     SkBlurDrawLooper::kHighQuality_BlurFlag);
        SkAutoUnref aurL2(shadowLoopers[2]);
        shadowLoopers[3] =
            SkBlurDrawLooper::Create(0x7FFF0000,
                                     SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(5)),
                                     SkIntToScalar(-5), SkIntToScalar(-10),
                                     SkBlurDrawLooper::kIgnoreTransform_BlurFlag |
                                     SkBlurDrawLooper::kOverrideColor_BlurFlag |
                                     SkBlurDrawLooper::kHighQuality_BlurFlag);
        SkAutoUnref aurL3(shadowLoopers[3]);
        shadowLoopers[4] =
            SkBlurDrawLooper::Create(SK_ColorBLACK, SkIntToScalar(0),
                                     SkIntToScalar(5), SkIntToScalar(5),
                                     SkBlurDrawLooper::kIgnoreTransform_BlurFlag |
                                     SkBlurDrawLooper::kOverrideColor_BlurFlag |
                                     SkBlurDrawLooper::kHighQuality_BlurFlag);
        SkAutoUnref aurL4(shadowLoopers[4]);

        static const struct {
            SkColor fColor;
            SkScalar fStrokeWidth;
        } gRec[] = {
            { SK_ColorRED,      -SK_Scalar1 },
            { SK_ColorGREEN,    SkIntToScalar(4) },
            { SK_ColorBLUE,     SkIntToScalar(0)},
        };

        SkPaint paint;
        paint.setAntiAlias(true);
        for (size_t i = 0; i < SK_ARRAY_COUNT(shadowLoopers); ++i) {
            SkAutoCanvasRestore acr(canvas, true);

            paint.setLooper(shadowLoopers[i]);

            canvas->translate(SkIntToScalar((unsigned int)i*40), SkIntToScalar(0));
            setup(&paint, gRec[0].fColor, gRec[0].fStrokeWidth);
            canvas->drawRect(fRect, paint);

            canvas->translate(SkIntToScalar(0), SkIntToScalar(40));
            setup(&paint, gRec[1].fColor, gRec[1].fStrokeWidth);
            canvas->drawPath(fCirclePath, paint);

            canvas->translate(SkIntToScalar(0), SkIntToScalar(40));
            setup(&paint, gRec[2].fColor, gRec[2].fStrokeWidth);
            canvas->drawPath(fCirclePath, paint);

            // see bug.skia.org/562 (reference, draws correct)
            canvas->translate(0, 40);
            paint.setColor(SK_ColorBLACK);
            canvas->drawBitmap(fBitmap, 10, 10, &paint);

            canvas->translate(0, 40);
            SkAutoTUnref<SkShader> shader(SkShader::CreateBitmapShader(
                                          fBitmap, SkShader::kRepeat_TileMode,
                                          SkShader::kRepeat_TileMode));

            // see bug.skia.org/562 (shows bug as reported)
            paint.setShader(shader);
            paint.setStyle(SkPaint::kFill_Style);
            canvas->drawRect(SkRect::MakeXYWH(10, 10, 20, 20), paint);
            paint.setShader(nullptr);
        }
    }

private:
    typedef GM INHERITED;
};

///////////////////////////////////////////////////////////////////////////////

static GM* MyFactory(void*) { return new ShadowsGM; }
static GMRegistry reg(MyFactory);

}
<commit_msg>update gm test size to include new elements<commit_after>/*
 * Copyright 2011 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include "gm.h"
#include "SkBlurDrawLooper.h"
#include "SkBlurMask.h"
#include "SkPath.h"

namespace skiagm {

///////////////////////////////////////////////////////////////////////////////

static void setup(SkPaint* paint, SkColor c, SkScalar strokeWidth) {
    paint->setColor(c);
    if (strokeWidth < 0) {
        paint->setStyle(SkPaint::kFill_Style);
    } else {
        paint->setStyle(SkPaint::kStroke_Style);
        paint->setStrokeWidth(strokeWidth);
    }
}

class ShadowsGM : public GM {
public:
    SkPath fCirclePath;
    SkRect fRect;
    SkBitmap fBitmap;

protected:
    void onOnceBeforeDraw() override {
        this->setBGColor(sk_tool_utils::color_to_565(0xFFDDDDDD));
        fCirclePath.addCircle(SkIntToScalar(20), SkIntToScalar(20), SkIntToScalar(10) );
        fRect.set(SkIntToScalar(10), SkIntToScalar(10),
                  SkIntToScalar(30), SkIntToScalar(30));
        fBitmap.allocPixels(SkImageInfo::Make(20, 20, SkColorType::kAlpha_8_SkColorType,
                            kPremul_SkAlphaType));
        SkCanvas canvas(fBitmap);
        canvas.clear(0x0);
        SkPaint p;
        canvas.drawRect(SkRect::MakeXYWH(10, 0, 10, 10), p);
        canvas.drawRect(SkRect::MakeXYWH(0, 10, 10, 10), p);
    }

    SkString onShortName() override {
        return SkString("shadows");
    }

    SkISize onISize() override {
        return SkISize::Make(200, 200);
    }

    void onDraw(SkCanvas* canvas) override {
        SkBlurDrawLooper* shadowLoopers[5];
        shadowLoopers[0] =
            SkBlurDrawLooper::Create(SK_ColorBLUE,
                                     SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(10)),
                                     SkIntToScalar(5), SkIntToScalar(10),
                                     SkBlurDrawLooper::kIgnoreTransform_BlurFlag |
                                     SkBlurDrawLooper::kOverrideColor_BlurFlag |
                                     SkBlurDrawLooper::kHighQuality_BlurFlag);
        SkAutoUnref aurL0(shadowLoopers[0]);
        shadowLoopers[1] =
            SkBlurDrawLooper::Create(SK_ColorBLUE,
                                     SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(10)),
                                     SkIntToScalar(5), SkIntToScalar(10),
                                     SkBlurDrawLooper::kIgnoreTransform_BlurFlag |
                                     SkBlurDrawLooper::kOverrideColor_BlurFlag);
        SkAutoUnref aurL1(shadowLoopers[1]);
        shadowLoopers[2] =
            SkBlurDrawLooper::Create(SK_ColorBLACK,
                                     SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(5)),
                                     SkIntToScalar(5),
                                     SkIntToScalar(10),
                                     SkBlurDrawLooper::kIgnoreTransform_BlurFlag |
                                     SkBlurDrawLooper::kHighQuality_BlurFlag);
        SkAutoUnref aurL2(shadowLoopers[2]);
        shadowLoopers[3] =
            SkBlurDrawLooper::Create(0x7FFF0000,
                                     SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(5)),
                                     SkIntToScalar(-5), SkIntToScalar(-10),
                                     SkBlurDrawLooper::kIgnoreTransform_BlurFlag |
                                     SkBlurDrawLooper::kOverrideColor_BlurFlag |
                                     SkBlurDrawLooper::kHighQuality_BlurFlag);
        SkAutoUnref aurL3(shadowLoopers[3]);
        shadowLoopers[4] =
            SkBlurDrawLooper::Create(SK_ColorBLACK, SkIntToScalar(0),
                                     SkIntToScalar(5), SkIntToScalar(5),
                                     SkBlurDrawLooper::kIgnoreTransform_BlurFlag |
                                     SkBlurDrawLooper::kOverrideColor_BlurFlag |
                                     SkBlurDrawLooper::kHighQuality_BlurFlag);
        SkAutoUnref aurL4(shadowLoopers[4]);

        static const struct {
            SkColor fColor;
            SkScalar fStrokeWidth;
        } gRec[] = {
            { SK_ColorRED,      -SK_Scalar1 },
            { SK_ColorGREEN,    SkIntToScalar(4) },
            { SK_ColorBLUE,     SkIntToScalar(0)},
        };

        SkPaint paint;
        paint.setAntiAlias(true);
        for (size_t i = 0; i < SK_ARRAY_COUNT(shadowLoopers); ++i) {
            SkAutoCanvasRestore acr(canvas, true);

            paint.setLooper(shadowLoopers[i]);

            canvas->translate(SkIntToScalar((unsigned int)i*40), SkIntToScalar(0));
            setup(&paint, gRec[0].fColor, gRec[0].fStrokeWidth);
            canvas->drawRect(fRect, paint);

            canvas->translate(SkIntToScalar(0), SkIntToScalar(40));
            setup(&paint, gRec[1].fColor, gRec[1].fStrokeWidth);
            canvas->drawPath(fCirclePath, paint);

            canvas->translate(SkIntToScalar(0), SkIntToScalar(40));
            setup(&paint, gRec[2].fColor, gRec[2].fStrokeWidth);
            canvas->drawPath(fCirclePath, paint);

            // see bug.skia.org/562 (reference, draws correct)
            canvas->translate(0, 40);
            paint.setColor(SK_ColorBLACK);
            canvas->drawBitmap(fBitmap, 10, 10, &paint);

            canvas->translate(0, 40);
            SkAutoTUnref<SkShader> shader(SkShader::CreateBitmapShader(
                                          fBitmap, SkShader::kRepeat_TileMode,
                                          SkShader::kRepeat_TileMode));

            // see bug.skia.org/562 (shows bug as reported)
            paint.setShader(shader);
            paint.setStyle(SkPaint::kFill_Style);
            canvas->drawRect(SkRect::MakeXYWH(10, 10, 20, 20), paint);
            paint.setShader(nullptr);
        }
    }

private:
    typedef GM INHERITED;
};

///////////////////////////////////////////////////////////////////////////////

static GM* MyFactory(void*) { return new ShadowsGM; }
static GMRegistry reg(MyFactory);

}
<|endoftext|>


<commit_before>#include "array_declaration_expression_builder.h"

#include "../visitors/vm_expression_visitor.h"

namespace elsa {
	namespace compiler {

		void ArrayDeclarationExpressionBuilder::build(VMProgram* program, VMExpressionVisitor* visitor, ArrayDeclarationExpression* expression)
		{

		}

	}
}
<commit_msg>added some basic code gen for array declarations<commit_after>#include "array_declaration_expression_builder.h"

#include "../visitors/vm_expression_visitor.h"

namespace elsa {
	namespace compiler {

		void ArrayDeclarationExpressionBuilder::build(VMProgram* program, VMExpressionVisitor* visitor, ArrayDeclarationExpression* expression)
		{
			program->emit(OpCode::iconst);
			program->emit(10);
			program->emit(OpCode::new_arr);
			program->emit(static_cast<int>(expression->get_type()->get_vm_type()));
		}

	}
}
<|endoftext|>


<commit_before>// Copyright eeGeo Ltd (2012-2014), All Rights Reserved

#include "InteriorsCustomMaterialParser.h"
#include "InteriorsCustomMaterialDto.h"
#include "CubeFaceFileNames.h"
#include "InteriorMaterialSemantics.h"
#include "LayerIds.h"
#include "InteriorsCustomMaterialKeys.h"

#include "document.h"
namespace ExampleApp
{
    namespace InteriorsCustomMaterials
    {
        namespace SdkModel
        {
            namespace
            {
                std::vector<InteriorsCustomTextureDto> ParseTextures(const rapidjson::Document& customMaterialJson)
                {
                    std::vector<InteriorsCustomTextureDto> result;
                    if (customMaterialJson.HasMember(InteriorsCustomMaterialKeys::Textures.c_str()))
                    {
                        const rapidjson::Value& texturesJson = customMaterialJson[InteriorsCustomMaterialKeys::Textures.c_str()];

                        int textureCount = texturesJson.Size();
                        result.reserve(textureCount);
                        for (int i = 0; i < textureCount; ++i)
                        {
                            const rapidjson::Value& textureJson = texturesJson[i];
                            InteriorsCustomTextureDto textureDto;
                            textureDto.textureKey = textureJson[InteriorsCustomMaterialKeys::TextureKey.c_str()].GetString();
                            textureDto.filename = textureJson[InteriorsCustomMaterialKeys::Filename.c_str()].GetString();
                            result.push_back(textureDto);
                        }

                    }

                    return result;
                }

                std::vector<InteriorsCustomCubeMapTextureDto> ParseCubeMapTextures(const rapidjson::Document& customMaterialJson)
                {
                    std::vector<InteriorsCustomCubeMapTextureDto> result;
                    if (customMaterialJson.HasMember(InteriorsCustomMaterialKeys::CubeMapTextures.c_str()))
                    {
                        const rapidjson::Value& texturesJson = customMaterialJson[InteriorsCustomMaterialKeys::CubeMapTextures.c_str()];

                        int textureCount = texturesJson.Size();
                        result.reserve(textureCount);
                        for (int i = 0; i < textureCount; ++i)
                        {
                            const rapidjson::Value& textureJson = texturesJson[i];
                            InteriorsCustomCubeMapTextureDto dto;
                            dto.textureKey = textureJson[InteriorsCustomMaterialKeys::TextureKey.c_str()].GetString();
                            dto.positiveXFilename = textureJson["PositiveXFilename"].GetString();
                            dto.negativeXFilename = textureJson["NegativeXFilename"].GetString();
                            dto.positiveYFilename = textureJson["PositiveYFilename"].GetString();
                            dto.negativeYFilename = textureJson["NegativeYFilename"].GetString();
                            dto.positiveZFilename = textureJson["PositiveZFilename"].GetString();
                            dto.negativeZFilename = textureJson["NegativeZFilename"].GetString();

                            result.push_back(dto);
                        }

                    }

                    return result;
                }

                void TryAddString(const std::string& key, const rapidjson::Value& materialJson, std::vector<std::pair<std::string, std::string> >& inout_strings)
                {
                    if (materialJson.HasMember(key.c_str()))
                    {
                        inout_strings.push_back(std::make_pair(key, materialJson[key.c_str()].GetString()));
                    }
                }

                void TryAddColor(const std::string& key, const rapidjson::Value& materialJson, std::vector<std::pair<std::string, Eegeo::v4> >& inout_colors)
                {
                    if (materialJson.HasMember(key.c_str()))
                    {
                        const rapidjson::Value& jsonValue = materialJson[key.c_str()];
                        Eegeo_ASSERT(jsonValue.IsArray());
                        Eegeo_ASSERT(jsonValue.Size() == 4);

                        Eegeo::v4 color;
                        int indexR = 0;
                        int indexG = 1;
                        int indexB = 2;
                        int indexA = 3;

                        color.x = static_cast<float>(jsonValue[indexR].GetDouble());
                        color.y = static_cast<float>(jsonValue[indexG].GetDouble());
                        color.z = static_cast<float>(jsonValue[indexB].GetDouble());
                        color.w = static_cast<float>(jsonValue[indexA].GetDouble());

                        inout_colors.push_back(std::make_pair(key, color));
                    }
                }

                void TryAddScalar(const std::string& key, const rapidjson::Value& materialJson, std::vector<std::pair<std::string, float> >& inout_scalars)
                {
                    if (materialJson.HasMember(key.c_str()))
                    {
                        const float value = static_cast<float>(materialJson[key.c_str()].GetDouble());
                        inout_scalars.push_back(std::make_pair(key, value));
                    }
                }

                void TryAddBoolean(const std::string& key, const rapidjson::Value& materialJson, std::vector<std::pair<std::string, bool> >& inout_booleans)
                {
                    if (materialJson.HasMember(key.c_str()))
                    {
                        const bool value = materialJson[key.c_str()].GetBool();
                        inout_booleans.push_back(std::make_pair(key, value));
                    }
                }

                InteriorsCustomMaterialDto ParseMaterial(const rapidjson::Value& materialJson)
                {
                    using namespace Eegeo::Resources::Interiors::InteriorMaterialSemantics;

                    InteriorsCustomMaterialDto result;

                    result.materialName = materialJson[InteriorsCustomMaterialKeys::MaterialName.c_str()].GetString();

                    TryAddString(MaterialType, materialJson, result.keyValueStrings);
                    TryAddString(DiffuseTexture, materialJson, result.keyValueStrings);
                    TryAddString(CubeMapTexture, materialJson, result.keyValueStrings);

                    TryAddColor(DiffuseColor, materialJson, result.keyValueColors);
                    TryAddColor(SpecularColor, materialJson, result.keyValueColors);
                    TryAddColor(ReflectionColor, materialJson, result.keyValueColors);
                    TryAddColor(RimColor, materialJson, result.keyValueColors);
                    TryAddColor(AmbientColor, materialJson, result.keyValueColors);

                    TryAddScalar(SpecularPowerScalar, materialJson, result.keyValueScalars);
                    TryAddScalar(SpecularModulateTextureScalar, materialJson, result.keyValueScalars);
                    TryAddScalar(SpecularityFromTextureLuminanceScalar, materialJson, result.keyValueScalars);
                    TryAddScalar(FresnelBias, materialJson, result.keyValueScalars);
                    TryAddScalar(FresnelScale, materialJson, result.keyValueScalars);
                    TryAddScalar(FresnelPower, materialJson, result.keyValueScalars);

                    TryAddBoolean(IsTranslucent, materialJson, result.keyValueBooleans);
                    TryAddBoolean(IsStencilMirror, materialJson, result.keyValueBooleans);

                    return result;
                }

                std::vector<InteriorsCustomMaterialDto> ParseMaterialDtos(const rapidjson::Document& customMaterialJson)
                {
                    std::vector<InteriorsCustomMaterialDto> result;

                    if (customMaterialJson.HasMember(InteriorsCustomMaterialKeys::Materials.c_str()))
                    {
                        const rapidjson::Value& materialsJson = customMaterialJson[InteriorsCustomMaterialKeys::Materials.c_str()];

                        int materialCount = materialsJson.Size();
                        result.reserve(materialCount);
                        for (int i = 0; i < materialCount; ++i)
                        {
                            const rapidjson::Value& materialJson = materialsJson[i];

                            const InteriorsCustomMaterialDto& materialDto = ParseMaterial(materialJson);
                            result.push_back(materialDto);
                        }
                    }

                    return result;
                }
            }

            InteriorsCustomMaterialParserResult InteriorsCustomMaterialParser::Parse(const std::string& materialsJson) const
            {
                rapidjson::Document document;
                if (document.Parse<0>(materialsJson.c_str()).HasParseError())
                {
                    Eegeo_ASSERT(false, "Error parsing materials josn");
                }

                InteriorsCustomMaterialParserResult result;

                result.textureDtos = ParseTextures(document);

                result.cubeMapTextureDtos = ParseCubeMapTextures(document);

                result.materialDtos = ParseMaterialDtos(document);

                return result;

            }

        }
    }
}<commit_msg>Add parsing of ViewOffsetScale material property Buddy: Paul<commit_after>// Copyright eeGeo Ltd (2012-2014), All Rights Reserved

#include "InteriorsCustomMaterialParser.h"
#include "InteriorsCustomMaterialDto.h"
#include "CubeFaceFileNames.h"
#include "InteriorMaterialSemantics.h"
#include "LayerIds.h"
#include "InteriorsCustomMaterialKeys.h"

#include "document.h"
namespace ExampleApp
{
    namespace InteriorsCustomMaterials
    {
        namespace SdkModel
        {
            namespace
            {
                std::vector<InteriorsCustomTextureDto> ParseTextures(const rapidjson::Document& customMaterialJson)
                {
                    std::vector<InteriorsCustomTextureDto> result;
                    if (customMaterialJson.HasMember(InteriorsCustomMaterialKeys::Textures.c_str()))
                    {
                        const rapidjson::Value& texturesJson = customMaterialJson[InteriorsCustomMaterialKeys::Textures.c_str()];

                        int textureCount = texturesJson.Size();
                        result.reserve(textureCount);
                        for (int i = 0; i < textureCount; ++i)
                        {
                            const rapidjson::Value& textureJson = texturesJson[i];
                            InteriorsCustomTextureDto textureDto;
                            textureDto.textureKey = textureJson[InteriorsCustomMaterialKeys::TextureKey.c_str()].GetString();
                            textureDto.filename = textureJson[InteriorsCustomMaterialKeys::Filename.c_str()].GetString();
                            result.push_back(textureDto);
                        }

                    }

                    return result;
                }

                std::vector<InteriorsCustomCubeMapTextureDto> ParseCubeMapTextures(const rapidjson::Document& customMaterialJson)
                {
                    std::vector<InteriorsCustomCubeMapTextureDto> result;
                    if (customMaterialJson.HasMember(InteriorsCustomMaterialKeys::CubeMapTextures.c_str()))
                    {
                        const rapidjson::Value& texturesJson = customMaterialJson[InteriorsCustomMaterialKeys::CubeMapTextures.c_str()];

                        int textureCount = texturesJson.Size();
                        result.reserve(textureCount);
                        for (int i = 0; i < textureCount; ++i)
                        {
                            const rapidjson::Value& textureJson = texturesJson[i];
                            InteriorsCustomCubeMapTextureDto dto;
                            dto.textureKey = textureJson[InteriorsCustomMaterialKeys::TextureKey.c_str()].GetString();
                            dto.positiveXFilename = textureJson["PositiveXFilename"].GetString();
                            dto.negativeXFilename = textureJson["NegativeXFilename"].GetString();
                            dto.positiveYFilename = textureJson["PositiveYFilename"].GetString();
                            dto.negativeYFilename = textureJson["NegativeYFilename"].GetString();
                            dto.positiveZFilename = textureJson["PositiveZFilename"].GetString();
                            dto.negativeZFilename = textureJson["NegativeZFilename"].GetString();

                            result.push_back(dto);
                        }

                    }

                    return result;
                }

                void TryAddString(const std::string& key, const rapidjson::Value& materialJson, std::vector<std::pair<std::string, std::string> >& inout_strings)
                {
                    if (materialJson.HasMember(key.c_str()))
                    {
                        inout_strings.push_back(std::make_pair(key, materialJson[key.c_str()].GetString()));
                    }
                }

                void TryAddColor(const std::string& key, const rapidjson::Value& materialJson, std::vector<std::pair<std::string, Eegeo::v4> >& inout_colors)
                {
                    if (materialJson.HasMember(key.c_str()))
                    {
                        const rapidjson::Value& jsonValue = materialJson[key.c_str()];
                        Eegeo_ASSERT(jsonValue.IsArray());
                        Eegeo_ASSERT(jsonValue.Size() == 4);

                        Eegeo::v4 color;
                        int indexR = 0;
                        int indexG = 1;
                        int indexB = 2;
                        int indexA = 3;

                        color.x = static_cast<float>(jsonValue[indexR].GetDouble());
                        color.y = static_cast<float>(jsonValue[indexG].GetDouble());
                        color.z = static_cast<float>(jsonValue[indexB].GetDouble());
                        color.w = static_cast<float>(jsonValue[indexA].GetDouble());

                        inout_colors.push_back(std::make_pair(key, color));
                    }
                }

                void TryAddScalar(const std::string& key, const rapidjson::Value& materialJson, std::vector<std::pair<std::string, float> >& inout_scalars)
                {
                    if (materialJson.HasMember(key.c_str()))
                    {
                        const float value = static_cast<float>(materialJson[key.c_str()].GetDouble());
                        inout_scalars.push_back(std::make_pair(key, value));
                    }
                }

                void TryAddBoolean(const std::string& key, const rapidjson::Value& materialJson, std::vector<std::pair<std::string, bool> >& inout_booleans)
                {
                    if (materialJson.HasMember(key.c_str()))
                    {
                        const bool value = materialJson[key.c_str()].GetBool();
                        inout_booleans.push_back(std::make_pair(key, value));
                    }
                }

                InteriorsCustomMaterialDto ParseMaterial(const rapidjson::Value& materialJson)
                {
                    using namespace Eegeo::Resources::Interiors::InteriorMaterialSemantics;

                    InteriorsCustomMaterialDto result;

                    result.materialName = materialJson[InteriorsCustomMaterialKeys::MaterialName.c_str()].GetString();

                    TryAddString(MaterialType, materialJson, result.keyValueStrings);
                    TryAddString(DiffuseTexture, materialJson, result.keyValueStrings);
                    TryAddString(CubeMapTexture, materialJson, result.keyValueStrings);

                    TryAddColor(DiffuseColor, materialJson, result.keyValueColors);
                    TryAddColor(SpecularColor, materialJson, result.keyValueColors);
                    TryAddColor(ReflectionColor, materialJson, result.keyValueColors);
                    TryAddColor(RimColor, materialJson, result.keyValueColors);
                    TryAddColor(AmbientColor, materialJson, result.keyValueColors);

                    TryAddScalar(SpecularPowerScalar, materialJson, result.keyValueScalars);
                    TryAddScalar(SpecularModulateTextureScalar, materialJson, result.keyValueScalars);
                    TryAddScalar(SpecularityFromTextureLuminanceScalar, materialJson, result.keyValueScalars);
                    TryAddScalar(FresnelBias, materialJson, result.keyValueScalars);
                    TryAddScalar(FresnelScale, materialJson, result.keyValueScalars);
                    TryAddScalar(FresnelPower, materialJson, result.keyValueScalars);
                    TryAddScalar(ViewOffsetScale, materialJson, result.keyValueScalars);

                    TryAddBoolean(IsTranslucent, materialJson, result.keyValueBooleans);
                    TryAddBoolean(IsStencilMirror, materialJson, result.keyValueBooleans);

                    return result;
                }

                std::vector<InteriorsCustomMaterialDto> ParseMaterialDtos(const rapidjson::Document& customMaterialJson)
                {
                    std::vector<InteriorsCustomMaterialDto> result;

                    if (customMaterialJson.HasMember(InteriorsCustomMaterialKeys::Materials.c_str()))
                    {
                        const rapidjson::Value& materialsJson = customMaterialJson[InteriorsCustomMaterialKeys::Materials.c_str()];

                        int materialCount = materialsJson.Size();
                        result.reserve(materialCount);
                        for (int i = 0; i < materialCount; ++i)
                        {
                            const rapidjson::Value& materialJson = materialsJson[i];

                            const InteriorsCustomMaterialDto& materialDto = ParseMaterial(materialJson);
                            result.push_back(materialDto);
                        }
                    }

                    return result;
                }
            }

            InteriorsCustomMaterialParserResult InteriorsCustomMaterialParser::Parse(const std::string& materialsJson) const
            {
                rapidjson::Document document;
                if (document.Parse<0>(materialsJson.c_str()).HasParseError())
                {
                    Eegeo_ASSERT(false, "Error parsing materials josn");
                }

                InteriorsCustomMaterialParserResult result;

                result.textureDtos = ParseTextures(document);

                result.cubeMapTextureDtos = ParseCubeMapTextures(document);

                result.materialDtos = ParseMaterialDtos(document);

                return result;

            }

        }
    }
}<|endoftext|>