| OLD | NEW | 
|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #include "config.h" | 5 #include "config.h" | 
| 6 | 6 | 
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" | 
| 8 #include "CCSettings.h" | 8 #include "CCSettings.h" | 
| 9 #include "cc/switches.h" | 9 #include "cc/switches.h" | 
| 10 | 10 | 
| 11 namespace { | 11 namespace { | 
|  | 12 static bool s_settingsInitialized = false; | 
|  | 13 | 
| 12 static bool s_perTilePaintingEnabled = false; | 14 static bool s_perTilePaintingEnabled = false; | 
| 13 static bool s_partialSwapEnabled = false; | 15 static bool s_partialSwapEnabled = false; | 
| 14 static bool s_acceleratedAnimationEnabled = false; | 16 static bool s_acceleratedAnimationEnabled = false; | 
| 15 static bool s_pageScalePinchZoomEnabled = false; | 17 static bool s_pageScalePinchZoomEnabled = false; | 
| 16 } // namespace | 18 static bool s_jankInsteadOfCheckerboard = false; | 
|  | 19 static bool s_backgroundColorInsteadOfCheckerboard = false; | 
|  | 20 | 
|  | 21 void reset() | 
|  | 22 { | 
|  | 23     s_settingsInitialized = true; | 
|  | 24 | 
|  | 25     s_perTilePaintingEnabled = CommandLine::ForCurrentProcess()->HasSwitch(cc::s
    witches::kEnablePerTilePainting); | 
|  | 26     s_partialSwapEnabled = CommandLine::ForCurrentProcess()->HasSwitch(cc::switc
    hes::kEnablePartialSwap); | 
|  | 27     s_acceleratedAnimationEnabled = CommandLine::ForCurrentProcess()->HasSwitch(
    cc::switches::kDisableThreadedAnimation); | 
|  | 28     s_pageScalePinchZoomEnabled = CommandLine::ForCurrentProcess()->HasSwitch(cc
    ::switches::kEnablePinchInCompositor); | 
|  | 29     s_jankInsteadOfCheckerboard = CommandLine::ForCurrentProcess()->HasSwitch(cc
    ::switches::kJankInsteadOfCheckerboard); | 
|  | 30     s_backgroundColorInsteadOfCheckerboard = CommandLine::ForCurrentProcess()->H
    asSwitch(cc::switches::kBackgroundColorInsteadOfCheckerboard); | 
|  | 31 } | 
|  | 32 | 
|  | 33 } | 
| 17 | 34 | 
| 18 namespace cc { | 35 namespace cc { | 
| 19 | 36 | 
| 20 bool CCSettings::perTilePaintingEnabled() { return s_perTilePaintingEnabled; } | 37 bool CCSettings::perTilePaintingEnabled() | 
| 21 void CCSettings::setPerTilePaintingEnabled(bool enabled) { s_perTilePaintingEnab
    led = enabled; } | 38 { | 
|  | 39     if (!s_settingsInitialized) | 
|  | 40         reset(); | 
|  | 41     return s_perTilePaintingEnabled; | 
|  | 42 } | 
| 22 | 43 | 
| 23 bool CCSettings::partialSwapEnabled() { return s_partialSwapEnabled; } | 44 bool CCSettings::partialSwapEnabled() | 
| 24 void CCSettings::setPartialSwapEnabled(bool enabled) { s_partialSwapEnabled = en
    abled; } | 45 { | 
|  | 46     if (!s_settingsInitialized) | 
|  | 47         reset(); | 
|  | 48     return s_partialSwapEnabled; | 
|  | 49 } | 
| 25 | 50 | 
| 26 bool CCSettings::acceleratedAnimationEnabled() { return s_acceleratedAnimationEn
    abled; } | 51 bool CCSettings::acceleratedAnimationEnabled() | 
| 27 void CCSettings::setAcceleratedAnimationEnabled(bool enabled) { s_acceleratedAni
    mationEnabled = enabled; } | 52 { | 
|  | 53     if (!s_settingsInitialized) | 
|  | 54         reset(); | 
|  | 55     return s_acceleratedAnimationEnabled; | 
|  | 56 } | 
| 28 | 57 | 
| 29 bool CCSettings::pageScalePinchZoomEnabled() { return s_pageScalePinchZoomEnable
    d; } | 58 bool CCSettings::pageScalePinchZoomEnabled() | 
| 30 void CCSettings::setPageScalePinchZoomEnabled(bool enabled) { s_pageScalePinchZo
    omEnabled = enabled; } | 59 { | 
|  | 60     if (!s_settingsInitialized) | 
|  | 61         reset(); | 
|  | 62     return s_pageScalePinchZoomEnabled; | 
|  | 63 } | 
| 31 | 64 | 
| 32 bool CCSettings::jankInsteadOfCheckerboard() | 65 bool CCSettings::jankInsteadOfCheckerboard() | 
| 33 { | 66 { | 
| 34     return CommandLine::ForCurrentProcess()->HasSwitch(switches::kJankInsteadOfC
    heckerboard); | 67     if (!s_settingsInitialized) | 
|  | 68         reset(); | 
|  | 69     return s_jankInsteadOfCheckerboard; | 
| 35 } | 70 } | 
| 36 | 71 | 
| 37 bool CCSettings::backgroundColorInsteadOfCheckerboard() | 72 bool CCSettings::backgroundColorInsteadOfCheckerboard() | 
| 38 { | 73 { | 
| 39     return CommandLine::ForCurrentProcess()->HasSwitch(switches::kBackgroundColo
    rInsteadOfCheckerboard); | 74     if (!s_settingsInitialized) | 
|  | 75         reset(); | 
|  | 76     return s_backgroundColorInsteadOfCheckerboard; | 
| 40 } | 77 } | 
| 41 | 78 | 
| 42 void CCSettings::reset() | 79 void CCSettings::resetForTest() | 
| 43 { | 80 { | 
| 44     s_perTilePaintingEnabled = false; | 81     reset(); | 
| 45     s_partialSwapEnabled = false; | 82 } | 
| 46     s_acceleratedAnimationEnabled = false; | 83 | 
| 47     s_pageScalePinchZoomEnabled = false; | 84 void CCSettings::setPartialSwapEnabledForTest(bool enabled) | 
|  | 85 { | 
|  | 86     s_partialSwapEnabled = enabled; | 
|  | 87 } | 
|  | 88 | 
|  | 89 void CCSettings::setAcceleratedAnimationEnabledForTest(bool enabled) | 
|  | 90 { | 
|  | 91     s_acceleratedAnimationEnabled = enabled; | 
|  | 92 } | 
|  | 93 | 
|  | 94 void CCSettings::setPageScalePinchZoomEnabledForTest(bool enabled) | 
|  | 95 { | 
|  | 96     s_pageScalePinchZoomEnabled = enabled; | 
| 48 } | 97 } | 
| 49 | 98 | 
| 50 } // namespace cc | 99 } // namespace cc | 
| OLD | NEW | 
|---|