OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 1226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1237 SkBitmap new_bitmap; | 1237 SkBitmap new_bitmap; |
1238 new_bitmap.allocPixels( | 1238 new_bitmap.allocPixels( |
1239 SkImageInfo::MakeN32Premul(rect.Width(), rect.Height())); | 1239 SkImageInfo::MakeN32Premul(rect.Width(), rect.Height())); |
1240 { | 1240 { |
1241 SkiaPaintCanvas canvas(new_bitmap); | 1241 SkiaPaintCanvas canvas(new_bitmap); |
1242 canvas.clear(SK_ColorTRANSPARENT); | 1242 canvas.clear(SK_ColorTRANSPARENT); |
1243 canvas.translate(-rect.X(), -rect.Y()); | 1243 canvas.translate(-rect.X(), -rect.Y()); |
1244 canvas.drawPicture(std::move(new_record)); | 1244 canvas.drawPicture(std::move(new_record)); |
1245 } | 1245 } |
1246 | 1246 |
1247 old_bitmap.lockPixels(); | |
1248 new_bitmap.lockPixels(); | |
1249 int mismatching_pixels = 0; | 1247 int mismatching_pixels = 0; |
1250 static const int kMaxMismatchesToReport = 50; | 1248 static const int kMaxMismatchesToReport = 50; |
1251 for (int bitmap_y = 0; bitmap_y < rect.Height(); ++bitmap_y) { | 1249 for (int bitmap_y = 0; bitmap_y < rect.Height(); ++bitmap_y) { |
1252 int layer_y = bitmap_y + rect.Y(); | 1250 int layer_y = bitmap_y + rect.Y(); |
1253 for (int bitmap_x = 0; bitmap_x < rect.Width(); ++bitmap_x) { | 1251 for (int bitmap_x = 0; bitmap_x < rect.Width(); ++bitmap_x) { |
1254 int layer_x = bitmap_x + rect.X(); | 1252 int layer_x = bitmap_x + rect.X(); |
1255 SkColor old_pixel = old_bitmap.getColor(bitmap_x, bitmap_y); | 1253 SkColor old_pixel = old_bitmap.getColor(bitmap_x, bitmap_y); |
1256 SkColor new_pixel = new_bitmap.getColor(bitmap_x, bitmap_y); | 1254 SkColor new_pixel = new_bitmap.getColor(bitmap_x, bitmap_y); |
1257 if (PixelsDiffer(old_pixel, new_pixel) && | 1255 if (PixelsDiffer(old_pixel, new_pixel) && |
1258 !tracking->raster_invalidation_region_since_last_paint.Contains( | 1256 !tracking->raster_invalidation_region_since_last_paint.Contains( |
(...skipping 11 matching lines...) Expand all Loading... |
1270 LOG(ERROR) << "and more..."; | 1268 LOG(ERROR) << "and more..."; |
1271 } | 1269 } |
1272 ++mismatching_pixels; | 1270 ++mismatching_pixels; |
1273 *new_bitmap.getAddr32(bitmap_x, bitmap_y) = | 1271 *new_bitmap.getAddr32(bitmap_x, bitmap_y) = |
1274 SkColorSetARGB(0xFF, 0xA0, 0, 0); // Dark red. | 1272 SkColorSetARGB(0xFF, 0xA0, 0, 0); // Dark red. |
1275 } else { | 1273 } else { |
1276 *new_bitmap.getAddr32(bitmap_x, bitmap_y) = SK_ColorTRANSPARENT; | 1274 *new_bitmap.getAddr32(bitmap_x, bitmap_y) = SK_ColorTRANSPARENT; |
1277 } | 1275 } |
1278 } | 1276 } |
1279 } | 1277 } |
1280 old_bitmap.unlockPixels(); | |
1281 new_bitmap.unlockPixels(); | |
1282 | 1278 |
1283 // Visualize under-invalidations by overlaying the new bitmap (containing red | 1279 // Visualize under-invalidations by overlaying the new bitmap (containing red |
1284 // pixels indicating under-invalidations, and transparent pixels otherwise) | 1280 // pixels indicating under-invalidations, and transparent pixels otherwise) |
1285 // onto the painting. | 1281 // onto the painting. |
1286 PaintRecorder recorder; | 1282 PaintRecorder recorder; |
1287 recorder.beginRecording(rect); | 1283 recorder.beginRecording(rect); |
1288 recorder.getRecordingCanvas()->drawBitmap(new_bitmap, rect.X(), rect.Y()); | 1284 recorder.getRecordingCanvas()->drawBitmap(new_bitmap, rect.X(), rect.Y()); |
1289 sk_sp<PaintRecord> record = recorder.finishRecordingAsPicture(); | 1285 sk_sp<PaintRecord> record = recorder.finishRecordingAsPicture(); |
1290 GetPaintController().AppendDebugDrawingAfterCommit( | 1286 GetPaintController().AppendDebugDrawingAfterCommit( |
1291 *this, record, OffsetFromLayoutObjectWithSubpixelAccumulation()); | 1287 *this, record, OffsetFromLayoutObjectWithSubpixelAccumulation()); |
1292 } | 1288 } |
1293 | 1289 |
1294 } // namespace blink | 1290 } // namespace blink |
1295 | 1291 |
1296 #ifndef NDEBUG | 1292 #ifndef NDEBUG |
1297 void showGraphicsLayerTree(const blink::GraphicsLayer* layer) { | 1293 void showGraphicsLayerTree(const blink::GraphicsLayer* layer) { |
1298 if (!layer) { | 1294 if (!layer) { |
1299 LOG(INFO) << "Cannot showGraphicsLayerTree for (nil)."; | 1295 LOG(INFO) << "Cannot showGraphicsLayerTree for (nil)."; |
1300 return; | 1296 return; |
1301 } | 1297 } |
1302 | 1298 |
1303 String output = layer->LayerTreeAsText(blink::kLayerTreeIncludesDebugInfo); | 1299 String output = layer->LayerTreeAsText(blink::kLayerTreeIncludesDebugInfo); |
1304 LOG(INFO) << output.Utf8().Data(); | 1300 LOG(INFO) << output.Utf8().Data(); |
1305 } | 1301 } |
1306 #endif | 1302 #endif |
OLD | NEW |