OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "PictureRenderer.h" | 8 #include "PictureRenderer.h" |
9 #include "picture_utils.h" | 9 #include "picture_utils.h" |
10 #include "SamplePipeControllers.h" | 10 #include "SamplePipeControllers.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 #include "SkRTree.h" | 27 #include "SkRTree.h" |
28 #include "SkScalar.h" | 28 #include "SkScalar.h" |
29 #include "SkStream.h" | 29 #include "SkStream.h" |
30 #include "SkString.h" | 30 #include "SkString.h" |
31 #include "SkTemplates.h" | 31 #include "SkTemplates.h" |
32 #include "SkTileGridPicture.h" | 32 #include "SkTileGridPicture.h" |
33 #include "SkTDArray.h" | 33 #include "SkTDArray.h" |
34 #include "SkThreadUtils.h" | 34 #include "SkThreadUtils.h" |
35 #include "SkTypes.h" | 35 #include "SkTypes.h" |
36 | 36 |
| 37 static inline SkScalar scalar_log2(SkScalar x) { |
| 38 static const SkScalar log2_conversion_factor = SkScalarDiv(1, SkScalarLog(2)
); |
| 39 |
| 40 return SkScalarLog(x) * log2_conversion_factor; |
| 41 } |
| 42 |
37 namespace sk_tools { | 43 namespace sk_tools { |
38 | 44 |
39 enum { | 45 enum { |
40 kDefaultTileWidth = 256, | 46 kDefaultTileWidth = 256, |
41 kDefaultTileHeight = 256 | 47 kDefaultTileHeight = 256 |
42 }; | 48 }; |
43 | 49 |
44 /* TODO(epoger): These constants are already maintained in 2 other places: | 50 /* TODO(epoger): These constants are already maintained in 2 other places: |
45 * gm/gm_json.py and gm/gm_expectations.cpp. We shouldn't add yet a third place
. | 51 * gm/gm_json.py and gm/gm_expectations.cpp. We shouldn't add yet a third place
. |
46 * Figure out a way to share the definitions instead. | 52 * Figure out a way to share the definitions instead. |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 void TiledPictureRenderer::setupPowerOf2Tiles() { | 511 void TiledPictureRenderer::setupPowerOf2Tiles() { |
506 // Only use enough tiles to cover the viewport | 512 // Only use enough tiles to cover the viewport |
507 const int width = this->getViewWidth(); | 513 const int width = this->getViewWidth(); |
508 const int height = this->getViewHeight(); | 514 const int height = this->getViewHeight(); |
509 | 515 |
510 int rounded_value = width; | 516 int rounded_value = width; |
511 if (width % fTileMinPowerOf2Width != 0) { | 517 if (width % fTileMinPowerOf2Width != 0) { |
512 rounded_value = width - (width % fTileMinPowerOf2Width) + fTileMinPowerO
f2Width; | 518 rounded_value = width - (width % fTileMinPowerOf2Width) + fTileMinPowerO
f2Width; |
513 } | 519 } |
514 | 520 |
515 int num_bits = SkScalarCeilToInt(SkScalarLog2(SkIntToScalar(width))); | 521 int num_bits = SkScalarCeilToInt(scalar_log2(SkIntToScalar(width))); |
516 int largest_possible_tile_size = 1 << num_bits; | 522 int largest_possible_tile_size = 1 << num_bits; |
517 | 523 |
518 fTilesX = fTilesY = 0; | 524 fTilesX = fTilesY = 0; |
519 // The tile height is constant for a particular picture. | 525 // The tile height is constant for a particular picture. |
520 for (int tile_y_start = 0; tile_y_start < height; tile_y_start += fTileHeigh
t) { | 526 for (int tile_y_start = 0; tile_y_start < height; tile_y_start += fTileHeigh
t) { |
521 fTilesY++; | 527 fTilesY++; |
522 int tile_x_start = 0; | 528 int tile_x_start = 0; |
523 int current_width = largest_possible_tile_size; | 529 int current_width = largest_possible_tile_size; |
524 // Set fTileWidth to be the width of the widest tile, so that each canva
s is large enough | 530 // Set fTileWidth to be the width of the widest tile, so that each canva
s is large enough |
525 // to draw each tile. | 531 // to draw each tile. |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
926 virtual SkString getConfigNameInternal() SK_OVERRIDE { | 932 virtual SkString getConfigNameInternal() SK_OVERRIDE { |
927 return SkString("picture_clone"); | 933 return SkString("picture_clone"); |
928 } | 934 } |
929 }; | 935 }; |
930 | 936 |
931 PictureRenderer* CreatePictureCloneRenderer() { | 937 PictureRenderer* CreatePictureCloneRenderer() { |
932 return SkNEW(PictureCloneRenderer); | 938 return SkNEW(PictureCloneRenderer); |
933 } | 939 } |
934 | 940 |
935 } // namespace sk_tools | 941 } // namespace sk_tools |
OLD | NEW |