Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(185)

Side by Side Diff: cc/output/renderer_pixeltest.cc

Issue 2710153004: cc: Fix up code to work with concrete cc paint types (Closed)
Patch Set: Rebase Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/base/math_util.h" 10 #include "cc/base/math_util.h"
11 #include "cc/output/gl_renderer.h" 11 #include "cc/output/gl_renderer.h"
12 #include "cc/paint/paint_canvas.h"
12 #include "cc/paint/paint_flags.h" 13 #include "cc/paint/paint_flags.h"
13 #include "cc/quads/draw_quad.h" 14 #include "cc/quads/draw_quad.h"
14 #include "cc/quads/picture_draw_quad.h" 15 #include "cc/quads/picture_draw_quad.h"
15 #include "cc/quads/texture_draw_quad.h" 16 #include "cc/quads/texture_draw_quad.h"
16 #include "cc/resources/video_resource_updater.h" 17 #include "cc/resources/video_resource_updater.h"
17 #include "cc/test/fake_raster_source.h" 18 #include "cc/test/fake_raster_source.h"
18 #include "cc/test/fake_recording_source.h" 19 #include "cc/test/fake_recording_source.h"
19 #include "cc/test/pixel_test.h" 20 #include "cc/test/pixel_test.h"
20 #include "gpu/command_buffer/client/gles2_interface.h" 21 #include "gpu/command_buffer/client/gles2_interface.h"
21 #include "media/base/video_frame.h" 22 #include "media/base/video_frame.h"
(...skipping 3184 matching lines...) Expand 10 before | Expand all | Expand 10 after
3206 3207
3207 SharedQuadState* shared_state = 3208 SharedQuadState* shared_state =
3208 CreateTestSharedQuadState(gfx::Transform(), rect, pass.get()); 3209 CreateTestSharedQuadState(gfx::Transform(), rect, pass.get());
3209 3210
3210 // Make a mask. 3211 // Make a mask.
3211 gfx::Rect mask_rect = rect; 3212 gfx::Rect mask_rect = rect;
3212 SkBitmap bitmap; 3213 SkBitmap bitmap;
3213 bitmap.allocPixels( 3214 bitmap.allocPixels(
3214 SkImageInfo::MakeN32Premul(mask_rect.width(), mask_rect.height())); 3215 SkImageInfo::MakeN32Premul(mask_rect.width(), mask_rect.height()));
3215 SkCanvas canvas(bitmap); 3216 SkCanvas canvas(bitmap);
3216 PaintFlags flags; 3217 SkPaint paint;
3217 flags.setStyle(PaintFlags::kStroke_Style); 3218 paint.setStyle(SkPaint::kStroke_Style);
3218 flags.setStrokeWidth(SkIntToScalar(4)); 3219 paint.setStrokeWidth(SkIntToScalar(4));
3219 flags.setColor(SK_ColorGREEN); 3220 paint.setColor(SK_ColorGREEN);
3220 canvas.clear(SK_ColorWHITE); 3221 canvas.clear(SK_ColorWHITE);
3221 gfx::Rect inset_rect = rect; 3222 gfx::Rect inset_rect = rect;
3222 while (!inset_rect.IsEmpty()) { 3223 while (!inset_rect.IsEmpty()) {
3223 inset_rect.Inset(6, 6, 4, 4); 3224 inset_rect.Inset(6, 6, 4, 4);
3224 canvas.drawRect(SkRect::MakeXYWH(inset_rect.x(), inset_rect.y(), 3225 canvas.drawRect(SkRect::MakeXYWH(inset_rect.x(), inset_rect.y(),
3225 inset_rect.width(), inset_rect.height()), 3226 inset_rect.width(), inset_rect.height()),
3226 flags); 3227 paint);
3227 inset_rect.Inset(6, 6, 4, 4); 3228 inset_rect.Inset(6, 6, 4, 4);
3228 } 3229 }
3229 3230
3230 ResourceId resource = this->resource_provider_->CreateResource( 3231 ResourceId resource = this->resource_provider_->CreateResource(
3231 mask_rect.size(), ResourceProvider::TEXTURE_HINT_IMMUTABLE, RGBA_8888, 3232 mask_rect.size(), ResourceProvider::TEXTURE_HINT_IMMUTABLE, RGBA_8888,
3232 gfx::ColorSpace()); 3233 gfx::ColorSpace());
3233 { 3234 {
3234 SkAutoLockPixels lock(bitmap); 3235 SkAutoLockPixels lock(bitmap);
3235 this->resource_provider_->CopyToResource( 3236 this->resource_provider_->CopyToResource(
3236 resource, reinterpret_cast<uint8_t*>(bitmap.getPixels()), 3237 resource, reinterpret_cast<uint8_t*>(bitmap.getPixels()),
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
3326 3327
3327 EXPECT_TRUE(this->RunPixelTest(&pass_list, base::FilePath(FILE_PATH_LITERAL( 3328 EXPECT_TRUE(this->RunPixelTest(&pass_list, base::FilePath(FILE_PATH_LITERAL(
3328 "translucent_rectangles.png")), 3329 "translucent_rectangles.png")),
3329 ExactPixelComparator(true))); 3330 ExactPixelComparator(true)));
3330 } 3331 }
3331 3332
3332 #endif // !defined(OS_ANDROID) 3333 #endif // !defined(OS_ANDROID)
3333 3334
3334 } // namespace 3335 } // namespace
3335 } // namespace cc 3336 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/painted_scrollbar_layer_unittest.cc ('k') | cc/playback/discardable_image_map_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698