blob: 05870bb2e07eca5656762791f5619ef09a09a915 [file] [log] [blame]
Romain Guye2d345e2010-09-24 18:39:22 -07001/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#define LOG_TAG "OpenGLRenderer"
18
19#include <utils/StopWatch.h>
20
21#include "OpenGLDebugRenderer.h"
22
23namespace android {
24namespace uirenderer {
25
Romain Guy885153e2011-01-27 18:34:41 -080026void OpenGLDebugRenderer::prepareDirty(float left, float top,
27 float right, float bottom, bool opaque) {
Romain Guye2d345e2010-09-24 18:39:22 -070028 mPrimitivesCount = 0;
29 LOGD("========= Frame start =========");
Romain Guy885153e2011-01-27 18:34:41 -080030 OpenGLRenderer::prepareDirty(left, top, right, bottom, opaque);
Romain Guye2d345e2010-09-24 18:39:22 -070031}
32
33void OpenGLDebugRenderer::finish() {
34 LOGD("========= Frame end =========");
35 LOGD("Primitives draw count = %d", mPrimitivesCount);
36 OpenGLRenderer::finish();
37}
38
39void OpenGLDebugRenderer::composeLayer(sp<Snapshot> current, sp<Snapshot> previous) {
40 mPrimitivesCount++;
41 StopWatch w("composeLayer");
42 return OpenGLRenderer::composeLayer(current, previous);
43}
44
45int OpenGLDebugRenderer::saveLayer(float left, float top, float right, float bottom,
Chet Haase5c13d892010-10-08 08:37:55 -070046 SkPaint* p, int flags) {
Romain Guye2d345e2010-09-24 18:39:22 -070047 mPrimitivesCount++;
48 StopWatch w("saveLayer");
49 return OpenGLRenderer::saveLayer(left, top, right, bottom, p, flags);
50}
51
Chet Haasedaf98e92011-01-10 14:10:36 -080052bool OpenGLDebugRenderer::drawDisplayList(DisplayList* displayList, uint32_t level) {
Romain Guy0fe478e2010-11-08 12:08:41 -080053 mPrimitivesCount++;
54 StopWatch w("drawDisplayList");
Chet Haasedaf98e92011-01-10 14:10:36 -080055 return OpenGLRenderer::drawDisplayList(displayList);
Romain Guy0fe478e2010-11-08 12:08:41 -080056}
57
Romain Guyada830f2011-01-13 12:13:20 -080058void OpenGLDebugRenderer::drawLayer(Layer* layer, float x, float y, SkPaint* paint) {
59 mPrimitivesCount++;
60 StopWatch w("drawLayer");
61 OpenGLRenderer::drawLayer(layer, x, y, paint);
62}
63
Romain Guye2d345e2010-09-24 18:39:22 -070064void OpenGLDebugRenderer::drawBitmap(SkBitmap* bitmap, float left, float top,
Chet Haase5c13d892010-10-08 08:37:55 -070065 SkPaint* paint) {
Romain Guye2d345e2010-09-24 18:39:22 -070066 mPrimitivesCount++;
67 StopWatch w("drawBitmap");
68 OpenGLRenderer::drawBitmap(bitmap, left, top, paint);
69}
70
Chet Haase5c13d892010-10-08 08:37:55 -070071void OpenGLDebugRenderer::drawBitmap(SkBitmap* bitmap, SkMatrix* matrix,
72 SkPaint* paint) {
Romain Guye2d345e2010-09-24 18:39:22 -070073 mPrimitivesCount++;
74 StopWatch w("drawBitmapMatrix");
75 OpenGLRenderer::drawBitmap(bitmap, matrix, paint);
76}
77
78void OpenGLDebugRenderer::drawBitmap(SkBitmap* bitmap, float srcLeft, float srcTop,
79 float srcRight, float srcBottom, float dstLeft, float dstTop,
Chet Haase5c13d892010-10-08 08:37:55 -070080 float dstRight, float dstBottom, SkPaint* paint) {
Romain Guye2d345e2010-09-24 18:39:22 -070081 mPrimitivesCount++;
82 StopWatch w("drawBitmapRect");
83 OpenGLRenderer::drawBitmap(bitmap, srcLeft, srcTop, srcRight, srcBottom,
84 dstLeft, dstTop, dstRight, dstBottom, paint);
85}
86
Romain Guy4aa90572010-09-26 18:40:37 -070087void OpenGLDebugRenderer::drawPatch(SkBitmap* bitmap, const int32_t* xDivs, const int32_t* yDivs,
Romain Guy4bb94202010-10-12 15:59:26 -070088 const uint32_t* colors, uint32_t width, uint32_t height, int8_t numColors,
Chet Haase5c13d892010-10-08 08:37:55 -070089 float left, float top, float right, float bottom, SkPaint* paint) {
Romain Guye2d345e2010-09-24 18:39:22 -070090 mPrimitivesCount++;
91 StopWatch w("drawPatch");
Romain Guy4bb94202010-10-12 15:59:26 -070092 OpenGLRenderer::drawPatch(bitmap, xDivs, yDivs, colors, width, height, numColors,
Romain Guy4aa90572010-09-26 18:40:37 -070093 left, top, right, bottom, paint);
Romain Guye2d345e2010-09-24 18:39:22 -070094}
95
96void OpenGLDebugRenderer::drawColor(int color, SkXfermode::Mode mode) {
97 mPrimitivesCount++;
98 StopWatch w("drawColor");
99 OpenGLRenderer::drawColor(color, mode);
100}
101
102void OpenGLDebugRenderer::drawRect(float left, float top, float right, float bottom,
Chet Haase5c13d892010-10-08 08:37:55 -0700103 SkPaint* paint) {
Romain Guye2d345e2010-09-24 18:39:22 -0700104 mPrimitivesCount++;
105 StopWatch w("drawRect");
106 OpenGLRenderer::drawRect(left, top, right, bottom, paint);
107}
108
Romain Guy885153e2011-01-27 18:34:41 -0800109void OpenGLDebugRenderer::drawRoundRect(float left, float top, float right, float bottom,
110 float rx, float ry, SkPaint* paint) {
111 mPrimitivesCount++;
112 StopWatch w("drawRoundRect");
113 OpenGLRenderer::drawRoundRect(left, top, right, bottom, rx, ry, paint);
114}
115
116void OpenGLDebugRenderer::drawCircle(float x, float y, float radius, SkPaint* paint) {
117 mPrimitivesCount++;
118 StopWatch w("drawCircle");
119 OpenGLRenderer::drawCircle(x, y, radius, paint);
120}
121
122void OpenGLDebugRenderer::drawOval(float left, float top, float right, float bottom,
123 SkPaint* paint) {
124 mPrimitivesCount++;
125 StopWatch w("drawOval");
126 OpenGLRenderer::drawOval(left, top, right, bottom, paint);
127}
128
129void OpenGLDebugRenderer::drawArc(float left, float top, float right, float bottom,
130 float startAngle, float sweepAngle, bool useCenter, SkPaint* paint) {
131 mPrimitivesCount++;
132 StopWatch w("drawArc");
133 OpenGLRenderer::drawArc(left, top, right, bottom, startAngle, sweepAngle, useCenter, paint);
134}
135
Romain Guye2d345e2010-09-24 18:39:22 -0700136void OpenGLDebugRenderer::drawPath(SkPath* path, SkPaint* paint) {
137 mPrimitivesCount++;
138 StopWatch w("drawPath");
139 OpenGLRenderer::drawPath(path, paint);
140}
141
Chet Haase5c13d892010-10-08 08:37:55 -0700142void OpenGLDebugRenderer::drawLines(float* points, int count, SkPaint* paint) {
Romain Guye2d345e2010-09-24 18:39:22 -0700143 mPrimitivesCount++;
144 StopWatch w("drawLines");
145 OpenGLRenderer::drawLines(points, count, paint);
146}
147
148void OpenGLDebugRenderer::drawText(const char* text, int bytesCount, int count, float x, float y,
149 SkPaint* paint) {
150 mPrimitivesCount++;
151 StopWatch w("drawText");
152 OpenGLRenderer::drawText(text, bytesCount, count, x, y, paint);
153}
154
155}; // namespace uirenderer
156}; // namespace android