Enable WebKit/Chromium style logging for Skia.

New macros called in Ganesh functions; by default are compiled away,
in example code resolve to printout, and are compatible with WebKit/Chromium
event logging and GPU profiler.



git-svn-id: http://skia.googlecode.com/svn/trunk@1770 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
tomhudson@google.com 2011-06-30 19:37:01 +00:00
Родитель 4ee7ae5dcf
Коммит 278cbb452a
7 изменённых файлов: 120 добавлений и 8 удалений

Просмотреть файл

@ -14,17 +14,18 @@
limitations under the License.
*/
#include "GrBufferAllocPool.h"
#include "GrClipIterator.h"
#include "GrContext.h"
#include "GrGpu.h"
#include "GrTextureCache.h"
#include "GrTextStrike.h"
#include "GrMemory.h"
#include "GrClipIterator.h"
#include "GrIndexBuffer.h"
#include "GrInOrderDrawBuffer.h"
#include "GrBufferAllocPool.h"
#include "GrMemory.h"
#include "GrPathRenderer.h"
#include "GrPathUtils.h"
#include "GrTextureCache.h"
#include "GrTextStrike.h"
#include SK_USER_TRACE_INCLUDE_FILE
// Using MSAA seems to be slower for some yet unknown reason.
#define PREFER_MSAA_OFFSCREEN_AA 0
@ -203,6 +204,7 @@ GrTextureEntry* GrContext::createAndLockTexture(GrTextureKey* key,
const GrSamplerState& sampler,
const GrTextureDesc& desc,
void* srcData, size_t rowBytes) {
SK_TRACE_EVENT0("GrContext::createAndLockTexture");
GrAssert(key->width() == desc.fWidth);
GrAssert(key->height() == desc.fHeight);
@ -712,7 +714,7 @@ void GrContext::doOffscreenAAPass2(GrDrawTarget* target,
const GrIRect& boundRect,
int tileX, int tileY,
OffscreenRecord* record) {
SK_TRACE_EVENT0("GrContext::doOffscreenAAPass2");
GrAssert(NULL != record->fEntry0);
GrIRect tileRect;
@ -928,7 +930,6 @@ GrIndexBuffer* GrContext::aaStrokeRectIndexBuffer() {
void GrContext::fillAARect(GrDrawTarget* target,
const GrPaint& paint,
const GrRect& devRect) {
GrVertexLayout layout = PaintStageVertexLayoutBits(paint, NULL) |
GrDrawTarget::kColor_VertexLayoutBit;
@ -1084,7 +1085,7 @@ void GrContext::drawRect(const GrPaint& paint,
const GrRect& rect,
GrScalar width,
const GrMatrix* matrix) {
SK_TRACE_EVENT0("GrContext::drawRect");
GrDrawTarget* target = this->prepareToDraw(paint, kUnbuffered_DrawCategory);
int stageMask = paint.getActiveStageMask();
@ -1190,6 +1191,7 @@ void GrContext::drawRectToRect(const GrPaint& paint,
const GrRect& srcRect,
const GrMatrix* dstMatrix,
const GrMatrix* srcMatrix) {
SK_TRACE_EVENT0("GrContext::drawRectToRect");
// srcRect refers to paint's first texture
if (NULL == paint.getTexture(0)) {
@ -1258,6 +1260,7 @@ void GrContext::drawVertices(const GrPaint& paint,
const GrColor colors[],
const uint16_t indices[],
int indexCount) {
SK_TRACE_EVENT0("GrContext::drawVertices");
GrDrawTarget::AutoReleaseGeometry geo;
@ -1426,6 +1429,7 @@ void GrContext::flushDrawBuffer() {
bool GrContext::readTexturePixels(GrTexture* texture,
int left, int top, int width, int height,
GrPixelConfig config, void* buffer) {
SK_TRACE_EVENT0("GrContext::readTexturePixels");
// TODO: code read pixels for textures that aren't rendertargets
@ -1443,6 +1447,7 @@ bool GrContext::readTexturePixels(GrTexture* texture,
bool GrContext::readRenderTargetPixels(GrRenderTarget* target,
int left, int top, int width, int height,
GrPixelConfig config, void* buffer) {
SK_TRACE_EVENT0("GrContext::readRenderTargetPixels");
uint32_t flushFlags = 0;
if (NULL == target) {
flushFlags |= GrContext::kForceCurrentRenderTarget_FlushBit;
@ -1457,6 +1462,7 @@ bool GrContext::readRenderTargetPixels(GrRenderTarget* target,
void GrContext::writePixels(int left, int top, int width, int height,
GrPixelConfig config, const void* buffer,
size_t stride) {
SK_TRACE_EVENT0("GrContext::writePixels");
// TODO: when underlying api has a direct way to do this we should use it
// (e.g. glDrawPixels on desktop GL).

Просмотреть файл

@ -21,6 +21,7 @@
#include "GrMemory.h"
#include "SkXfermode.h"
#include SK_USER_TRACE_INCLUDE_FILE
namespace {
@ -758,6 +759,9 @@ GrGLuint GrGLProgram::CompileShader(GrGLenum type,
int stringCnt,
const char** strings,
int* stringLengths) {
SK_TRACE_EVENT1("GrGLProgram::CompileShader",
"stringCount", SkStringPrintf("%i", stringCnt).c_str());
GrGLuint shader = GR_GL(CreateShader(type));
if (0 == shader) {
return 0;

Просмотреть файл

@ -6,6 +6,9 @@
#include "GrMemory.h"
#include "GrTexture.h"
#include "SkString.h"
#include SK_USER_TRACE_INCLUDE_FILE
GrPathRenderer::GrPathRenderer()
: fCurveTolerance (GR_Scalar1) {
@ -191,6 +194,8 @@ void GrDefaultPathRenderer::onDrawPath(GrDrawTarget* target,
GrPathFill fill,
const GrPoint* translate,
bool stencilOnly) {
SK_TRACE_EVENT1("GrDefaultPathRenderer::onDrawPath",
"points", SkStringPrintf("%i", path.countPoints()).c_str());
GrDrawTarget::AutoStateRestore asr(target);
bool colorWritesWereDisabled = target->isColorWriteDisabled();
@ -334,7 +339,10 @@ void GrDefaultPathRenderer::onDrawPath(GrDrawTarget* target,
SkPath::Iter iter(path, false);
{
SK_TRACE_EVENT0("GrDefaultPathRenderer::onDrawPath::assembleVerts");
for (;;) {
GrPathCmd cmd = (GrPathCmd)iter.next(pts);
switch (cmd) {
case kMove_PathCmd:
@ -371,6 +379,7 @@ void GrDefaultPathRenderer::onDrawPath(GrDrawTarget* target,
}
first = false;
}
}
FINISHED:
GrAssert(subpath == subpathCnt);
GrAssert((vert - base) <= maxPts);
@ -406,6 +415,9 @@ FINISHED:
bounds.fBottom);
}
{
SK_TRACE_EVENT1("GrDefaultPathRenderer::onDrawPath::renderPasses",
"verts", SkStringPrintf("%i", vert - base).c_str());
for (int p = 0; p < passCount; ++p) {
target->setDrawFace(drawFace[p]);
if (NULL != passes[p]) {
@ -432,6 +444,7 @@ FINISHED:
}
}
}
}
}
void GrDefaultPathRenderer::drawPath(GrDrawTarget* target,

Просмотреть файл

@ -140,6 +140,7 @@
'../src/core/SkTypefaceCache.cpp',
'../src/core/SkTypefaceCache.h',
'../src/core/SkUnPreMultiply.cpp',
'../src/core/SkUserTrace.h',
'../src/core/SkUtils.cpp',
'../src/core/SkWriter32.cpp',
'../src/core/SkXfermode.cpp',
@ -235,6 +236,7 @@
'../include/core/SkThread.h',
'../include/core/SkThread_platform.h',
'../include/core/SkTime.h',
'../include/core/SkTrace.h',
'../include/core/SkTypeface.h',
'../include/core/SkTypes.h',
'../include/core/SkUnPreMultiply.h',

Просмотреть файл

@ -148,6 +148,18 @@
//#define SK_SUPPORT_UNITTEST
#endif
/* If your system embeds skia and has complex event logging, redefine this
symbol to point to a file that maps the following macros to your system's
equivalents:
SK_TRACE_EVENT0(event)
SK_TRACE_EVENT1(event, name1, value1)
SK_TRACE_EVENT2(event, name1, value1, name2, value2)
include/config/SkUserTrace.h has a no-op implementation, while
src/utils/SkDebugTrace.h has a trivial implementation that writes to
the debug output stream.
*/
#define SK_USER_TRACE_INCLUDE_FILE "../../include/config/SkUserTrace.h"
/* Change the ordering to work in X windows.
*/
#ifdef SK_SAMPLES_FOR_X

Просмотреть файл

@ -0,0 +1,42 @@
/*
Copyright 2010 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef SkUserTrace_DEFINED
#define SkUserTrace_DEFINED
/* If your system embeds skia and has complex event logging, define these
to map to your system's equivalents. A trivial example is given in
src/utils/SkDebugTrace.h.
All arguments are const char*. Skia typically passes the name of
the object and function (and sometimes region of interest within
the function) separated by double colons for 'event'.
SK_TRACE_EVENT1 and SK_TRACE_EVENT2 take one or two arbitrary
name-value pairs that you also want to log. SkStringPrintf() is useful
for formatting these values.
For example:
SK_TRACE_EVENT0("GrContext::createAndLockTexture");
SK_TRACE_EVENT1("GrDefaultPathRenderer::onDrawPath::renderPasses",
"verts", SkStringPrintf("%i", vert - base).c_str());
*/
#define SK_TRACE_EVENT0(event)
#define SK_TRACE_EVENT1(event, name1, value1)
#define SK_TRACE_EVENT2(event, name1, value1, name2, value2)
#endif

33
src/utils/SkDebugTrace.h Normal file
Просмотреть файл

@ -0,0 +1,33 @@
/*
Copyright 2011 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef SkUserTrace_DEFINED
#define SkUserTrace_DEFINED
/* Sample implementation of SkUserTrace that routes all of the
trace macros to debug output stream.
To use this, redefine SK_USER_TRACE_INCLUDE_FILE in
include/config/SkUserConfig.h to point to this file
*/
#define SK_TRACE_EVENT0(event) \
SkDebugf("Trace: %s\n", event)
#define SK_TRACE_EVENT1(event, name1, value1) \
SkDebugf("Trace: %s (%s=%s)\n", event, name1, value1)
#define SK_TRACE_EVENT2(event, name1, value1, name2, value2) \
SkDebugf("Trace: %s (%s=%s, %s=%s)\n", event, name1, value1, name2, value2)
#endif