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

Side by Side Diff: cc/test/fake_content_layer_client.cc

Issue 519583003: Use the solid color detection to create solid layers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: final merge Created 6 years, 3 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
« no previous file with comments | « cc/test/fake_content_layer_client.h ('k') | cc/trees/layer_tree_host_pixeltest_readback.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "cc/test/fake_content_layer_client.h" 5 #include "cc/test/fake_content_layer_client.h"
6 6
7 #include "third_party/skia/include/core/SkCanvas.h" 7 #include "third_party/skia/include/core/SkCanvas.h"
8 #include "ui/gfx/skia_util.h" 8 #include "ui/gfx/skia_util.h"
9 9
10 namespace cc { 10 namespace cc {
11 11
12 FakeContentLayerClient::FakeContentLayerClient() : last_canvas_(NULL) { 12 FakeContentLayerClient::FakeContentLayerClient()
13 : fill_with_nonsolid_color_(false), last_canvas_(NULL) {
13 } 14 }
14 15
15 FakeContentLayerClient::~FakeContentLayerClient() { 16 FakeContentLayerClient::~FakeContentLayerClient() {
16 } 17 }
17 18
18 void FakeContentLayerClient::PaintContents( 19 void FakeContentLayerClient::PaintContents(
19 SkCanvas* canvas, 20 SkCanvas* canvas,
20 const gfx::Rect& paint_rect, 21 const gfx::Rect& paint_rect,
21 ContentLayerClient::GraphicsContextStatus gc_status) { 22 ContentLayerClient::GraphicsContextStatus gc_status) {
22 last_canvas_ = canvas; 23 last_canvas_ = canvas;
23 last_context_status_ = gc_status; 24 last_context_status_ = gc_status;
24 25
25 canvas->clipRect(gfx::RectToSkRect(paint_rect)); 26 canvas->clipRect(gfx::RectToSkRect(paint_rect));
26 for (RectPaintVector::const_iterator it = draw_rects_.begin(); 27 for (RectPaintVector::const_iterator it = draw_rects_.begin();
27 it != draw_rects_.end(); ++it) { 28 it != draw_rects_.end(); ++it) {
28 const gfx::RectF& draw_rect = it->first; 29 const gfx::RectF& draw_rect = it->first;
29 const SkPaint& paint = it->second; 30 const SkPaint& paint = it->second;
30 canvas->drawRectCoords(draw_rect.x(), 31 canvas->drawRectCoords(draw_rect.x(),
31 draw_rect.y(), 32 draw_rect.y(),
32 draw_rect.right(), 33 draw_rect.right(),
33 draw_rect.bottom(), 34 draw_rect.bottom(),
34 paint); 35 paint);
35 } 36 }
36 37
37 for (BitmapVector::const_iterator it = draw_bitmaps_.begin(); 38 for (BitmapVector::const_iterator it = draw_bitmaps_.begin();
38 it != draw_bitmaps_.end(); ++it) { 39 it != draw_bitmaps_.end(); ++it) {
39 canvas->drawBitmap(it->bitmap, it->point.x(), it->point.y(), &it->paint); 40 canvas->drawBitmap(it->bitmap, it->point.x(), it->point.y(), &it->paint);
40 } 41 }
42
43 // Add a rectangle to the middle that doesn't fill |paint_rect| so that solid
44 // color analysis will fail.
45 if (fill_with_nonsolid_color_) {
46 gfx::RectF draw_rect = paint_rect;
47 draw_rect.Inset(draw_rect.width() / 4.0f, draw_rect.height() / 4.0f);
48 SkPaint paint;
49 canvas->drawRectCoords(draw_rect.x(),
50 draw_rect.y(),
51 draw_rect.right(),
52 draw_rect.bottom(),
53 paint);
54 }
41 } 55 }
42 56
43 bool FakeContentLayerClient::FillsBoundsCompletely() const { return false; } 57 bool FakeContentLayerClient::FillsBoundsCompletely() const { return false; }
44 58
45 } // namespace cc 59 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/fake_content_layer_client.h ('k') | cc/trees/layer_tree_host_pixeltest_readback.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698