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

Side by Side Diff: cc/trees/layer_tree_host_pixeltest_blending.cc

Issue 2873003002: Add stable id to PaintImage. (Closed)
Patch Set: rebase Created 3 years, 7 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.cc ('k') | cc/trees/layer_tree_host_pixeltest_masks.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include "cc/layers/picture_image_layer.h" 7 #include "cc/layers/picture_image_layer.h"
8 #include "cc/layers/solid_color_layer.h" 8 #include "cc/layers/solid_color_layer.h"
9 #include "cc/paint/paint_image.h" 9 #include "cc/paint/paint_image.h"
10 #include "cc/test/layer_tree_pixel_resource_test.h" 10 #include "cc/test/layer_tree_pixel_resource_test.h"
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 canvas->clear(SK_ColorTRANSPARENT); 139 canvas->clear(SK_ColorTRANSPARENT);
140 for (int i = 0; i < kCSSTestColorsCount; ++i) { 140 for (int i = 0; i < kCSSTestColorsCount; ++i) {
141 SkPaint paint; 141 SkPaint paint;
142 paint.setColor(kCSSTestColors[i]); 142 paint.setColor(kCSSTestColors[i]);
143 canvas->drawRect( 143 canvas->drawRect(
144 SkRect::MakeXYWH(0, i * kLaneHeight, kLaneWidth, kLaneHeight), paint); 144 SkRect::MakeXYWH(0, i * kLaneHeight, kLaneWidth, kLaneHeight), paint);
145 } 145 }
146 scoped_refptr<PictureImageLayer> layer = PictureImageLayer::Create(); 146 scoped_refptr<PictureImageLayer> layer = PictureImageLayer::Create();
147 layer->SetIsDrawable(true); 147 layer->SetIsDrawable(true);
148 layer->SetBounds(gfx::Size(width, height)); 148 layer->SetBounds(gfx::Size(width, height));
149 layer->SetImage(PaintImage(backing_store->makeImageSnapshot())); 149 layer->SetImage(PaintImage(PaintImage::GetNextId(),
150 backing_store->makeImageSnapshot()));
150 return layer; 151 return layer;
151 } 152 }
152 153
153 void SetupMaskLayer(scoped_refptr<Layer> layer) { 154 void SetupMaskLayer(scoped_refptr<Layer> layer) {
154 const int kMaskOffset = 2; 155 const int kMaskOffset = 2;
155 gfx::Size bounds = layer->bounds(); 156 gfx::Size bounds = layer->bounds();
156 scoped_refptr<PictureImageLayer> mask = PictureImageLayer::Create(); 157 scoped_refptr<PictureImageLayer> mask = PictureImageLayer::Create();
157 mask->SetIsDrawable(true); 158 mask->SetIsDrawable(true);
158 mask->SetLayerMaskType(Layer::LayerMaskType::MULTI_TEXTURE_MASK); 159 mask->SetLayerMaskType(Layer::LayerMaskType::MULTI_TEXTURE_MASK);
159 mask->SetBounds(bounds); 160 mask->SetBounds(bounds);
160 161
161 sk_sp<SkSurface> surface = 162 sk_sp<SkSurface> surface =
162 SkSurface::MakeRasterN32Premul(bounds.width(), bounds.height()); 163 SkSurface::MakeRasterN32Premul(bounds.width(), bounds.height());
163 SkCanvas* canvas = surface->getCanvas(); 164 SkCanvas* canvas = surface->getCanvas();
164 SkPaint paint; 165 SkPaint paint;
165 paint.setColor(SK_ColorWHITE); 166 paint.setColor(SK_ColorWHITE);
166 canvas->clear(SK_ColorTRANSPARENT); 167 canvas->clear(SK_ColorTRANSPARENT);
167 canvas->drawRect(SkRect::MakeXYWH(kMaskOffset, kMaskOffset, 168 canvas->drawRect(SkRect::MakeXYWH(kMaskOffset, kMaskOffset,
168 bounds.width() - kMaskOffset * 2, 169 bounds.width() - kMaskOffset * 2,
169 bounds.height() - kMaskOffset * 2), 170 bounds.height() - kMaskOffset * 2),
170 paint); 171 paint);
171 mask->SetImage(PaintImage(surface->makeImageSnapshot())); 172 mask->SetImage(
173 PaintImage(PaintImage::GetNextId(), surface->makeImageSnapshot()));
172 layer->SetMaskLayer(mask.get()); 174 layer->SetMaskLayer(mask.get());
173 } 175 }
174 176
175 void SetupColorMatrix(scoped_refptr<Layer> layer) { 177 void SetupColorMatrix(scoped_refptr<Layer> layer) {
176 FilterOperations filter_operations; 178 FilterOperations filter_operations;
177 filter_operations.Append(FilterOperation::CreateSepiaFilter(.001f)); 179 filter_operations.Append(FilterOperation::CreateSepiaFilter(.001f));
178 layer->SetFilters(filter_operations); 180 layer->SetFilters(filter_operations);
179 } 181 }
180 182
181 void CreateBlendingColorLayers(int lane_width, 183 void CreateBlendingColorLayers(int lane_width,
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 RunBlendingWithRenderPass( 503 RunBlendingWithRenderPass(
502 GL_ZERO_COPY_RECT_DRAW, 504 GL_ZERO_COPY_RECT_DRAW,
503 FILE_PATH_LITERAL("blending_render_pass_mask.png"), 505 FILE_PATH_LITERAL("blending_render_pass_mask.png"),
504 kUseMasks | kUseAntialiasing | kUseColorMatrix | kForceShaders); 506 kUseMasks | kUseAntialiasing | kUseColorMatrix | kForceShaders);
505 } 507 }
506 508
507 } // namespace 509 } // namespace
508 } // namespace cc 510 } // namespace cc
509 511
510 #endif // OS_ANDROID 512 #endif // OS_ANDROID
OLDNEW
« no previous file with comments | « cc/test/fake_content_layer_client.cc ('k') | cc/trees/layer_tree_host_pixeltest_masks.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698