SkRecord: turn on cull annotation pass in public API.

Also, switch Skia internal tools over to use the public headers where
possible.  Where it's not, the tools -Isrc/record explicitly now, and
if it's not obvious, note why they don't use SkRecording.h.

BUG=skia:2378
R=reed@google.com, mtklein@google.com, fmalita@chromium.org

Author: mtklein@chromium.org

Review URL: https://codereview.chromium.org/231853006

git-svn-id: http://skia.googlecode.com/svn/trunk@14191 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
commit-bot@chromium.org 2014-04-14 20:33:05 +00:00
parent 06aca01c23
commit b17a24fedb
8 changed files with 23 additions and 20 deletions

View File

@ -2,8 +2,7 @@
#include "DMUtil.h"
#include "DMWriteTask.h"
#include "SkCommandLineFlags.h"
#include "SkRecordDraw.h"
#include "SkRecorder.h"
#include "SkRecording.h"
DEFINE_bool(skr, false, "If true, run SKR tests.");
@ -17,19 +16,19 @@ RecordTask::RecordTask(const Task& parent, skiagm::GM* gm, SkBitmap reference)
{}
void RecordTask::draw() {
using EXPERIMENTAL::SkRecording;
using EXPERIMENTAL::SkPlayback;
// Record the GM into an SkRecord.
SkRecord record;
SkRecorder canvas(SkRecorder::kWriteOnly_Mode, &record,
fReference.width(), fReference.height());
canvas.concat(fGM->getInitialTransform());
fGM->draw(&canvas);
SkRecording* recording = SkRecording::Create(fReference.width(), fReference.height());
fGM->draw(recording->canvas());
SkAutoTDelete<const SkPlayback> playback(SkRecording::Delete(recording));
// Draw the SkRecord back into a bitmap.
SkBitmap bitmap;
SetupBitmap(fReference.colorType(), fGM.get(), &bitmap);
SkCanvas target(bitmap);
SkRecordDraw(record, &target);
playback->draw(&target);
if (!BitmapsEqual(bitmap, fReference)) {
this->fail();

View File

@ -10,8 +10,7 @@
],
'direct_dependent_settings': {
'include_dirs': [
'../include/record', # World-public headers.
'../src/record', # Skia-public headers.
'../include/record', # Public headers.
],
},
'sources': [

View File

@ -9,6 +9,7 @@
'../src/pathops',
'../src/pdf',
'../src/pipe/utils',
'../src/record',
'../src/utils',
'../src/utils/debugger',
'../tools/',

View File

@ -313,12 +313,11 @@
'type': 'executable',
'sources': [
'../tools/bench_playback.cpp',
'../tools/LazyDecodeBitmap.cpp',
],
'include_dirs': [
'../src/core/',
'../src/images',
'../src/lazy',
'../src/record',
],
'dependencies': [
'flags.gyp:flags',

View File

@ -66,7 +66,7 @@ private:
~SkRecording();
SkRecorder* fRecorder;
const SkRecord* fRecord;
SkRecord* fRecord;
};
} // namespace EXPERIMENTAL

View File

@ -8,8 +8,9 @@
#include "SkRecording.h"
#include "SkRecord.h"
#include "SkRecorder.h"
#include "SkRecordCulling.h"
#include "SkRecordDraw.h"
#include "SkRecorder.h"
namespace EXPERIMENTAL {
@ -35,7 +36,8 @@ SkRecording::SkRecording(int width, int height) {
}
/*static*/ const SkPlayback* SkRecording::Delete(SkRecording* recording) {
const SkRecord* record = recording->fRecord;
SkRecord* record = recording->fRecord;
SkRecordAnnotateCullingPairs(record);
SkDELETE(recording);
return SkNEW_ARGS(SkPlayback, (record));
}

View File

@ -24,6 +24,8 @@ DEFINE_bool(skr, false, "Play via SkRecord instead of SkPicture.");
DEFINE_int32(tile, 1000000000, "Simulated tile size.");
static void bench(SkPMColor* scratch, SkPicture& src, const char* name) {
// We don't use the public SkRecording interface here because we need kWriteOnly_Mode.
// (We don't want SkPicturePlayback to be able to optimize playing into our SkRecord.)
SkRecord record;
SkRecorder recorder(SkRecorder::kWriteOnly_Mode, &record, src.width(), src.height());
src.draw(&recorder);

View File

@ -11,7 +11,7 @@
#include "SkOSFile.h"
#include "SkPicture.h"
#include "SkQuadTreePicture.h"
#include "SkRecorder.h"
#include "SkRecording.h"
#include "SkStream.h"
#include "SkString.h"
#include "SkTileGridPicture.h"
@ -86,11 +86,12 @@ static void bench_record(SkPicture* src, const char* name, PictureFactory pictur
for (int i = 0; i < FLAGS_loops; i++) {
if (FLAGS_skr) {
SkRecord record;
SkRecorder canvas(SkRecorder::kWriteOnly_Mode, &record, width, height);
using EXPERIMENTAL::SkRecording;
SkRecording* recording = SkRecording::Create(width, height);
if (NULL != src) {
src->draw(&canvas);
src->draw(recording->canvas());
}
SkDELETE(SkRecording::Delete(recording)); // delete the SkPlayback*.
} else {
int recordingFlags = FLAGS_flags;
SkAutoTUnref<SkPictureFactory> factory(pictureFactory(&recordingFlags));