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

Side by Side Diff: cc/picture.cc

Issue 12221077: Fixing tile grid size used by cc:Picture to make it respect current tile configuration (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixing unit test build Created 7 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 | Annotate | Revision Log
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 "base/debug/trace_event.h" 5 #include "base/debug/trace_event.h"
6 #include "cc/content_layer_client.h" 6 #include "cc/content_layer_client.h"
7 #include "cc/picture.h" 7 #include "cc/picture.h"
8 #include "cc/rendering_stats.h" 8 #include "cc/rendering_stats.h"
9 #include "skia/ext/analysis_canvas.h" 9 #include "skia/ext/analysis_canvas.h"
10 #include "third_party/skia/include/core/SkCanvas.h" 10 #include "third_party/skia/include/core/SkCanvas.h"
11 #include "third_party/skia/include/core/SkData.h" 11 #include "third_party/skia/include/core/SkData.h"
12 #include "third_party/skia/include/core/SkTileGridPicture.h" 12 #include "third_party/skia/include/core/SkTileGridPicture.h"
13 #include "third_party/skia/include/utils/SkPictureUtils.h" 13 #include "third_party/skia/include/utils/SkPictureUtils.h"
14 #include "ui/gfx/rect_conversions.h" 14 #include "ui/gfx/rect_conversions.h"
15 #include "ui/gfx/skia_util.h" 15 #include "ui/gfx/skia_util.h"
16 16
17 namespace { 17 namespace {
18 // URI label for a lazily decoded SkPixelRef. 18 // URI label for a lazily decoded SkPixelRef.
19 const char labelLazyDecoded[] = "lazy"; 19 const char labelLazyDecoded[] = "lazy";
20 // Tile size in recording coordinates used by SkTileGridPicture
21 const int tileGridSize = 256;
22 } 20 }
23 21
24 namespace cc { 22 namespace cc {
25 23
26 scoped_refptr<Picture> Picture::Create(gfx::Rect layer_rect) { 24 scoped_refptr<Picture> Picture::Create(gfx::Rect layer_rect) {
27 return make_scoped_refptr(new Picture(layer_rect)); 25 return make_scoped_refptr(new Picture(layer_rect));
28 } 26 }
29 27
30 Picture::Picture(gfx::Rect layer_rect) 28 Picture::Picture(gfx::Rect layer_rect)
31 : layer_rect_(layer_rect) { 29 : layer_rect_(layer_rect) {
(...skipping 12 matching lines...) Expand all
44 42
45 scoped_refptr<Picture> Picture::Clone() const { 43 scoped_refptr<Picture> Picture::Clone() const {
46 // SkPicture is not thread-safe to rasterize with, so return a thread-safe 44 // SkPicture is not thread-safe to rasterize with, so return a thread-safe
47 // clone of it. 45 // clone of it.
48 DCHECK(picture_); 46 DCHECK(picture_);
49 skia::RefPtr<SkPicture> clone = skia::AdoptRef(picture_->clone()); 47 skia::RefPtr<SkPicture> clone = skia::AdoptRef(picture_->clone());
50 return make_scoped_refptr(new Picture(clone, layer_rect_, opaque_rect_)); 48 return make_scoped_refptr(new Picture(clone, layer_rect_, opaque_rect_));
51 } 49 }
52 50
53 void Picture::Record(ContentLayerClient* painter, 51 void Picture::Record(ContentLayerClient* painter,
54 RenderingStats* stats) { 52 RenderingStats* stats,
53 gfx::Size tile_grid_stride) {
55 TRACE_EVENT2("cc", "Picture::Record", 54 TRACE_EVENT2("cc", "Picture::Record",
56 "width", layer_rect_.width(), "height", layer_rect_.height()); 55 "width", layer_rect_.width(), "height", layer_rect_.height());
57 56
58 // Record() should only be called once. 57 // Record() should only be called once.
59 DCHECK(!picture_); 58 DCHECK(!picture_);
60 picture_ = skia::AdoptRef(new SkTileGridPicture( 59 picture_ = skia::AdoptRef(new SkTileGridPicture(
61 tileGridSize, tileGridSize, layer_rect_.width(), layer_rect_.height())); 60 tile_grid_stride.width(), tile_grid_stride.height(), layer_rect_.width(), layer_rect_.height()));
62 61
63 SkCanvas* canvas = picture_->beginRecording( 62 SkCanvas* canvas = picture_->beginRecording(
64 layer_rect_.width(), 63 layer_rect_.width(),
65 layer_rect_.height(), 64 layer_rect_.height(),
66 SkPicture::kUsePathBoundsForClip_RecordingFlag | 65 SkPicture::kUsePathBoundsForClip_RecordingFlag |
67 SkPicture::kOptimizeForClippedPlayback_RecordingFlag); 66 SkPicture::kOptimizeForClippedPlayback_RecordingFlag);
68 67
69 canvas->save(); 68 canvas->save();
70 canvas->translate(SkFloatToScalar(-layer_rect_.x()), 69 canvas->translate(SkFloatToScalar(-layer_rect_.x()),
71 SkFloatToScalar(-layer_rect_.y())); 70 SkFloatToScalar(-layer_rect_.y()));
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 if (*refs && (*refs)->getURI() && !strncmp( 148 if (*refs && (*refs)->getURI() && !strncmp(
150 (*refs)->getURI(), labelLazyDecoded, 4)) { 149 (*refs)->getURI(), labelLazyDecoded, 4)) {
151 pixel_ref_list.push_back(static_cast<skia::LazyPixelRef*>(*refs)); 150 pixel_ref_list.push_back(static_cast<skia::LazyPixelRef*>(*refs));
152 } 151 }
153 refs++; 152 refs++;
154 } 153 }
155 pixel_refs->unref(); 154 pixel_refs->unref();
156 } 155 }
157 156
158 } // namespace cc 157 } // namespace cc
OLDNEW
« no previous file with comments | « cc/picture.h ('k') | cc/picture_layer.cc » ('j') | cc/picture_layer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698