| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "cc/output/gl_renderer.h" | 10 #include "cc/output/gl_renderer.h" |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 SkColorGetR(texel_stripe_color), | 128 SkColorGetR(texel_stripe_color), |
| 129 SkColorGetG(texel_stripe_color), | 129 SkColorGetG(texel_stripe_color), |
| 130 SkColorGetB(texel_stripe_color)); | 130 SkColorGetB(texel_stripe_color)); |
| 131 std::vector<uint32_t> pixels(rect.size().GetArea(), pixel_color); | 131 std::vector<uint32_t> pixels(rect.size().GetArea(), pixel_color); |
| 132 for (int i = rect.height() / 4; i < (rect.height() * 3 / 4); ++i) { | 132 for (int i = rect.height() / 4; i < (rect.height() * 3 / 4); ++i) { |
| 133 for (int k = rect.width() / 4; k < (rect.width() * 3 / 4); ++k) { | 133 for (int k = rect.width() / 4; k < (rect.width() * 3 / 4); ++k) { |
| 134 pixels[i * rect.width() + k] = pixel_stripe_color; | 134 pixels[i * rect.width() + k] = pixel_stripe_color; |
| 135 } | 135 } |
| 136 } | 136 } |
| 137 ResourceId resource = resource_provider->CreateResource( | 137 ResourceId resource = resource_provider->CreateResource( |
| 138 rect.size(), ResourceProvider::TEXTURE_HINT_IMMUTABLE, RGBA_8888); | 138 rect.size(), ResourceProvider::TEXTURE_HINT_IMMUTABLE, RGBA_8888, |
| 139 gfx::ColorSpace()); |
| 139 resource_provider->CopyToResource( | 140 resource_provider->CopyToResource( |
| 140 resource, reinterpret_cast<uint8_t*>(&pixels.front()), rect.size()); | 141 resource, reinterpret_cast<uint8_t*>(&pixels.front()), rect.size()); |
| 141 | 142 |
| 142 float vertex_opacity[4] = {1.0f, 1.0f, 1.0f, 1.0f}; | 143 float vertex_opacity[4] = {1.0f, 1.0f, 1.0f, 1.0f}; |
| 143 const gfx::PointF uv_top_left(0.0f, 0.0f); | 144 const gfx::PointF uv_top_left(0.0f, 0.0f); |
| 144 const gfx::PointF uv_bottom_right(1.0f, 1.0f); | 145 const gfx::PointF uv_bottom_right(1.0f, 1.0f); |
| 145 const bool flipped = false; | 146 const bool flipped = false; |
| 146 const bool nearest_neighbor = false; | 147 const bool nearest_neighbor = false; |
| 147 TextureDrawQuad* quad = | 148 TextureDrawQuad* quad = |
| 148 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); | 149 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 162 SkPMColor pixel_color = premultiplied_alpha ? | 163 SkPMColor pixel_color = premultiplied_alpha ? |
| 163 SkPreMultiplyColor(texel_color) : | 164 SkPreMultiplyColor(texel_color) : |
| 164 SkPackARGB32NoCheck(SkColorGetA(texel_color), | 165 SkPackARGB32NoCheck(SkColorGetA(texel_color), |
| 165 SkColorGetR(texel_color), | 166 SkColorGetR(texel_color), |
| 166 SkColorGetG(texel_color), | 167 SkColorGetG(texel_color), |
| 167 SkColorGetB(texel_color)); | 168 SkColorGetB(texel_color)); |
| 168 size_t num_pixels = static_cast<size_t>(rect.width()) * rect.height(); | 169 size_t num_pixels = static_cast<size_t>(rect.width()) * rect.height(); |
| 169 std::vector<uint32_t> pixels(num_pixels, pixel_color); | 170 std::vector<uint32_t> pixels(num_pixels, pixel_color); |
| 170 | 171 |
| 171 ResourceId resource = resource_provider->CreateResource( | 172 ResourceId resource = resource_provider->CreateResource( |
| 172 rect.size(), ResourceProvider::TEXTURE_HINT_IMMUTABLE, RGBA_8888); | 173 rect.size(), ResourceProvider::TEXTURE_HINT_IMMUTABLE, RGBA_8888, |
| 174 gfx::ColorSpace()); |
| 173 resource_provider->CopyToResource( | 175 resource_provider->CopyToResource( |
| 174 resource, reinterpret_cast<uint8_t*>(&pixels.front()), rect.size()); | 176 resource, reinterpret_cast<uint8_t*>(&pixels.front()), rect.size()); |
| 175 | 177 |
| 176 float vertex_opacity[4] = {1.0f, 1.0f, 1.0f, 1.0f}; | 178 float vertex_opacity[4] = {1.0f, 1.0f, 1.0f, 1.0f}; |
| 177 | 179 |
| 178 const gfx::PointF uv_top_left(0.0f, 0.0f); | 180 const gfx::PointF uv_top_left(0.0f, 0.0f); |
| 179 const gfx::PointF uv_bottom_right(1.0f, 1.0f); | 181 const gfx::PointF uv_bottom_right(1.0f, 1.0f); |
| 180 const bool flipped = false; | 182 const bool flipped = false; |
| 181 const bool nearest_neighbor = false; | 183 const bool nearest_neighbor = false; |
| 182 TextureDrawQuad* quad = | 184 TextureDrawQuad* quad = |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 color_space = YUVVideoDrawQuad::JPEG; | 502 color_space = YUVVideoDrawQuad::JPEG; |
| 501 } | 503 } |
| 502 | 504 |
| 503 const gfx::Rect opaque_rect(0, 0, 0, 0); | 505 const gfx::Rect opaque_rect(0, 0, 0, 0); |
| 504 const gfx::Size ya_tex_size = rect.size(); | 506 const gfx::Size ya_tex_size = rect.size(); |
| 505 const gfx::Size uv_tex_size = media::VideoFrame::PlaneSize( | 507 const gfx::Size uv_tex_size = media::VideoFrame::PlaneSize( |
| 506 media::PIXEL_FORMAT_NV12, media::VideoFrame::kUVPlane, rect.size()); | 508 media::PIXEL_FORMAT_NV12, media::VideoFrame::kUVPlane, rect.size()); |
| 507 | 509 |
| 508 ResourceId y_resource = resource_provider->CreateResource( | 510 ResourceId y_resource = resource_provider->CreateResource( |
| 509 rect.size(), ResourceProvider::TEXTURE_HINT_DEFAULT, | 511 rect.size(), ResourceProvider::TEXTURE_HINT_DEFAULT, |
| 510 resource_provider->YuvResourceFormat(8)); | 512 resource_provider->YuvResourceFormat(8), gfx::ColorSpace()); |
| 511 ResourceId u_resource = resource_provider->CreateResource( | 513 ResourceId u_resource = resource_provider->CreateResource( |
| 512 uv_tex_size, ResourceProvider::TEXTURE_HINT_DEFAULT, RGBA_8888); | 514 uv_tex_size, ResourceProvider::TEXTURE_HINT_DEFAULT, RGBA_8888, |
| 515 gfx::ColorSpace()); |
| 513 ResourceId v_resource = u_resource; | 516 ResourceId v_resource = u_resource; |
| 514 ResourceId a_resource = 0; | 517 ResourceId a_resource = 0; |
| 515 | 518 |
| 516 std::vector<uint8_t> y_pixels(ya_tex_size.GetArea(), y); | 519 std::vector<uint8_t> y_pixels(ya_tex_size.GetArea(), y); |
| 517 resource_provider->CopyToResource(y_resource, y_pixels.data(), ya_tex_size); | 520 resource_provider->CopyToResource(y_resource, y_pixels.data(), ya_tex_size); |
| 518 | 521 |
| 519 // U goes in the R component and V goes in the G component. | 522 // U goes in the R component and V goes in the G component. |
| 520 uint32_t rgba_pixel = (u << 24) | (v << 16); | 523 uint32_t rgba_pixel = (u << 24) | (v << 16); |
| 521 std::vector<uint32_t> uv_pixels(uv_tex_size.GetArea(), rgba_pixel); | 524 std::vector<uint32_t> uv_pixels(uv_tex_size.GetArea(), rgba_pixel); |
| 522 resource_provider->CopyToResource( | 525 resource_provider->CopyToResource( |
| (...skipping 1300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1823 gfx::Rect rect = mask_rect; | 1826 gfx::Rect rect = mask_rect; |
| 1824 while (!rect.IsEmpty()) { | 1827 while (!rect.IsEmpty()) { |
| 1825 rect.Inset(6, 6, 4, 4); | 1828 rect.Inset(6, 6, 4, 4); |
| 1826 canvas.drawRect( | 1829 canvas.drawRect( |
| 1827 SkRect::MakeXYWH(rect.x(), rect.y(), rect.width(), rect.height()), | 1830 SkRect::MakeXYWH(rect.x(), rect.y(), rect.width(), rect.height()), |
| 1828 paint); | 1831 paint); |
| 1829 rect.Inset(6, 6, 4, 4); | 1832 rect.Inset(6, 6, 4, 4); |
| 1830 } | 1833 } |
| 1831 | 1834 |
| 1832 ResourceId mask_resource_id = this->resource_provider_->CreateResource( | 1835 ResourceId mask_resource_id = this->resource_provider_->CreateResource( |
| 1833 mask_rect.size(), ResourceProvider::TEXTURE_HINT_IMMUTABLE, RGBA_8888); | 1836 mask_rect.size(), ResourceProvider::TEXTURE_HINT_IMMUTABLE, RGBA_8888, |
| 1837 gfx::ColorSpace()); |
| 1834 { | 1838 { |
| 1835 SkAutoLockPixels lock(bitmap); | 1839 SkAutoLockPixels lock(bitmap); |
| 1836 this->resource_provider_->CopyToResource( | 1840 this->resource_provider_->CopyToResource( |
| 1837 mask_resource_id, reinterpret_cast<uint8_t*>(bitmap.getPixels()), | 1841 mask_resource_id, reinterpret_cast<uint8_t*>(bitmap.getPixels()), |
| 1838 mask_rect.size()); | 1842 mask_rect.size()); |
| 1839 } | 1843 } |
| 1840 | 1844 |
| 1841 // This RenderPassDrawQuad does not include the full |viewport_rect| which is | 1845 // This RenderPassDrawQuad does not include the full |viewport_rect| which is |
| 1842 // the size of the child render pass. | 1846 // the size of the child render pass. |
| 1843 gfx::Rect sub_rect = gfx::Rect(50, 50, 200, 100); | 1847 gfx::Rect sub_rect = gfx::Rect(50, 50, 200, 100); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1916 gfx::Rect rect = mask_rect; | 1920 gfx::Rect rect = mask_rect; |
| 1917 while (!rect.IsEmpty()) { | 1921 while (!rect.IsEmpty()) { |
| 1918 rect.Inset(6, 6, 4, 4); | 1922 rect.Inset(6, 6, 4, 4); |
| 1919 canvas.drawRect( | 1923 canvas.drawRect( |
| 1920 SkRect::MakeXYWH(rect.x(), rect.y(), rect.width(), rect.height()), | 1924 SkRect::MakeXYWH(rect.x(), rect.y(), rect.width(), rect.height()), |
| 1921 paint); | 1925 paint); |
| 1922 rect.Inset(6, 6, 4, 4); | 1926 rect.Inset(6, 6, 4, 4); |
| 1923 } | 1927 } |
| 1924 | 1928 |
| 1925 ResourceId mask_resource_id = this->resource_provider_->CreateResource( | 1929 ResourceId mask_resource_id = this->resource_provider_->CreateResource( |
| 1926 mask_rect.size(), ResourceProvider::TEXTURE_HINT_IMMUTABLE, RGBA_8888); | 1930 mask_rect.size(), ResourceProvider::TEXTURE_HINT_IMMUTABLE, RGBA_8888, |
| 1931 gfx::ColorSpace()); |
| 1927 { | 1932 { |
| 1928 SkAutoLockPixels lock(bitmap); | 1933 SkAutoLockPixels lock(bitmap); |
| 1929 this->resource_provider_->CopyToResource( | 1934 this->resource_provider_->CopyToResource( |
| 1930 mask_resource_id, reinterpret_cast<uint8_t*>(bitmap.getPixels()), | 1935 mask_resource_id, reinterpret_cast<uint8_t*>(bitmap.getPixels()), |
| 1931 mask_rect.size()); | 1936 mask_rect.size()); |
| 1932 } | 1937 } |
| 1933 | 1938 |
| 1934 // This RenderPassDrawQuad does not include the full |viewport_rect| which is | 1939 // This RenderPassDrawQuad does not include the full |viewport_rect| which is |
| 1935 // the size of the child render pass. | 1940 // the size of the child render pass. |
| 1936 gfx::Rect sub_rect = gfx::Rect(50, 20, 200, 60); | 1941 gfx::Rect sub_rect = gfx::Rect(50, 20, 200, 60); |
| (...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2671 SkAutoLockPixels lock(bitmap); | 2676 SkAutoLockPixels lock(bitmap); |
| 2672 SkCanvas canvas(bitmap); | 2677 SkCanvas canvas(bitmap); |
| 2673 canvas.drawPoint(0, 0, SK_ColorGREEN); | 2678 canvas.drawPoint(0, 0, SK_ColorGREEN); |
| 2674 canvas.drawPoint(0, 1, SK_ColorBLUE); | 2679 canvas.drawPoint(0, 1, SK_ColorBLUE); |
| 2675 canvas.drawPoint(1, 0, SK_ColorBLUE); | 2680 canvas.drawPoint(1, 0, SK_ColorBLUE); |
| 2676 canvas.drawPoint(1, 1, SK_ColorGREEN); | 2681 canvas.drawPoint(1, 1, SK_ColorGREEN); |
| 2677 } | 2682 } |
| 2678 | 2683 |
| 2679 gfx::Size tile_size(2, 2); | 2684 gfx::Size tile_size(2, 2); |
| 2680 ResourceId resource = this->resource_provider_->CreateResource( | 2685 ResourceId resource = this->resource_provider_->CreateResource( |
| 2681 tile_size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, RGBA_8888); | 2686 tile_size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, RGBA_8888, |
| 2687 gfx::ColorSpace()); |
| 2682 | 2688 |
| 2683 { | 2689 { |
| 2684 SkAutoLockPixels lock(bitmap); | 2690 SkAutoLockPixels lock(bitmap); |
| 2685 this->resource_provider_->CopyToResource( | 2691 this->resource_provider_->CopyToResource( |
| 2686 resource, static_cast<uint8_t*>(bitmap.getPixels()), tile_size); | 2692 resource, static_cast<uint8_t*>(bitmap.getPixels()), tile_size); |
| 2687 } | 2693 } |
| 2688 | 2694 |
| 2689 RenderPassId id(1, 1); | 2695 RenderPassId id(1, 1); |
| 2690 gfx::Transform transform_to_root; | 2696 gfx::Transform transform_to_root; |
| 2691 std::unique_ptr<RenderPass> pass = | 2697 std::unique_ptr<RenderPass> pass = |
| (...skipping 29 matching lines...) Expand all Loading... |
| 2721 SkAutoLockPixels lock(bitmap); | 2727 SkAutoLockPixels lock(bitmap); |
| 2722 SkCanvas canvas(bitmap); | 2728 SkCanvas canvas(bitmap); |
| 2723 canvas.drawPoint(0, 0, SK_ColorGREEN); | 2729 canvas.drawPoint(0, 0, SK_ColorGREEN); |
| 2724 canvas.drawPoint(0, 1, SK_ColorBLUE); | 2730 canvas.drawPoint(0, 1, SK_ColorBLUE); |
| 2725 canvas.drawPoint(1, 0, SK_ColorBLUE); | 2731 canvas.drawPoint(1, 0, SK_ColorBLUE); |
| 2726 canvas.drawPoint(1, 1, SK_ColorGREEN); | 2732 canvas.drawPoint(1, 1, SK_ColorGREEN); |
| 2727 } | 2733 } |
| 2728 | 2734 |
| 2729 gfx::Size tile_size(2, 2); | 2735 gfx::Size tile_size(2, 2); |
| 2730 ResourceId resource = this->resource_provider_->CreateResource( | 2736 ResourceId resource = this->resource_provider_->CreateResource( |
| 2731 tile_size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, RGBA_8888); | 2737 tile_size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, RGBA_8888, |
| 2738 gfx::ColorSpace()); |
| 2732 | 2739 |
| 2733 { | 2740 { |
| 2734 SkAutoLockPixels lock(bitmap); | 2741 SkAutoLockPixels lock(bitmap); |
| 2735 this->resource_provider_->CopyToResource( | 2742 this->resource_provider_->CopyToResource( |
| 2736 resource, static_cast<uint8_t*>(bitmap.getPixels()), tile_size); | 2743 resource, static_cast<uint8_t*>(bitmap.getPixels()), tile_size); |
| 2737 } | 2744 } |
| 2738 | 2745 |
| 2739 RenderPassId id(1, 1); | 2746 RenderPassId id(1, 1); |
| 2740 gfx::Transform transform_to_root; | 2747 gfx::Transform transform_to_root; |
| 2741 std::unique_ptr<RenderPass> pass = | 2748 std::unique_ptr<RenderPass> pass = |
| (...skipping 30 matching lines...) Expand all Loading... |
| 2772 SkAutoLockPixels lock(bitmap); | 2779 SkAutoLockPixels lock(bitmap); |
| 2773 SkCanvas canvas(bitmap); | 2780 SkCanvas canvas(bitmap); |
| 2774 canvas.drawPoint(0, 0, SK_ColorGREEN); | 2781 canvas.drawPoint(0, 0, SK_ColorGREEN); |
| 2775 canvas.drawPoint(0, 1, SK_ColorBLUE); | 2782 canvas.drawPoint(0, 1, SK_ColorBLUE); |
| 2776 canvas.drawPoint(1, 0, SK_ColorBLUE); | 2783 canvas.drawPoint(1, 0, SK_ColorBLUE); |
| 2777 canvas.drawPoint(1, 1, SK_ColorGREEN); | 2784 canvas.drawPoint(1, 1, SK_ColorGREEN); |
| 2778 } | 2785 } |
| 2779 | 2786 |
| 2780 gfx::Size tile_size(2, 2); | 2787 gfx::Size tile_size(2, 2); |
| 2781 ResourceId resource = this->resource_provider_->CreateResource( | 2788 ResourceId resource = this->resource_provider_->CreateResource( |
| 2782 tile_size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, RGBA_8888); | 2789 tile_size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, RGBA_8888, |
| 2790 gfx::ColorSpace()); |
| 2783 | 2791 |
| 2784 { | 2792 { |
| 2785 SkAutoLockPixels lock(bitmap); | 2793 SkAutoLockPixels lock(bitmap); |
| 2786 this->resource_provider_->CopyToResource( | 2794 this->resource_provider_->CopyToResource( |
| 2787 resource, static_cast<uint8_t*>(bitmap.getPixels()), tile_size); | 2795 resource, static_cast<uint8_t*>(bitmap.getPixels()), tile_size); |
| 2788 } | 2796 } |
| 2789 | 2797 |
| 2790 RenderPassId id(1, 1); | 2798 RenderPassId id(1, 1); |
| 2791 gfx::Transform transform_to_root; | 2799 gfx::Transform transform_to_root; |
| 2792 std::unique_ptr<RenderPass> pass = | 2800 std::unique_ptr<RenderPass> pass = |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3135 gfx::Rect inset_rect = rect; | 3143 gfx::Rect inset_rect = rect; |
| 3136 while (!inset_rect.IsEmpty()) { | 3144 while (!inset_rect.IsEmpty()) { |
| 3137 inset_rect.Inset(6, 6, 4, 4); | 3145 inset_rect.Inset(6, 6, 4, 4); |
| 3138 canvas.drawRect(SkRect::MakeXYWH(inset_rect.x(), inset_rect.y(), | 3146 canvas.drawRect(SkRect::MakeXYWH(inset_rect.x(), inset_rect.y(), |
| 3139 inset_rect.width(), inset_rect.height()), | 3147 inset_rect.width(), inset_rect.height()), |
| 3140 paint); | 3148 paint); |
| 3141 inset_rect.Inset(6, 6, 4, 4); | 3149 inset_rect.Inset(6, 6, 4, 4); |
| 3142 } | 3150 } |
| 3143 | 3151 |
| 3144 ResourceId resource = this->resource_provider_->CreateResource( | 3152 ResourceId resource = this->resource_provider_->CreateResource( |
| 3145 mask_rect.size(), ResourceProvider::TEXTURE_HINT_IMMUTABLE, RGBA_8888); | 3153 mask_rect.size(), ResourceProvider::TEXTURE_HINT_IMMUTABLE, RGBA_8888, |
| 3154 gfx::ColorSpace()); |
| 3146 { | 3155 { |
| 3147 SkAutoLockPixels lock(bitmap); | 3156 SkAutoLockPixels lock(bitmap); |
| 3148 this->resource_provider_->CopyToResource( | 3157 this->resource_provider_->CopyToResource( |
| 3149 resource, reinterpret_cast<uint8_t*>(bitmap.getPixels()), | 3158 resource, reinterpret_cast<uint8_t*>(bitmap.getPixels()), |
| 3150 mask_rect.size()); | 3159 mask_rect.size()); |
| 3151 } | 3160 } |
| 3152 | 3161 |
| 3153 // Arbitrary dividing lengths to divide up the resource into 16 quads. | 3162 // Arbitrary dividing lengths to divide up the resource into 16 quads. |
| 3154 int widths[] = { | 3163 int widths[] = { |
| 3155 0, 60, 50, 40, | 3164 0, 60, 50, 40, |
| (...skipping 30 matching lines...) Expand all Loading... |
| 3186 | 3195 |
| 3187 EXPECT_TRUE(this->RunPixelTest( | 3196 EXPECT_TRUE(this->RunPixelTest( |
| 3188 &pass_list, base::FilePath(FILE_PATH_LITERAL("spiral.png")), | 3197 &pass_list, base::FilePath(FILE_PATH_LITERAL("spiral.png")), |
| 3189 FuzzyPixelOffByOneComparator(true))); | 3198 FuzzyPixelOffByOneComparator(true))); |
| 3190 } | 3199 } |
| 3191 | 3200 |
| 3192 #endif // !defined(OS_ANDROID) | 3201 #endif // !defined(OS_ANDROID) |
| 3193 | 3202 |
| 3194 } // namespace | 3203 } // namespace |
| 3195 } // namespace cc | 3204 } // namespace cc |
| OLD | NEW |